IMU Library
Dependents: Cube_Mini_Solution Cube_Mini_Solution
I2Cdev.h@3:8d033f880fce, 2020-01-31 (annotated)
- Committer:
- BoulusAJ
- Date:
- Fri Jan 31 17:59:05 2020 +0000
- Revision:
- 3:8d033f880fce
- Parent:
- 2:8c562a8fed36
Latest changes.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
garfieldsg | 0:662207e34fba | 1 | //ported from arduino library: https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050 |
garfieldsg | 0:662207e34fba | 2 | //written by szymon gaertig (email: szymon@gaertig.com.pl) |
garfieldsg | 0:662207e34fba | 3 | // |
garfieldsg | 0:662207e34fba | 4 | //Changelog: |
garfieldsg | 0:662207e34fba | 5 | //2013-01-08 - first beta release |
garfieldsg | 0:662207e34fba | 6 | |
garfieldsg | 0:662207e34fba | 7 | #ifndef I2Cdev_h |
garfieldsg | 0:662207e34fba | 8 | #define I2Cdev_h |
garfieldsg | 0:662207e34fba | 9 | |
garfieldsg | 0:662207e34fba | 10 | #include "mbed.h" |
garfieldsg | 0:662207e34fba | 11 | |
garfieldsg | 0:662207e34fba | 12 | |
garfieldsg | 0:662207e34fba | 13 | class I2Cdev { |
garfieldsg | 0:662207e34fba | 14 | private: |
garfieldsg | 0:662207e34fba | 15 | I2C i2c; |
garfieldsg | 0:662207e34fba | 16 | public: |
Yihui Xiong | 2:8c562a8fed36 | 17 | I2Cdev(I2C &interface); |
garfieldsg | 0:662207e34fba | 18 | |
garfieldsg | 0:662207e34fba | 19 | int8_t readBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
garfieldsg | 0:662207e34fba | 20 | int8_t readBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
garfieldsg | 0:662207e34fba | 21 | int8_t readBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
garfieldsg | 0:662207e34fba | 22 | int8_t readBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
garfieldsg | 0:662207e34fba | 23 | int8_t readByte(uint8_t devAddr, uint8_t regAddr, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
garfieldsg | 0:662207e34fba | 24 | int8_t readWord(uint8_t devAddr, uint8_t regAddr, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
garfieldsg | 0:662207e34fba | 25 | int8_t readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
garfieldsg | 0:662207e34fba | 26 | int8_t readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
garfieldsg | 0:662207e34fba | 27 | |
garfieldsg | 0:662207e34fba | 28 | bool writeBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t data); |
garfieldsg | 0:662207e34fba | 29 | bool writeBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t data); |
garfieldsg | 0:662207e34fba | 30 | bool writeBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t data); |
garfieldsg | 0:662207e34fba | 31 | bool writeBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t data); |
garfieldsg | 0:662207e34fba | 32 | bool writeByte(uint8_t devAddr, uint8_t regAddr, uint8_t data); |
garfieldsg | 0:662207e34fba | 33 | bool writeWord(uint8_t devAddr, uint8_t regAddr, uint16_t data); |
garfieldsg | 0:662207e34fba | 34 | bool writeBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data); |
garfieldsg | 0:662207e34fba | 35 | bool writeWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data); |
garfieldsg | 0:662207e34fba | 36 | |
garfieldsg | 0:662207e34fba | 37 | static uint16_t readTimeout(void); |
garfieldsg | 0:662207e34fba | 38 | }; |
garfieldsg | 0:662207e34fba | 39 | |
Yihui Xiong | 2:8c562a8fed36 | 40 | #endif |