Nuvoton
/
NuMaker-mbed-OS-Core-RTOS-Basic
NuMaker mbed RTOS basic (Thread)
Diff: main.cpp
- Revision:
- 13:e84e74cba750
- Parent:
- 9:3b8bf3ce2801
--- 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 } }