Lab 2 sample 2: use of interrupts

Dependents:   digitalInInterrupt_sample

Fork of digitalInPolling_sample by William Marsh

Files at this revision

API Documentation at this revision

Comitter:
WilliamMarshQMUL
Date:
Thu Jan 30 08:16:04 2020 +0000
Parent:
4:728667196916
Commit message:
Replace wait with sleep_for

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
diff -r 728667196916 -r 86742cfaf4e4 main.cpp
--- a/main.cpp	Tue Jan 15 10:09:53 2019 +0000
+++ b/main.cpp	Thu Jan 30 08:16:04 2020 +0000
@@ -6,7 +6,7 @@
 //    is pressed
 // The callback uses a shared variable to signal another thread
 
-InterruptIn button(PTD0);
+InterruptIn button(PTD0);  // Pin must be on ports A or D
 DigitalOut led(LED_GREEN);
 
 volatile int pressEvent = 0 ;
@@ -15,7 +15,7 @@
 //   Signal that the button has been pressed
 //   Note: bounce may occur 
 void buttonCallback(){
-    pressEvent = 1 ;
+    pressEvent = 1 ;  
 }
 
 /*  ---- Main function (default thread) ----
@@ -31,6 +31,6 @@
             led = !led ;
             pressEvent = 0 ; // Clear the event variable
         }
-        wait(0.1) ;
+        ThisThread::sleep_for(100) ; // delay for 100ms 
     }
 }
\ No newline at end of file
diff -r 728667196916 -r 86742cfaf4e4 mbed-os.lib
--- a/mbed-os.lib	Tue Jan 15 10:09:53 2019 +0000
+++ b/mbed-os.lib	Thu Jan 30 08:16:04 2020 +0000
@@ -1,1 +1,1 @@
-https://github.com/ARMmbed/mbed-os/#c966348d3f9ca80843be7cdc9b748f06ea73ced0
+https://github.com/ARMmbed/mbed-os/#430e64fce8098fd5e54f6de32f3f029f35dc705f