For nucleoF103 change sda,scl to PB_7,PB_6
Dependents: AGV_0411 AGV_SMT_Sevro AGV_SMT
Fork of MPU6050-DMP by
Diff: I2Cdev.cpp
- Revision:
- 6:fe57b4405983
- Parent:
- 2:f8bfb37b2e1f
- Child:
- 8:473800bd51ac
--- a/I2Cdev.cpp Sat Nov 23 16:47:00 2013 +0000 +++ b/I2Cdev.cpp Wed Oct 25 08:08:53 2017 +0000 @@ -5,7 +5,7 @@ #include "I2Cdev.h" -#define useDebugSerial +//#define useDebugSerial I2Cdev::I2Cdev(): i2c(I2C_SDA,I2C_SCL), debugSerial(USBTX, USBRX) { @@ -254,14 +254,15 @@ 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]); + char *writeData = (char*)malloc(length+1); + writeData[0] = regAddr; + + for(int i=0; i<length ; i++){ + writeData[i+1] = data[i]; } - i2c.stop(); - return true; + int res = i2c.write(devAddr<<1, writeData, length+1, true); + free(writeData); + return res; } bool I2Cdev::writeWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data)