金牌会员
- 积分
- 1153
- 威望
- 579
- 贡献
- 358
- 兑换币
- 381
- 注册时间
- 2014-11-22
- 在线时间
- 108 小时
- 毕业学校
- 河南理工大学万方科技学院
|
void mpu6050_init()
{
i2c_init(I2C0,200000);
lptmr_delay_ms(10);
i2c_write_reg(I2C0,0x68,0x6b,0x00);
i2c_write_reg(I2C0,0x68,0x19,0x00);
i2c_write_reg(I2C0,0x68,0x1a,0x00);
i2c_write_reg(I2C0,0x68,0x1b,0x08);
i2c_write_reg(I2C0,0x68,0x1c,0x00);
}
/************************************
读取mpu6050的值
*************************************/
void mpu6050_read()
{
uint16 msb,lsb;
msb=i2c_read_reg(I2C0,0x68,0x3b);
lsb=i2c_read_reg(I2C0,0x68,0x3c);
accel_x=msb<<8|lsb;
/* msb=i2c_read_reg(I2C0,0x68,0x3d);
lsb=i2c_read_reg(I2C0,0x68,0x3e);
accel_y=msb<<8|lsb;
msb=i2c_read_reg(I2C0,0x68,0x3f);
lsb=i2c_read_reg(I2C0,0x68,0x40);
accel_z=msb<<8|lsb;
msb=i2c_read_reg(I2C0,0x68,0x43);
lsb=i2c_read_reg(I2C0,0x68,0x44);
gyro_x=msb<<8|lsb; */
msb=i2c_read_reg(I2C0,0x68,0x45);
lsb=i2c_read_reg(I2C0,0x68,0x46);
gyro_y=msb<<8|lsb;
/* msb=i2c_read_reg(I2C0,0x68,0x47);
lsb=i2c_read_reg(I2C0,0x68,0x48);
gyro_z=msb<<8|lsb; */
}
I2C野火底层
|
|