ddwdwdrr
Fork of MPU6050 by
Revision 3:4cd07e9f2802, committed 2015-10-07
- Comitter:
- antoine4375
- Date:
- Wed Oct 07 12:23:32 2015 +0000
- Parent:
- 2:1215907c700d
- Commit message:
- dddd
Changed in this revision
I2Cdev.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 1215907c700d -r 4cd07e9f2802 I2Cdev.cpp --- 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)