Marco Zecchini
/
Example_RTOS
Rtos API example
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 #include "test_env.h" 00003 00004 #if !DEVICE_RTC 00005 #error [NOT_SUPPORTED] RTC is not supported 00006 #endif 00007 00008 #define CUSTOM_TIME 1256729737 00009 00010 int main() { 00011 MBED_HOSTTEST_TIMEOUT(20); 00012 MBED_HOSTTEST_SELECT(rtc_auto); 00013 MBED_HOSTTEST_DESCRIPTION(RTC); 00014 MBED_HOSTTEST_START("MBED_16"); 00015 00016 char buffer[32] = {0}; 00017 set_time(CUSTOM_TIME); // Set RTC time to Wed, 28 Oct 2009 11:35:37 00018 while(1) { 00019 time_t seconds = time(NULL); 00020 strftime(buffer, 32, "%Y-%m-%d %H:%M:%S %p", localtime(&seconds)); 00021 printf("MBED: [%ld] [%s]\r\n", seconds, buffer); 00022 wait(1); 00023 } 00024 }
Generated on Sun Jul 17 2022 08:25:26 by 1.7.2