Task 6.1.3 Starting point updated for mbed OS 5.4

Files at this revision

API Documentation at this revision

Comitter:
noutram
Date:
Thu Mar 30 13:52:37 2017 +0000
Parent:
0:1f4d20070876
Commit message:
updated for mbed OS 5.4

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
mbed-rtos.lib Show diff for this revision Revisions of this file
mbed.bld Show diff for this revision Revisions of this file
diff -r 1f4d20070876 -r cf2510fcf09a main.cpp
--- a/main.cpp	Tue Mar 08 11:45:42 2016 +0000
+++ b/main.cpp	Thu Mar 30 13:52:37 2017 +0000
@@ -1,5 +1,4 @@
 #include "mbed.h"
-#include "rtos.h"
 
 #define RED_ON 1
 #define YELLOW_ON 2
@@ -7,10 +6,10 @@
 #define ALL_ON 7
 
 //Function declarations
-void Function1(void const *args);
-void Function2(void const *args);
-void Function3(void const *args);
-void Function4(void const *args);
+void Function1();
+void Function2();
+void Function3();
+void Function4();
 
 //I/O
 DigitalOut onBoardLED(LED1);
@@ -22,10 +21,10 @@
 DigitalIn  SW1(D4);
 DigitalIn  SW2(D3);
 
-Thread* t1;
-Thread* t2;
-Thread* t3;
-Thread* t4;
+Thread t1;
+Thread t2;
+Thread t3;
+Thread t4;
 
 //Thread ID
 osThreadId idMain;
@@ -34,43 +33,43 @@
 osThreadId id3;
 osThreadId id4;
 
-void Function1(void const *args)
+void Function1()
 {
     while (true) {
         redLED = !redLED;
         if (redLED == 1) {
-            t4->signal_set(RED_ON);
+            t4.signal_set(RED_ON);
         }
         
         Thread::wait(5100);
     }
 }
 
-void Function2(void const *args)
+void Function2()
 {
     while (true) {
         yellowLED = !yellowLED;
         if (yellowLED == 1) {
-            t4->signal_set(YELLOW_ON);
+            t4.signal_set(YELLOW_ON);
         }
         Thread::wait(1900);
     }
 }
 
 //Green Flashing
-void Function3(void const *args)
+void Function3()
 {
     while (true) {
         greenLED = !greenLED;
         if (greenLED == 1) {
-            t4->signal_set(GREEN_ON);
+            t4.signal_set(GREEN_ON);
         }       
         Thread::wait(700);
     }
 }
 
 //This function waits for signals from all other threads
-void Function4(void const *args)
+void Function4()
 {
     while (true) {
         
@@ -94,18 +93,18 @@
     //Main thread ID
     idMain = osThreadGetId();   //CMSIS RTOS call
     
-    //Create and run threads
-    t4 = new Thread(Function4);
-    t1 = new Thread(Function1);           
-    t2 = new Thread(Function2);    
-    t3 = new Thread(Function3);     //Dynamically allocated
+    //Run threads
+    t4.start(Function4);
+    t1.start(Function1);           
+    t2.start(Function2);    
+    t3.start(Function3);     
 
     
     //Thread ID
-    id1 = t1->gettid();
-    id2 = t2->gettid();
-    id3 = t3->gettid();
-    id4 = t4->gettid();
+    id1 = t1.gettid();
+    id2 = t2.gettid();
+    id3 = t3.gettid();
+    id4 = t4.gettid();
     
     while(1) {
         //Wait for the ALL_ON signal
diff -r 1f4d20070876 -r cf2510fcf09a mbed-os.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Thu Mar 30 13:52:37 2017 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#50b3418e45484ebf442b88cd935a2d5355402d7d
diff -r 1f4d20070876 -r cf2510fcf09a mbed-rtos.lib
--- a/mbed-rtos.lib	Tue Mar 08 11:45:42 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/mbed-rtos/#b4c5542476ba
diff -r 1f4d20070876 -r cf2510fcf09a mbed.bld
--- a/mbed.bld	Tue Mar 08 11:45:42 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/252557024ec3
\ No newline at end of file