Testing the accelerometer

Dependencies:   BNO055_fusion mbed

Committer:
simonscott
Date:
Tue Sep 15 19:37:25 2015 +0000
Revision:
1:f2e456d8ee54
Parent:
0:e4b33729023f
First commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
simonscott 0:e4b33729023f 1 #include "mbed.h"
simonscott 0:e4b33729023f 2 #include "BNO055.h"
simonscott 0:e4b33729023f 3
simonscott 0:e4b33729023f 4 Serial pc(USBTX,USBRX);
simonscott 0:e4b33729023f 5 I2C i2c(D14, D15); // SDA, SCL
simonscott 1:f2e456d8ee54 6 BNO055 imu(i2c, D12); // Reset =D7, addr = BNO055_G_CHIP_ADDR, mode = MODE_NDOF <- as default
simonscott 0:e4b33729023f 7
simonscott 0:e4b33729023f 8 BNO055_ID_INF_TypeDef bno055_id_inf;
simonscott 0:e4b33729023f 9 BNO055_EULER_TypeDef euler_angles;
simonscott 0:e4b33729023f 10
simonscott 0:e4b33729023f 11 int main()
simonscott 0:e4b33729023f 12 {
simonscott 0:e4b33729023f 13 pc.printf("Bosch Sensortec BNO055 test program on " __DATE__ "/" __TIME__ "\r\n");
simonscott 0:e4b33729023f 14 if (imu.chip_ready() == 0)
simonscott 0:e4b33729023f 15 {
simonscott 0:e4b33729023f 16 pc.printf("Bosch BNO055 is NOT avirable!!\r\n");
simonscott 0:e4b33729023f 17 }
simonscott 0:e4b33729023f 18
simonscott 0:e4b33729023f 19 imu.read_id_inf(&bno055_id_inf);
simonscott 0:e4b33729023f 20 pc.printf("CHIP:0x%02x, ACC:0x%02x, MAG:0x%02x, GYR:0x%02x, , SW:0x%04x, , BL:0x%02x\r\n",
simonscott 0:e4b33729023f 21 bno055_id_inf.chip_id, bno055_id_inf.acc_id, bno055_id_inf.mag_id,
simonscott 0:e4b33729023f 22 bno055_id_inf.gyr_id, bno055_id_inf.sw_rev_id, bno055_id_inf.bootldr_rev_id);
simonscott 0:e4b33729023f 23
simonscott 0:e4b33729023f 24 while(1)
simonscott 0:e4b33729023f 25 {
simonscott 0:e4b33729023f 26 imu.get_Euler_Angles(&euler_angles);
simonscott 0:e4b33729023f 27 pc.printf("Heading:%+6.1f [deg], Roll:%+6.1f [deg], Pich:%+6.1f [deg]\r\n",
simonscott 0:e4b33729023f 28 euler_angles.h, euler_angles.r, euler_angles.p);
simonscott 0:e4b33729023f 29 wait(0.5);
simonscott 0:e4b33729023f 30 }
simonscott 0:e4b33729023f 31 }
simonscott 0:e4b33729023f 32