
Solution to 6.1.5 updated for mbed os 5.4
Diff: main.cpp
- Revision:
- 2:91200df5ccd6
- Parent:
- 1:4fb27aea76b2
--- a/main.cpp Tue Mar 08 12:26:28 2016 +0000 +++ b/main.cpp Thu Mar 30 14:24:24 2017 +0000 @@ -1,13 +1,12 @@ #include "mbed.h" -#include "rtos.h" #define RED_DONE 1 #define YELLOW_DONE 2 //Function declarations -void countUP(void const *args); -void countDOWN(void const *args); +void countUP(); +void countDOWN(); //Digital outputs DigitalOut onBoardLED(LED1); @@ -30,7 +29,7 @@ volatile long long count = 0; //Threads -void countUP(void const *args) +void countUP() { redLED = 1; @@ -58,7 +57,7 @@ osSignalSet(tidMain, RED_DONE); //Signal main thread we are done } -void countDOWN(void const *args) +void countDOWN() { yellowLED = 1; @@ -89,6 +88,9 @@ //Main thread int main() { + Thread t1; + Thread t2; + redLED = 0; yellowLED = 0; greenLED = 1; @@ -102,12 +104,12 @@ //Press the switch to run concurrently if (onBoardSwitch == 1) { printf("Running sequntially\n"); - countUP(NULL); - countDOWN(NULL); + countUP(); + countDOWN(); } else { printf("Running concurrently\n"); - Thread t1(countUP); - Thread t2(countDOWN); + t1.start(countUP); + t2.start(countDOWN); //Wait for the ALL_ON signal Thread::signal_wait(RED_DONE,osWaitForever);