Permalink
Browse files

fixed mag output

mag output was actually accel output. needed to enable bypass mode on
the 9150, then enable the mag
  • Loading branch information...
1 parent 3fb69e8 commit ed9e7f3aadeba27db4e580a785a578acb747f6e0 aaron committed Jan 23, 2013
Showing with 5 additions and 3 deletions.
  1. +5 −3 firmware/MPU6050/MPU6050.cpp
@@ -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);
//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);
*mx = (((int16_t)buffer[0]) << 8) | buffer[1];
*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).
* Retrieves all currently available motion sensor values.

0 comments on commit ed9e7f3

Please sign in to comment.