Nuvoton
/
NuMaker-mbed-OS-Core-RTOS-Basic
NuMaker mbed RTOS basic (Thread)
Revision 13:e84e74cba750, committed 2021-02-25
- Comitter:
- SHLIU1@OANBE02333.nuvoton.com
- Date:
- Thu Feb 25 13:04:26 2021 +0800
- Parent:
- 12:bdb7c703f81e
- Commit message:
- Support the both V5.X and V6.X for mbed-os
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Oct 24 10:13:17 2019 +0000 +++ b/main.cpp Thu Feb 25 13:04:26 2021 +0800 @@ -4,18 +4,32 @@ DigitalOut led1(LED1); DigitalOut led2(LED2); -void led2_thread(void const *args) { +void led2_thread(DigitalOut *led) { while (true) { - led2 = !led2; + *led = !*led; +#if MBED_MAJOR_VERSION >= 6 + ThisThread::sleep_for(1000); +#else Thread::wait(1000); +#endif } } int main() { - Thread thread(led2_thread); - + Thread thread; + +#ifdef MBED_MAJOR_VERSION + printf("Mbed OS version %d.%d.%d\r\n\n", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION); +#endif + + thread.start(callback(led2_thread, &led2)); + while (true) { led1 = !led1; +#if MBED_MAJOR_VERSION >= 6 + ThisThread::sleep_for(500); +#else Thread::wait(500); +#endif } }