EJEMPLO 4

Dependencies:   mbed

Revision:
0:3c37e1389d2a
Child:
1:216bc483f4f3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Oct 28 02:20:28 2017 +0000
@@ -0,0 +1,36 @@
+#include "mbed.h"
+
+ 
+Serial device(USBTX, USBRX);  // tx, rx
+DigitalOut output1(LED1); // digital output 
+ 
+void Rx_interrupt();
+void send_line();
+void read_line();
+ 
+  
+// main test program
+int main() {
+   
+    device.baud(9600);
+    output1=0;
+// Setup a serial interrupt function to receive data
+    device.attach(&Rx_interrupt, Serial::RxIrq);
+    while(1) { 
+    wait_ms(2000);
+   
+    } 
+}
+ 
+ 
+// Interupt Routine to read in data from serial port
+void Rx_interrupt() {
+    output1=1;
+    device.printf("irq\n");
+    wait_ms(2000);
+    output1=1;
+    return;
+}
+ 
+ 
+ 
\ No newline at end of file