Arduino board run on Mbed-os6.8.1 (only test purpose not official). Need Mbed Studio(1.3.1) not online compiler. If you compile on the online compiler, you can get a hex file but it does NOT work!!!

Dependencies:   APDS_9960 LPS22HB LSM9DS1 HTS221

1) DAPLink(LPC11U35)の準備
使用したボード →https://akizukidenshi.com/catalog/g/gK-12144/
プログラムは、nRF52840-MDK用に公開されているDAPLinkのコンパイル済のバイナリコードを使わせていただきました。
https://github.com/makerdiary/nrf52840-mdk/tree/master/firmware/daplink
LPC11U35への書込みは、SW1(ISP)を押したままSW2(RESET)を操作するとPCに「CRP DISABLD」という名称でマウントされるので、書込まれているfirmware.binを削除してから、上記のbinファイルをコピーすれば書き込みが行われます。
書込み完了後にSW1を押さずに起動すれば、「DAPLINK」として認識されます。
DETAILS.TXTでDAPLinkの内容を確認できます。

2) 接続

Arduino Nano 33 BLE SenseLPC11U35 Interface CPUコメント
J3:Pin2 (ボード裏のパッド)CN1:Pin3 P0_7SWDIO
J3:Pin3 (ボード裏のパッド)CN1:Pin4 P0_8SWCLK
JP2:Pin14  GNDCN2:Pin1 GNDGND

https://os.mbed.com/media/uploads/kenjiArai/snano_daplink.jpg https://os.mbed.com/media/uploads/kenjiArai/snano33ble_bottom.jpg
3)USBSerial
シリアル出力は、NANO 33 BLE SENSEボードのUSB端子経由で出力されます。

4)Mbed Studio 1.3.1を使って開発のこと!(オンラインコンパイラでは動作しません!)
https://os.mbed.com/media/uploads/kenjiArai/s1_2020-02-13.png https://os.mbed.com/media/uploads/kenjiArai/s2_2020-02-13.png

5)ボードピン配置 https://os.mbed.com/media/uploads/kenjiArai/nano33ble_pin.png

Files at this revision

API Documentation at this revision

Comitter:
kenjiArai
Date:
Sun Feb 28 07:31:58 2021 +0000
Parent:
0:f1a10797d9f6
Child:
2:9ee17e6e5900
Commit message:
run on mbed-os6.8.0 (compile on Mbed Studio 1.3.1)

Changed in this revision

0_Blinky_LED/main0.cpp Show annotated file Show diff for this revision Revisions of this file
1_check_I2C_devices/main1.cpp Show annotated file Show diff for this revision Revisions of this file
2_check_LSM9DS1/main2.cpp Show annotated file Show diff for this revision Revisions of this file
3_check_LPS22HB/main3.cpp Show annotated file Show diff for this revision Revisions of this file
4_check_HTS221/main4.cpp Show annotated file Show diff for this revision Revisions of this file
5_Combined_enviromental_sensors/main5.cpp Show annotated file Show diff for this revision Revisions of this file
6_check_APDS_9960/main6.cpp Show annotated file Show diff for this revision Revisions of this file
PinDetect.lib Show diff for this revision Revisions of this file
check_revision.cpp Show diff for this revision Revisions of this file
common.cpp Show diff for this revision Revisions of this file
common_functions/check_revision.h Show annotated file Show diff for this revision Revisions of this file
common_functions/common.h Show annotated file Show diff for this revision Revisions of this file
common_functions/nano33blesense_iodef.h Show annotated file Show diff for this revision Revisions of this file
common_functions/usb_serial_as_stdio.h 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
nano33blesense_iodef.h Show diff for this revision Revisions of this file
readme_1st.txt Show annotated file Show diff for this revision Revisions of this file
select_example.h Show annotated file Show diff for this revision Revisions of this file
--- a/0_Blinky_LED/main0.cpp	Fri Feb 07 01:21:16 2020 +0000
+++ b/0_Blinky_LED/main0.cpp	Sun Feb 28 07:31:58 2021 +0000
@@ -1,13 +1,13 @@
 /*
  * Mbed Application program
- *  Nano 33 BLE Sense board runs on mbed-OS5
+ *  Nano 33 BLE Sense board runs on mbed-OS6
  *      3 LED (Y+G+RGB) blinky
  *
- * Copyright (c) 2020 Kenji Arai / JH1PJL
+ * Copyright (c) 2020,'21 Kenji Arai / JH1PJL
  *      http://www7b.biglobe.ne.jp/~kenjia/
  *      https://os.mbed.com/users/kenjiArai/
  *      Started:    January   22nd, 2020
- *      Revised:    Feburary   5th, 2020
+ *      Revised:    February  28th, 2021
  */
 
 //  Pre-selection --------------------------------------------------------------
@@ -34,56 +34,105 @@
 
 //  Function prototypes --------------------------------------------------------
 
+//  subroutin (must be at this below line and do NOT change order) -------------
+#include    "usb_serial_as_stdio.h"
+#include    "check_revision.h"
+#include    "common.h"
+
 //------------------------------------------------------------------------------
 //  Control Program
 //------------------------------------------------------------------------------
 int main()
 {
-    thread_sleep_for(1000);
+    usb_serial_initialize();
+    print_revision();
+    ThisThread::sleep_for(100ms);
+    uint32_t counter = 0;
     while (true) {
+        print_usb("Blinky LED's %u\r\n", ++counter);
         led_y = 1;
         led_g = 0;
         lr = 1;
         lg = 1;
         lb = 1;
-        thread_sleep_for(1000);
+        ThisThread::sleep_for(1s);
         led_y = 0;
         led_g = 1;
         lr = 1;
         lg = 1;
         lb = 1;
-        thread_sleep_for(1000);
+        ThisThread::sleep_for(1s);
         led_y = 0;
         led_g = 0;
         lr = 0;
         lg = 1;
         lb = 1;
-        thread_sleep_for(1000);
+        ThisThread::sleep_for(1s);
         led_y = 0;
         led_g = 0;
         lr = 1;
         lg = 0;
         lb = 1;
-        thread_sleep_for(1000);
+        ThisThread::sleep_for(1s);
         led_y = 0;
         led_g = 0;
         lr = 1;
         lg = 1;
         lb = 0;
-        thread_sleep_for(1000);
+        ThisThread::sleep_for(1s);
         led_y = 1;
         led_g = 1;
         lr = 0;
         lg = 0;
         lb = 0;
-        thread_sleep_for(1000);
+        ThisThread::sleep_for(1s);
         led_y = 0;
         led_g = 0;
         lr = 1;
         lg = 1;
         lb = 1;
-        thread_sleep_for(1000);
+        ThisThread::sleep_for(1s);
+    }
+}
+
+#if 0
+/*
+    https://cpplover.blogspot.com/2010/03/variadic-templates.html
+ */
+template <typename ... Args>
+void print_usb(const char *format, Args const & ... args)
+{
+    if (usb == NULL) {
+        return;
+    } else {
+        if (usb->connected() == true) {
+            usb->printf(format, args ...);
+        }
     }
 }
 
+uint8_t readable()
+{
+    return usb->readable();
+}
+
+void putc(uint8_t c)
+{
+    if (usb == NULL) {
+        return;
+    } else {
+        usb->putc(c);
+    }
+}
+
+uint8_t getc()
+{
+    if (usb == NULL) {
+        while(true){ ;} // infinit loop
+    } else {
+        return usb->getc();
+    }
+}
+#endif
+
 #endif  // EXAMPLE_0_BLINKY_LED
