Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of Amaldi_2_Exercise_Keyboard_Interrupt by
Revision 2:39c2ed3c84e3, committed 2018-05-07
- Comitter:
- pinofal
- Date:
- Mon May 07 07:10:08 2018 +0000
- Parent:
- 1:5440b3d7f435
- Commit message:
- Amaldi 2 Exercise
Changed in this revision
--- /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
