a

Committer:
nanjo
Date:
Mon May 06 04:21:43 2019 +0000
Revision:
1:0631d7e009fa
Parent:
0:3aa973ebe3e5
a

Who changed what in which revision?

UserRevisionLine numberNew contents of line
syundo0730 0:3aa973ebe3e5 1 //ported from arduino library: https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050
syundo0730 0:3aa973ebe3e5 2 //written by szymon gaertig (email: szymon@gaertig.com.pl)
syundo0730 0:3aa973ebe3e5 3 // modified by shundo kishi
syundo0730 0:3aa973ebe3e5 4 //
syundo0730 0:3aa973ebe3e5 5 // Changelog:
syundo0730 0:3aa973ebe3e5 6 // 2013-01-08 - first release
syundo0730 0:3aa973ebe3e5 7 // 2016-01-31 - changed all functions and variables static to make porting from arduino easier(by shundo kishi)
syundo0730 0:3aa973ebe3e5 8
syundo0730 0:3aa973ebe3e5 9 #ifndef I2Cdev_h
syundo0730 0:3aa973ebe3e5 10 #define I2Cdev_h
syundo0730 0:3aa973ebe3e5 11
syundo0730 0:3aa973ebe3e5 12 #include "mbed.h"
syundo0730 0:3aa973ebe3e5 13
nanjo 1:0631d7e009fa 14 #define I2C_SDA PB_9
nanjo 1:0631d7e009fa 15 #define I2C_SCL PB_8
syundo0730 0:3aa973ebe3e5 16
nanjo 1:0631d7e009fa 17 class I2Cdev
nanjo 1:0631d7e009fa 18 {
nanjo 1:0631d7e009fa 19 private:
syundo0730 0:3aa973ebe3e5 20
nanjo 1:0631d7e009fa 21 I2C i2c;
nanjo 1:0631d7e009fa 22 public:
nanjo 1:0631d7e009fa 23 I2Cdev();
nanjo 1:0631d7e009fa 24 I2Cdev(PinName i2cSda, PinName i2cScl);
nanjo 1:0631d7e009fa 25 int8_t readBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout());
nanjo 1:0631d7e009fa 26 int8_t readBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout());
nanjo 1:0631d7e009fa 27 int8_t readBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout());
nanjo 1:0631d7e009fa 28 int8_t readBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout());
nanjo 1:0631d7e009fa 29 int8_t readByte(uint8_t devAddr, uint8_t regAddr, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout());
nanjo 1:0631d7e009fa 30 int8_t readWord(uint8_t devAddr, uint8_t regAddr, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout());
nanjo 1:0631d7e009fa 31 int8_t readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout());
nanjo 1:0631d7e009fa 32 int8_t readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout());
syundo0730 0:3aa973ebe3e5 33
nanjo 1:0631d7e009fa 34 bool writeBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t data);
nanjo 1:0631d7e009fa 35 bool writeBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t data);
nanjo 1:0631d7e009fa 36 bool writeBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t data);
nanjo 1:0631d7e009fa 37 bool writeBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t data);
nanjo 1:0631d7e009fa 38 bool writeByte(uint8_t devAddr, uint8_t regAddr, uint8_t data);
nanjo 1:0631d7e009fa 39 bool writeWord(uint8_t devAddr, uint8_t regAddr, uint16_t data);
nanjo 1:0631d7e009fa 40 bool writeBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data);
nanjo 1:0631d7e009fa 41 bool writeWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data);
syundo0730 0:3aa973ebe3e5 42
nanjo 1:0631d7e009fa 43 static uint16_t readTimeout(void);
syundo0730 0:3aa973ebe3e5 44 };
syundo0730 0:3aa973ebe3e5 45
syundo0730 0:3aa973ebe3e5 46 #endif