Recepcion por Interrupcion Serial

Dependencies:   mbed

Committer:
franni
Date:
Mon May 08 22:14:54 2017 +0000
Revision:
0:6c1c7f430469
Interrupcion Serial Recepcion

Who changed what in which revision?

UserRevisionLine numberNew contents of line
franni 0:6c1c7f430469 1 #include "mbed.h"
franni 0:6c1c7f430469 2
franni 0:6c1c7f430469 3 DigitalOut led_r(LED2);
franni 0:6c1c7f430469 4 DigitalOut led_b(LED3);
franni 0:6c1c7f430469 5 DigitalOut led_g(LED1);
franni 0:6c1c7f430469 6
franni 0:6c1c7f430469 7
franni 0:6c1c7f430469 8 Serial rs232(USBTX,USBRX);
franni 0:6c1c7f430469 9
franni 0:6c1c7f430469 10 void int_rx()
franni 0:6c1c7f430469 11 {
franni 0:6c1c7f430469 12 int datoin = rs232.getc();
franni 0:6c1c7f430469 13
franni 0:6c1c7f430469 14 switch (datoin) {
franni 0:6c1c7f430469 15
franni 0:6c1c7f430469 16
franni 0:6c1c7f430469 17 case 'r':
franni 0:6c1c7f430469 18 led_r=1;
franni 0:6c1c7f430469 19 led_g=0;
franni 0:6c1c7f430469 20 led_b=0;
franni 0:6c1c7f430469 21
franni 0:6c1c7f430469 22 break;
franni 0:6c1c7f430469 23
franni 0:6c1c7f430469 24 case 'g':
franni 0:6c1c7f430469 25 led_r=0;
franni 0:6c1c7f430469 26 led_g=1;
franni 0:6c1c7f430469 27 led_b=0;
franni 0:6c1c7f430469 28
franni 0:6c1c7f430469 29 break;
franni 0:6c1c7f430469 30
franni 0:6c1c7f430469 31 case 'b':
franni 0:6c1c7f430469 32 led_r=0;
franni 0:6c1c7f430469 33 led_g=0;
franni 0:6c1c7f430469 34 led_b=1;
franni 0:6c1c7f430469 35
franni 0:6c1c7f430469 36 break;
franni 0:6c1c7f430469 37
franni 0:6c1c7f430469 38 default:
franni 0:6c1c7f430469 39
franni 0:6c1c7f430469 40 break;
franni 0:6c1c7f430469 41
franni 0:6c1c7f430469 42 }
franni 0:6c1c7f430469 43 }
franni 0:6c1c7f430469 44
franni 0:6c1c7f430469 45 int main()
franni 0:6c1c7f430469 46 {
franni 0:6c1c7f430469 47 rs232.baud(9600);
franni 0:6c1c7f430469 48 rs232.attach(&int_rx);
franni 0:6c1c7f430469 49 while(1) {}
franni 0:6c1c7f430469 50 }