SD-Card Control Program / Using Micro-SD / based on SDCardTest Program (http://mbed.org/users/simon/programs/SDCardTest/gpdz4x/)

Dependencies:   mbed SDFileSystem

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:
Sat May 02 03:45:17 2020 +0000
Parent:
6:b4538dd09336
Commit message:
changed starting process(wait key input)

Changed in this revision

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
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r b4538dd09336 -r 4467fbfa888b FatFs_Mon/mon.cpp
--- a/FatFs_Mon/mon.cpp	Fri Dec 27 03:01:20 2019 +0000
+++ b/FatFs_Mon/mon.cpp	Sat May 02 03:45:17 2020 +0000
@@ -2,13 +2,13 @@
  * mbed Application program for the mbed
  *  FatFs Check program / monitor part
  *
- * Copyright (c) 2015,'18,'19 Kenji Arai / JH1PJL
- *  http://www.page.sannet.ne.jp/kenjia/index.html
+ * Copyright (c) 2015,'18,'19,'20 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:    December  24th, 2019
+ *      Revised:    May        2nd, 2020
  */
 
 /*
@@ -119,7 +119,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 19 12 24 10 11 12 -> 2019-12-24 10:11:12\r\n"
+    "      e.g. t 20 5 2 10 11 12 -> May 02,'20, 10:11:12\r\n"
     "?     Help/You know the command\r\n"
     "\r\n";
 
diff -r b4538dd09336 -r 4467fbfa888b FatFs_Mon/mon.h
--- a/FatFs_Mon/mon.h	Fri Dec 27 03:01:20 2019 +0000
+++ b/FatFs_Mon/mon.h	Sat May 02 03:45:17 2020 +0000
@@ -2,12 +2,12 @@
  * mbed Application program for the mbed
  *  FatFs Check program /monitor part
  *
- * Copyright (c) 2015,'18,'19 Kenji Arai / JH1PJL
- *  http://www.page.sannet.ne.jp/kenjia/index.html
+ * Copyright (c) 2015,'18,'19,'20 Kenji Arai / JH1PJL
+ *  http://www7b.biglobe.ne.jp/~kenjia/
  *  https://os.mbed.com/users/kenjiArai/
  *      Created:    May        5th, 2015
  *      Revised:    June      14th, 2015
- *      Revised:    December  24th, 2019
+ *      Revised:    May        2nd, 2020
  */
 
 //  Function prototypes --------------------------------------------------------
diff -r b4538dd09336 -r 4467fbfa888b check_revision.cpp
--- a/check_revision.cpp	Fri Dec 27 03:01:20 2019 +0000
+++ b/check_revision.cpp	Sat May 02 03:45:17 2020 +0000
@@ -1,20 +1,31 @@
 /*
  * Check Mbed revision
  *
- * Copyright (c) 2019 Kenji Arai / JH1PJL
- *  http://www.page.sannet.ne.jp/kenjia/index.html
+ * 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    17th, 2019
+ *      Revised:    May        2nd, 2020
  */
 
 #include "mbed.h"
-
-//    RUN ONLY ON mbed 2.0.165
-#if (MBED_MAJOR_VERSION == 2) &&\
+ 
+//    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)
+#elif (MBED_MAJOR_VERSION == 2) &&\
     (MBED_MINOR_VERSION == 0) &&\
     (MBED_PATCH_VERSION == 165)
 #else
-    //#warning "Please use mbed 2.0.165"
-    #error "Please use mbed 2.0.165"
-#endif
\ No newline at end of file
+    //#warning "Please use mbed-os-5.15.3 or mbed 2.0.165"
+    #error "Please use mbed-os-5.15.3 or mbed 2.0.165"
+#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);
+}
diff -r b4538dd09336 -r 4467fbfa888b main.cpp
--- a/main.cpp	Fri Dec 27 03:01:20 2019 +0000
+++ b/main.cpp	Sat May 02 03:45:17 2020 +0000
@@ -2,11 +2,11 @@
  * Mbed Application program
  *  SD Card file control function with FatFs on Mbed-os5 or os2
  *
- * Copyright (c) 2018,'19 Kenji Arai / JH1PJL
- *  http://www.page.sannet.ne.jp/kenjia/index.html
+ * Copyright (c) 2018,'19,'20 Kenji Arai / JH1PJL
+ *  http://www7b.biglobe.ne.jp/~kenjia/
  *  https://os.mbed.com/users/kenjiArai/
  *      Created:    April      4th, 2018
- *      Revised:    December  27th, 2019
+ *      Revised:    May        2nd, 2020
  */
 
 /*
@@ -15,7 +15,7 @@
     Tested board on OS5.15.0
         Nucleo-F401RE, -F411RE, -F446RE, -L152RE, -L073RZ, -L476RG          
         nRF52840-DK, nRF52-DK
-        FRDM-F64K
+        FRDM-K64F
  */
 
 //  Include --------------------------------------------------------------------
@@ -72,8 +72,13 @@
 #elif (MBED_MAJOR_VERSION == 5)
 const char *const opening_msg1 = " -> run on Mbed OS-5\r\n";
 #endif
+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";
 
 //  Function prototypes --------------------------------------------------------
+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
@@ -88,9 +93,8 @@
     uint32_t data4 = 50000U;
     uint32_t data5 = 60000U;
 
-    if (user_sw == USER_SW_ON) {
-        mon();
-    }
+    pc.printf("\r\n\r\n");
+    print_revision();
     DBG("line:%d\r\n", __LINE__);
 #if (MBED_MAJOR_VERSION == 5)
     /* Init SD CARD reader */
@@ -105,20 +109,21 @@
         DBG("line:%d\r\n", __LINE__);
         pc.printf("%s%s",  opening_msg0, opening_msg1);
         fprintf(fp,"%s%s", opening_msg0, opening_msg1);
+        pc.printf("%s",  opening_msg2);
         fclose(fp);
     } else {
         pc.printf("ERROR\r\n");
     }
-    while (pc.readable()) {
-        char c = pc.getc(); // dummy read
-    }
+    pc.printf("%s",  opening_msg3);
+    while (pc.readable() == 0) { ;}
+    char c = pc.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:%8u, file:%8u  ", size_disk, size_file);
+        pc.printf("free disk:%10u, file:%8u  ", size_disk, size_file);
         fp = fopen("/fs/mydata.txt", "a");
         if(fp != 0) {
             char tmp[64];