Demonstrating a ISR signalling a high-priority thread

Dependencies:   ELEC350-Practicals-FZ429

Fork of Task622Solution-mbedos54 by Nicholas Outram

Files at this revision

API Documentation at this revision

Comitter:
noutram
Date:
Tue Nov 14 14:22:03 2017 +0000
Parent:
10:730250526509
Commit message:
Streamlined version

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 730250526509 -r 9dcbcda8ea12 main.cpp
--- a/main.cpp	Tue Nov 14 14:12:15 2017 +0000
+++ b/main.cpp	Tue Nov 14 14:22:03 2017 +0000
@@ -21,7 +21,6 @@
 
 //Called on the falling edge of a switch
 void switchISR() {
-     sw.fall(NULL);
      t1.signal_set(SWITCH1_RELEASE);    //Very short
 }
 
@@ -30,9 +29,13 @@
 {
     redLED = 1;
     while (true) {
+         //Block (WAITING) for signal from the ISR
          Thread::signal_wait(SWITCH1_RELEASE);
+         
+         //Flash LED
          redLED = !redLED;
-         sw.fall(NULL);  //Turn off any further interrupts
+         
+         //Wait for switch bounce to settle
          Thread::wait(200); 
          
          //Block using BUSY-WAIT
@@ -40,9 +43,8 @@
 //         t.start();
 //         while (t < 2);
          
-         //Clear any additional signals
+         //Clear any additional signals (caused by switch bounce and ISR)
          t1.signal_clr(SWITCH1_RELEASE);   //Debounce - clear pending signals
-         sw.fall(switchISR);
     }
 }