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.

Committer:
hudakz
Date:
Mon Jul 30 09:40:23 2018 +0000
Revision:
1:1d2b38950e98
Parent:
0:85e4298d91d6
Child:
2:2b031e7e30e9
Updated.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hudakz 0:85e4298d91d6 1 #include "mbed.h"
hudakz 0:85e4298d91d6 2 #include "ManchesterUART.h"
hudakz 0:85e4298d91d6 3 #include "CRC16.h"
hudakz 0:85e4298d91d6 4
hudakz 1:1d2b38950e98 5 ManchesterUART man(D8, D2, 115200); // Tx pin name, Rx pin name, baudrate [bps]
hudakz 1:1d2b38950e98 6 ManchesterMsg msg(256); // Message container (max bytes)
hudakz 0:85e4298d91d6 7 CRC16 crc16; // CRC16 object
hudakz 0:85e4298d91d6 8 DigitalOut led(LED1);
hudakz 0:85e4298d91d6 9
hudakz 0:85e4298d91d6 10 int main(void) {
hudakz 0:85e4298d91d6 11 while(1) {
hudakz 0:85e4298d91d6 12 msg.clear(); // Clear the message
hudakz 1:1d2b38950e98 13 msg << 0xfa74c309; // Add some binary data to the message
hudakz 1:1d2b38950e98 14 msg << "Hello World!"; // Add some string data to the message
hudakz 0:85e4298d91d6 15 msg << crc16.calc(msg.data, msg.len); // Append CRC16 to the message
hudakz 0:85e4298d91d6 16 man.transmit(msg); // Transmit the message
hudakz 0:85e4298d91d6 17 wait_ms(1000);
hudakz 0:85e4298d91d6 18 led = !led;
hudakz 0:85e4298d91d6 19 }
hudakz 0:85e4298d91d6 20 }
hudakz 0:85e4298d91d6 21