Based on F401 example.Changed reset sequence and added RESET control and Power On/Off control. Check several mbed, LPC1768, LPC1114, NucleoF401RE, F411RE, L152RE and GR-PEACH

Dependencies:   BNO055_fusion TextLCD

Please see follows.
/users/kenjiArai/notebook/bno055---orientation-sensor/

Files at this revision

API Documentation at this revision

Comitter:
kenjiArai
Date:
Wed Aug 05 05:29:12 2020 +0000
Parent:
6:5f380fbcf849
Commit message:
run on mbed-os6.2.0

Changed in this revision

BNO055_fusion.lib Show annotated file Show diff for this revision Revisions of this file
TextLCD.lib Show annotated file Show diff for this revision Revisions of this file
check_revision.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
mbed_app.json Show annotated file Show diff for this revision Revisions of this file
--- a/BNO055_fusion.lib	Wed Aug 23 09:45:18 2017 +0000
+++ b/BNO055_fusion.lib	Wed Aug 05 05:29:12 2020 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/users/kenjiArai/code/BNO055_fusion/#07d01bf36ad0
+http://developer.mbed.org/users/kenjiArai/code/BNO055_fusion/#b48d96169302
--- a/TextLCD.lib	Wed Aug 23 09:45:18 2017 +0000
+++ b/TextLCD.lib	Wed Aug 05 05:29:12 2020 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/kenjiArai/code/TextLCD/#986538f94abe
+http://mbed.org/users/kenjiArai/code/TextLCD/#f8e67a681560
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/check_revision.cpp	Wed Aug 05 05:29:12 2020 +0000
@@ -0,0 +1,27 @@
+/*
+ * Check Mbed revision
+ *
+ * Copyright (c) 2019,'20 Kenji Arai / JH1PJL
+ *  http://www7b.biglobe.ne.jp/~kenjia/
+ *  https://os.mbed.com/users/kenjiArai/
+ *      Created:    July      17th, 2019
+ *      Revised:    August     1st, 2020
+ */
+
+#include "mbed.h"
+ 
+//    RUN ONLY ON mbed-os-6.2.0
+//      https://github.com/ARMmbed/mbed-os/releases/tag/mbed-os-6.2.0
+#if (MBED_MAJOR_VERSION == 6) &&\
+    (MBED_MINOR_VERSION == 2) &&\
+    (MBED_PATCH_VERSION == 0)
+#else
+#   error "Please use mbed-os-6.2.0"
+#endif
+
+void print_revision(void)
+{
+    printf("MBED_MAJOR_VERSION = %d, ", MBED_MAJOR_VERSION);
+    printf("MINOR = %d, ", MBED_MINOR_VERSION);
+    printf("PATCH = %d\r\n", MBED_PATCH_VERSION);
+}
--- a/main.cpp	Wed Aug 23 09:45:18 2017 +0000
+++ b/main.cpp	Wed Aug 05 05:29:12 2020 +0000
@@ -1,42 +1,39 @@
 /*
- * mbed Application program for the mbed Nucleo F401
+ * mbed Application program for the mbed Nucleo series
  *  BNO055 Intelligent 9-axis absolute orientation sensor
  *  by Bosch Sensortec
  *
- * Copyright (c) 2015,'17 Kenji Arai / JH1PJL
- *  http://www.page.sannet.ne.jp/kenjia/index.html
- *  http://mbed.org/users/kenjiArai/
+ * Copyright (c) 2015,'17,'20 Kenji Arai / JH1PJL
+ *  http://www7b.biglobe.ne.jp/~kenjia/
+ *  https://os.mbed.com/users/kenjiArai/
  *      Created: March     30th, 2015
- *      Revised: August    23rd, 2017
+ *      Revised: August     5th, 2020
  */
 
-//  Include ---------------------------------------------------------------------------------------
+//  Include --------------------------------------------------------------------
 #include    "mbed.h"
 #include    "BNO055.h"
 #include    "TextLCD.h"
 
-//  Definition ------------------------------------------------------------------------------------
+//  Definition -----------------------------------------------------------------
 #define NUM_LOOP    100
 
