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/1_rtc.cpp
- Revision:
- 4:0f4affc00183
- Parent:
- 3:35ac9ee7d2d6
--- a/z_example/1_rtc.cpp Wed Aug 07 05:39:01 2019 +0000 +++ b/z_example/1_rtc.cpp Mon Oct 14 08:55:15 2019 +0000 @@ -5,7 +5,7 @@ * http://www.page.sannet.ne.jp/kenjia/index.html * https://os.mbed.com/users/kenjiArai/ * Created: August 11th, 2017 - * Revised: July 30th, 2019 + * Revised: October 14th, 2019 */ #include "select_program.h" @@ -16,10 +16,11 @@ #include "mbed.h" // Definition ----------------------------------------------------------------- +#define USER_SW_ON 1 // Constructor ---------------------------------------------------------------- DigitalIn userSW(BUTTON1); -DigitalOut myled(LED1); // Indicate the sampling period +DigitalOut myled(LED1); // Indicate the sampling period Serial pc(USBTX, USBRX, 115200); // RAM ------------------------------------------------------------------------ @@ -30,14 +31,12 @@ const char * msg2 = "\r\nEnter Standby Mode, please push RESET to wake-up\r\n"; // Function prototypes -------------------------------------------------------- -extern void time_enter_mode(void); static void goto_standby(void); -#if 0 static void time_enter_mode(void); static void chk_and_set_time(char *ptr); static int xatoi (char **str, unsigned long *res); static void get_line (char *buff, int len); -#endif + //------------------------------------------------------------------------------ // Control Program //------------------------------------------------------------------------------ @@ -49,6 +48,7 @@ pc.printf("\x1b[2J\x1b[H %s\r\n %s %s (UTC)\r\n", __FILE__, __DATE__, __TIME__); + printf(" RTC EXAMPLE FOR DISCO-F769NI:\r\n"); myled = !myled; ThisThread::sleep_for(1000); myled = !myled; @@ -62,11 +62,11 @@ pc.printf("%s\r", msg1); wait_counter = 0; while (seconds == time(NULL)) { - if (pc.readable() == 1) { + if (pc.readable()) { buf[0] = pc.getc(); // dummy read time_enter_mode(); } - if (userSW == 1) { + if (userSW == USER_SW_ON) { pc.printf("%s", msg2); ThisThread::sleep_for(1000); myled = 0; @@ -91,14 +91,13 @@ ThisThread::sleep_for(0x7fffffff); // sleep 24 days } -#if 0 void time_enter_mode(void) { char *ptr; char linebuf[64]; pc.printf("\r\nSet time into RTC\r\n"); - pc.printf(" e.g. >19 7 15 10 11 12 -> July 15th,'19, 10:11:12\r\n"); + pc.printf(" e.g. >19 10 14 10 11 12 -> October 14th,'19, 10:11:12\r\n"); pc.printf(" If time is fine, just hit enter\r\n"); pc.putc('>'); ptr = linebuf; @@ -165,7 +164,8 @@ set_time(seconds); pc.printf( "Date: %04d/%02d/%02d, %02d:%02d:%02d\r\n", - t.tm_year + 1900, t.tm_mon + 1, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec + t.tm_year + 1900, t.tm_mon + 1, t.tm_mday, + t.tm_hour, t.tm_min, t.tm_sec ); } @@ -233,6 +233,5 @@ *res = val; return 1; } -#endif #endif