\ No newline at end of file
--- a/1_check_I2C_devices/main1.cpp	Fri Feb 07 01:21:16 2020 +0000
+++ b/1_check_I2C_devices/main1.cpp	Sun Feb 28 07:31:58 2021 +0000
@@ -1,13 +1,13 @@
 /*
  * Mbed Application program
- *  Nano 33 BLE Sense board runs on mbed-OS5
+ *  Nano 33 BLE Sense board runs on mbed-OS6
  *      Check I2C control line
  *
- * Copyright (c) 2020 Kenji Arai / JH1PJL
+ * Copyright (c) 2020,'21 Kenji Arai / JH1PJL
  *      http://www7b.biglobe.ne.jp/~kenjia/
  *      https://os.mbed.com/users/kenjiArai/
  *      Started:    January   22nd, 2020
- *      Revised:    Feburary   5th, 2020
+ *      Revised:    February  28th, 2021
  */
 
 //  Pre-selection --------------------------------------------------------------
@@ -18,16 +18,10 @@
 //  Include --------------------------------------------------------------------
 #include    "mbed.h"
 #include    "nano33blesense_iodef.h"
-#include    "USBSerial.h"
-#include    "LPS22HB.h"
-#include    "LSM9DS1.h"
-#include    "HTS221.h"
-#include    "glibr.h"
 
 //  Definition -----------------------------------------------------------------
 
 //  Constructor ----------------------------------------------------------------
-RawSerial       pc(STDIO_UART_TX, STDIO_UART_RX, 115200);
 DigitalOut      sen_pwr(PIN_VDD_ENV, 1);
 DigitalOut      i2c_pullup(PIN_I2C_PULLUP, 1);
 I2C             i2c(PIN_SDA1, PIN_SCL1);
@@ -37,22 +31,28 @@
 //  ROM / Constant data --------------------------------------------------------
 
 //  Function prototypes --------------------------------------------------------
-extern void check_i2c_connected_devices(void);
-extern void check_i2c_sensors(void);
+
+//  subroutin (must be at this below line and do NOT change order) -------------
+#include    "usb_serial_as_stdio.h"
+#include    "check_revision.h"
+#include    "common.h"
 
 //------------------------------------------------------------------------------
 //  Control Program
 //------------------------------------------------------------------------------
 int main()
 {
+    usb_serial_initialize();
+    print_revision();
     i2c_pullup = 1;
     sen_pwr = 1;
-    pc.printf("\r\nCheck I2C line\r\n");
-    thread_sleep_for(200);
+    print_usb("Check I2C line\r\n");
+    ThisThread::sleep_for(200ms);
     check_i2c_connected_devices();
     while (true) {
+        print_usb("\r\n");
         check_i2c_sensors();
-        thread_sleep_for(10000);
+        ThisThread::sleep_for(2s);
     }
 }
 
--- a/2_check_LSM9DS1/main2.cpp	Fri Feb 07 01:21:16 2020 +0000
+++ b/2_check_LSM9DS1/main2.cpp	Sun Feb 28 07:31:58 2021 +0000
@@ -1,15 +1,15 @@
 /*
  * Mbed Application program
- *  Nano 33 BLE Sense board runs on mbed-OS5
+ *  Nano 33 BLE Sense board runs on mbed-OS6
  *  LSM9DS1 -> iNEMO inertial module:
  *    3D accelerometer, 3D gyroscope, 3D magnetometer
  *      by STMicroelectronics
  *
- * Copyright (c) 2020 Kenji Arai / JH1PJL
+ * Copyright (c) 2020,'21 Kenji Arai / JH1PJL
  *      http://www7b.biglobe.ne.jp/~kenjia/
  *      https://os.mbed.com/users/kenjiArai/
  *      Started:    January   22nd, 2020
- *      Revised:    Feburary   5th, 2020
+ *      Revised:    February  28th, 2021
  */
 
 //  Pre-selection --------------------------------------------------------------
@@ -25,7 +25,6 @@
 //  Definition -----------------------------------------------------------------
 
 //  Constructor ----------------------------------------------------------------
-RawSerial       pc(STDIO_UART_TX, STDIO_UART_RX, 115200);
 DigitalOut      sen_pwr(PIN_VDD_ENV, 1);
 DigitalOut      i2c_pullup(PIN_I2C_PULLUP, 1);
 I2C             i2c(PIN_SDA1, PIN_SCL1);
@@ -37,28 +36,33 @@
 //  ROM / Constant data --------------------------------------------------------
 
 //  Function prototypes --------------------------------------------------------
-extern void check_i2c_connected_devices(void);
+
+//  subroutin (must be at this below line and do NOT change order) -------------
+#include    "usb_serial_as_stdio.h"
+#include    "check_revision.h"
+#include    "common.h"
 
 //------------------------------------------------------------------------------
 //  Control Program
 //------------------------------------------------------------------------------
 int main()
 {
+    usb_serial_initialize();
+    print_revision();
     i2c_pullup = 1;
     sen_pwr = 1;
-    pc.printf("\r\nCheck LSM9DS1\r\n");
-    thread_sleep_for(200);
-    check_i2c_connected_devices();
+    print_usb("Check LSM9DS1\r\n");
+    ThisThread::sleep_for(200ms);
     imu = new LSM9DS1(PIN_SDA1, PIN_SCL1);
     uint16_t reg = imu->begin();
-    pc.printf("IMU(LSM9DS1) 0x%x\r\n", reg);
+    print_usb("IMU(LSM9DS1) 0x%x\r\n", reg);
     imu->calibration();
     //  check I2C line
     check_i2c_connected_devices();
     if (reg == 0x683d){
-        pc.printf("ACC+GYR+MAG are ready!\r\n");
+        print_usb("ACC+GYR+MAG are ready!\r\n");
     } else {
-        pc.printf("ACC+GYR+MAG are NOT ready!\r\n");
+        print_usb("ACC+GYR+MAG are NOT ready!\r\n");
     }
     uint32_t n = 0;
     while(true) {
@@ -68,15 +72,16 @@
         imu->readGyro();
         imu->readMag();
         imu->readTemp();
-        pc.printf("acc = %+5.3f, %+5.3f, %+5.3f, ", imu->ax, imu->ay, imu->az);
-        pc.printf("gyr = %+8.3f, %+8.3f, %+8.3f, ", imu->gx, imu->gy, imu->gz);
-        pc.printf("mag = %+5.3f, %+5.3f, %+5.3f, ", imu->mx, imu->my, imu->mz);
-        pc.printf("temperature = %+5.1f, ", imu->temperature_c);
+        print_usb("acc=,%+5.3f,%+5.3f,%+5.3f,", imu->ax, imu->ay, imu->az);
+        print_usb("gyr=,%+8.3f,%+8.3f,%+8.3f,", imu->gx, imu->gy, imu->gz);
+        print_usb("mag=,%+5.3f,%+5.3f,%+5.3f,", imu->mx, imu->my, imu->mz);
+        print_usb("temperature=,%+5.1f,", imu->temperature_c);
         ++n;
-        uint32_t passed_time = t.read_ms();
-        pc.printf("processing time: %d [ms], count: %4d\r\n", passed_time, n);
+        uint32_t passed_time = chrono::duration_cast<chrono::milliseconds>(
+                               t.elapsed_time()).count();
+        print_usb("processing time:,%2d,[ms],count:,%4d\r\n", passed_time, n);
         if (passed_time < 199){
-            thread_sleep_for(200 - t.read_ms());
+            ThisThread::sleep_for(chrono::milliseconds(200 - passed_time));
         }
     }
 }
