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.
Revision 0:dd52dcc80425, committed 2022-04-10
- Comitter:
- cspista
- Date:
- Sun Apr 10 12:15:08 2022 +0000
- Commit message:
- Final version
Changed in this revision
--- /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