microSD Card control function for DISCO-F469NI based on BD_SD_DISCO_F746NG library by Roy Krikke

Dependencies:   BSP_DISCO_F469NI_modified BD_SD_DISCO_F469NI

Fork of DISCO-F769NI_BD_SD_Card_Control by Kenji Arai

Please refer following my Notebook page.
/users/kenjiArai/notebook/sd-card-control-new/

Files at this revision

API Documentation at this revision

Comitter:
kenjiArai
Date:
Thu Jan 14 00:38:59 2021 +0000
Parent:
10:b5665028f662
Commit message:
run on mbed-os6.6.0

Changed in this revision

1_main.cpp Show annotated file Show diff for this revision Revisions of this file
2_main.cpp Show annotated file Show diff for this revision Revisions of this file
BSP_DISCO_F469NI.lib Show diff for this revision Revisions of this file
BSP_DISCO_F469NI_modified.lib Show annotated file Show diff for this revision Revisions of this file
FatFs_Mon/mon.cpp Show annotated file Show diff for this revision Revisions of this file
FatFs_Mon/mon.h 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
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
select_program.h Show annotated file Show diff for this revision Revisions of this file
uart_as_stdio/uart_as_stdio.cpp Show annotated file Show diff for this revision Revisions of this file
uart_as_stdio/uart_as_stdio.h Show annotated file Show diff for this revision Revisions of this file
diff -r b5665028f662 -r a13b9833d5f4 1_main.cpp
--- a/1_main.cpp	Sat May 02 03:44:38 2020 +0000
+++ b/1_main.cpp	Thu Jan 14 00:38:59 2021 +0000
@@ -1,12 +1,12 @@
 /*
  * Mbed Application program
- *  SD Card file control function with FatFs on Mbed-os5
+ *  SD Card file control function with FatFs on Mbed-os6
  *
- * Copyright (c) 2018,'19,'20 Kenji Arai / JH1PJL
+ * Copyright (c) 2018,'19,'20,'21 Kenji Arai / JH1PJL
  *  http://www7b.biglobe.ne.jp/~kenjia/
  *  https://os.mbed.com/users/kenjiArai/
  *      Created:    April      7th, 2018
- *      Revised:    May        2nd, 2020
+ *      Revised:    January   14th, 2021
  */
 
 //  Select ---------------------------------------------------------------------
@@ -18,15 +18,17 @@
 #include    "FATFileSystem.h"
 #include    "SDBlockDeviceDISCOF469NI.h"
 #include    "mon.h"
+#include    "uart_as_stdio.h"
 
 //  Definition -----------------------------------------------------------------
 #define     USER_SW_ON      1
-#define     LOOP_TIME       25      // 25mS
+//#define     LOOP_TIME       25      // 25mS
+#define     LOOP_TIME       150     // 150mS
 
 #define DEBUG  0
 
 #if DEBUG
-#define DBG(...)    pc.printf(__VA_ARGS__)
+#define DBG(...)    printf(__VA_ARGS__)
 #else
 #define DBG(...)    {;}
 #endif
@@ -34,7 +36,6 @@
 //  Constructor ----------------------------------------------------------------
 DigitalOut      led(LED1);
 DigitalIn       user_sw(USER_BUTTON);
-Serial          pc(USBTX, USBRX, 115200);
 // Instantiate the Block Device for sd card on DISCO-F469NI
 SDBlockDeviceDISCOF469NI bd;
 FATFileSystem   fs("fs");
@@ -44,7 +45,7 @@
 
 //  ROM / Constant data --------------------------------------------------------
 const char *const opening_msg0 = "microSD Card test program";
-const char *const opening_msg1 = " -> run on Mbed OS-5\r\n";
+const char *const opening_msg1 = " -> run on Mbed OS-6\r\n";
 const char *const opening_msg2 = "microSD Card is ready for use\r\n";
 const char *const opening_msg3 = "Please hit any key to start!\r\n";
 
@@ -52,8 +53,6 @@
 void return_error (int ret_val);
 void errno_error (void* ret_val);
 extern void print_revision(void);
-extern uint32_t get_disk_freespace(void);
-extern uint32_t get_data_file_size(const char *const file_name);
 
 //------------------------------------------------------------------------------
 //  Control Program