--- a/3_check_LPS22HB/main3.cpp	Fri Feb 07 01:21:16 2020 +0000
+++ b/3_check_LPS22HB/main3.cpp	Sun Feb 28 07:31:58 2021 +0000
@@ -1,15 +1,15 @@
 /*
  * Mbed Application program
- *  Nano 33 BLE Sense board runs on mbed-OS5
+ *  Nano 33 BLE Sense board runs on mbed-OS6
  *  LPS33HB -> MEMS nano pressure sensor:
  *    260-1260 hPa absolute Digital output barometer
  *      by STMicroelectronics
  *
- * Copyright (c) 2020 Kenji Arai / JH1PJL
+ * Copyright (c) 2020,'21 Kenji Arai / JH1PJL
  *      http://www7b.biglobe.ne.jp/~kenjia/
  *      https://os.mbed.com/users/kenjiArai/
  *      Started:    January   22nd, 2020
- *      Revised:    Feburary   5th, 2020
+ *      Revised:    February  28th, 2021
  */
 
 //  Pre-selection --------------------------------------------------------------
@@ -25,7 +25,6 @@
 //  Definition -----------------------------------------------------------------
 
 //  Constructor ----------------------------------------------------------------
-RawSerial       pc(STDIO_UART_TX, STDIO_UART_RX, 115200);
 DigitalOut      sen_pwr(PIN_VDD_ENV, 1);
 DigitalOut      i2c_pullup(PIN_I2C_PULLUP, 1);
 I2C             i2c(PIN_SDA1, PIN_SCL1);
@@ -37,25 +36,31 @@
 //  ROM / Constant data --------------------------------------------------------
 
 //  Function prototypes --------------------------------------------------------
-extern void check_i2c_connected_devices(void);
+
+//  subroutin (must be at this below line and do NOT change order) -------------
+#include    "usb_serial_as_stdio.h"
+#include    "check_revision.h"
+#include    "common.h"
 
 //------------------------------------------------------------------------------
 //  Control Program
 //------------------------------------------------------------------------------
 int main()
 {
+    usb_serial_initialize();
+    print_revision();
     i2c_pullup = 1;
     sen_pwr = 1;
-    pc.printf("\r\nCheck LSM9DS1\r\n");
-    thread_sleep_for(200);
+    print_usb("Check LSM9DS1\r\n");
+    ThisThread::sleep_for(200ms);
     //  check I2C line
     check_i2c_connected_devices();
     baro = new LPS22HB(i2c, LPS22HB_G_CHIP_ADDR);
     uint8_t id = baro->read_id();
     if (id == I_AM_LPS22HB) {
-        pc.printf("LPS22H is ready. ID = 0x%x\r\n", id);
+        print_usb("LPS22H is ready. ID = 0x%x\r\n", id);
     } else {
-        pc.printf("LPS22H is NOT ready. return value = 0x%x\r\n", id);
+        print_usb("LPS22H is NOT ready. return value = 0x%x\r\n", id);
     }
     baro->set_odr();
     uint32_t n = 0;
@@ -64,15 +69,16 @@
         t.start();
         baro->get();
         while (baro->data_ready() == 0){
-             thread_sleep_for(2);
+                 ThisThread::sleep_for(2ms);
         }
-        pc.printf("Pressure: %6.1f [hPa], Temperature: %+4.1f [degC], ",
+        print_usb("Pressure:,%6.1f,[hPa],Temperature:,%+4.1f,[degC],",
                   baro->pressure(), baro->temperature());
         ++n;
-        uint32_t passed_time = t.read_ms();
-        pc.printf("processing time: %d [ms], count: %4d\r\n", passed_time, n);
+        uint32_t passed_time = chrono::duration_cast<chrono::milliseconds>(
+                               t.elapsed_time()).count();
+        print_usb("processing time:,%2d,[ms],count:,%4d\r\n", passed_time, n);
         if (passed_time < 999){
-            thread_sleep_for(1000 - t.read_ms());
+            ThisThread::sleep_for(chrono::milliseconds(1000 - passed_time));
         }
     }
 }
--- a/4_check_HTS221/main4.cpp	Fri Feb 07 01:21:16 2020 +0000
+++ b/4_check_HTS221/main4.cpp	Sun Feb 28 07:31:58 2021 +0000
@@ -1,14 +1,14 @@
 /*
  * Mbed Application program
- *  Nano 33 BLE Sense board runs on mbed-OS5
+ *  Nano 33 BLE Sense board runs on mbed-OS6
  *  HTS221 -> Capacitive digital sensor for relative humidity and temperature
  *      by STMicroelectronics
  *
- * Copyright (c) 2020 Kenji Arai / JH1PJL
+ * Copyright (c) 2020,'21 Kenji Arai / JH1PJL
  *      http://www7b.biglobe.ne.jp/~kenjia/
  *      https://os.mbed.com/users/kenjiArai/
  *      Started:    January   22nd, 2020
- *      Revised:    Feburary   5th, 2020
+ *      Revised:    February  28th, 2021
  */
 
 //  Pre-selection --------------------------------------------------------------
@@ -24,7 +24,6 @@
 //  Definition -----------------------------------------------------------------
 
 //  Constructor ----------------------------------------------------------------
-RawSerial       pc(STDIO_UART_TX, STDIO_UART_RX, 115200);
 DigitalOut      sen_pwr(PIN_VDD_ENV, 1);
 DigitalOut      i2c_pullup(PIN_I2C_PULLUP, 1);
 I2C             i2c(PIN_SDA1, PIN_SCL1);
@@ -36,7 +35,11 @@
 //  ROM / Constant data --------------------------------------------------------
 
 //  Function prototypes --------------------------------------------------------
-extern void check_i2c_connected_devices(void);
+
+//  subroutin (must be at this below line and do NOT change order) -------------
+#include    "usb_serial_as_stdio.h"
+#include    "check_revision.h"
+#include    "common.h"
 
 //------------------------------------------------------------------------------
 //  Control Program
