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
KeyBoard-Interrupt.cpp
- Committer:
- pinofal
- Date:
- 2018-05-07
- Revision:
- 2:39c2ed3c84e3
File content as of revision 2:39c2ed3c84e3:
// 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;
}
}
