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.

Dependencies:   mbed mbed-rtos

Files at this revision

API Documentation at this revision

Comitter:
cspista
Date:
Sun Apr 10 12:15:08 2022 +0000
Commit message:
Final version

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /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
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Sun Apr 10 12:15:08 2022 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed-rtos/#5713cbbdb706
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Apr 10 12:15:08 2022 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file