
Task on mixing interrupts and threads updated for mbed os 5.4
Revision 9:f9031b045b9a, committed 2017-04-03
- Comitter:
- noutram
- Date:
- Mon Apr 03 11:53:02 2017 +0000
- Parent:
- 8:c5663f5fa848
- Commit message:
- updated for mbed os 5.4
Changed in this revision
--- a/main.cpp Mon Mar 14 19:48:24 2016 +0000 +++ b/main.cpp Mon Apr 03 11:53:02 2017 +0000 @@ -6,8 +6,8 @@ #define SWITCH1_RELEASE 1 -void thread1( const void* ); -void thread2( const void* ); +void thread1(); +void thread2(); void switchISR(); //Digital outputs @@ -40,7 +40,7 @@ } //High priority thread -void thread1( const void* arg ) +void thread1() { redLED = 1; while (true) { @@ -63,7 +63,7 @@ // This thread has normal priority // It is supposed to flash the green LED every second. // THIS IS NOT WORKING because it is currently being starved by thread1 (while polling the switch) -void thread2( const void* arg ) +void thread2() { greenLED = 1; while (true) { @@ -79,10 +79,14 @@ yellowLED = 0; greenLED = 0; - //Threads - t1 = new Thread(&thread1, NULL, osPriorityRealtime); //HIGH PRIORITY - t2 = new Thread(&thread2, NULL, osPriorityNormal); - + //Threads - created dynamically with new + t1 = new Thread(osPriorityRealtime); //HIGH PRIORITY + t2 = new Thread(osPriorityNormal); + + //Note t1 and t2 are pointers (32 bit addresses), so the arrow -> is used + t1->start(thread1); + t2->start(thread2); + // Thread IDs tidMain = Thread::gettid(); tid1 = t1->gettid();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Mon Apr 03 11:53:02 2017 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#50b3418e45484ebf442b88cd935a2d5355402d7d
--- a/mbed-rtos.lib Mon Mar 14 19:48:24 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
--- a/mbed.bld Mon Mar 14 19:48:24 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