a

Committer:
syundo0730
Date:
Sun Jan 31 13:52:23 2016 +0000
Revision:
0:3aa973ebe3e5
Child:
1:0631d7e009fa
first commit

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
syundo0730 0:3aa973ebe3e5 14 #define I2C_SDA p28
syundo0730 0:3aa973ebe3e5 15 #define I2C_SCL p27
syundo0730 0:3aa973ebe3e5 16
syundo0730 0:3aa973ebe3e5 17 class I2Cdev {
syundo0730 0:3aa973ebe3e5 18 private:
syundo0730 0:3aa973ebe3e5 19 static I2C i2c;
syundo0730 0:3aa973ebe3e5 20 public:
syundo0730 0:3aa973ebe3e5 21 I2Cdev();
syundo0730 0:3aa973ebe3e5 22
syundo0730 0:3aa973ebe3e5 23 static int8_t readBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout());
syundo0730 0:3aa973ebe3e5 24 static int8_t readBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout());
syundo0730 0:3aa973ebe3e5 25 static int8_t readBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout());
syundo0730 0:3aa973ebe3e5 26 static int8_t readBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout());
syundo0730 0:3aa973ebe3e5 27 static int8_t readByte(uint8_t devAddr, uint8_t regAddr, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout());
syundo0730 0:3aa973ebe3e5 28 static int8_t readWord(uint8_t devAddr, uint8_t regAddr, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout());
syundo0730 0:3aa973ebe3e5 29 static int8_t readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout());
syundo0730 0:3aa973ebe3e5 30 static int8_t readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout());
syundo0730 0:3aa973ebe3e5 31
syundo0730 0:3aa973ebe3e5 32 static bool writeBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t data);
syundo0730 0:3aa973ebe3e5 33 static bool writeBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t data);
syundo0730 0:3aa973ebe3e5 34 static bool writeBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t data);
syundo0730 0:3aa973ebe3e5 35 static bool writeBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t data);
syundo0730 0:3aa973ebe3e5 36 static bool writeByte(uint8_t devAddr, uint8_t regAddr, uint8_t data);
syundo0730 0:3aa973ebe3e5 37 static bool writeWord(uint8_t devAddr, uint8_t regAddr, uint16_t data);
syundo0730 0:3aa973ebe3e5 38 static bool writeBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data);
syundo0730 0:3aa973ebe3e5 39 static bool writeWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data);
syundo0730 0:3aa973ebe3e5 40
syundo0730 0:3aa973ebe3e5 41 static uint16_t readTimeout(void);
syundo0730 0:3aa973ebe3e5 42 };
syundo0730 0:3aa973ebe3e5 43
syundo0730 0:3aa973ebe3e5 44 #endif