Ported from Arduino Library : https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050

Dependents:   mpu6050_test testI2C Hobby_Humanoid_controlor mpu6050_test ... more

Adding support for magnetometer of MPU9150

I also fixed some compiler warnings

Ported from Arduino Library by Szymon Gaertig: https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050 added Magnetometer support gyroscope, I2C, MPU-6050, MPU6050, MPU60x0, MPU9150

1 comment:

20 Jun 2013

I should use Mr. Kodewitz's version, but I used Mr. Gaertig's original, found a bug in the i2cdev code. After fixing this bug, the library works very well.

a bug in the I2Cdev, memory leak

int8_t I2Cdev::readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data, uint16_t timeout)
{
    char command[1];
    command[0] = regAddr;
    char *redData = (char*)malloc(length);
    i2c.write(devAddr<<1, command, 1, true);
    i2c.read(devAddr<<1, redData, length);
    for(int i =0; i < length; i++) {
        data[i] = redData[i];
    }
    
    /////////////////////////////////////////////////////////////
    free(redData);   // Y.Kuroda   Jun.20,2013
    /////////////////////////////////////////////////////////////
    
    return length;
}