Gurvan PRIEM
/
RaptorControl
An incomplete quadcopter control programme.
MPU6050/I2Cdev.h@0:9cb9445a11f0, 2013-07-17 (annotated)
- Committer:
- Gurvan
- Date:
- Wed Jul 17 15:58:25 2013 +0000
- Revision:
- 0:9cb9445a11f0
Pour Zobson, fi(r)st commit.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Gurvan | 0:9cb9445a11f0 | 1 | //ported from arduino library: https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050 |
Gurvan | 0:9cb9445a11f0 | 2 | //written by szymon gaertig (email: szymon@gaertig.com.pl), small correction by Aloïs Wolff |
Gurvan | 0:9cb9445a11f0 | 3 | // |
Gurvan | 0:9cb9445a11f0 | 4 | //Changelog: |
Gurvan | 0:9cb9445a11f0 | 5 | //2013-01-08 - first beta release |
Gurvan | 0:9cb9445a11f0 | 6 | //2013-02-18 - fixed a malloc with no free in ::readBytes |
Gurvan | 0:9cb9445a11f0 | 7 | |
Gurvan | 0:9cb9445a11f0 | 8 | #ifndef I2Cdev_h |
Gurvan | 0:9cb9445a11f0 | 9 | #define I2Cdev_h |
Gurvan | 0:9cb9445a11f0 | 10 | |
Gurvan | 0:9cb9445a11f0 | 11 | #include "mbed.h" |
Gurvan | 0:9cb9445a11f0 | 12 | |
Gurvan | 0:9cb9445a11f0 | 13 | #define I2C_SDA PTE0 |
Gurvan | 0:9cb9445a11f0 | 14 | #define I2C_SCL PTE1 |
Gurvan | 0:9cb9445a11f0 | 15 | |
Gurvan | 0:9cb9445a11f0 | 16 | class I2Cdev { |
Gurvan | 0:9cb9445a11f0 | 17 | private: |
Gurvan | 0:9cb9445a11f0 | 18 | I2C i2c; |
Gurvan | 0:9cb9445a11f0 | 19 | Serial debugSerial; |
Gurvan | 0:9cb9445a11f0 | 20 | public: |
Gurvan | 0:9cb9445a11f0 | 21 | I2Cdev(); |
Gurvan | 0:9cb9445a11f0 | 22 | I2Cdev(PinName i2cSda, PinName i2cScl); |
Gurvan | 0:9cb9445a11f0 | 23 | |
Gurvan | 0:9cb9445a11f0 | 24 | int8_t readBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
Gurvan | 0:9cb9445a11f0 | 25 | int8_t readBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
Gurvan | 0:9cb9445a11f0 | 26 | int8_t readBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
Gurvan | 0:9cb9445a11f0 | 27 | int8_t readBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
Gurvan | 0:9cb9445a11f0 | 28 | int8_t readByte(uint8_t devAddr, uint8_t regAddr, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
Gurvan | 0:9cb9445a11f0 | 29 | int8_t readWord(uint8_t devAddr, uint8_t regAddr, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
Gurvan | 0:9cb9445a11f0 | 30 | int8_t readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
Gurvan | 0:9cb9445a11f0 | 31 | int8_t readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
Gurvan | 0:9cb9445a11f0 | 32 | |
Gurvan | 0:9cb9445a11f0 | 33 | bool writeBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t data); |
Gurvan | 0:9cb9445a11f0 | 34 | bool writeBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t data); |
Gurvan | 0:9cb9445a11f0 | 35 | bool writeBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t data); |
Gurvan | 0:9cb9445a11f0 | 36 | bool writeBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t data); |
Gurvan | 0:9cb9445a11f0 | 37 | bool writeByte(uint8_t devAddr, uint8_t regAddr, uint8_t data); |
Gurvan | 0:9cb9445a11f0 | 38 | bool writeWord(uint8_t devAddr, uint8_t regAddr, uint16_t data); |
Gurvan | 0:9cb9445a11f0 | 39 | bool writeBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data); |
Gurvan | 0:9cb9445a11f0 | 40 | bool writeWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data); |
Gurvan | 0:9cb9445a11f0 | 41 | |
Gurvan | 0:9cb9445a11f0 | 42 | static uint16_t readTimeout(void); |
Gurvan | 0:9cb9445a11f0 | 43 | }; |
Gurvan | 0:9cb9445a11f0 | 44 | |
Gurvan | 0:9cb9445a11f0 | 45 | #endif |