A helper class for I2C
I2CHelper.h@2:51de41e0e0c9, 2014-06-09 (annotated)
- Committer:
- ethanharstad
- Date:
- Mon Jun 09 21:17:12 2014 +0000
- Revision:
- 2:51de41e0e0c9
- Parent:
- 0:e0f604f504c4
Fix writeBytes
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ethanharstad | 0:e0f604f504c4 | 1 | #ifndef I2CHELPER_H_ |
ethanharstad | 0:e0f604f504c4 | 2 | #define I2CHELPER_H_ |
ethanharstad | 0:e0f604f504c4 | 3 | |
ethanharstad | 0:e0f604f504c4 | 4 | #include "mbed.h" |
ethanharstad | 0:e0f604f504c4 | 5 | |
ethanharstad | 0:e0f604f504c4 | 6 | class I2CHelper { |
ethanharstad | 0:e0f604f504c4 | 7 | public: |
ethanharstad | 0:e0f604f504c4 | 8 | I2CHelper(); |
ethanharstad | 0:e0f604f504c4 | 9 | I2CHelper(PinName sda, PinName scl); |
ethanharstad | 0:e0f604f504c4 | 10 | |
ethanharstad | 2:51de41e0e0c9 | 11 | void setFrequency(int hz); |
ethanharstad | 2:51de41e0e0c9 | 12 | |
ethanharstad | 0:e0f604f504c4 | 13 | bool readBit(const uint8_t devAddr, const uint8_t regAddr, const uint8_t bit, uint8_t *data); |
ethanharstad | 0:e0f604f504c4 | 14 | bool readBits(const uint8_t devAddr, const uint8_t regAddr, const uint8_t startBit, const uint8_t length, uint8_t *data); |
ethanharstad | 0:e0f604f504c4 | 15 | bool readByte(const uint8_t devAddr, const uint8_t regAddr, uint8_t *data); |
ethanharstad | 0:e0f604f504c4 | 16 | bool readBytes(const uint8_t devAddr, const uint8_t regAddr, uint8_t *data, const uint8_t length); |
ethanharstad | 2:51de41e0e0c9 | 17 | bool readWord(const uint8_t devAddr, const uint8_t regAddr, uint16_t *data); |
ethanharstad | 2:51de41e0e0c9 | 18 | bool readWords(const uint8_t devAddr, const uint8_t regAddr, uint16_t *data, const uint8_t length); |
ethanharstad | 0:e0f604f504c4 | 19 | |
ethanharstad | 0:e0f604f504c4 | 20 | bool writeBit(const uint8_t devAddr, const uint8_t regAddr, const uint8_t bit, const uint8_t data); |
ethanharstad | 0:e0f604f504c4 | 21 | bool writeBits(const uint8_t devAddr, const uint8_t regAddr, const uint8_t startBit, const uint8_t length, const uint8_t data); |
ethanharstad | 0:e0f604f504c4 | 22 | bool writeByte(const uint8_t devAddr, const uint8_t regAddr, const uint8_t data); |
ethanharstad | 0:e0f604f504c4 | 23 | bool writeBytes(const uint8_t devAddr, const uint8_t regAddr, const uint8_t *data, const uint8_t length); |
ethanharstad | 0:e0f604f504c4 | 24 | private: |
ethanharstad | 0:e0f604f504c4 | 25 | I2C i2c_; |
ethanharstad | 0:e0f604f504c4 | 26 | }; |
ethanharstad | 0:e0f604f504c4 | 27 | |
ethanharstad | 0:e0f604f504c4 | 28 | #endif |