dsafeadf
Fork of MPU6050-DMP-Ian by
I2C/I2Cdev.h@6:2dc23167c8d8, 2014-04-29 (annotated)
- Committer:
- pHysiX
- Date:
- Tue Apr 29 10:36:21 2014 +0000
- Revision:
- 6:2dc23167c8d8
- Child:
- 14:3f0bc381e1dd
Working in RTOS
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pHysiX | 6:2dc23167c8d8 | 1 | //ported from arduino library: https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050 |
pHysiX | 6:2dc23167c8d8 | 2 | //written by szymon gaertig (email: szymon@gaertig.com.pl) |
pHysiX | 6:2dc23167c8d8 | 3 | // |
pHysiX | 6:2dc23167c8d8 | 4 | //Changelog: |
pHysiX | 6:2dc23167c8d8 | 5 | //2013-01-08 - first beta release |
pHysiX | 6:2dc23167c8d8 | 6 | |
pHysiX | 6:2dc23167c8d8 | 7 | #ifndef I2Cdev_h |
pHysiX | 6:2dc23167c8d8 | 8 | #define I2Cdev_h |
pHysiX | 6:2dc23167c8d8 | 9 | |
pHysiX | 6:2dc23167c8d8 | 10 | #include "mbed.h" |
pHysiX | 6:2dc23167c8d8 | 11 | |
pHysiX | 6:2dc23167c8d8 | 12 | #define I2C_SDA p9 |
pHysiX | 6:2dc23167c8d8 | 13 | #define I2C_SCL p10 |
pHysiX | 6:2dc23167c8d8 | 14 | |
pHysiX | 6:2dc23167c8d8 | 15 | class I2Cdev |
pHysiX | 6:2dc23167c8d8 | 16 | { |
pHysiX | 6:2dc23167c8d8 | 17 | private: |
pHysiX | 6:2dc23167c8d8 | 18 | I2C i2c; |
pHysiX | 6:2dc23167c8d8 | 19 | |
pHysiX | 6:2dc23167c8d8 | 20 | public: |
pHysiX | 6:2dc23167c8d8 | 21 | Serial debugSerial; |
pHysiX | 6:2dc23167c8d8 | 22 | I2Cdev(); |
pHysiX | 6:2dc23167c8d8 | 23 | I2Cdev(PinName i2cSda, PinName i2cScl); |
pHysiX | 6:2dc23167c8d8 | 24 | |
pHysiX | 6:2dc23167c8d8 | 25 | int8_t readBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
pHysiX | 6:2dc23167c8d8 | 26 | int8_t readBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
pHysiX | 6:2dc23167c8d8 | 27 | int8_t readBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
pHysiX | 6:2dc23167c8d8 | 28 | int8_t readBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
pHysiX | 6:2dc23167c8d8 | 29 | int8_t readByte(uint8_t devAddr, uint8_t regAddr, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
pHysiX | 6:2dc23167c8d8 | 30 | int8_t readWord(uint8_t devAddr, uint8_t regAddr, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
pHysiX | 6:2dc23167c8d8 | 31 | int8_t readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
pHysiX | 6:2dc23167c8d8 | 32 | int8_t readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
pHysiX | 6:2dc23167c8d8 | 33 | |
pHysiX | 6:2dc23167c8d8 | 34 | bool writeBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t data); |
pHysiX | 6:2dc23167c8d8 | 35 | bool writeBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t data); |
pHysiX | 6:2dc23167c8d8 | 36 | bool writeBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t data); |
pHysiX | 6:2dc23167c8d8 | 37 | bool writeBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t data); |
pHysiX | 6:2dc23167c8d8 | 38 | bool writeByte(uint8_t devAddr, uint8_t regAddr, uint8_t data); |
pHysiX | 6:2dc23167c8d8 | 39 | bool writeWord(uint8_t devAddr, uint8_t regAddr, uint16_t data); |
pHysiX | 6:2dc23167c8d8 | 40 | bool writeBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data); |
pHysiX | 6:2dc23167c8d8 | 41 | bool writeWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data); |
pHysiX | 6:2dc23167c8d8 | 42 | |
pHysiX | 6:2dc23167c8d8 | 43 | static uint16_t readTimeout(void); |
pHysiX | 6:2dc23167c8d8 | 44 | }; |
pHysiX | 6:2dc23167c8d8 | 45 | |
pHysiX | 6:2dc23167c8d8 | 46 | #endif |