|
- #include "delay.h"
- #include "sys.h"
- #include "usart.h"
- #include "serial.h"
- #include "led.h"
- #include "motor.h"
- #include "cap.h"
- #include "timer.h"
- #include "mpu6050.h"
- #include "mpuiic.h"
- #include "inv_mpu.h"
- #include "inv_mpu_dmp_motion_driver.h"
- extern u16 ADV[128];
- extern u8 CCD_Zhongzhi;
- extern u8 CCD_Yuzhi;
- extern u16 TIM2CH1_CAPTURE_STA;
- extern u16 TIM2CH1_CAPTURE_VAL;
- extern u16 TIM1CH1_CAPTURE_STA;
- extern u16 TIM1CH1_CAPTURE_VAL;
- u8 count_flag=0;
- int main(void)
- {
- u8 num;
- float pitch,roll,yaw; //歐拉角
- short aacx,aacy,aacz; //加速度傳感器原始數據
- short gyrox,gyroy,gyroz; //陀螺儀原始數據
- short temp; //溫度
-
- SystemInit(); //初始化RCC 設置系統主頻為72MHZ
- delay_init(); //延時初始化
- uart_init(115200);
- MPU_Init(); //初始化MPU6050
- mpu_dmp_init();
- while(mpu_dmp_init())//初始化dmp,初始化不過報錯
- {
- printf("%d",mpu_dmp_init());
- }
-
- while(1)
- {
- if(mpu_dmp_get_data(&pitch,&roll,&yaw)==0)
- {
- temp=MPU_Get_Temperature(); //得到溫度值
- MPU_Get_Accelerometer(&aacx,&aacy,&aacz); //得到加速度傳感器數據
- MPU_Get_Gyroscope(&gyrox,&gyroy,&gyroz); //得到陀螺儀數據
- }
- num++;
- if(num == 50) //每500msLED0閃爍一次
- {
- num = 0;
- // printf("%d %d %d\r\n",gyrox,gyroy,gyroz);
- // printf("%d %d %d\r\n",aacx,aacy,aacz);
- printf("x:%3.3f y:%3.3f z:%3.3f\r\n",pitch,roll,yaw);
- // printf("temp:%d\r\n",temp);
- printf("\r\n");
- }
- delay_ms(10);
- }
- }
復制代碼
|
-
-
串口.7z
2019-10-13 18:07 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
245.13 KB, 下載次數: 12, 下載積分: 黑幣 -5
|