
Projet interfaçage
Dependencies: mbed BSP_DISCO_F746NG
I2Cdev.h@1:eb044e6a9033, 2021-06-22 (annotated)
- Committer:
- anthonyp08
- Date:
- Tue Jun 22 12:04:16 2021 +0000
- Revision:
- 1:eb044e6a9033
- Parent:
- 0:1c6757f4b61c
projet
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
anthonyp08 | 0:1c6757f4b61c | 1 | //ported from arduino library: https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050 |
anthonyp08 | 0:1c6757f4b61c | 2 | //written by szymon gaertig (email: szymon@gaertig.com.pl) |
anthonyp08 | 0:1c6757f4b61c | 3 | // |
anthonyp08 | 0:1c6757f4b61c | 4 | //Changelog: |
anthonyp08 | 0:1c6757f4b61c | 5 | //2013-01-08 - first beta release |
anthonyp08 | 0:1c6757f4b61c | 6 | |
anthonyp08 | 0:1c6757f4b61c | 7 | #ifndef I2Cdev_h |
anthonyp08 | 0:1c6757f4b61c | 8 | #define I2Cdev_h |
anthonyp08 | 0:1c6757f4b61c | 9 | |
anthonyp08 | 0:1c6757f4b61c | 10 | #include "mbed.h" |
anthonyp08 | 0:1c6757f4b61c | 11 | |
anthonyp08 | 0:1c6757f4b61c | 12 | |
anthonyp08 | 0:1c6757f4b61c | 13 | class I2Cdev { |
anthonyp08 | 0:1c6757f4b61c | 14 | private: |
anthonyp08 | 0:1c6757f4b61c | 15 | I2C &i2c; |
anthonyp08 | 0:1c6757f4b61c | 16 | public: |
anthonyp08 | 0:1c6757f4b61c | 17 | I2Cdev(I2C &interface); |
anthonyp08 | 0:1c6757f4b61c | 18 | |
anthonyp08 | 0:1c6757f4b61c | 19 | int8_t readBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
anthonyp08 | 0:1c6757f4b61c | 20 | int8_t readBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
anthonyp08 | 0:1c6757f4b61c | 21 | int8_t readBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
anthonyp08 | 0:1c6757f4b61c | 22 | int8_t readBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
anthonyp08 | 0:1c6757f4b61c | 23 | int8_t readByte(uint8_t devAddr, uint8_t regAddr, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
anthonyp08 | 0:1c6757f4b61c | 24 | int8_t readWord(uint8_t devAddr, uint8_t regAddr, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
anthonyp08 | 0:1c6757f4b61c | 25 | int8_t readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
anthonyp08 | 0:1c6757f4b61c | 26 | int8_t readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout()); |
anthonyp08 | 0:1c6757f4b61c | 27 | |
anthonyp08 | 0:1c6757f4b61c | 28 | bool writeBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t data); |
anthonyp08 | 0:1c6757f4b61c | 29 | bool writeBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t data); |
anthonyp08 | 0:1c6757f4b61c | 30 | bool writeBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t data); |
anthonyp08 | 0:1c6757f4b61c | 31 | bool writeBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t data); |
anthonyp08 | 0:1c6757f4b61c | 32 | bool writeByte(uint8_t devAddr, uint8_t regAddr, uint8_t data); |
anthonyp08 | 0:1c6757f4b61c | 33 | bool writeWord(uint8_t devAddr, uint8_t regAddr, uint16_t data); |
anthonyp08 | 0:1c6757f4b61c | 34 | bool writeBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data); |
anthonyp08 | 0:1c6757f4b61c | 35 | bool writeWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data); |
anthonyp08 | 0:1c6757f4b61c | 36 | |
anthonyp08 | 0:1c6757f4b61c | 37 | static uint16_t readTimeout(void); |
anthonyp08 | 0:1c6757f4b61c | 38 | }; |
anthonyp08 | 0:1c6757f4b61c | 39 | |
anthonyp08 | 0:1c6757f4b61c | 40 | #endif |
anthonyp08 | 0:1c6757f4b61c | 41 |