Transmitter demo for the Manchester encoding library using UART's hardware.

Dependencies:   CRC16 ManchesterMsg ManchesterUART mbed

Example of a Manchester code transmitter using the ManchesterUART library.

Files at this revision

API Documentation at this revision

Comitter:
hudakz
Date:
Wed Oct 17 16:17:37 2018 +0000
Parent:
1:1d2b38950e98
Commit message:
Number of start patterns in preamble can be set.

Changed in this revision

ManchesterUART.lib Show annotated file Show diff for this revision Revisions of this file
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 1d2b38950e98 -r 2b031e7e30e9 ManchesterUART.lib
--- a/ManchesterUART.lib	Mon Jul 30 09:40:23 2018 +0000
+++ b/ManchesterUART.lib	Wed Oct 17 16:17:37 2018 +0000
@@ -1,1 +1,1 @@
-https://os.mbed.com/users/hudakz/code/ManchesterUART/#b869674fe56e
+https://os.mbed.com/users/hudakz/code/ManchesterUART/#8cb6a0a77e56
diff -r 1d2b38950e98 -r 2b031e7e30e9 main.cpp
--- a/main.cpp	Mon Jul 30 09:40:23 2018 +0000
+++ b/main.cpp	Wed Oct 17 16:17:37 2018 +0000
@@ -2,20 +2,29 @@
 #include "ManchesterUART.h"
 #include "CRC16.h"
 
-ManchesterUART  man(D8, D2, 115200);    // Tx pin name, Rx pin name, baudrate [bps]
-ManchesterMsg   msg(256);               // Message container (max bytes)
-CRC16           crc16;                  // CRC16 object
-DigitalOut      led(LED1);
-    
-int main(void) {
-    while(1) {
-        msg.clear();                                // Clear the message
-        msg << 0xfa74c309;                          // Add some binary data to the message
-        msg << "Hello World!";                      // Add some string data to the message
-        msg << crc16.calc(msg.data, msg.len);       // Append CRC16 to the message
-        man.transmit(msg);                          // Transmit the message
+static ManchesterUART   man(D8, D2, 115200);    // Tx pin name, Rx pin name, speed [bps]
+static ManchesterMsg    msg(256);               // Message container (max bytes)
+static CRC16            crc16;                  // CRC16 object
+static DigitalOut       led(LED1);
+
+/**
+ * @brief
+ * @note
+ * @param
+ * @retval
+ */
+int main(void)
+{
+    man.setPreamble(20);                        // Set number of start patterns
+    while (1)
+    {
+        msg.clear();                            // Clear the message
+        msg << 0xfa74c309;                      // Add some binary data to the message
+        msg << "Hello, World!";                 // Add some string to the message
+        msg << crc16.calc(msg.data, msg.len);   // Append CRC16 to the message
+        man.transmit(msg);                      // Transmit the message
+        led = !led;
         wait_ms(1000);
-        led = !led;
     }
 }
 
diff -r 1d2b38950e98 -r 2b031e7e30e9 mbed.bld
--- a/mbed.bld	Mon Jul 30 09:40:23 2018 +0000
+++ b/mbed.bld	Wed Oct 17 16:17:37 2018 +0000
@@ -1,1 +1,1 @@
-https://os.mbed.com/users/mbed_official/code/mbed/builds/a7c7b631e539
\ No newline at end of file
+https://os.mbed.com/users/mbed_official/code/mbed/builds/e95d10626187
\ No newline at end of file