InvenSense Motion Driver v5.1.2 ported
I2Cdev/I2Cdev.h@4:2cb380415dc7, 2014-11-02 (annotated)
- Committer:
- oprospero
- Date:
- Sun Nov 02 19:17:45 2014 +0000
- Revision:
- 4:2cb380415dc7
- Parent:
- 0:4dd021344a6b
Added reset function
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
oprospero | 0:4dd021344a6b | 1 | //ported from arduino library: https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050 |
oprospero | 0:4dd021344a6b | 2 | //written by szymon gaertig (email: szymon@gaertig.com.pl) |
oprospero | 0:4dd021344a6b | 3 | //Altered for Motion Driver v5.1.2 by Prosper Van |
oprospero | 0:4dd021344a6b | 4 | // |
oprospero | 0:4dd021344a6b | 5 | // |
oprospero | 0:4dd021344a6b | 6 | //Changelog: |
oprospero | 0:4dd021344a6b | 7 | //2013-01-08 - first beta release |
oprospero | 0:4dd021344a6b | 8 | //2014-05-30 - Altered for Inverse Motion Driver v5.1.2 |
oprospero | 0:4dd021344a6b | 9 | |
oprospero | 0:4dd021344a6b | 10 | #ifndef I2Cdev_h |
oprospero | 0:4dd021344a6b | 11 | #define I2Cdev_h |
oprospero | 0:4dd021344a6b | 12 | |
oprospero | 0:4dd021344a6b | 13 | #include "mbed.h" |
oprospero | 0:4dd021344a6b | 14 | |
oprospero | 0:4dd021344a6b | 15 | #define I2C_SDA PTC9 |
oprospero | 0:4dd021344a6b | 16 | #define I2C_SCL PTC8 |
oprospero | 0:4dd021344a6b | 17 | |
oprospero | 0:4dd021344a6b | 18 | class I2Cdev { |
oprospero | 0:4dd021344a6b | 19 | private: |
oprospero | 0:4dd021344a6b | 20 | I2C i2c; |
oprospero | 0:4dd021344a6b | 21 | public: |
oprospero | 0:4dd021344a6b | 22 | I2Cdev(); |
oprospero | 0:4dd021344a6b | 23 | I2Cdev(PinName i2cSda, PinName i2cScl); |
oprospero | 0:4dd021344a6b | 24 | void frequency(int hz); |
oprospero | 0:4dd021344a6b | 25 | int8_t readBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
oprospero | 0:4dd021344a6b | 26 | int8_t readBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
oprospero | 0:4dd021344a6b | 27 | int8_t readBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
oprospero | 0:4dd021344a6b | 28 | int8_t readBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
oprospero | 0:4dd021344a6b | 29 | int8_t readByte(uint8_t devAddr, uint8_t regAddr, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
oprospero | 0:4dd021344a6b | 30 | int8_t readWord(uint8_t devAddr, uint8_t regAddr, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
oprospero | 0:4dd021344a6b | 31 | int8_t readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
oprospero | 0:4dd021344a6b | 32 | int8_t readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
oprospero | 0:4dd021344a6b | 33 | |
oprospero | 0:4dd021344a6b | 34 | bool writeBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t data); |
oprospero | 0:4dd021344a6b | 35 | bool writeBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t data); |
oprospero | 0:4dd021344a6b | 36 | bool writeBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t data); |
oprospero | 0:4dd021344a6b | 37 | bool writeBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t data); |
oprospero | 0:4dd021344a6b | 38 | int writeByte(uint8_t devAddr, uint8_t regAddr, uint8_t data); |
oprospero | 0:4dd021344a6b | 39 | bool writeWord(uint8_t devAddr, uint8_t regAddr, uint16_t data); |
oprospero | 0:4dd021344a6b | 40 | int writeBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data); |
oprospero | 0:4dd021344a6b | 41 | bool writeWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data); |
oprospero | 0:4dd021344a6b | 42 | |
oprospero | 0:4dd021344a6b | 43 | static uint16_t readTimeout(void); |
oprospero | 0:4dd021344a6b | 44 | }; |
oprospero | 0:4dd021344a6b | 45 | |
oprospero | 0:4dd021344a6b | 46 | #endif |