@@ -68,13 +67,13 @@
     uint32_t data4 = 50000U;
     uint32_t data5 = 60000U;
 
-    pc.printf("\r\n\r\n");
+    printf("\r\n\r\n");
     print_revision();
     DBG("line:%d\r\n", __LINE__);
-    pc.printf("\r\nStart\r\n");
+    printf("\r\nStart\r\n");
     int error = 0;
-    pc.printf("Welcome to the filesystem example.\r\n");
-    pc.printf("Mounting the filesystem on \"/fs\". \r\n");
+    printf("Welcome to the filesystem example.\r\n");
+    printf("Mounting the filesystem on \"/fs\". \r\n");
     error = fs.mount(&bd);
     return_error(error);
 
@@ -82,51 +81,51 @@
     errno_error(fp);
     if (fp != 0) {
         DBG("line:%d\r\n", __LINE__);
-        pc.printf("%s%s",  opening_msg0, opening_msg1);
+        printf("%s%s",  opening_msg0, opening_msg1);
         fprintf(fp,"%s%s", opening_msg0, opening_msg1);
-        pc.printf("%s",  opening_msg2);
-        pc.printf("File: mydata.txt\r\n");
+        printf("%s",  opening_msg2);
+        printf("File: mydata.txt\r\n");
         fclose(fp);
     } else {
-        pc.printf("ERROR\r\n");
+        printf("ERROR\r\n");
     }
-    pc.printf("%s",  opening_msg3);
-    while (pc.readable() == 0) { ;}
-    char c = pc.getc(); // dummy read
+    printf("%s",  opening_msg3);
+    while (readable() == 0) { ;}
+    char c = getc(); // dummy read
     while (true) {
         DBG("line:%d\r\n", __LINE__);
         tmr.reset();
         tmr.start();
-        uint32_t size_disk = get_disk_freespace();
-        uint32_t size_file = get_data_file_size("mydata.txt");
-        pc.printf("free disk:%10u, file:%8u  ", size_disk, size_file);
+        float size_disk = get_disk_freespace() / (1024.0f * 1024.0f * 1024.0f);
+        uint32_t size_file = get_data_file_size("mydata.txt") / 1024;
+        printf(", free disk: %.3f GB, file: %u kB, ", size_disk, size_file);
         fp = fopen("/fs/mydata.txt", "a");
         if(fp != 0) {
             char tmp[64];
             DBG("line:%d\r\n", __LINE__);
             seconds = time(NULL);
             strftime(tmp, 64, "DATE %H:%M:%S,%Y/%m/%d,", localtime(&seconds));
-            pc.printf("%s", tmp);
+            printf("%s", tmp);
             fprintf(fp, "%s", tmp);
-            pc.printf("%08d;%08d;%08d;%08d;%08d;%08d\r\n",
-                      ++data0, ++data1, ++data2, ++data3, ++data4, ++data5);
+            printf("%08d;%08d;%08d;%08d;%08d;%08d\r\n",
+                   ++data0, ++data1, ++data2, ++data3, ++data4, ++data5);
             fprintf(fp, "%08d;%08d;%08d;%08d;%08d;%08d\r\n",
-                        data0,   data1,   data2,   data3,   data4,   data5);
+                    data0,   data1,   data2,   data3,   data4,   data5);
             fclose(fp);
         } else {
-            pc.printf("ERROR\r\n");
+            printf("ERROR\r\n");
         }
