dsafeadf
Fork of MPU6050-DMP-Ian by
I2C/I2Cdev.h@14:3f0bc381e1dd, 2014-05-27 (annotated)
- Committer:
- majik
- Date:
- Tue May 27 09:21:09 2014 +0000
- Revision:
- 14:3f0bc381e1dd
- Parent:
- 6:2dc23167c8d8
tempory code
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 | // |
majik | 14:3f0bc381e1dd | 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 | |
majik | 14:3f0bc381e1dd | 12 | #define I2C_SDA PTE0 |
majik | 14:3f0bc381e1dd | 13 | #define I2C_SCL PTE1 |
pHysiX | 6:2dc23167c8d8 | 14 | |
majik | 14:3f0bc381e1dd | 15 | class I2Cdev { |
majik | 14:3f0bc381e1dd | 16 | private: |
majik | 14:3f0bc381e1dd | 17 | I2C i2c; |
majik | 14:3f0bc381e1dd | 18 | Serial debugSerial; |
majik | 14:3f0bc381e1dd | 19 | public: |
majik | 14:3f0bc381e1dd | 20 | I2Cdev(); |
majik | 14:3f0bc381e1dd | 21 | I2Cdev(PinName i2cSda, PinName i2cScl); |
majik | 14:3f0bc381e1dd | 22 | |
majik | 14:3f0bc381e1dd | 23 | int8_t readBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
majik | 14:3f0bc381e1dd | 24 | int8_t readBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
majik | 14:3f0bc381e1dd | 25 | int8_t readBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
majik | 14:3f0bc381e1dd | 26 | int8_t readBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
majik | 14:3f0bc381e1dd | 27 | int8_t readByte(uint8_t devAddr, uint8_t regAddr, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
majik | 14:3f0bc381e1dd | 28 | int8_t readWord(uint8_t devAddr, uint8_t regAddr, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
majik | 14:3f0bc381e1dd | 29 | int8_t readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
majik | 14:3f0bc381e1dd | 30 | int8_t readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
pHysiX | 6:2dc23167c8d8 | 31 | |
majik | 14:3f0bc381e1dd | 32 | bool writeBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t data); |
majik | 14:3f0bc381e1dd | 33 | bool writeBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t data); |
majik | 14:3f0bc381e1dd | 34 | bool writeBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t data); |
majik | 14:3f0bc381e1dd | 35 | bool writeBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t data); |
majik | 14:3f0bc381e1dd | 36 | bool writeByte(uint8_t devAddr, uint8_t regAddr, uint8_t data); |
majik | 14:3f0bc381e1dd | 37 | bool writeWord(uint8_t devAddr, uint8_t regAddr, uint16_t data); |
majik | 14:3f0bc381e1dd | 38 | bool writeBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data); |
majik | 14:3f0bc381e1dd | 39 | bool writeWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data); |
pHysiX | 6:2dc23167c8d8 | 40 | |
majik | 14:3f0bc381e1dd | 41 | static uint16_t readTimeout(void); |
pHysiX | 6:2dc23167c8d8 | 42 | }; |
pHysiX | 6:2dc23167c8d8 | 43 | |
pHysiX | 6:2dc23167c8d8 | 44 | #endif |