-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
46 lines (39 loc) · 1.02 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "stm32f10x.h"
#include "bsp_usart1.h"
#include "bsP_i2c_ee.h"
#include "bno055.h"
#include "delay.h"
#include <string.h>
extern bno055_struct bno055;
void I2C_Test(void);
int main(void)
{
u8 data=0;
u8 i=BNO055_CONFIG_MODE,j=0x20;
double pitch=0,roll=0,yaw=0;
/* ´®¿Ú1³õʼ»¯ */
delay_init();
USARTx_Config();
/* I2C ÍâÉè³õ(AT24C02)ʼ»¯ */
I2C_BNO_Init();
delay_ms(1000);
/* at least 650ms from reset to config mode */
while(BNO055_Init()){
printf("devier init error\r\n");
I2C_WriteByte_s(BNO055_OPR_MODE_ADDR,&i,1);
I2C_WriteByte_s(BNO055_SYS_TRIGGER_ADDR,&j,1);
delay_ms(1000);
}
delay_ms(1000);
while (1){
get_euler_angles(bno055.eular);
for(i=0;i<3;i++)
printf("euler [%d]:%d\r\n",i,bno055.eular[i]);
yaw=(double)bno055.eular[0]/16.0;
roll=(double)bno055.eular[1]/16.0;
pitch=(double)bno055.eular[2]/16.0;
printf("roll %0.2f,pitch %0.2f,yaw %0.2f\r\n",roll,pitch,yaw);
delay_ms(200);
}
}
/*********************************************END OF FILE**********************/