Simple firmware to test the I/O capabilities of a Nucleo 64 board

Dependencies:   mbed

Revision:
1:69c43e344369
Parent:
0:43a77ff47221
--- a/main.cpp	Mon Mar 14 02:30:27 2016 +0000
+++ b/main.cpp	Tue Mar 15 21:55:12 2016 +0000
@@ -15,18 +15,21 @@
 DigitalOut      led1(LED1);
 InterruptIn     userButton(USER_BUTTON);
 
+bool buttonPressedInterrupt = false;
+bool buttonReleasedInterrupt = false;
+
 void 
 buttonPressedCallback(void)
 {
-    led1 = BUTTON_PRESSED_LED_STATE;
-    DEBUG_0("button pressed\n");
+    // Flag main to handle heavy work. Heavy work should not be handle in interrupt handler
+    buttonPressedInterrupt = true;
 }
 
 void
 buttonReleasedCallback(void)
 {
-    led1 = BUTTON_RELEASED_LED_STATE;
-    DEBUG_0("button released\n");
+    // Flag main to handle heavy work. Heavy work should not be handle in interrupt handler
+    buttonReleasedInterrupt = true;
 }
 
 void
@@ -44,10 +47,28 @@
 main() 
 {
     initBoard();
+    
+    DEBUG_0("NUCLEO_BTN_LED_DEMO started\n");
+    
     led1 = LED_ON;
     wait_ms(1000);
     led1 = LED_OFF;
     wait_ms(1000);
     while(1) {
+        if (buttonReleasedInterrupt)
+        {
+            led1 = BUTTON_RELEASED_LED_STATE;
+            DEBUG_0("button released\n");
+            
+            buttonReleasedInterrupt = false;
+        }
+        
+        if (buttonPressedInterrupt)
+        {
+            led1 = BUTTON_PRESSED_LED_STATE;
+            DEBUG_0("button pressed\n");
+            
+            buttonPressedInterrupt = false;
+        }
     }
 }