STM32 MPU6050驱动程序
| 芯片复制提供完整的附加函数,方便移植使用: 芯片复制提供完整的驱动以及移植好的DMP库: 芯片复制MPU6050模块:输出原始数据通过内置DMP进行数据处理,获取姿态信息:角度、角速度,多用于PID控制。 IIC接口引脚配置 3.3V供电 SDA:PB11 SCL:PB10 AD0:PB2 //INT:PB5 中断,暂时用不到 通信协议层:mpu_iic.c/mpu_iic.h 软件模拟IIC,是STM32与MPU6050通信的基本框架 驱动层:mpu6050.c/mpu6050.h 建立在IIC通信机制上的,向DMP库提供对MPU6050寄存器的读写操作,以及完成对MPU6050初始化的任务。 应用层: 移植的库:inv_mpu.c/inv_mpu_dmp_motion_driver.c(及所包含的头文件) 移植的DMP库,对原始数据进行处理, 调用时,在inv_mpu.c中添加如下代码即可(实际上是让DMP库和我们写的驱动层建立联系) #define i2c_write MPU_Write_Continue #define i2c_read MPU_Read_Continue #define delay_ms delay_ms #define get_ms mget_ms 附加的函数:延时、串口打印,这些到时候可以统一 芯片复制具体使用例子如下: #include "stm32f10x.h" #include "usart.h" #include "delay.h" #include "mpu6050.h" #include "inv_mpu.h" #include "inv_mpu_dmp_motion_driver.h" int main(void) { uint8_t x=0; float pitch,roll,yaw; //欧拉角 short aacx,aacy,aacz; //加速度传感器原始数据 short gyrox,gyroy,gyroz; //陀螺仪原始数据 short temp; //温度 NVIC_PriorityGroupConfig( 2 ); delay_init(); USART1_Init(115200); printf("程序开始\n"); if( MPU_Init()!=0 ) { printf("MPU6050初始化错误!\n"); return 0; } if( mpu_dmp_init() ) { printf("DMP初始化错误!\n"); return 0; } |

芯片解密