Mateo Morales / Mbed 2 deprecated Interrupcion_Serial

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 Serial device(USBTX, USBRX);
00004 DigitalOut led(LED1);
00005 
00006 void Rx_interrupt();
00007 double delay=1;
00008 int main()
00009 {
00010     device.baud(9600);
00011     device.attach(&Rx_interrupt, Serial::RxIrq);
00012     while (1) {
00013         led = !led;
00014         wait(delay);
00015     }
00016 }
00017 
00018 
00019 void Rx_interrupt() {
00020     led=!led;
00021     delay = delay / 2;   
00022     char d = device.getc();
00023     device.printf("numero %d\n",d);
00024     return; 
00025 }
00026