oscar simons / Mbed OS elec350courcework

Dependencies:   BMP280

Fork of Task617-mbedos by University of Plymouth - Stages 1, 2 and 3

Files at this revision

API Documentation at this revision

Comitter:
noutram
Date:
Wed Mar 09 17:55:01 2016 +0000
Parent:
4:dae8898e55fe
Child:
6:bd736256c32d
Commit message:
Thread alive LEDs now added

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Mar 09 17:18:55 2016 +0000
+++ b/main.cpp	Wed Mar 09 17:55:01 2016 +0000
@@ -33,6 +33,7 @@
 {
     pc.printf("Entering thread 1\n");
     while (true) {
+        yellowLED = 1;
         
         //Start critical section
         lock1.lock();
@@ -43,16 +44,15 @@
         //Thread::wait(1); //1ms
         
         if (SW1 == 1) {
-            yellowLED = 1;
             lock2.lock();
             sw2Count--;
-            lock2.unlock();  
-            yellowLED = 0; 
+            lock2.unlock();   
         }
         
         //End critical section
         lock1.unlock();
         
+        yellowLED = 0;
         Thread::wait(DELAY);       
     }
 }
@@ -61,6 +61,7 @@
 {
     pc.printf("Entering thread 2\n");  
     while (true) {
+        redLED = 1; 
         
         //Start critical section
         lock2.lock();
@@ -71,15 +72,14 @@
         //Thread::wait(1);  //1ms
         
         if (SW2 == 1) {
-            redLED = 1; 
             lock1.lock();
             sw1Count--;
             lock1.unlock();  
-            redLED = 0;
         }  
         //End critical section
         lock2.unlock();
         
+        redLED = 0;
         Thread::wait(DELAY); 
     } 
 }