Manchester receiver demo.

Dependencies:   Manchester mbed CRC16 ManchesterMsg

Revision:
0:91017f5f5cb3
Child:
1:2ce05484e526
diff -r 000000000000 -r 91017f5f5cb3 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed May 17 07:59:46 2017 +0000
@@ -0,0 +1,32 @@
+#include "mbed.h"
+#include "Manchester.h"
+
+DigitalOut      led(LED1);
+Manchester      man(p11, p12, 9600);    // Tx pin, Rx pin, speed [bps]
+ManchesterMsg   msg(255);               // Message container (max bytes)
+char            str[255];               // Array of char
+uint32_t        val;
+
+int main(void) {
+
+    while(1) {
+        if(man.receive(msg)) {      // Receive message
+            // Print data length and raw data
+            printf("\r\n----------------------\r\n");
+            printf("len = %d\r\n", msg.len);
+            printf("raw data :\r\n");
+            for(int i = 0; i < msg.len; i++)
+                printf("\t0x%.2x\r\n", msg.data[i]);
+                
+            // Extract data from message and print
+            msg >> str >> val;
+            printf("data :\r\n");
+            printf("\tstr = %s\r\n", str);
+            printf("\tval = 0x%x\r\n", val);
+        }
+        else
+            printf("Error\r\n");
+
+        led = !led;
+    }
+}