SerialRxInterrupt

Dependencies:   mbed

Fork of SerialReceiveInterrupt by Doug Wendelboe

Files at this revision

API Documentation at this revision

Comitter:
thinkfire
Date:
Fri Jan 20 11:49:15 2017 +0000
Parent:
0:444ff736d35e
Commit message:
tested

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 444ff736d35e -r 6fb6fabd8592 main.cpp
--- a/main.cpp	Thu May 26 19:50:24 2011 +0000
+++ b/main.cpp	Fri Jan 20 11:49:15 2017 +0000
@@ -21,48 +21,37 @@
 unsigned char inIdx;                // Read by background, written by Int Handler.
 unsigned char outIdx;               // Read by Int Handler, written by Background.
 
-DigitalOut myled(LED1);
-Serial pc (USBTX,USBRX);
+DigitalOut led4(LED4);
+Serial usbS(USBTX,USBRX);
+Serial pins(p9,p10);
 
 //*****************************************************************************
 // mc serial receive interrupt handler
 //***************************************************************************** 
-
-void SerialRecvInterrupt (void)
-{
-    unsigned char c;
-     
-    c = pc.getc();                // On receive interrupt, get the character.
-    
-    while (!pc.writeable()){};    // Wait until xmit buffer is empty.
-    pc.putc(c);                   // Echo char back out the serial port.
-     
-    while (!pc.writeable()){};    // Make sure transmit buffer is empty.
-    pc.putc(toupper(c));          // Echo the uppercase value of input char.
+void rx_interrupt(void) {
+    char c;
+    led4 = 1;
+    usbS.printf("Ack Recieved from Module\n");
+    c=pins.getc();
+    c=pins.getc();
 }
-
 //*****************************************************************************
 // Main Program
 //*****************************************************************************
 
 int main() {
-    int i;
+    int adc_val = rand()%100+1;
+    char msg[30];
     
-    for (i=0; i<BFR_SIZE; i++) {  // Clear buffer if you have OCD. 
-        rcvBuffer[i] = 0; 
-    }
-
-    inIdx  = 0;                   // Initialize bfr input and output pointers. 
-    outIdx = 0;  
+    usbS.printf("Msg Send to Module\n");
+    pins.attach(&rx_interrupt,pins.RxIrq);
     
-    pc.baud(38400);                                // USART to PC USB USART.
-    pc.attach (&SerialRecvInterrupt, pc.RxIrq);    // Recv interrupt handler
-    pc.printf ("Serial interrupt demo\n");          
-
+     
     while(1) {
-        myled = 1;
-        wait(0.2);
-        myled = 0;
-        wait(0.2);
+        sprintf(msg,"Adc_val %d\n",adc_val);
+        while(!pins.writeable());
+        pins.puts(msg);
+        wait(2);
+        led4 = 0;
     }
 }
diff -r 444ff736d35e -r 6fb6fabd8592 mbed.bld
--- a/mbed.bld	Thu May 26 19:50:24 2011 +0000
+++ b/mbed.bld	Fri Jan 20 11:49:15 2017 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/63bcd7ba4912
+http://mbed.org/users/mbed_official/code/mbed/builds/ad3be0349dc5
\ No newline at end of file