-#if MBED_MAJOR_VERSION == 2
-#define WAIT_MS(x)       wait_ms(x)
-#elif  MBED_MAJOR_VERSION == 5
-#define WAIT_MS(x)       Thread::wait(x)
-#else
-#error "Running on Unknown OS"
-#endif
-
-//  Object ----------------------------------------------------------------------------------------
-Serial pc(USBTX,USBRX);
+//  Object ---------------------------------------------------------------------
+static BufferedSerial pc(USBTX, USBRX, 9600);
 #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
+// Reset =D7, addr = BNO055_G_CHIP_ADDR, mode = MODE_NDOF <- as default
+BNO055 imu(i2c, dp18);
 #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)
+// Reset =D7, addr = BNO055_G_CHIP_ADDR, mode = MODE_NDOF <- as default
+BNO055 imu(i2c, p29);
+#elif defined(TARGET_NUCLEO_L152RE)\
+    || defined(TARGET_NUCLEO_F401RE)\
+    || defined(TARGET_NUCLEO_F411RE)\
+    || defined(TARGET_NUCLEO_F446RE)
 #if 0
 DigitalOut pwr_onoff(PB_10);
 #else
@@ -44,7 +41,8 @@
 #endif
 I2C    i2c(PB_9, PB_8); // SDA, SCL
 #if 0
-BNO055 imu(i2c, PA_8);  // Reset = ??, addr = BNO055_G_CHIP_ADDR, mode = MODE_NDOF <- as default
+// Reset = ??, addr = BNO055_G_CHIP_ADDR, mode = MODE_NDOF <- as default
+BNO055 imu(i2c, PA_8);
 #else
 BNO055 imu(PB_9, PB_8, PA_8);
 #endif
@@ -52,13 +50,14 @@
 #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
+// Reset =D7, addr = BNO055_G_CHIP_ADDR, mode = MODE_NDOF <- as default
+BNO055 imu(i2c, P8_13);
 #else
 #error "Not cheched yet"
 #endif
 Timer t;
 
-//  RAM -------------------------------------------------------------------------------------------
+//  RAM ------------------------------------------------------------------------
 BNO055_ID_INF_TypeDef       bno055_id_inf;
 BNO055_EULER_TypeDef        euler_angles;
 BNO055_QUATERNION_TypeDef   quaternion;
@@ -66,60 +65,62 @@
 BNO055_GRAVITY_TypeDef      gravity;
 BNO055_TEMPERATURE_TypeDef  chip_temp;
 
-//  ROM / Constant data ---------------------------------------------------------------------------
+//  ROM / Constant data --------------------------------------------------------
 
-//  Function prototypes ---------------------------------------------------------------------------
+//  Function prototypes --------------------------------------------------------
 
-//-------------------------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
 //  Control Program
-//-------------------------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
 // Calibration