@@ -45,19 +48,21 @@
 {
     HTS221::HTS221_data_t   hum_data;
 
+    usb_serial_initialize();
+    print_revision();
     i2c_pullup = 1;
     sen_pwr = 1;
-    pc.printf("\r\nCheck LSM9DS1\r\n");
-    thread_sleep_for(200);
+    print_usb("Check LSM9DS1\r\n");
+    ThisThread::sleep_for(200ms);
     //  check I2C line
     check_i2c_connected_devices();
     hum = new HTS221(PIN_SDA1, PIN_SCL1,HTS221::HTS221_ADDRESS, 400000);
     hum->HTS221_GetDeviceID (&hum_data);
     uint8_t id = hum_data.deviceID;
     if (id == HTS221::WHO_AM_I_VALUE) {
-        pc.printf("HTS221 is ready. ID = 0x%x\r\n", id);
+        print_usb("HTS221 is ready. ID = 0x%x\r\n", id);
     } else {
-        pc.printf("HTS221 is NOT ready. return value = 0x%x\r\n", id);
+        print_usb("HTS221 is NOT ready. return value = 0x%x\r\n", id);
     }
     uint32_t n = 0;
     while(true) {
@@ -71,13 +76,14 @@
         hum->HTS221_GetCalibrationCoefficients (&hum_data);
         hum->HTS221_GetTemperature(&hum_data);
         hum->HTS221_GetHumidity(&hum_data);
-        pc.printf("Temperature: %0.1f [degC], RH: %0.1f [%%], ",
+        print_usb("Temperature:,%0.1f,[degC],RH:,%0.1f,[%%],",
                     hum_data.temperature, hum_data.humidity);
         ++n;
-        uint32_t passed_time = t.read_ms();
-        pc.printf("processing time: %d [ms], count: %4d\r\n", passed_time, n);
+        uint32_t passed_time = chrono::duration_cast<chrono::milliseconds>(
+                               t.elapsed_time()).count();
+        print_usb("processing time:,%2d,[ms],count:,%4d\r\n", passed_time, n);
         if (passed_time < 999){
-            thread_sleep_for(1000 - t.read_ms());
+            ThisThread::sleep_for(chrono::milliseconds(1000 - passed_time));
         }
     }
 }
--- a/5_Combined_enviromental_sensors/main5.cpp	Fri Feb 07 01:21:16 2020 +0000
+++ b/5_Combined_enviromental_sensors/main5.cpp	Sun Feb 28 07:31:58 2021 +0000
@@ -1,13 +1,13 @@
 /*
  * Mbed Application program
- *  Nano 33 BLE Sense board runs on mbed-OS5
+ *  Nano 33 BLE Sense board runs on mbed-OS6
  *      HTS221 + LSM9DS1 + LPS22HB sensors
  *
- * Copyright (c) 2020 Kenji Arai / JH1PJL
+ * Copyright (c) 2020,'21 Kenji Arai / JH1PJL
  *      http://www7b.biglobe.ne.jp/~kenjia/
  *      https://os.mbed.com/users/kenjiArai/
  *      Started:    January   22nd, 2020
- *      Revised:    Feburary   7th, 2020
+ *      Revised:    February  28th, 2021
  */
 
 //  Pre-selection --------------------------------------------------------------
@@ -18,18 +18,15 @@
 //  Include --------------------------------------------------------------------
 #include    "mbed.h"
 #include    "nano33blesense_iodef.h"
-#include    "USBSerial.h"
 #include    "LPS22HB.h"
 #include    "LSM9DS1.h"
 #include    "HTS221.h"
-#include    "glibr.h"
 
 //  Definition -----------------------------------------------------------------
 
 //  Object ---------------------------------------------------------------------
 DigitalOut      sen_pwr(PIN_VDD_ENV, 1);
 DigitalOut      i2c_pullup(PIN_I2C_PULLUP, 1);
-RawSerial       pc(STDIO_UART_TX, STDIO_UART_RX, 115200);
 DigitalOut      led_y(PIN_YELLOW, 0);
 DigitalOut      led_g(PIN_GREEN, 0);
 DigitalOut      lr(PIN_LR, 1);
@@ -44,13 +41,16 @@
 //  RAM ------------------------------------------------------------------------
 
 //  ROM / Constant data --------------------------------------------------------
-const char *const msg0 = "Run Nano 33 BLE Sense module on Mbed-os5.15.0";
-const char *const msg1 = "Compiled on Mbed Studio:0.8.1";
+const char *const msg0 = "Run Nano 33 BLE Sense module on Mbed-os";
+const char *const msg1 = "Compiled on Mbed Studio:1.3.1";
 const char *const msg2 = "Target is ARDUINO_NANO33BLE with Debug mode";
 
 //  Function prototypes --------------------------------------------------------
-extern void check_i2c_connected_devices(void);
-extern void check_i2c_sensors(void);
+
+//  subroutin (must be at this below line and do NOT change order) -------------
+#include    "usb_serial_as_stdio.h"
+#include    "check_revision.h"
+#include    "common.h"
 
 //------------------------------------------------------------------------------
 //  Control Program
@@ -60,11 +60,13 @@
     HTS221::HTS221_status_t aux;
     HTS221::HTS221_data_t   hum_data;
 
+    usb_serial_initialize();
+    print_revision();
     led_y = 1;
     i2c_pullup = 1;
     sen_pwr = 1;
-    pc.printf("\r\n%s\r\n%s\r\n%s\r\n", msg0, msg1, msg2);
-    thread_sleep_for(200);
+    print_usb("%s\r\n%s\r\n%s\r\n", msg0, msg1, msg2);
+    ThisThread::sleep_for(200ms);
     imu  = new LSM9DS1(PIN_SDA1, PIN_SCL1);
     baro = new LPS22HB(i2c, LPS22HB_G_CHIP_ADDR);
     hum  = new HTS221(PIN_SDA1, PIN_SCL1,HTS221::HTS221_ADDRESS, 400000);
@@ -100,24 +102,25 @@
         imu->readTemp();
         float press = baro->pressure();
         float temp = baro->temperature();
-        uint32_t passed_time = t.read_ms();
+        uint32_t passed_time = chrono::duration_cast<chrono::milliseconds>(
+                               t.elapsed_time()).count();
         lb = 1;
         // Showing
         lr = 0;
         lg = 0;
         lb = 0;
-        pc.printf("Temperature[degC]: HTS221= %+4.1f, ", hum_data.temperature);
-        pc.printf("LPS22HB= %+4.1f, LSM9DS1= %+4.1f, ",
+        print_usb("Temperature[degC]: HTS221=,%+4.1f,", hum_data.temperature);
+        print_usb("LPS22HB=,%+4.1f,LSM9DS1=,%+4.1f,",
                   temp, imu->temperature_c);
-        pc.printf("Humidity[RH %%]: HTS221= %3.1f, ", hum_data.humidity);
-        pc.printf("Pressure[hPa]: LPS22H= %6.2f, ",  press);
+        print_usb("Humidity[RH %%]: HTS221=,%3.1f,", hum_data.humidity);
+        print_usb("Pressure[hPa]: LPS22H=,%6.2f,",  press);
         ++n;
-        pc.printf("processing time: %d [ms], count: %4d\r\n", passed_time, n);
+        print_usb("processing time:,%2d,[ms],count:,%4d\r\n", passed_time, n);
         lr = 1;
         lg = 1;
         lb = 1;
         if (passed_time < 999){
-            thread_sleep_for(1000 - t.read_ms());
+            ThisThread::sleep_for(chrono::milliseconds(1000 - passed_time));
         }
     }
 }
--- a/6_check_APDS_9960/main6.cpp	Fri Feb 07 01:21:16 2020 +0000
+++ b/6_check_APDS_9960/main6.cpp	Sun Feb 28 07:31:58 2021 +0000
@@ -2,12 +2,13 @@
  * APDS-9960
  *  Digital Proximity, Ambient Light, RGB and Gesture Sensor
  *
+ * Mbed Application program
+ *  Nano 33 BLE Sense board runs on mbed-OS6
  *  Modified by Kenji Arai / JH1PJL
  *      http://www7b.biglobe.ne.jp/~kenjia/
  *      https://os.mbed.com/users/kenjiArai/
- *
- *      Started:    Feburary   2nd, 2020
- *      Revised:    Feburary   3rd, 2020
+ *      Started:    February   2nd, 2020
+ *      Revised:    February  28th, 2021
  *
  *  Original:
  *      https://os.mbed.com/users/kbhagat6/code/Gesture_User_Interface/
@@ -21,14 +22,12 @@
 //  Include --------------------------------------------------------------------
 #include    "mbed.h"
 #include    "nano33blesense_iodef.h"
-#include    "PinDetect.h"
 #include    "glibr.h"
 
 //  Definition -----------------------------------------------------------------
 
 //  Object ---------------------------------------------------------------------
