我使用地址0x68访问了mpu-9250,并读取了加速度计和陀螺仪的数据。
但现在当我将地址更改为0x0C以访问磁力计时,无论何时尝试读取数据,但它都不会给出确认。
我也有enable_bypass_i2c_pin。
我使用下面的代码:我有问题来获取磁力计的数据。
readBytes_jt(0x68, MPU9250_RA_ACCEL_XOUT_H, 14, buffer);
*ax = (((int16_t)buffer[0]) << 8) | buffer[1];
*ay = (((int16_t)buffer[2]) << 8) | buffer[3];
*az = (((int16_t)buffer[4]) << 8) | buffer[5];
*gx = (((int16_t)buffer[8]) << 8) | buffer[9];
*gy = (((int16_t)buffer[10]) << 8) | buffer[11];
*gz = (((int16_t)buffer[12]) << 8) | buffer[13];
//read mag
writeByte_jt(0x68, MPU9250_RA_INT_PIN_CFG, 0x02); //set i2c bypass enable pin to true to access magnetometer
// delay(10);
delay_s_jt(10);
writeByte_jt(0x0C, 0x0A, 0x01); //enable the magnetometer
// delay(10);
delay_s_jt(10);
readBytes_jt(0x0C,MPU9150_RA_MAG_XOUT_L, 6, buffer);
*mx = (((int16_t)buffer[1]) << 8) | buffer[0];
*my = (((int16_t)buffer[3]) << 8) | buffer[2];
*mz = (((int16_t)buffer[5]) << 8) | buffer[4];