assignment 4 exercise 2

Files at this revision

API Documentation at this revision

Comitter:
mcalzana
Date:
Thu Nov 15 14:14:35 2018 +0000
Commit message:
assignment 4 exercise 2

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib 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	Thu Nov 15 14:14:35 2018 +0000
@@ -0,0 +1,26 @@
+#include "mbed.h"
+
+
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+//volatile bool running = true;
+
+// Blink function toggles the led in a long running loop
+void blink(DigitalOut *led) {
+    *led = 1;
+    wait(1);
+    *led = 0;
+    return;
+}
+
+// Spawns a thread to run blink for 5 seconds
+int main() {
+    while(true){
+        Thread thread1;
+        Thread thread2;
+        thread1.start(callback(blink, &led1));
+        thread1.join();
+        thread2.start(callback(blink, &led2));
+        thread2.join();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Thu Nov 15 14:14:35 2018 +0000
@@ -0,0 +1,1 @@
+https://github.com/armmbed/mbed-os/#bf6f2c3c6434a6de9eb9511feffa5948b3d1f20f