SD Card control on Mbed os5
Please refer following my Notebook page.
/users/kenjiArai/notebook/sd-card-control-new/#
Revision 6:7f8bc932cede, committed 2020-05-02
- Comitter:
- kenjiArai
- Date:
- Sat May 02 03:44:56 2020 +0000
- Parent:
- 5:bbd17b77d405
- Commit message:
- updated os5. changed starting process(wait key input)
Changed in this revision
diff -r bbd17b77d405 -r 7f8bc932cede FatFs_Mon/mon.cpp --- a/FatFs_Mon/mon.cpp Fri Dec 27 03:01:55 2019 +0000 +++ b/FatFs_Mon/mon.cpp Sat May 02 03:44:56 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 bbd17b77d405 -r 7f8bc932cede FatFs_Mon/mon.h --- a/FatFs_Mon/mon.h Fri Dec 27 03:01:55 2019 +0000 +++ b/FatFs_Mon/mon.h Sat May 02 03:44:56 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 bbd17b77d405 -r 7f8bc932cede check_revision.cpp --- a/check_revision.cpp Fri Dec 27 03:01:55 2019 +0000 +++ b/check_revision.cpp Sat May 02 03:44:56 2020 +0000 @@ -1,21 +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: December 24th, 2019 + * Revised: May 2nd, 2020 */ #include "mbed.h" - -// RUN ONLY ON mbed-os5.15.0 -// https://github.com/ARMmbed/mbed-os/releases/tag/mbed-os-5.15.0 + +// 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 == 0) + (MBED_PATCH_VERSION == 3) +#elif (MBED_MAJOR_VERSION == 2) &&\ + (MBED_MINOR_VERSION == 0) &&\ + (MBED_PATCH_VERSION == 165) #else - //#warning "Please use Mbed-os5.15.0" - #error "Please use Mbed-os5.15.0" -#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 bbd17b77d405 -r 7f8bc932cede main.cpp --- a/main.cpp Fri Dec 27 03:01:55 2019 +0000 +++ b/main.cpp Sat May 02 03:44:56 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 */ /* @@ -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,13 +109,14 @@ 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();
diff -r bbd17b77d405 -r 7f8bc932cede mbed-os.lib --- a/mbed-os.lib Fri Dec 27 03:01:55 2019 +0000 +++ b/mbed-os.lib Sat May 02 03:44:56 2020 +0000 @@ -1,1 +1,1 @@ -https://github.com/ARMmbed/mbed-os/#64853b354fa188bfe8dbd51e78771213c7ed37f7 +https://github.com/ARMmbed/mbed-os/#b6370b4c37f3d4665ed1cdcb1afea85396bba1b3