-//  Please refer BNO055 Data sheet 3.10 Calibration & 3.6.4 Sensor calibration data
-void bno055_calbration(void){
+//  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
-    //     gyroscope to calibrate
-    pc.printf("Step1) Please wait few seconds\r\n");
+    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 gyroscope to calibrate
+    printf("Step1) Please wait few seconds\r\n");
     t.start();
-    while (t.read() < 10){
+    while (t.elapsed_time().count() < 10) {
         d = imu.read_calib_status();
-        pc.printf("Calb dat = 0x%x target  = 0x30(at least)\r\n", d);
-        if ((d & 0x30) == 0x30){
+        printf("Calb dat = 0x%x target  = 0x30(at least)\r\n", d);
+        if ((d & 0x30) == 0x30) {
             break;
         }
-        WAIT_MS(1000);
+        ThisThread::sleep_for(1s);
     }
-    pc.printf("-> Step1) is done\r\n\r\n");
-    //---------- Magnetometer Caliblation ---------------------------------------------------------
-    // (a) Make some random movements (for example: writing the number ‘8’ on air) until the
-    //     CALIB_STAT register indicates fully calibrated.
-    // (b) It takes more calibration movements to get the magnetometer calibrated than in the
-    //     NDOF mode.
-    pc.printf("Step2) random moving (try to change the BNO055 axis)\r\n");
+    printf("-> Step1) is done\r\n\r\n");
+    //---------- Magnetometer Caliblation --------------------------------------
+    // (a) Make some random movements (for example: writing the number ‘8’
+    //     on air) until the CALIB_STAT register indicates fully calibrated.
+    // (b) It takes more calibration movements to get the magnetometer
+    //     calibrated than in the NDOF mode.
+    printf("Step2) random moving (try to change the BNO055 axis)\r\n");
     t.start();
-    while (t.read() < 30){
+    while (t.elapsed_time().count() < 30) {
         d = imu.read_calib_status();
-        pc.printf("Calb dat = 0x%x target  = 0x33(at least)\r\n", d);
-        if ((d & 0x03) == 0x03){
+        printf("Calb dat = 0x%x target  = 0x33(at least)\r\n", d);
+        if ((d & 0x03) == 0x03) {
             break;
         }
-        WAIT_MS(1000);   
+        ThisThread::sleep_for(1s);
     }
-    pc.printf("-> Step2) is done\r\n\r\n");
-    //---------- Magnetometer Caliblation ---------------------------------------------------------
-    // a) Place the device in 6 different stable positions for a period of few seconds
-    //    to allow the accelerometer to calibrate.
+    printf("-> Step2) is done\r\n\r\n");
+    //---------- Magnetometer Caliblation --------------------------------------
+    // a) Place the device in 6 different stable positions for a period of
+    //    few seconds to allow the accelerometer to calibrate.
     // b) Make sure that there is slow movement between 2 stable positions
-    //    The 6 stable positions could be in any direction, but make sure that the device is
-    //    lying at least once perpendicular to the x, y and z axis.
-    pc.printf("Step3) Change rotation each X,Y,Z axis KEEP SLOWLY!!");
-    pc.printf(" Each 90deg stay a 5 sec and set at least 6 position.\r\n");
-    pc.printf(" e.g. (1)ACC:X0,Y0,Z-9,(2)ACC:X9,Y0,Z0,(3)ACC:X0,Y0,Z9,");
-    pc.printf("(4)ACC:X-9,Y0,Z0,(5)ACC:X0,Y-9,Z0,(6)ACC:X0,Y9,Z0,\r\n");
-    pc.printf(" If you will give up, hit any key.\r\n", d);
+    //    The 6 stable positions could be in any direction, but make sure that
+    //    the device is lying at least once perpendicular to the x, y and z axis
+    printf("Step3) Change rotation each X,Y,Z axis KEEP SLOWLY!!");
+    printf(" Each 90deg stay a 5 sec and set at least 6 position.\r\n");
+    printf(" e.g. (1)ACC:X0,Y0,Z-9,(2)ACC:X9,Y0,Z0,(3)ACC:X0,Y0,Z9,");
+    printf("(4)ACC:X-9,Y0,Z0,(5)ACC:X0,Y-9,Z0,(6)ACC:X0,Y9,Z0,\r\n");
+    printf(" If you will give up, hit any key.\r\n");
     t.stop();
 
     // lcd
@@ -131,136 +132,173 @@
     lcd.puts(" JH1PJL ");
     lcd.setContrast(0x14);
 
-    while (true){
+    while (true) {
         d = imu.read_calib_status();
         imu.get_gravity(&gravity);
-        pc.printf("Calb dat = 0x%x target  = 0xff ACC:X %4.1f, Y %4.1f, Z %4.1f\r\n",
-                   d, gravity.x, gravity.y, gravity.z);
-        if (d == 0xff){     break;}
-        if (pc.readable()){ break;}
-        WAIT_MS(1000);
+        printf(
+            "Calb dat = 0x%x target  = 0xff ACC:X %4.1f, Y %4.1f, Z %4.1f\r\n",
+            d, gravity.x, gravity.y, gravity.z
+        );
+        if (d == 0xff) {
+            break;
+        }
+        if (pc.readable()) {
+            break;
+        }
+        ThisThread::sleep_for(1s);
     }
-    if (imu.read_calib_status() == 0xff){
-        pc.printf("-> All of Calibration steps are done successfully!\r\n\r\n");
+    if (imu.read_calib_status() == 0xff) {
+        printf("-> All of Calibration steps are done successfully!\r\n\r\n");
     } else {
-        pc.printf("-> Calibration steps are suspended!\r\n\r\n");
+        printf("-> Calibration steps are suspended!\r\n\r\n");
     }
     t.stop();
 }
 
-int main(){
+int main()
+{
+    uint8_t ser_buf[4];
+
     imu.set_mounting_position(MT_P6);
     pwr_onoff = 1;
-    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");
+    printf("\r\n\r\nIf pc terminal soft is ready, please hit any key!\r\n");
+    while (pc.readable() == 0) {;}
+    printf(
+        "Bosch Sensortec BNO055 test program on " __DATE__ "/" __TIME__ "\r\n"
+    );
     // Is BNO055 avairable?
-    if (imu.chip_ready() == 0){
+    if (imu.chip_ready() == 0) {
         do {
-            pc.printf("Bosch BNO055 is NOT avirable!!\r\n Reset\r\n");
+            printf("Bosch BNO055 is NOT avirable!!\r\n Reset\r\n");
             pwr_onoff = 0;  // Power off
-            WAIT_MS(100);
+            ThisThread::sleep_for(100ms);
             pwr_onoff = 1;  // Power on
-            WAIT_MS(20);
+            ThisThread::sleep_for(20ms);
         } while(imu.reset());
     }
-    pc.printf("Bosch BNO055 is available now!!\r\n");
-    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));    
+    printf("Bosch BNO055 is available now!!\r\n");
+    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 ID:0x%02x, ACC ID:0x%02x, MAG ID:0x%02x, GYR ID:0x%02x, ",
-        bno055_id_inf.chip_id, bno055_id_inf.acc_id, bno055_id_inf.mag_id, bno055_id_inf.gyr_id);
-    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'){
+    printf("CHIP ID:0x%02x, ACC ID:0x%02x, MAG ID:0x%02x, GYR ID:0x%02x, ",
+           bno055_id_inf.chip_id, bno055_id_inf.acc_id,
+           bno055_id_inf.mag_id, bno055_id_inf.gyr_id
+          );
+    printf("SW REV:0x%04x, BL REV:0x%02x\r\n",
+           bno055_id_inf.sw_rev_id, bno055_id_inf.bootldr_rev_id);
+    while (pc.readable() == 1) {
+        pc.read(ser_buf, 1);
+    }
+    printf("If you would like to calibrate the BNO055,");
+    printf(" please hit 'y' (No: any other key)\r\n");
+    while (pc.readable() == 0) {;}
+    pc.read(ser_buf, 1);
+    uint8_t c = ser_buf[0];
+    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");
+    printf("[E]:Euler Angles[deg],[Q]:Quaternion[],[L]:Linear accel[m/s*s],");
+    printf("[G]:Gravity vector[m/s*s],[T]:Chip temperature,Acc,Gyr[degC]");
+    printf(",[S]:Status,[M]:time[mS]\r\n");
     t.start();
-    while(1) {
+    while(true) {
         imu.get_Euler_Angles(&euler_angles);
-        pc.printf("[E],Y,%+6.1f,R,%+6.1f,P,%+6.1f,",
-                   euler_angles.h, euler_angles.r, euler_angles.p);
+        printf("[E],Y,%+6.1f,R,%+6.1f,P,%+6.1f,",
+               euler_angles.h, euler_angles.r, euler_angles.p);
         imu.get_quaternion(&quaternion);
-        pc.printf("[Q],W,%d,X,%d,Y,%d,Z,%d,",
-                   quaternion.w, quaternion.x, quaternion.y, quaternion.z);
+        printf("[Q],W,%d,X,%d,Y,%d,Z,%d,",
+               quaternion.w, quaternion.x, quaternion.y, quaternion.z);
         imu.get_linear_accel(&linear_acc);
-        pc.printf("[L],X,%+6.1f,Y,%+6.1f,Z,%+6.1f,",
-                   linear_acc.x, linear_acc.y, linear_acc.z);
+        printf("[L],X,%+6.1f,Y,%+6.1f,Z,%+6.1f,",
+               linear_acc.x, linear_acc.y, linear_acc.z);
         imu.get_gravity(&gravity);
-        pc.printf("[G],X,%+6.1f,Y,%+6.1f,Z,%+6.1f,",
-                   gravity.x, gravity.y, gravity.z);
+        printf("[G],X,%+6.1f,Y,%+6.1f,Z,%+6.1f,",
+               gravity.x, gravity.y, gravity.z);
         imu.get_chip_temperature(&chip_temp);
-        pc.printf("[T],%+d,%+d,",
-                   chip_temp.acc_chip, chip_temp.gyr_chip);
-        pc.printf("[S],0x%x,[M],%d\r\n",
-                   imu.read_calib_status(), t.read_ms());
+        printf("[T],%+d,%+d,",
+               chip_temp.acc_chip, chip_temp.gyr_chip);
+        printf("[S],0x%x,[M],%d\r\n",
+               imu.read_calib_status(), (uint32_t)t.elapsed_time().count());
     }
 }
 
 
 // Diffrent output format as for your reference
 #if 0
-int main() {
+int main()
+{
     uint8_t i;
 
     pwr_onoff = 1;
-    pc.printf("Bosch Sensortec BNO055 test program on " __DATE__ "/" __TIME__ "\r\n");
+    printf(
+        "Bosch Sensortec BNO055 test program on " __DATE__ "/" __TIME__ "\r\n"
+    );
     // Is BNO055 avairable?
-    if (imu.chip_ready() == 0){
+    if (imu.chip_ready() == 0) {
         do {
-            pc.printf("Bosch BNO055 is NOT avirable!!\r\n");
+            printf("Bosch BNO055 is NOT avirable!!\r\n");
             pwr_onoff = 0;  // Power off
-            WAIT_MS(100);
+            ThisThread::sleep_for(100ms);
             pwr_onoff = 1;  // Power on
-            WAIT_MS(20);
+            ThisThread::sleep_for(20ms);
         } 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));    
+    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++){
+    printf("CHIP:0x%02x, ACC:0x%02x, MAG:0x%02x,",
+           bno055_id_inf.chip_id, bno055_id_inf.acc_id, bno055_id_inf.mag_id
+          );
+    printf("GYR:0x%02x, , SW:0x%04x, , BL:0x%02x\r\n",
+           bno055_id_inf.gyr_id, bno055_id_inf.sw_rev_id,
+           bno055_id_inf.bootldr_rev_id
+          );
+    while(true) {
+        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_MS(500);
-        }
-        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_MS(500);
+            printf("Heading:%+6.1f [deg], Roll:%+6.1f [deg],",
+                   euler_angles.h, euler_angles.r,);
+            printf(" Pich:%+6.1f [deg], #%02d\r\n",
+                   euler_angles.p, i);
+            ThisThread::sleep_for(500ms);
         }
-        pc.printf("Linear accel data\r\n");
-        for (i = 0; i < NUM_LOOP; i++){
+        printf("Quaternion data\r\n");
+        for (i = 0; i < NUM_LOOP; i++) {
+            imu.get_quaternion(&quaternion);
+            printf("W:%d, X:%d, Y:%d, Z:%d, #%02d\r\n",
+                   quaternion.w, quaternion.x, quaternion.y, quaternion.z, i);
+            ThisThread::sleep_for(500ms);
+        }
+        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_MS(500);
+            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
+            );
+            ThisThread::sleep_for(500ms);
         }
-        pc.printf("Gravity vector data\r\n");
-        for (i = 0; i < NUM_LOOP; i++){
+        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_MS(500);
+            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
+            );
+            ThisThread::sleep_for(500ms);
         }
-        pc.printf("Chip temperature data\r\n");
-        for (i = 0; i < (NUM_LOOP / 4); i++){
+        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_MS(500);
+            printf("Acc chip:%+d [degC], Gyr chip:%+d [degC], #%02d\r\n",
+                   chip_temp.acc_chip, chip_temp.gyr_chip, i);
+            ThisThread::sleep_for(500ms);
         }
     }
 }
--- a/mbed-os.lib	Wed Aug 23 09:45:18 2017 +0000
+++ b/mbed-os.lib	Wed Aug 05 05:29:12 2020 +0000
@@ -1,1 +1,1 @@
-https://github.com/ARMmbed/mbed-os/#db4be94693c3a873cfa0c025a5ad2e62b86a8474
+https://github.com/ARMmbed/mbed-os/#a2ada74770f043aff3e61e29d164a8e78274fcd4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_app.json	Wed Aug 05 05:29:12 2020 +0000
@@ -0,0 +1,8 @@
+{
+    "requires": ["bare-metal"],
+    "target_overrides": {
+        "*": {
+            "target.printf_lib": "std"
+        }
+    }
+}