u8 MPU9250SPI_Init(void)
{
u8 res;
MPU9250_IOAndSPI_Init();//MPU9250 IO¿úoíSPI3õê¼»ˉ
MPU9250_Write_Reg(PWR_MGMT_1,0X80); //μçÔ′1üàí,¸′λMPU9250
delay_ms(100);
MPU9250_Write_Reg(PWR_MGMT_1,0X00); //μçÔ′1üàí,¸′λMPU9250
MPU9250_Write_Reg(USER_CTRL,0X00); //I2CÖ÷Ä£ê½1رÕ
MPU9250_Write_Reg(USER_CTRL,0X10); //ê1ÄüMPU9250SPI
MPU9250_Write_Reg(SMPLRT_DIV,0x07);//2éÑùÂê1000/(1+7)=125HZ
MPU9250_Write_Reg(CONFIG,0X07); //μíí¨ÂË2¨Æ÷ 0x06 5hz,èôéèÎa0x00 X07£¬íóÂYòÇμÄÆμÂê¿é′ïμ½8000HZ,
//MPU9250_Write_Reg(ACCEL_CONFIG2,0x00); //¼óËù¶è¼Æ2aá¿·¶Î§ 4000hz
MPU9250_Write_Reg(MPU_INT_EN_REG,0X00); //1رÕËùóDÖD¶Ï
MPU9250_Write_Reg(FIFO_EN,0X00); //1رÕFIFO£¬è«2¿2»ê1Äü£¬BIT3éèÖüóËù¶è′«¸DÆ÷μÄèy¸öÖᣬֻòa¸ÃλÖÃ1£¬Ôò¼óËù¶è′«¸DÆ÷μÄèy¸öí¨μ඼¿aÆôFIFOáË
MPU9250_Write_Reg(MPU_INTBP_CFG_REG,0X80); //INTòy½ÅμíμçƽóDD§
//MPU9250_Write_Reg(GYRO_CONFIG,0X18); //íóÂYòÇ2aá¿·¶Î§ 0X18 Õy¸o2000¶è
//MPU9250_Write_Reg(ACCEL_CONFIG,0x18); //¼óËù¶è¼Æ2aá¿·¶Î§ 0X18 Õy¸o16g
res=MPU9250_Read_Reg(WHO_AM_I);//·μ»ØÖμ
if(res==MPU_ADDR)
{
//MPU9250_Write_Reg(USER_CTRL,0X10); //ê1ÄüMPU9250SPI
//MPU9250_Write_Reg(PWR_MGMT_1,0X00); //μçÔ′1üàí,¸′λMPU9250
//MPU9250_Write_Reg(SMPLRT_DIV,0x07);//2éÑùÂê1000/(1+7)=125HZ
//MPU9250_Write_Reg(CONFIG,0X06); //μíí¨ÂË2¨Æ÷ 0x06 5hz
MPU9250_Write_Reg(GYRO_CONFIG,0X18); //íóÂYòÇ2aá¿·¶Î§ 0X18 Õy¸o2000¶è£¬Ã»óD×Լ죬±äÎa×Ô¼ì0XF8
MPU9250_Write_Reg(ACCEL_CONFIG,0x18); //¼óËù¶è¼Æ2aá¿·¶Î§ 0X18 Õy¸o16g£¬Ã»óD×Լ죬±äÎa×Ô¼ì0XF8
//MPU9250_Write_Reg(ACCEL_CONFIG2,0x08); //¼óËù¶è¼Æ2aá¿·¶Î§ 4000hz
}
else return 1;
return 0;
}
res=MPU9250_Read_Reg(WHO_AM_I); 测试这步不执行 哪位大神指导一下
而且不出数据
一周热门 更多>