IMU code

Dependencies:   BNO055_fusion mbed

Fork of Bosch_BNO055_Fusion_example by Kenji Arai

Files at this revision

API Documentation at this revision

Comitter:
EmbeddedSam
Date:
Thu Apr 27 09:41:19 2017 +0000
Parent:
5:9594519c9462
Commit message:
Example from online, working before Croatia;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 9594519c9462 -r 58bb66439a03 main.cpp
--- a/main.cpp	Thu Apr 16 11:25:47 2015 +0000
+++ b/main.cpp	Thu Apr 27 09:41:19 2017 +0000
@@ -25,25 +25,11 @@
 
 //  Object ----------------------------------------------------------------------------------------
 Serial pc(USBTX,USBRX);
-#if defined(TARGET_LPC1114)
-DigitalOut pwr_onoff(dp17);
-I2C    i2c(dp5, dp27);   // SDA, SCL
-BNO055 imu(i2c, dp18);  // Reset =D7, addr = BNO055_G_CHIP_ADDR, mode = MODE_NDOF <- as default
-#elif defined(TARGET_LPC1768)
-DigitalOut pwr_onoff(p30);
-I2C    i2c(p28, p27); // SDA, SCL
-BNO055 imu(i2c, p29);  // Reset =D7, addr = BNO055_G_CHIP_ADDR, mode = MODE_NDOF <- as default
-#elif defined(TARGET_STM32L152RE) || defined(TARGET_STM32F401RE) || defined(TARGET_STM32F411RE)
+
 DigitalOut pwr_onoff(PB_10);
-I2C    i2c(PB_9, PB_8); // SDA, SCL
-BNO055 imu(i2c, PA_8);  // Reset =D7, addr = BNO055_G_CHIP_ADDR, mode = MODE_NDOF <- as default
-#elif defined(TARGET_RZ_A1H)
-DigitalOut pwr_onoff(P8_11);
-I2C    i2c(P1_3, P1_2); // SDA, SCL
-BNO055 imu(i2c, P8_13);  // Reset =D7, addr = BNO055_G_CHIP_ADDR, mode = MODE_NDOF <- as default
-#else
-#error "Not cheched yet"
-#endif
+I2C    i2c(D14, D15); // SDA, SCL
+BNO055 imu(i2c, D5);  // Reset =D5, addr = BNO055_G_CHIP_ADDR, mode = MODE_NDOF <- as default
+
 Timer t;
 
 //  RAM -------------------------------------------------------------------------------------------
