![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
MPU6050 issues
Fork of MPU6050 by
I2Cdev.h@6:6300d9561dfd, 2014-07-01 (annotated)
- Committer:
- chris1seto
- Date:
- Tue Jul 01 16:56:00 2014 +0000
- Revision:
- 6:6300d9561dfd
- Parent:
- 0:662207e34fba
Initial MPU6050 issues
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 | |
chris1seto | 6:6300d9561dfd | 12 | #define I2C_SDA PB_9 |
chris1seto | 6:6300d9561dfd | 13 | #define I2C_SCL PB_8 |
garfieldsg | 0:662207e34fba | 14 | |
garfieldsg | 0:662207e34fba | 15 | class I2Cdev { |
garfieldsg | 0:662207e34fba | 16 | private: |
garfieldsg | 0:662207e34fba | 17 | I2C i2c; |
garfieldsg | 0:662207e34fba | 18 | public: |
garfieldsg | 0:662207e34fba | 19 | I2Cdev(); |
garfieldsg | 0:662207e34fba | 20 | I2Cdev(PinName i2cSda, PinName i2cScl); |
garfieldsg | 0:662207e34fba | 21 | |
garfieldsg | 0:662207e34fba | 22 | int8_t readBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
garfieldsg | 0:662207e34fba | 23 | int8_t readBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
garfieldsg | 0:662207e34fba | 24 | 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 | 25 | 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 | 26 | int8_t readByte(uint8_t devAddr, uint8_t regAddr, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
garfieldsg | 0:662207e34fba | 27 | int8_t readWord(uint8_t devAddr, uint8_t regAddr, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
garfieldsg | 0:662207e34fba | 28 | int8_t readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
garfieldsg | 0:662207e34fba | 29 | int8_t readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
garfieldsg | 0:662207e34fba | 30 | |
garfieldsg | 0:662207e34fba | 31 | bool writeBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t data); |
garfieldsg | 0:662207e34fba | 32 | bool writeBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t data); |
garfieldsg | 0:662207e34fba | 33 | bool writeBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t data); |
garfieldsg | 0:662207e34fba | 34 | bool writeBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t data); |
garfieldsg | 0:662207e34fba | 35 | bool writeByte(uint8_t devAddr, uint8_t regAddr, uint8_t data); |
garfieldsg | 0:662207e34fba | 36 | bool writeWord(uint8_t devAddr, uint8_t regAddr, uint16_t data); |
garfieldsg | 0:662207e34fba | 37 | bool writeBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data); |
garfieldsg | 0:662207e34fba | 38 | bool writeWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data); |
garfieldsg | 0:662207e34fba | 39 | |
garfieldsg | 0:662207e34fba | 40 | static uint16_t readTimeout(void); |
garfieldsg | 0:662207e34fba | 41 | }; |
garfieldsg | 0:662207e34fba | 42 | |
garfieldsg | 0:662207e34fba | 43 | #endif |