48 lines
880 B
C
48 lines
880 B
C
#include "stm32f10x.h" // Device header
|
|
#include "delay.h"
|
|
#include "MPU6050.h"
|
|
#include "usart1.h"
|
|
#include "imu.h"
|
|
#include "alldata.h"
|
|
#include "string.h"
|
|
#include "stdlib.h"
|
|
#include "stdio.h"
|
|
#include "led.h"
|
|
#define _PI 3.14159265359
|
|
#define _PI_2 1.57079632679
|
|
uint8_t ID;
|
|
|
|
int main(void)
|
|
{
|
|
usart1_Init(2000000);
|
|
TX_485;
|
|
led_init();
|
|
led = 1;
|
|
printf("hello world\n");
|
|
|
|
delay_ms(1000);
|
|
delay_ms(1000);
|
|
delay_ms(1000);
|
|
MPU6050_Init(); //³õʼ»¯MPU6050
|
|
ID = MPU6050_GetID();
|
|
printf("id=%d",ID);
|
|
imu_rest();
|
|
|
|
USART_RX_STA=0;
|
|
memset(USART_RX_BUF,0,64);
|
|
u32 i=0;
|
|
while(1)
|
|
{
|
|
if( MpuGetData() == 0)
|
|
{
|
|
// i++;
|
|
GetAngle(&MPU6050,&Angle,0.003f);
|
|
float x = Angle.pitch / 180.f * _PI;
|
|
float y = Angle.roll / 180.f * _PI;
|
|
printf("%fy%f\r\n",x,y);
|
|
//// printf("y%.3f\r\n",Angle.roll / 180.f * _PI);
|
|
// printf("A%dA",i);
|
|
}
|
|
}
|
|
}
|