うおーるぼっとLEDのワークショップ用

Dependencies:   mbed

Committer:
jksoft
Date:
Sat Feb 04 03:33:08 2017 +0000
Revision:
3:b707c09b4433
Parent:
0:9fcc79b3f00e
????

Who changed what in which revision?

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