![](/media/cache/profiles/c8045671083f48d8d09d1d2523ea8941.50x50_q85.jpg)
Complete MPU6050dmp example working with processing 2.1 teapot code v1.0 Jan. 2014
Fork of MPU6050 by
I2Cdev.h@0:662207e34fba, 2013-01-11 (annotated)
- Committer:
- garfieldsg
- Date:
- Fri Jan 11 00:54:28 2013 +0000
- Revision:
- 0:662207e34fba
- Child:
- 6:029b4b8111ef
first beta release
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 | |
garfieldsg | 0:662207e34fba | 12 | #define I2C_SDA p28 |
garfieldsg | 0:662207e34fba | 13 | #define I2C_SCL p27 |
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 | Serial debugSerial; |
garfieldsg | 0:662207e34fba | 19 | public: |
garfieldsg | 0:662207e34fba | 20 | I2Cdev(); |
garfieldsg | 0:662207e34fba | 21 | I2Cdev(PinName i2cSda, PinName i2cScl); |
garfieldsg | 0:662207e34fba | 22 | |
garfieldsg | 0:662207e34fba | 23 | int8_t readBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
garfieldsg | 0:662207e34fba | 24 | int8_t readBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
garfieldsg | 0:662207e34fba | 25 | 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 | 26 | 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 | 27 | int8_t readByte(uint8_t devAddr, uint8_t regAddr, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
garfieldsg | 0:662207e34fba | 28 | int8_t readWord(uint8_t devAddr, uint8_t regAddr, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
garfieldsg | 0:662207e34fba | 29 | int8_t readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
garfieldsg | 0:662207e34fba | 30 | int8_t readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
garfieldsg | 0:662207e34fba | 31 | |
garfieldsg | 0:662207e34fba | 32 | bool writeBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t data); |
garfieldsg | 0:662207e34fba | 33 | bool writeBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t data); |
garfieldsg | 0:662207e34fba | 34 | bool writeBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t data); |
garfieldsg | 0:662207e34fba | 35 | bool writeBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t data); |
garfieldsg | 0:662207e34fba | 36 | bool writeByte(uint8_t devAddr, uint8_t regAddr, uint8_t data); |
garfieldsg | 0:662207e34fba | 37 | bool writeWord(uint8_t devAddr, uint8_t regAddr, uint16_t data); |
garfieldsg | 0:662207e34fba | 38 | bool writeBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data); |
garfieldsg | 0:662207e34fba | 39 | bool writeWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data); |
garfieldsg | 0:662207e34fba | 40 | |
garfieldsg | 0:662207e34fba | 41 | static uint16_t readTimeout(void); |
garfieldsg | 0:662207e34fba | 42 | }; |
garfieldsg | 0:662207e34fba | 43 | |
garfieldsg | 0:662207e34fba | 44 | #endif |