Skip to content

Commit

Permalink
fixed mag output
Browse files Browse the repository at this point in the history
mag output was actually accel output. needed to enable bypass mode on
the 9150, then enable the mag
  • Loading branch information
aaron committed Jan 23, 2013
1 parent 3fb69e8 commit ed9e7f3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions firmware/MPU6050/MPU6050.cpp
Expand Up @@ -1721,12 +1721,14 @@ void MPU6050::getMotion9(int16_t* ax, int16_t* ay, int16_t* az, int16_t* gx, int
getMotion6(ax, ay, az, gx, gy, gz); getMotion6(ax, ay, az, gx, gy, gz);


//read mag //read mag
I2Cdev::writeByte(devAddr, MPU6050_RA_INT_PIN_CFG, 0x02); //set i2c bypass enable pin to true to access magnetometer
delay(10);
I2Cdev::writeByte(MPU9150_RA_MAG_ADDRESS, 0x0A, 0x01); //enable the magnetometer
delay(10);
I2Cdev::readBytes(MPU9150_RA_MAG_ADDRESS, MPU9150_RA_MAG_XOUT_L, 6, buffer); I2Cdev::readBytes(MPU9150_RA_MAG_ADDRESS, MPU9150_RA_MAG_XOUT_L, 6, buffer);
*mx = (((int16_t)buffer[0]) << 8) | buffer[1]; *mx = (((int16_t)buffer[0]) << 8) | buffer[1];
*my = (((int16_t)buffer[2]) << 8) | buffer[3]; *my = (((int16_t)buffer[2]) << 8) | buffer[3];
*mz = (((int16_t)buffer[4]) << 8) | buffer[5]; *mz = (((int16_t)buffer[4]) << 8) | buffer[5];


} }
/** Get raw 6-axis motion sensor readings (accel/gyro). /** Get raw 6-axis motion sensor readings (accel/gyro).
* Retrieves all currently available motion sensor values. * Retrieves all currently available motion sensor values.
Expand Down

0 comments on commit ed9e7f3

Please sign in to comment.