-        uint32_t time_sd = tmr.read_us();
-        pc.printf("time[uS]:%6d ", time_sd);
-        time_sd /= 1000;    // change uS to ms
-        if (time_sd < LOOP_TIME -2){
-            ThisThread::sleep_for(LOOP_TIME - time_sd);
+        uint32_t time_sd = chrono::duration_cast<chrono::milliseconds>(
+                               tmr.elapsed_time()).count();
+        printf("time:%3d ", time_sd);
+        if (time_sd < LOOP_TIME -2) {
+            ThisThread::sleep_for(chrono::milliseconds(LOOP_TIME - time_sd));
         }
         if (user_sw == USER_SW_ON) {
             DBG("line:%d\r\n", __LINE__);
             break;
         }
-        if (pc.readable()) {
+        if (readable()) {
             mon();
         }
         led = !led;
@@ -140,14 +139,14 @@
 void return_error (int ret_val)
 {
     if (ret_val) {
-        pc.printf("retrun error/Failure. %d\r\n", ret_val);
+        printf("retrun error/Failure. %d\r\n", ret_val);
     }
 }
 
 void errno_error (void* ret_val)
 {
     if (ret_val == NULL) {
-        pc.printf("error #/Failure. %d \r\n", errno);
+        printf("error #/Failure. %d \r\n", errno);
     }
 }
 
diff -r b5665028f662 -r a13b9833d5f4 2_main.cpp
--- a/2_main.cpp	Sat May 02 03:44:38 2020 +0000
+++ b/2_main.cpp	Thu Jan 14 00:38:59 2021 +0000
@@ -19,7 +19,7 @@
 // https://os.mbed.com/users/roykrikke/code/BD_SD_DISCO_F746NG/
 //
 // Modified by K.Arai
-//      December 27th, 2019
+//      January 14th, 2021
 //
 
 #include "select_program.h"
@@ -30,12 +30,12 @@
 #include "SDBlockDeviceDISCOF469NI.h"
 #include <stdio.h>
 #include <errno.h>
- 
+#include "uart_as_stdio.h"
+
 DigitalOut led (LED1);
-Serial pc(USBTX, USBRX, 115200);
 SDBlockDeviceDISCOF469NI bd;
 FATFileSystem fs ("fs");
- 
+
 void
 return_error (int ret_val)
 {
@@ -44,7 +44,7 @@
     else
         printf ("done.\r\n");
 }
- 
+
 void
 errno_error (void* ret_val)
 {
@@ -53,40 +53,40 @@
     else
         printf (" done.\r\n");
 }
- 
+
 int
 main ()
 {
     printf("Start\n");
- 
+
     int error = 0;
     printf("Welcome to the filesystem example.\r\n"
            "Formatting a FAT, RAM-backed filesystem. ");
     error = FATFileSystem::format(&bd);
     return_error(error);
- 
+
     printf("Mounting the filesystem on \"/fs\". ");
     error = fs.mount(&bd);
     return_error(error);
- 
+
     printf("Opening a new file, numbers.txt.");
     FILE* fd = fopen("/fs/numbers.txt", "w");
     errno_error(fd);
- 
+
     for (int i = 0; i < 20; i++) {
         printf("Writing decimal numbers to a file (%d/20)\r", i);
         fprintf(fd, "%d\r\n", i);
     }
     printf("Writing decimal numbers to a file (20/20) done.\r\n");
- 
+
     printf("Closing file.");
     fclose(fd);
     printf(" done.\r\n");
- 
+
     printf("Re-opening file read-only.");
     fd = fopen("/fs/numbers.txt", "r");
     errno_error(fd);
- 
+
     printf("Dumping file to screen.\r\n");
     char buff[16] = { 0 };
     while(!feof (fd)) {
@@ -94,30 +94,30 @@
         fwrite(&buff[0], 1, size, stdout);
     }
     printf("EOF.\r\n");
- 
+
     printf("Closing file.");
     fclose(fd);
     printf(" done.\r\n");
- 
+
     printf("Opening root directory.");
     DIR* dir = opendir("/fs/");
     errno_error(fd);
- 
+
     struct dirent* de;
     printf("Printing all filenames:\r\n");
     while((de = readdir (dir)) != NULL) {
         printf("  %s\r\n", &(de->d_name)[0]);
     }
- 
+
     printf("Closeing root directory. ");
     error = closedir(dir);
     return_error(error);
     printf("Filesystem Demo complete.\r\n");
- 
+
     // Blink led with 2 Hz
     while(true) {
         led = !led;
-        ThisThread::sleep_for(500);
+        ThisThread::sleep_for(500ms);
     }
 }
 #endif
\ No newline at end of file
diff -r b5665028f662 -r a13b9833d5f4 BSP_DISCO_F469NI.lib
--- a/BSP_DISCO_F469NI.lib	Sat May 02 03:44:38 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://developer.mbed.org/teams/ST/code/BSP_DISCO_F469NI/#3cdfcc4f7c9d
diff -r b5665028f662 -r a13b9833d5f4 BSP_DISCO_F469NI_modified.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BSP_DISCO_F469NI_modified.lib	Thu Jan 14 00:38:59 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/kenjiArai/code/BSP_DISCO_F469NI_modified/#74b777d023c0
diff -r b5665028f662 -r a13b9833d5f4 FatFs_Mon/mon.cpp
--- a/FatFs_Mon/mon.cpp	Sat May 02 03:44:38 2020 +0000
+++ b/FatFs_Mon/mon.cpp	Thu Jan 14 00:38:59 2021 +0000
@@ -2,13 +2,14 @@
  * mbed Application program for the mbed
  *  FatFs Check program / monitor part
  *
- * Copyright (c) 2015,'18,'19,'20 Kenji Arai / JH1PJL
+ * Copyright (c) 2015,'18,'19,'20,'21 Kenji Arai / JH1PJL
  *  http://www7b.biglobe.ne.jp/~kenjia/
  *  https://os.mbed.com/users/kenjiArai/
  *      Created:    May        5th, 2015
  *      Revised:    June      14th, 2015
  *      Revised:    April      7th, 2018
- *      Revised:    May        2nd, 2020
+ *      Revised:    August     8th, 2020
+ *      Revised:    January   14th, 2021
  */
 
 /*
@@ -24,35 +25,30 @@
 
 //  Include --------------------------------------------------------------------
 #include "mbed.h"
-#if (MBED_MAJOR_VERSION == 2)
-#include "SDFileSystem.h"
-#elif (MBED_MAJOR_VERSION == 5)
 #include "FATFileSystem.h"
-#endif
 #include "ff.h"
 #include "ffconf.h"
 #include "diskio.h"
 #include "mon.h"
+#include "uart_as_stdio.h"
 
 //  Definition -----------------------------------------------------------------
 #define DO_DEBUG    0
 
 #if DO_DEBUG
-#define DEBUG_LINE  pc.printf("line:%d\r\n", __LINE__);
+#define DEBUG_LINE  printf("line:%d\r\n", __LINE__);
 #else
 #define DEBUG_LINE  {;}
 #endif
 
 // Com
 #if  1
-#define BAUD(x)     pc.baud(x)
-#define GETC(x)     pc.getc(x)
-#define PUTC(x)     pc.putc(x)
-#define PUTS(x)     pc.puts(x)
-#define PRINTF(...) pc.printf(__VA_ARGS__)
-#define READABLE(x) pc.readable(x)
+#define GETC(x)     getc(x)
+#define PUTC(x)     putc(x)
+#define PUTS(x)     puts(x)
+#define PRINTF(...) printf(__VA_ARGS__)
+#define READABLE(x) readable(x)
 #else
-#define BAUD(x)     {;}
 #define GETC(x)     {;}
 #define PUTC(x)     {;}
 #define PRINTF(...) {;}
@@ -119,7 +115,7 @@
     "x     extend commands mode\r\n"
     "q     Return to main\r\n"
     "t     Show current time or Adjust time\r\n"
-    "      e.g. t 20 5 2 10 11 12 -> May 02,'20, 10:11:12\r\n"
+    "      e.g. t 21 1 13 10 11 12 -> January 13,'21, 10:11:12\r\n"
     "?     Help/You know the command\r\n"
     "\r\n";
 
@@ -164,12 +160,8 @@
     "\r\n";
 
 //  Function prototypes --------------------------------------------------------
-#if (MBED_MAJOR_VERSION == 2)
-extern SDFileSystem fs;
-#elif (MBED_MAJOR_VERSION == 5)
 extern HeapBlockDevice bd;
 extern FATFileSystem fs;
-#endif
 
 static void extended_mon( char *ptr );
 static void v_next( char *ptr );
@@ -192,7 +184,6 @@
 void get_line (char *buff, int len);
 
 //  Object ---------------------------------------------------------------------
-extern  Serial pc;
 Timer   t;
 
 //------------------------------------------------------------------------------
@@ -214,23 +205,23 @@
         ptr = Linebuf;
         get_line( ptr, sizeof(Linebuf) );
         switch ( *ptr++ ) {
-                // vol
+            // vol
             case 'v' :
                 v_next(ptr);
                 break;
-                // dir
+            // dir
             case 'd' :
                 d_next(ptr);
                 break;
-                // cd, copy
+            // cd, copy
             case 'c' :
                 c_next(ptr);
                 break;
-                // mkdir
+            // mkdir
             case 'm' :
                 m_next(ptr);
                 break;
-                // ren
+            // ren
             case 'r' :
                 r_next(ptr);
                 break;
@@ -240,15 +231,15 @@
             case 'x' :
                 extended_mon(ptr);
                 break;
-                // Help
+            // Help
             case '?' :
                 PUTS(HelpMsg0);
                 break;
-                // Exit monitor (return to main())
+            // Exit monitor (return to main())
             case 'q' :
                 PUTS("Return to main\r\n");
                 return;
-                // Not a command
+            // Not a command
             default:
                 PUTS("? [HELP]=?");
                 crlf();
@@ -257,36 +248,30 @@
     }
 }
 
-uint32_t get_disk_freespace(void)
+float get_disk_freespace(void)
 {
-    long  p1;
+    DWORD  p1;
     UINT   s1, s2;
     FATFS  *fs;
     BYTE res;
 
-    if (Dirx == NULL){
+    if (Dirx == NULL) {
         Dirx = new FATFS_DIR;
     }
-    char p = NULL;
-    res = f_opendir(Dirx, &p);
+    //char p = NULL;
+    char p[8] = {0};
+    res = f_opendir(Dirx, p);
     if (res) {
         return 0;
     }
-    p1 = s1 = s2 = 0;
-    for(;;) {
-        res = f_readdir(Dirx, &Finfo);
-        if ((res != FR_OK) || !Finfo.fname[0]) break;
-        if (Finfo.fattrib & AM_DIR) {
-            s2++;
-        } else {
-            s1++;
-            p1 += Finfo.fsize;
-        }
-    }
-    res = f_getfree(&p, (DWORD*)&p1, &fs);
-    uint32_t size = p1 * fs->csize * 512;
+    p1 = 0;
+    p[0] = '0';
+    p[1] = ':';
+    p[2] = 0;
+    res = f_getfree(p, (DWORD*)&p1, &fs);
+    float size_float = (float)p1 * (float)fs->csize * (float)fs->ssize;
     if (res == FR_OK) {
-        return size;
+        return size_float;
     } else {
         return 0;
     }
@@ -296,8 +281,8 @@
 {
     BYTE res;
     //const char *file_name ="acc_data.txt";
- 
-    if (Dirx == NULL){
+
+    if (Dirx == NULL) {
         Dirx = new FATFS_DIR;
     }
     char p = NULL;
@@ -309,7 +294,7 @@
     for(;;) {
         res = f_readdir(Dirx, &Finfo);
         if ((res != FR_OK) || !Finfo.fname[0]) break;
-        if (strcmp(Finfo.fname, file_name) == 0){
+        if (strcmp(Finfo.fname, file_name) == 0) {
             return Finfo.fsize;
         }
     }
@@ -675,7 +660,7 @@
                 p2 += s2;
                 if (cnt != s2) break;
             }
-            tim = t.read_ms();
+            tim = t.elapsed_time().count();
             PRINTF("%lu bytes read with %lu kB/sec.\r\n",
                    p2, tim ? (p2 / tim) : 0);
             break;
@@ -702,7 +687,7 @@
                 p2 += s2;
                 if (cnt != s2) break;
             }
-            tim = t.read_ms();
+            tim = t.elapsed_time().count();
             PRINTF("%lu bytes written with %lu kB/sec.\r\n",
                    p2, tim ? (p2 / tim) : 0);
             break;
@@ -737,8 +722,8 @@
             break;
 #endif
 #if 0
-            /* ft <year> <month> <day> <hour> <min> <sec> <name>
-                                                 - Change timestamp of an object */
+        /* ft <year> <month> <day> <hour> <min> <sec> <name>
+                                             - Change timestamp of an object */
         case 't' :
             if (!xatoi(&ptr, &p1) || !xatoi(&ptr, &p2) || !xatoi(&ptr, &p3)) {
                 break;
@@ -866,7 +851,7 @@
                 put_rc(f_mkfs("", (BYTE)p2, (DWORD)p3, Buff, sizeof Buff));
             break;
 #endif  /* FF_USE_MKFS */
-            /* fz [<size>] - Change/Show R/W length for fr/fw/fx command */
+        /* fz [<size>] - Change/Show R/W length for fr/fw/fx command */
         case 'z' :
             if (xatoi(&ptr, &p1) && p1 >= 1 && p1 <= (long)sizeof Buff)
                 blen = p1;
@@ -1098,29 +1083,29 @@
 
     if (xatoi(&ptr, &p1)) {
         t.tm_year       = (uint8_t)p1 + 100;
-        pc.printf("Year:%ld ",p1);
+        printf("Year:%ld ",p1);
         xatoi( &ptr, &p1 );
         t.tm_mon        = (uint8_t)p1 - 1;
-        pc.printf("Month:%ld ",p1);
+        printf("Month:%ld ",p1);
         xatoi( &ptr, &p1 );
         t.tm_mday       = (uint8_t)p1;
-        pc.printf("Day:%ld ",p1);
+        printf("Day:%ld ",p1);
         xatoi( &ptr, &p1 );
         t.tm_hour       = (uint8_t)p1;
-        pc.printf("Hour:%ld ",p1);
+        printf("Hour:%ld ",p1);
         xatoi( &ptr, &p1 );
         t.tm_min        = (uint8_t)p1;
-        pc.printf("Min:%ld ",p1);
+        printf("Min:%ld ",p1);
         xatoi( &ptr, &p1 );
         t.tm_sec        = (uint8_t)p1;
-        pc.printf("Sec: %ld \r\n",p1);
+        printf("Sec: %ld \r\n",p1);
         seconds = mktime(&t);
         set_time(seconds);
     } else {
         seconds = time(NULL);
     }
     strftime(buf, 50, " %B %d,'%y, %H:%M:%S\r\n", localtime(&seconds));
-    pc.printf("[Time] %s", buf);
+    printf("[Time] %s", buf);
 }
 
 //  Get key input data
@@ -1130,6 +1115,7 @@
     int idx = 0;
 
     for (;;) {
+        //DEBUG_LINE
         c = GETC();
         //    Added by Kenji Arai / JH1PJL   May 9th, 2010
         if (c == '\r') {
diff -r b5665028f662 -r a13b9833d5f4 FatFs_Mon/mon.h
--- a/FatFs_Mon/mon.h	Sat May 02 03:44:38 2020 +0000
+++ b/FatFs_Mon/mon.h	Thu Jan 14 00:38:59 2021 +0000
@@ -2,15 +2,16 @@
  * mbed Application program for the mbed
  *  FatFs Check program /monitor part
  *
- * Copyright (c) 2015,'18,'19,'20 Kenji Arai / JH1PJL
+ * Copyright (c) 2015,'18,'19,'20,'21 Kenji Arai / JH1PJL
  *  http://www7b.biglobe.ne.jp/~kenjia/
  *  https://os.mbed.com/users/kenjiArai/
  *      Created:    May        5th, 2015
  *      Revised:    June      14th, 2015
- *      Revised:    May        2nd, 2020
+ *      Revised:    August     8th, 2020
+ *      Revised:    January   14th, 2021
  */
 
 //  Function prototypes --------------------------------------------------------
 void mon(void);
-uint32_t get_disk_freespace(void);
+float get_disk_freespace(void);
 uint32_t get_data_file_size(const char *const file_name);
diff -r b5665028f662 -r a13b9833d5f4 check_revision.cpp
--- a/check_revision.cpp	Sat May 02 03:44:38 2020 +0000
+++ b/check_revision.cpp	Thu Jan 14 00:38:59 2021 +0000
@@ -1,23 +1,22 @@
 /*
  * Check Mbed revision
  *
- * Copyright (c) 2019,'20 Kenji Arai / JH1PJL
+ * 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:    May        2nd, 2020
+ *      Revised:    January   11th, 2021
  */
 
 #include "mbed.h"
- 
-//    RUN ONLY ON mbed-os-5.15.3
-//      https://github.com/ARMmbed/mbed-os/releases/tag/mbed-os-5.15.3
-#if (MBED_MAJOR_VERSION == 5) &&\
-    (MBED_MINOR_VERSION == 15) &&\
-    (MBED_PATCH_VERSION == 3)
+
+//    RUN ONLY ON mbed-os-6.6.0
+//      https://github.com/ARMmbed/mbed-os/releases/tag/mbed-os-6.6.0
+#if (MBED_MAJOR_VERSION == 6) &&\
+    (MBED_MINOR_VERSION == 6) &&\
+    (MBED_PATCH_VERSION == 0)
 #else
-    //#warning "Please use mbed-os-5.15.3"
-    #error "Please use mbed-os-5.15.3"
+#   error "Please use mbed-os-6.6.0"
 #endif
 
 void print_revision(void)
diff -r b5665028f662 -r a13b9833d5f4 mbed-os.lib
--- a/mbed-os.lib	Sat May 02 03:44:38 2020 +0000
+++ b/mbed-os.lib	Thu Jan 14 00:38:59 2021 +0000
@@ -1,1 +1,1 @@
-https://github.com/ARMmbed/mbed-os/#b6370b4c37f3d4665ed1cdcb1afea85396bba1b3
+https://github.com/ARMmbed/mbed-os/#84d991342a41011fc417aab62c0f5a8832f1d18f
diff -r b5665028f662 -r a13b9833d5f4 mbed_app.json
--- a/mbed_app.json	Sat May 02 03:44:38 2020 +0000
+++ b/mbed_app.json	Thu Jan 14 00:38:59 2021 +0000
@@ -1,6 +1,7 @@
 {
     "target_overrides": {
         "*": {
+            "target.printf_lib": "std",
             "target.features_add": ["STORAGE"],
             "target.components_add": ["SD"],
             "sd.INIT_FREQUENCY": 400000
diff -r b5665028f662 -r a13b9833d5f4 select_program.h
--- a/select_program.h	Sat May 02 03:44:38 2020 +0000
+++ b/select_program.h	Thu Jan 14 00:38:59 2021 +0000
@@ -1,11 +1,11 @@
 /*
  * DISCO-F469NI
  *
- * Copyright (c) 2019,'20 Kenji Arai / JH1PJL
+ * Copyright (c) 2019,'20,'21 Kenji Arai / JH1PJL
  *  http://www7b.biglobe.ne.jp/~kenjia/
  *  https://os.mbed.com/users/kenjiArai/
  *      Created:    December   6th, 2019
- *      Revised:    May        2nd, 2020
+ *      Revised:    January   12th, 2021
  */
 
 /*
diff -r b5665028f662 -r a13b9833d5f4 uart_as_stdio/uart_as_stdio.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uart_as_stdio/uart_as_stdio.cpp	Thu Jan 14 00:38:59 2021 +0000
@@ -0,0 +1,46 @@
+/*
+ * 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:    January   14th, 2021
+ */
+
+//  Include --------------------------------------------------------------------
+#include "mbed.h"
+
+//  Definition -----------------------------------------------------------------
+
+//  Constructor ----------------------------------------------------------------
+static BufferedSerial pc(USBTX, USBRX, 115200);
+
+//  RAM ------------------------------------------------------------------------
+
+//  ROM / Constant data --------------------------------------------------------
+
+//  Function prototypes --------------------------------------------------------
+
+//------------------------------------------------------------------------------
+//  Control Program
+//------------------------------------------------------------------------------
+uint8_t readable()
+{
+    return pc.readable();
+}
+
+void putc(uint8_t c)
+{
+    char dt[4];
+    dt[0] = (char)c;
+    pc.write(dt, 1);
+}
+
+uint8_t getc()
+{
+    char dt[4];
+    pc.read(dt, 1);
+    return (uint8_t)dt[0];
+}
diff -r b5665028f662 -r a13b9833d5f4 uart_as_stdio/uart_as_stdio.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uart_as_stdio/uart_as_stdio.h	Thu Jan 14 00:38:59 2021 +0000
@@ -0,0 +1,17 @@
+/*
+ * 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:    January   14th, 2021
+ */
+
+#include "mbed.h"
+
+//  Function prototypes --------------------------------------------------------
+uint8_t readable(void);
+void putc(uint8_t c);
+uint8_t getc(void);