-RawSerial       pc(STDIO_UART_TX, STDIO_UART_RX, 115200);
-PinDetect       apds_int(PIN_APDS_INT);
+InterruptIn     apds_int(PIN_APDS_INT);
 DigitalOut      sen_pwr(PIN_VDD_ENV, 1);
 DigitalOut      i2c_pullup(PIN_I2C_PULLUP, 1);
 DigitalOut      led_y(PIN_YELLOW, 0);
@@ -44,9 +43,13 @@
 //  RAM ------------------------------------------------------------------------
 
 //  Function prototypes --------------------------------------------------------
-extern void check_i2c_connected_devices(void);
 void apds_hit_callback (void);
 
+//  subroutin (must be at this below line and do NOT change order) -------------
+#include    "usb_serial_as_stdio.h"
+#include    "check_revision.h"
+#include    "common.h"
+
 //------------------------------------------------------------------------------
 //  Control Program
 //------------------------------------------------------------------------------
@@ -54,95 +57,78 @@
 {
     bool gerror = false;
 
+    usb_serial_initialize();
+    print_revision();
     i2c_pullup = 1;
     sen_pwr = 1;
-    pc.printf("\r\nCheck APDS_9960\r\n");
-    thread_sleep_for(200);
+    print_usb("Check APDS_9960\r\n");
+    ThisThread::sleep_for(200ms);
     //  check I2C line
     check_i2c_connected_devices();
     gesture = new glibr(PIN_SDA1, PIN_SCL1);
     if (gesture->ginit()) {
-        pc.printf("APDS-9960 initialization complete\n\r");
+        print_usb("APDS-9960 initialization complete\n\r");
     } else {
-        pc.printf("Something went wrong during APDS-9960 init\n\r");
+        print_usb("Something went wrong during APDS-9960 init\n\r");
         gerror=true;
     }
-    uint8_t id = 0;
-    if (id == 0) {
-        pc.printf("??? is ready. ID = 0x%x\r\n", id);
-    } else {
-        pc.printf("??? is NOT ready. return value = 0x%x\r\n", id);
-    }
     // Start running the APDS-9960 gesture sensor engine
     if ( gesture->enableGestureSensor(true) ) {
-        pc.printf("Gesture sensor is now running\n\r");
+        print_usb("Gesture sensor is now running\n\r");
     } else {
-        pc.printf("Something went wrong during gesture sensor init!\n\r");
+        print_usb("Something went wrong during gesture sensor init!\n\r");
         gerror=true;
     }
-    //
+    // set pullup for Interrupt input pin
     apds_int.mode(PullUp);
     // Delay for initial pullup to take effect
-    thread_sleep_for(100);
+    ThisThread::sleep_for(1ms);
     // Setup Interrupt callback function for a pb hit
-    apds_int.attach_deasserted(&apds_hit_callback);
-    // Start sampling pb input using interrupts
-    apds_int.setSampleFrequency();   
+    apds_int.fall(&apds_hit_callback);
+    // Enable interrut
+    apds_int.enable_irq(); 
     while(!(gesture->isGestureAvailable())){        
-        ;
-        thread_sleep_for(500);
-        ;
-        thread_sleep_for(500);
+        ThisThread::sleep_for(200ms);
     }
-
     int temp;
     while(gerror == false) {
-        /*ret = gesture->isGestureAvailable();
-        pc.printf("Is Gesture Available?: %d\n", ret);
-        val = gesture->readGesture();
-        */
         if (gesture->isGestureAvailable()) {
             if(gesture->isGestureAvailable()){
                 temp = gesture->readGesture();
             }
             switch ( temp) {
                 case DIR_UP:
-                    pc.printf("Forward\r\n");
+                    print_usb("Forward\r\n");
                     break;
                 case DIR_DOWN:
-                    pc.printf("Backward\r\n");
+                    print_usb("Backward\r\n");
                     break;
                 case DIR_LEFT:
-                    pc.printf("LEFT\r\n");
+                    print_usb("LEFT\r\n");
                     break;
                 case DIR_RIGHT:
-                    pc.printf("RIGHT\r\n");
+                    print_usb("RIGHT\r\n");
                     break;
                 case 67: 
-                    pc.printf("Collision\r\n");
+                    print_usb("Collision\r\n");
                     break;
                 case DIR_NEAR:
-                    pc.printf("NEAR\r\n");
+                    print_usb("NEAR\r\n");
                     break;
                 case DIR_FAR:
-                    pc.printf("FAR\r\n");
+                    print_usb("FAR\r\n");
                     break;
                 default:
-                    pc.printf("NONE\r\n");
+                    print_usb("NONE\r\n");
                     break; 
             }
         }
-        //thread_sleep_for(1000);
     }
 }
 
 void apds_hit_callback (void)
 {
     led_y =!led_y;
-    //str.append("S");
-    //pc2.printf("%s\n", str);
-    //printSTOP(3, 7); 
-    //str.clear();
 }
 