@@ -65,7 +51,7 @@
 //  Please refer BNO055 Data sheet 3.10 Calibration & 3.6.4 Sensor calibration data
 void bno055_calbration(void){
     uint8_t d;
-
+ 
     pc.printf("------ Enter BNO055 Manual Calibration Mode ------\r\n");
     //---------- Gyroscope Caliblation ------------------------------------------------------------
     // (a) Place the device in a single stable position for a period of few seconds to allow the
@@ -127,10 +113,11 @@
 }
 
 int main(){
+    pc.baud(921600);
     imu.set_mounting_position(MT_P6);
     pwr_onoff = 0;
-    pc.printf("\r\n\r\nIf pc terminal soft is ready, please hit any key!\r\n");
-    char c = pc.getc();
+    //pc.printf("\r\n\r\nIf pc terminal soft is ready, please hit any key!\r\n");
+    //char c = pc.getc();
     pc.printf("Bosch Sensortec BNO055 test program on " __DATE__ "/" __TIME__ "\r\n");
     // Is BNO055 avairable?
     if (imu.chip_ready() == 0){
@@ -151,10 +138,10 @@
     pc.printf("SW REV:0x%04x, BL REV:0x%02x\r\n",
         bno055_id_inf.sw_rev_id, bno055_id_inf.bootldr_rev_id);
     pc.printf("If you would like to calibrate the BNO055, please hit 'y' (No: any other key)\r\n");
-    c = pc.getc();
-    if (c == 'y'){
-        bno055_calbration();
-    }
+    //c = pc.getc();
+//    if (c == 'y'){
+//        bno055_calbration();
+//    }
     pc.printf("[E]:Euler Angles[deg],[Q]:Quaternion[],[L]:Linear accel[m/s*s],");
     pc.printf("[G]:Gravity vector[m/s*s],[T]:Chip temperature,Acc,Gyr[degC],[S]:Status,[M]:time[mS]\r\n");
     t.start();
@@ -180,66 +167,3 @@
 }
 
 
-// Diffrent output format as for your reference
-#if 0
-int main() {
-    uint8_t i;
-
-    pwr_onoff = 0;
-    pc.printf("Bosch Sensortec BNO055 test program on " __DATE__ "/" __TIME__ "\r\n");
-    // Is BNO055 avairable?
-    if (imu.chip_ready() == 0){
-        do {
-            pc.printf("Bosch BNO055 is NOT avirable!!\r\n");
-            pwr_onoff = 1;  // Power off
-            wait(0.1);
-            pwr_onoff = 0;  // Power on
-            wait(0.02);
-        } while(imu.reset());
-    }
-    imu.set_mounting_position(MT_P6);
-    pc.printf("AXIS_REMAP_CONFIG:0x%02x, AXIS_REMAP_SIGN:0x%02x\r\n",
-               imu.read_reg0(BNO055_AXIS_MAP_CONFIG), imu.read_reg0(BNO055_AXIS_MAP_SIGN));    
-    imu.read_id_inf(&bno055_id_inf);
-    pc.printf("CHIP:0x%02x, ACC:0x%02x, MAG:0x%02x, GYR:0x%02x, , SW:0x%04x, , BL:0x%02x\r\n",
-               bno055_id_inf.chip_id, bno055_id_inf.acc_id, bno055_id_inf.mag_id,
-               bno055_id_inf.gyr_id, bno055_id_inf.sw_rev_id, bno055_id_inf.bootldr_rev_id);
-    while(1) {
-        pc.printf("Euler Angles data\r\n");
-        for (i = 0; i < NUM_LOOP; i++){
-            imu.get_Euler_Angles(&euler_angles);
-            pc.printf("Heading:%+6.1f [deg], Roll:%+6.1f [deg], Pich:%+6.1f [deg], #%02d\r\n",
-                       euler_angles.h, euler_angles.r, euler_angles.p, i);
-            wait(0.5);
-        }
-        pc.printf("Quaternion data\r\n");
-        for (i = 0; i < NUM_LOOP; i++){
-            imu.get_quaternion(&quaternion);
-            pc.printf("W:%d, X:%d, Y:%d, Z:%d, #%02d\r\n",
-                       quaternion.w, quaternion.x, quaternion.y, quaternion.z, i);
-            wait(0.5);
-        }
-        pc.printf("Linear accel data\r\n");
-        for (i = 0; i < NUM_LOOP; i++){
-            imu.get_linear_accel(&linear_acc);
-            pc.printf("X:%+6.1f [m/s*s], Y:%+6.1f [m/s*s], Z:%+6.1f [m/s*s], #%02d\r\n",
-                       linear_acc.x, linear_acc.y, linear_acc.z, i);
-            wait(0.5);
-        }
-        pc.printf("Gravity vector data\r\n");
-        for (i = 0; i < NUM_LOOP; i++){
-            imu.get_gravity(&gravity);
-            pc.printf("X:%+6.1f [m/s*s], Y:%+6.1f [m/s*s], Z:%+6.1f [m/s*s], #%02d\r\n",
-                       gravity.x, gravity.y, gravity.z, i);
-            wait(0.5);
-        }
-        pc.printf("Chip temperature data\r\n");
-        for (i = 0; i < (NUM_LOOP / 4); i++){
-            imu.get_chip_temperature(&chip_temp);
-            pc.printf("Acc chip:%+d [degC], Gyr chip:%+d [degC], #%02d\r\n",
-                       chip_temp.acc_chip, chip_temp.gyr_chip, i);
-            wait(0.5);
-        }
-    }
-}
-#endif
diff -r 9594519c9462 -r 58bb66439a03 mbed.bld
--- a/mbed.bld	Thu Apr 16 11:25:47 2015 +0000
+++ b/mbed.bld	Thu Apr 27 09:41:19 2017 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/433970e64889
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/082adc85693f
\ No newline at end of file