RTOS timer example - This program was borrowed from the book 'ARM-Based microcontroller projects using MBED' written by Dogan Ibrahim, Newsnes (an imprint of Elsevier) 2019. ISBN: 978-0-08-102969-5.
Diff: main.cpp
- Revision:
- 0:dd52dcc80425
diff -r 000000000000 -r dd52dcc80425 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Apr 10 12:15:08 2022 +0000 @@ -0,0 +1,28 @@ + +/* RTOS timer example + * This program was borrowed from the book + * 'ARM-Based microcontroller projects using MBED' + * written by Dogan Ibrahim + * Newsnes (an imprint of Elsevier) 2019. ISBN: 978-0-08-102969-5 + * + * https://www.sciencedirect.com/book/9780081029695/arm-based-microcontroller-projects-using-mbed + */ + +#include "mbed.h" +#include "rtos.h" +DigitalOut led(LED1); + +void Flash() { + led = !led; // Flash the LED +} + +int main() { + led = 1; + RtosTimer timer(Flash); // Create a timer + timer.start(500); // Start the timer + Thread::wait(5000); // Wait 5 seconds + timer.stop(); // Stop the timer + + Thread::wait(osWaitForever); // Wait forever +} +