FalaFam / Mbed 2 deprecated Amaldi_2_Exercise_Keyboard_Interrupt

Dependencies:   mbed

Fork of Amaldi_2_Exercise_Keyboard_Interrupt by Amaldi

Files at this revision

API Documentation at this revision

Comitter:
pinofal
Date:
Mon May 07 07:10:08 2018 +0000
Parent:
1:5440b3d7f435
Commit message:
Amaldi 2 Exercise

Changed in this revision

KeyBoard-Interrupt.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/KeyBoard-Interrupt.cpp	Mon May 07 07:10:08 2018 +0000
@@ -0,0 +1,45 @@
+// Tested: NUCLEO-L476RG
+
+#include "mbed.h"
+
+Serial pc(USBTX, USBRX);
+DigitalOut myLed (LED1);
+
+/**************************************/
+/* Routine di Gestione Interrupt IRQ  */
+/**************************************/
+void myInterrupt()
+{
+    char key;
+    
+    // cattura carattere da seriale
+    key = pc.getc();
+    
+    // invia stringa al PC
+    pc.printf("Interrupted %c\r\n", key);
+}
+
+/********/
+/* MAIN */
+/********/
+int main() 
+{
+    // inizializza seriale
+    pc.baud(921600);
+    
+    // inizializza variabili
+    myLed=0;
+    
+    // messaggio di benvenuto
+    pc.printf("\r\nHallo Amaldi Students - Exercise 2 \r\n");
+    
+    // inizializza routine interrupt
+    pc.attach(myInterrupt, Serial::RxIrq);
+    
+    // accendi/spegni LED mentre attende Rx da seriale per gestire la IRQ
+    while(1)
+    {
+        // inverte lo stato acceso/spento del LED
+        myLed=!myLed;   
+    }
+}
--- a/main.cpp	Tue Jun 02 03:00:32 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-#include "mbed.h"
-
-Serial pc(SERIAL_TX, SERIAL_RX);
-
-void my_Interrupt(){
-    char key;
-    key = pc.getc();
-    pc.printf("Interrupted %c\r\n", key);
-}
-
-int main() {
-    pc.attach(my_Interrupt, Serial::RxIrq);
-    while(1){}
-}
--- a/mbed.bld	Tue Jun 02 03:00:32 2015 +0000
+++ b/mbed.bld	Mon May 07 07:10:08 2018 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/487b796308b0
\ No newline at end of file
+https://os.mbed.com/users/mbed_official/code/mbed/builds/5aab5a7997ee
\ No newline at end of file