ddwdwdrr
Fork of MPU6050 by
Diff: I2Cdev.cpp
- Revision:
- 3:4cd07e9f2802
- Parent:
- 0:662207e34fba
--- a/I2Cdev.cpp Wed Oct 07 06:58:05 2015 +0000 +++ b/I2Cdev.cpp Wed Oct 07 12:23:32 2015 +0000 @@ -129,6 +129,8 @@ */ int8_t I2Cdev::readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data, uint16_t timeout) { + /* + // I don't know why not work if i use this code. maybe malloc problem? char command[1]; command[0] = regAddr; char *redData = (char*)malloc(length); @@ -138,6 +140,10 @@ data[i] = redData[i]; } return length; + */ + i2c.write(devAddr<<1, (char*)®Addr, sizeof(regAddr), true); + i2c.read(devAddr<<1, (char*)data, length); + return length; } int8_t I2Cdev::readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data, uint16_t timeout)