IRQ Demo

Revision:
0:96fb278b654f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu May 23 06:25:18 2019 +0000
@@ -0,0 +1,38 @@
+#include "mbed.h"
+
+InterruptIn fireIrq(p14);
+Timeout timeoutIrq;
+
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+
+Serial pc(USBTX, USBRX);
+
+
+// funktion runs in interrupt-context
+void fireIrqHandler( void )
+{
+    led1 = !led1;
+    pc.printf("Starting up...\n\r");
+}
+
+// runs in irq-context
+void timeoutIrqHandler( void )
+{
+    led2 = 0;   
+}
+
+int main()
+{
+    pc.printf("Starting up...\n\r");
+    
+    fireIrq.fall( &fireIrqHandler );
+    fireIrq.rise( &fireIrqHandler );
+    
+    led2 = 1;
+    timeoutIrq.attach( &timeoutIrqHandler, 3 );
+    
+    while(1) {
+        wait(5);
+    }
+}
\ No newline at end of file