Several examples run on only mbed-os5.13.0 (not 5.14.0)
Dependencies: BD_SD_DISCO_F769NI BSP_DISCO_F769NI LCD_DISCO_F769NI TS_DISCO_F769NI USBHost_F769NI
Diff: z_example/4_microSD.cpp
- Revision:
- 4:0f4affc00183
- Parent:
- 3:35ac9ee7d2d6
--- a/z_example/4_microSD.cpp Wed Aug 07 05:39:01 2019 +0000 +++ b/z_example/4_microSD.cpp Mon Oct 14 08:55:15 2019 +0000 @@ -2,11 +2,11 @@ * Mbed Application program * SD Card file control function with FatFs on Mbed-os5 * - * Copyright (c) 2018 Kenji Arai / JH1PJL + * Copyright (c) 2018,'19 Kenji Arai / JH1PJL * http://www.page.sannet.ne.jp/kenjia/index.html * https://os.mbed.com/users/kenjiArai/ * Created: April 7th, 2018 - * Revised: July 21st, 2019 + * Revised: October 14th, 2019 */ #include "select_program.h" @@ -18,9 +18,6 @@ #include "FATFileSystem.h" #include "SDBlockDeviceDISCOF769NI.h" #include "mon.h" -#include <stdlib.h> -#include <stdio.h> -#include <errno.h> // Definition ----------------------------------------------------------------- #define USER_SW_ON 1 @@ -36,8 +33,8 @@ // RAM ------------------------------------------------------------------------ // ROM / Constant data -------------------------------------------------------- -char *const opening_msg0 = "microSD Card test program"; -char *const opening_msg1 = " -> run on Mbed OS-5\r\n"; +const char * opening_msg0 = "microSD Card test program"; +const char * opening_msg1 = " -> run on Mbed OS-5\r\n"; // Function prototypes -------------------------------------------------------- void return_error (int ret_val); @@ -56,9 +53,10 @@ uint32_t data4 = 50000U; uint32_t data5 = 60000U; - if (user_sw == USER_SW_ON) { - mon(); - } + pc.printf("\x1b[2J\x1b[H %s\r\n %s %s (UTC)\r\n", + __FILE__, __DATE__, __TIME__); + printf(" microSD FOR DISCO-F769NI:\r\n"); + //pc.printf("line:%d\r\n", __LINE__); pc.printf("\r\nStart\r\n"); int error = 0; @@ -67,6 +65,10 @@ error = fs.mount(&bd); return_error(error); + if (user_sw == USER_SW_ON) { + mon(); + } + FILE* fp = fopen("/fs/mydata.txt", "a"); errno_error(fp); if (fp != 0) { @@ -92,7 +94,7 @@ char tmp[64]; seconds = time(NULL); strftime(tmp, 64, "DATE %H:%M:%S,%Y/%m/%d,", localtime(&seconds)); - pc.printf(tmp); + pc.printf("%s", tmp); fprintf(fp, "%s", tmp); pc.printf("%08d;%08d;%08d;%08d;%08d;%08d\r\n", ++data0, ++data1, ++data2, ++data3, ++data4, ++data5); @@ -114,7 +116,7 @@ system_reset(); } } - Thread::wait(100); + ThisThread::sleep_for(100); if (user_sw == USER_SW_ON) { break; }