Demo of ISR waking MCU

Files at this revision

API Documentation at this revision

Comitter:
noutram
Date:
Thu Sep 12 13:57:55 2019 +0000
Parent:
3:52ced27ad588
Child:
5:c11d12dab1e2
Commit message:
2019

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
mbed.bld Show diff for this revision Revisions of this file
mbed_app.json Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Feb 06 12:42:56 2018 +0000
+++ b/main.cpp	Thu Sep 12 13:57:55 2019 +0000
@@ -4,24 +4,34 @@
 // However, pressing and releasing the switch can result in spurious falling edges
 // which trigger the routine 
 
+//Uncomment this if you want to use the onboard LEDs and Blue Switch on a F429ZI
+#define USEONBOARD
+
 //Declare functions
 void sw1FallingEdge();
 
 //Global Objects
+#ifdef USEONBOARD
 DigitalOut  red_led(LED3);
-DigitalOut  yellow_led(LED2);
 DigitalOut  green_led(LED1);
-InterruptIn   sw1(USER_BUTTON);
+InterruptIn sw1(USER_BUTTON);
+#else
+DigitalOut  red_led(D7);
+DigitalOut  green_led(D5);
+InterruptIn sw1(D4);
+#endif
 
 //Interrupt service routine for a rising edge (press)
 void sw1FallingEdge() {
     red_led = !red_led;     //Toggle the LED
 }
 
+Serial pc(USBTX, USBRX);
+
 //Main - only has to initialise and sleep
 int main() {
-    //Initial logging message
-    puts("START");
+
+    pc.set_blocking(true);
     red_led   = 0;
     green_led = 1;
     
@@ -35,7 +45,10 @@
         sleep();
         
         //You can ONLY reach this point if an ISR wakes the CPU
-        puts("ISR just woke the MPU");
+        green_led = !green_led;
+        
+        //Any use of the serial port will produce a series of interrupts
+        //pc.puts("Ping!\n\r");
         
     } //end while
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Thu Sep 12 13:57:55 2019 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#1bf6b20df9d3cd5f29f001ffc6f0d0fcbbb96118
--- a/mbed.bld	Tue Feb 06 12:42:56 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/a97add6d7e64
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_app.json	Thu Sep 12 13:57:55 2019 +0000
@@ -0,0 +1,3 @@
+{
+    "requires": ["bare-metal"]
+}
\ No newline at end of file