USART RX Interrupt

Dependencies:   mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
thinkfire
Date:
Fri Jan 20 11:47:27 2017 +0000
Commit message:
Generating ADC value and transmitting it to USART. If USART RX interrupt occured It will echo the msg.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Jan 20 11:47:27 2017 +0000
@@ -0,0 +1,47 @@
+#include "mbed.h"
+#include "string.h"
+#include "stdio.h"
+
+DigitalOut led2(LED2);
+DigitalOut led3(LED3);
+
+Serial device(p9, p10);  // tx, rx
+char msgPC[20],msgDEV[20];
+
+void serialRXmon(){
+    char msg1[] = "Your msg-> ",msg[30];
+    msg[0] = '\0';
+    int i=0;
+     while(msgDEV[i-1]!=0x0D){
+      msgDEV[i] = device.getc();
+        i++;
+        led3 = 1;
+      }
+        msgDEV[i] = '\0';
+        strcat(msg,msg1);
+        strcat(msg,msgDEV);
+        device.puts(msg);
+        led3 = 0;
+        device.getc();
+    }
+
+int main() {
+    int adcVal;
+  device.attach(&serialRXmon);
+    while(1) {
+        
+        adcVal = rand()%255+1;
+        
+        sprintf(msgPC,"adcVal -> %d\n",adcVal);
+        
+        if(device.writeable()) {
+            device.puts(msgPC);
+        }
+        led2 = 1;
+        wait(1);
+        led2 = 0;
+        wait(1);
+}
+    
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Fri Jan 20 11:47:27 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#58563e6cba1e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Jan 20 11:47:27 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/ad3be0349dc5
\ No newline at end of file