Device sends a byte Coordinator reads a byte uart communication

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
giuseppe_guida
Date:
Tue May 28 13:23:33 2019 +0000
Commit message:
device sends coordinator receives a byte via uart

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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue May 28 13:23:33 2019 +0000
@@ -0,0 +1,30 @@
+#include "mbed.h"
+//#define DEVICE
+#define COORDINATOR
+
+#ifdef COORDINATOR
+Serial pc(USBTX, USBRX);
+#endif
+
+RawSerial uart(PB_6,PB_7,9600);
+int msg;
+
+int main()
+{
+    #ifdef DEVICE
+    int msg = 0x0F;
+    while(1) {
+        uart.putc(msg);
+    }
+    #endif
+    
+    #ifdef COORDINATOR
+    while(1) {
+        msg = uart.getc();
+        wait(0.1);
+        pc.printf("Messaggio letto: %d\n\r",msg);
+    }
+    #endif
+   
+   
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue May 28 13:23:33 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file