-#endif  // EXAMPLE_9_CHECK_APDS_9960
\ No newline at end of file
+#endif  // EXAMPLE_6_CHECK_APDS_9960
\ No newline at end of file
--- a/PinDetect.lib	Fri Feb 07 01:21:16 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://os.mbed.com/users/AjK/code/PinDetect/#cb3afc45028b
--- a/check_revision.cpp	Fri Feb 07 01:21:16 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-/*
- * 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:    January   30th, 2020
- */
-
-#include "mbed.h"
-
-//    RUN ONLY ON mbed-os5.15.0
-//      https://github.com/ARMmbed/mbed-os/releases/tag/mbed-os-5.15.0
-#if (MBED_MAJOR_VERSION == 5) &&\
-    (MBED_MINOR_VERSION == 15) &&\
-    (MBED_PATCH_VERSION == 0)
-#else
-//#warning "Please use Mbed-os5.15.0"
-#   error "Please use Mbed-os5.15.0"
-#endif
-
-#ifndef TARGET_NRF52840
-#   error "Select Nordic nRF52840-DK"
-#   warning "see https://os.mbed.com/platforms/Nordic-nRF52840-DK/"
-#endif
\ No newline at end of file
--- a/common.cpp	Fri Feb 07 01:21:16 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,123 +0,0 @@
-/*
- * Nano 33 BLE Sense
- *      Arudiono nRF52840 module
- *      Common functions
- *
- * Copyright (c) 2020 Kenji Arai / JH1PJL
- *      http://www7b.biglobe.ne.jp/~kenjia/
- *      https://os.mbed.com/users/kenjiArai/
- *      Started:    January   22nd, 2020
- *      Revised:    Feburary   5th, 2020
- *
- */
-
-//  Pre-selection --------------------------------------------------------------
-#include    "select_example.h"
-//#define USE_COMMON_FUNCTION
-#ifdef USE_COMMON_FUNCTION
-
-//  Include --------------------------------------------------------------------
-#include    "mbed.h"
-#include    "nano33blesense_iodef.h"
-#include    "USBSerial.h"
-#include    "LPS22HB.h"
-#include    "LSM9DS1.h"
-#include    "HTS221.h"
-#include    "glibr.h"
-
-//  Definition -----------------------------------------------------------------
-
-//  Constructor ----------------------------------------------------------------
-extern RawSerial       pc;
-extern I2C             i2c;
-
-//  RAM ------------------------------------------------------------------------
-
-//  ROM / Constant data --------------------------------------------------------
-
-//  Function prototypes --------------------------------------------------------
-
-//------------------------------------------------------------------------------
-//  Control Program
-//------------------------------------------------------------------------------
-void check_i2c_connected_devices(void)
-{
-    char dt[2];
-    int status;
-
-    // Check I2C line
-    i2c.frequency(400000);
-    dt[0] = 0;
-    pc.printf("check I2C device --> START\r\n");
-    for (uint8_t i = 0; i < 0x80; i++) {
-        int addr = i << 1;
-        status = i2c.write(addr, dt, 1, true);
-        if (status == 0) {
-            pc.printf("Get ACK form address = 0x%x\r\n", i);
-        }
-    }
-}
-
-void check_i2c_sensors(void)
-{
-    char dt[2];
-
-    // LSM9DS1
-    dt[0] = WHO_AM_I_XG;
-    int addr = LSM9DS1_AG_I2C_ADDR(1);
-    i2c.write(addr, dt, 1, true);
-    dt[0] = 0;
-    i2c.read(addr, dt, 1, false);
-    pc.printf("LSM9DS1_AG is ");
-    if (dt[0] != WHO_AM_I_AG_RSP) {
-        pc.printf("NOT ");
-    }
-    pc.printf("available -> 0x%x = 0x%x\r\n", addr >> 1, dt[0]);
-    dt[0] = WHO_AM_I_M;
-    addr = LSM9DS1_M_I2C_ADDR(1);
-    i2c.write(addr, dt, 1, true);
-    dt[0] = 0;
-    i2c.read(addr, dt, 1, false);
-    pc.printf("LSM9DS1_M is ");
-    if (dt[0] != WHO_AM_I_M_RSP) {
-        pc.printf("NOT ");
-    } 
-    pc.printf("available -> 0x%x = 0x%x\r\n", addr >> 1, dt[0]);
-    // LPS22HB
-    dt[0] = LPS22HB_WHO_AM_I;
-    addr = LPS22HB_G_CHIP_ADDR;
-    i2c.write(addr, dt, 1, true);
-    dt[0] = 0;
-    i2c.read(addr, dt, 1, false);
-    pc.printf("LPS22HB is ");
-    if (dt[0] != I_AM_LPS22HB) {
-        pc.printf("NOT ");
-    } 
-    pc.printf("available -> 0x%x = 0x%x\r\n", addr >> 1, dt[0]);
-    // HTS221
-    dt[0] =  HTS221::HTS221_WHO_AM_I;
-    addr =  HTS221::HTS221_ADDRESS;
-    i2c.write(addr, dt, 1, true);
-    dt[0] = 0;
-    i2c.read(addr, dt, 1, false);
-    pc.printf("HTS221 is ");
-    if (dt[0] !=  HTS221::WHO_AM_I_VALUE) {
-        pc.printf("NOT ");
-    } 
-    pc.printf("available -> 0x%x = 0x%x\r\n", addr >> 1, dt[0]);
-    // APDS_9960
-    dt[0] = APDS9960_ID;
-    addr =  APDS9960_I2C_ADDR << 1;
-    i2c.write(addr, dt, 1, true);
-    dt[0] = 0;
-    i2c.read(addr, dt, 1, false);
-    pc.printf("APDS_9960 is ");
-    if (dt[0] == APDS9960_ID_1 || dt[0] == APDS9960_ID_2) {
-        ;
-    } else {
-        pc.printf("NOT ");
-    } 
-    pc.printf("available -> 0x%x = 0x%x\r\n", addr >> 1, dt[0]);
-}
-
-#endif  // USE_COMMON_FUNCTION
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common_functions/check_revision.h	Sun Feb 28 07:31:58 2021 +0000
@@ -0,0 +1,25 @@
+/*
+ * Check Mbed revision
+ *
+ * Copyright (c) 2019,'20,'21 Kenji Arai / JH1PJL
+ *  http://www7b.biglobe.ne.jp/~kenjia/
+ *  https://os.mbed.com/users/kenjiArai/
+ *      Created:    July      17th, 2019
+ *      Revised:    February  28th, 2021
+ */
+
+//    RUN ONLY ON mbed-os-6.8.0
+//      https://github.com/ARMmbed/mbed-os/releases/tag/mbed-os-6.8.0
+#if (MBED_MAJOR_VERSION == 6) &&\
+    (MBED_MINOR_VERSION == 8) &&\
+    (MBED_PATCH_VERSION == 0)
+#else
+#   error "Please use mbed-os-6.8.0"
+#endif
+
+void print_revision(void)
+{
+    print_usb("MBED_MAJOR_VERSION = %d, ", MBED_MAJOR_VERSION);
+    print_usb("MINOR = %d, ", MBED_MINOR_VERSION);
+    print_usb("PATCH = %d\r\n", MBED_PATCH_VERSION);
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common_functions/common.h	Sun Feb 28 07:31:58 2021 +0000
@@ -0,0 +1,127 @@
+/*
+ * Nano 33 BLE Sense
+ *      Arudiono nRF52840 module
+ *      Common functions
+ *
+ * Copyright (c) 2020,'21 Kenji Arai / JH1PJL
+ *      http://www7b.biglobe.ne.jp/~kenjia/
+ *      https://os.mbed.com/users/kenjiArai/
+ *      Started:    January   22nd, 2020
+ *      Revised:    February  28th, 2021
+ *
+ */
+
+//  Pre-selection --------------------------------------------------------------
+#include    "select_example.h"
+//#define USE_COMMON_FUNCTION
+#ifdef USE_COMMON_FUNCTION
+
+//  Include --------------------------------------------------------------------
+#include    "mbed.h"
+#include    "nano33blesense_iodef.h"
+#include    "LPS22HB.h"
+#include    "LSM9DS1.h"
+#include    "HTS221.h"
+//#include    "glibr.h" // define as follows
+
+//  Definition -----------------------------------------------------------------
+/* APDS-9960 I2C address */
+#define APDS9960_I2C_ADDR       0x39
+/* APDS-9960 register */
+#define APDS9960_ID             0x92
+/* Acceptable device IDs */
+#define APDS9960_ID_1           0xAB
+#define APDS9960_ID_2           0x9C 
+
+//  Constructor ----------------------------------------------------------------
+
+//  RAM ------------------------------------------------------------------------
+
+//  ROM / Constant data --------------------------------------------------------
+
+//  Function prototypes --------------------------------------------------------
+
+//------------------------------------------------------------------------------
+//  Control Program
+//------------------------------------------------------------------------------
+void check_i2c_connected_devices(void)
+{
+    char dt[2];
+    int status;
+
+    // Check I2C line
+    i2c.frequency(400000);
+    dt[0] = 0;
+    print_usb("check I2C device --> START\r\n");
+    for (uint8_t i = 0; i < 0x80; i++) {
+        int addr = i << 1;
+        status = i2c.write(addr, dt, 1, true);
+        if (status == 0) {
+            print_usb("Get ACK form address = 0x%x\r\n", i);
+        }
+    }
+}
+
+void check_i2c_sensors(void)
+{
+    char dt[2];
+
+    // LSM9DS1
+    dt[0] = WHO_AM_I_XG;
+    int addr = LSM9DS1_AG_I2C_ADDR(1);
+    i2c.write(addr, dt, 1, true);
+    dt[0] = 0;
+    i2c.read(addr, dt, 1, false);
+    print_usb("LSM9DS1_AG is ");
+    if (dt[0] != WHO_AM_I_AG_RSP) {
+        print_usb("NOT ");
+    }
+    print_usb("available -> 0x%x = 0x%x\r\n", addr >> 1, dt[0]);
+    dt[0] = WHO_AM_I_M;
+    addr = LSM9DS1_M_I2C_ADDR(1);
+    i2c.write(addr, dt, 1, true);
+    dt[0] = 0;
+    i2c.read(addr, dt, 1, false);
+    print_usb("LSM9DS1_M is ");
+    if (dt[0] != WHO_AM_I_M_RSP) {
+        print_usb("NOT ");
+    } 
+    print_usb("available -> 0x%x = 0x%x\r\n", addr >> 1, dt[0]);
+    // LPS22HB
+    dt[0] = LPS22HB_WHO_AM_I;
+    addr = LPS22HB_G_CHIP_ADDR;
+    i2c.write(addr, dt, 1, true);
+    dt[0] = 0;
+    i2c.read(addr, dt, 1, false);
+    print_usb("LPS22HB is ");
+    if (dt[0] != I_AM_LPS22HB) {
+        print_usb("NOT ");
+    } 
+    print_usb("available -> 0x%x = 0x%x\r\n", addr >> 1, dt[0]);
+    // HTS221
+    dt[0] =  HTS221::HTS221_WHO_AM_I;
+    addr =  HTS221::HTS221_ADDRESS;
+    i2c.write(addr, dt, 1, true);
+    dt[0] = 0;
+    i2c.read(addr, dt, 1, false);
+    print_usb("HTS221 is ");
+    if (dt[0] !=  HTS221::WHO_AM_I_VALUE) {
+        print_usb("NOT ");
+    } 
+    print_usb("available -> 0x%x = 0x%x\r\n", addr >> 1, dt[0]);
+    // APDS_9960
+    dt[0] = APDS9960_ID;
+    addr =  APDS9960_I2C_ADDR << 1;
+    i2c.write(addr, dt, 1, true);
+    dt[0] = 0;
+    i2c.read(addr, dt, 1, false);
+    print_usb("APDS_9960 is ");
+    if (dt[0] == APDS9960_ID_1 || dt[0] == APDS9960_ID_2) {
+        ;
+    } else {
+        print_usb("NOT ");
+    } 
+    print_usb("available -> 0x%x = 0x%x\r\n", addr >> 1, dt[0]);
+}
+
+#endif  // USE_COMMON_FUNCTION
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common_functions/nano33blesense_iodef.h	Sun Feb 28 07:31:58 2021 +0000
@@ -0,0 +1,97 @@
+/*
+ * Nano 33 BLE Sense
+ *      Arudiono nRF52840 module
+ *
+ * Copyright (c) 2020,'21 Kenji Arai / JH1PJL
+ *      http://www7b.biglobe.ne.jp/~kenjia/
+ *      https://os.mbed.com/users/kenjiArai/
+ *      Started:    January   22nd, 2020
+ *      Revised:    February  28th, 2021
+ *
+ */
+
+// LEDs
+#define PIN_YELLOW      P0_13
+#define PIN_GREEN       P1_9
+#define PIN_LR          P0_24
+#define PIN_LG          P0_16
+#define PIN_LB          P0_6
+
+// APDS-9960
+#define PIN_APDS_INT    P0_19
+
+// SPI
+#define PIN_SPI_MOSI    P1_1
+#define PIN_SPI_MISO    P1_8
+#define PIN_SPI_SCK     P0_13
+
+// External I2C
+#define PIN_EXT_SDA     P0_31
+#define PIN_EXT_SCL     P0_2
+
+// Internal I2C
+#define PIN_SDA1        P0_14
+#define PIN_SCL1        P0_15
+
+// Power line control
+#define PIN_I2C_PULLUP  P1_0
+#define PIN_VDD_ENV     P0_22
+#define PIN_APDS_PWR    P0_20
+#define PIN_MIC_PWR     P0_17
+
+//-------- Reference --------------------------------------------------
+#if 0
+https://github.com/arduino/ArduinoCore-nRF528x-mbedos
+\variants\ARDUINO_NANO33BLE\variant.cpp
+&
+\variants\ARDUINO_NANO33BLE\pins_arduino.h
+
+  // D0 - D7
+  P1_3,     0
+  P1_10,    1
+  P1_11,    2
+  P1_12,    3
+  P1_15,    4
+  P1_13,    5
+  P1_14,    6
+  P0_23,    7
+
+  // D8 - D13
+  P0_21,    8   
+  P0_27,    9   
+  P1_2,     10  PIN_SPI_SS    (10u)
+  P1_1,     11  PIN_SPI_MOSI  (11u)
+  P1_8,     12  PIN_SPI_MISO  (12u)
+  P0_13,    13  LED_BUILTIN (13u) / PIN_SPI_SCK   (13u)
+
+  // A0 - A7
+  P0_4,     14  PIN_A0 (14u)
+  P0_5,     15  PIN_A1 (15u)
+  P0_30,    16  PIN_A2 (16u)
+  P0_29,    17  PIN_A3 (17u)
+  P0_31,    18  PIN_A4 (18u) / PIN_WIRE_SDA        (18u)
+  P0_2,     19  PIN_A5 (19u) / PIN_WIRE_SCL        (19u)
+  P0_28,    20  PIN_A6 (20u)
+  P0_3,     21  PIN_A7 (21u)
+
+  // LEDs
+  P0_24,    22  LEDR        (22u)
+  P0_16,    23  LEDG        (23u)
+  P0_6,     24  LEDB        (24u)
+  P1_9,     25  LED_PWR     (25u)
+
+  P0_19,    26  PIN_INT_APDS (26u)
+
+  // PDM
+  P0_17,    27  PIN_PDM_PWR  (27)
+  P0_26,    28  PIN_PDM_CLK  (28)
+  P0_25,    29  PIN_PDM_DIN  (29)
+
+  // Internal I2C
+  P0_14,    30  PIN_WIRE_SDA1       (30u)
+  P0_15,    31  PIN_WIRE_SCL1       (31u)
+
+  // Internal I2C
+  P1_0,     32  PIN_ENABLE_SENSORS_3V3     (32u)
+  P0_22,    33  PIN_ENABLE_I2C_PULLUP      (33u)
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common_functions/usb_serial_as_stdio.h	Sun Feb 28 07:31:58 2021 +0000
@@ -0,0 +1,71 @@
+/*
+ * mbed Application program
+ *      Redirect Standard Input/Output
+ *
+ * Copyright (c) 2021 Kenji Arai / JH1PJL
+ *  http://www7b.biglobe.ne.jp/~kenjia/
+ *  https://os.mbed.com/users/kenjiArai/
+ *      Created:    January   13th, 2021
+ *      Revised:    February  28th, 2021
+ */
+
+//  Include --------------------------------------------------------------------
+//#include    "mbed.h"
+#include    "USBSerial.h"
+
+//  Definition -----------------------------------------------------------------
+
+//  Constructor ----------------------------------------------------------------
+USBSerial *usb = NULL;
+
+//  RAM ------------------------------------------------------------------------
+
+//  ROM / Constant data --------------------------------------------------------
+
+//  Function prototypes --------------------------------------------------------
+
+//------------------------------------------------------------------------------
+//  Control Program
+//------------------------------------------------------------------------------
+/*
+    https://cpplover.blogspot.com/2010/03/variadic-templates.html
+ */
+template <typename ... Args>
+void print_usb(const char *format, Args const & ... args)
+{
+    if (usb == NULL) {
+        return;
+    } else {
+        if (usb->connected() == true) {
+            usb->printf(format, args ...);
+        }
+    }
+}
+
+void usb_serial_initialize(void)
+{
+    usb = new USBSerial;
+}
+
+uint8_t readable()
+{
+    return usb->readable();
+}
+
+void putc(uint8_t c)
+{
+    if (usb == NULL) {
+        return;
+    } else {
+        usb->putc(c);
+    }
+}
+
+uint8_t getc()
+{
+    if (usb == NULL) {
+        while(true){ ;} // infinit loop
+    } else {
+        return usb->getc();
+    }
+}
--- a/mbed-os.lib	Fri Feb 07 01:21:16 2020 +0000
+++ b/mbed-os.lib	Sun Feb 28 07:31:58 2021 +0000
@@ -1,1 +1,1 @@
-https://github.com/ARMmbed/mbed-os/#64853b354fa188bfe8dbd51e78771213c7ed37f7
+https://github.com/ARMmbed/mbed-os/#bfde5aa1e74802771eaeacfa74789f71677325cb
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_app.json	Sun Feb 28 07:31:58 2021 +0000
@@ -0,0 +1,7 @@
+{
+    "target_overrides": {
+        "*": {
+            "target.printf_lib": "std"
+        }
+    }
+}
\ No newline at end of file
--- a/nano33blesense_iodef.h	Fri Feb 07 01:21:16 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,97 +0,0 @@
-/*
- * Nano 33 BLE Sense
- *      Arudiono nRF52840 module
- *
- * Copyright (c) 2020 Kenji Arai / JH1PJL
- *      http://www7b.biglobe.ne.jp/~kenjia/
- *      https://os.mbed.com/users/kenjiArai/
- *      Started:    January   22nd, 2020
- *      Revised:    Feburary   5th, 2020
- *
- */
-
-// LEDs
-#define PIN_YELLOW      P0_13
-#define PIN_GREEN       P1_9
-#define PIN_LR          P0_24
-#define PIN_LG          P0_16
-#define PIN_LB          P0_6
-
-// APDS-9960
-#define PIN_APDS_INT    P0_19
-
-// SPI
-#define PIN_SPI_MOSI    P1_1
-#define PIN_SPI_MISO    P1_8
-#define PIN_SPI_SCK     P0_13
-
-// External I2C
-#define PIN_EXT_SDA     P0_31
-#define PIN_EXT_SCL     P0_2
-
-// Internal I2C
-#define PIN_SDA1        P0_14
-#define PIN_SCL1        P0_15
-
-// Power line control
-#define PIN_I2C_PULLUP  P1_0
-#define PIN_VDD_ENV     P0_22
-#define PIN_APDS_PWR    P0_20
-#define PIN_MIC_PWR     P0_17
-
-//-------- Reference --------------------------------------------------
-#if 0
-https://github.com/arduino/ArduinoCore-nRF528x-mbedos
-\variants\ARDUINO_NANO33BLE\variant.cpp
-&
-\variants\ARDUINO_NANO33BLE\pins_arduino.h
-
-  // D0 - D7
-  P1_3,     0
-  P1_10,    1
-  P1_11,    2
-  P1_12,    3
-  P1_15,    4
-  P1_13,    5
-  P1_14,    6
-  P0_23,    7
-
-  // D8 - D13
-  P0_21,    8   
-  P0_27,    9   
-  P1_2,     10  PIN_SPI_SS    (10u)
-  P1_1,     11  PIN_SPI_MOSI  (11u)
-  P1_8,     12  PIN_SPI_MISO  (12u)
-  P0_13,    13  LED_BUILTIN (13u) / PIN_SPI_SCK   (13u)
-
-  // A0 - A7
-  P0_4,     14  PIN_A0 (14u)
-  P0_5,     15  PIN_A1 (15u)
-  P0_30,    16  PIN_A2 (16u)
-  P0_29,    17  PIN_A3 (17u)
-  P0_31,    18  PIN_A4 (18u) / PIN_WIRE_SDA        (18u)
-  P0_2,     19  PIN_A5 (19u) / PIN_WIRE_SCL        (19u)
-  P0_28,    20  PIN_A6 (20u)
-  P0_3,     21  PIN_A7 (21u)
-
-  // LEDs
-  P0_24,    22  LEDR        (22u)
-  P0_16,    23  LEDG        (23u)
-  P0_6,     24  LEDB        (24u)
-  P1_9,     25  LED_PWR     (25u)
-
-  P0_19,    26  PIN_INT_APDS (26u)
-
-  // PDM
-  P0_17,    27  PIN_PDM_PWR  (27)
-  P0_26,    28  PIN_PDM_CLK  (28)
-  P0_25,    29  PIN_PDM_DIN  (29)
-
-  // Internal I2C
-  P0_14,    30  PIN_WIRE_SDA1       (30u)
-  P0_15,    31  PIN_WIRE_SCL1       (31u)
-
-  // Internal I2C
-  P1_0,     32  PIN_ENABLE_SENSORS_3V3     (32u)
-  P0_22,    33  PIN_ENABLE_I2C_PULLUP      (33u)
-#endif
--- a/readme_1st.txt	Fri Feb 07 01:21:16 2020 +0000
+++ b/readme_1st.txt	Sun Feb 28 07:31:58 2021 +0000
@@ -1,28 +1,31 @@
 --------------------------------------------------------------------------------
-Nano 33 BLE Sense --- Arudiono nRF52840 module (Nano 33 BLE Sense)
+Nano 33 BLE Sense --- Arduino nRF52840 module (Nano 33 BLE Sense)
     By Kenji Arai / JH1PJL
         http://www7b.biglobe.ne.jp/~kenjia/
         https://os.mbed.com/users/kenjiArai/
 
-        Feburary   7th, 2020
+        February  28th, 2021
 --------------------------------------------------------------------------------
+Board Information
+        https://store.arduino.cc/usa/nano-33-ble-sense
+        https://www.st.com/ja/ecosystems/arduino-nano-ble-33-sense.html#overview
 
 ------- Mbed Online Compiler ---------------------------------------------------
 
 Target:         nRF52840-DK
-mbed-os:        mbed-os5.15.0
+mbed-os:        mbed-os6.8.0
 Select program:
             Open select_example.h
             Change EXAMPLE_NUMBER (line31)
 Compile:
 <!!!! CAUTION !!!>
             You can compile without error.
-            Created hex file does NOT run on Nano 33 BLE Sense board.
+            Created hex file does NOT run on Nano 33 BLE Sense board!!!!!.
 
 ------- Mbed Studio ------------------------------------------------------------
 
 Target:         ARDUINO_NANO33BLE
-Mbed Studio:    0.8.1
+Mbed Studio:    1.3.1
 Select program:
                 Same as online program
 Compile:
@@ -33,4 +36,3 @@
             Orignal board has Arduino bootloarder and 
             Mbed hex file overwrites it.
             As a resule, you cannot use Arduino bootloarder anymore.
-                      
--- a/select_example.h	Fri Feb 07 01:21:16 2020 +0000
+++ b/select_example.h	Sun Feb 28 07:31:58 2021 +0000
@@ -1,12 +1,12 @@
 /*
  * Mbed Application program
- *  Nano 33 BLE Sense board runs on mbed-OS5
+ *  Nano 33 BLE Sense board runs on mbed-OS6
  *
- * Copyright (c) 2020 Kenji Arai / JH1PJL
+ * Copyright (c) 2020,'21 Kenji Arai / JH1PJL
  *      http://www7b.biglobe.ne.jp/~kenjia/
  *      https://os.mbed.com/users/kenjiArai/
  *      Started:    January   22nd, 2020
- *      Revised:    Feburary   7th, 2020
+ *      Revised:    February  28th, 2021
  */
 
 /*