Ported from Arduino Library : https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050
Dependents: kopija_NUCLEO_CELL_LOCKER_copy
Fork of MPU6050 by
Diff: I2Cdev.cpp
- Revision:
- 3:b21c8c3456be
- Parent:
- 2:e2081d9de7af
- Child:
- 4:1e0b279766be
--- a/I2Cdev.cpp Wed Feb 01 11:09:14 2017 +0000 +++ b/I2Cdev.cpp Tue Aug 01 15:03:01 2017 +0000 @@ -7,12 +7,12 @@ #define useDebugSerial -I2Cdev::I2Cdev(): debugSerial(p6, p8), i2c(p26,p27) +I2Cdev::I2Cdev(): i2c(p26,p27) { } -I2Cdev::I2Cdev(PinName p26, PinName p27): debugSerial(p30, p31), i2c(p26,p27) +I2Cdev::I2Cdev(PinName p26, PinName p27): i2c(p26,p27) { } @@ -248,7 +248,7 @@ data_write[0]=regAddr; // I2C sends MSB first. Namely >>|subAddress|>>|data| data_write[1]=data; i2c.write(devAddr,data_write,2,0); // i2c.write(int address, char* data, int length, bool repeated=false); - //return writeBytes(devAddr, regAddr, 1, &data); + return writeBytes(devAddr, regAddr, 1, &data); return true; } @@ -265,11 +265,11 @@ bool I2Cdev::writeBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data) { i2c.start(); - //i2c.write(devAddr<<1); - //i2c.write(regAddr); - //for(int i = 0; i < length; i++) { - // i2c.write(data[i]); - //} + i2c.write(devAddr<<1); + i2c.write(regAddr); + for(int i = 0; i < length; i++) { + i2c.write(data[i]); + } //i2c.write(devAddr, regAddr, ) i2c.stop(); return true;