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:
Wed Nov 22 16:50:01 2017 +0000
Revision:
0:85e4298d91d6
Child:
1:1d2b38950e98
Initial release.

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 0:85e4298d91d6 5 ManchesterUART man(D8, D2, 230400); // Tx pin name, Rx pin name, speed [bps]
hudakz 0:85e4298d91d6 6 ManchesterMsg msg(255); // 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 0:85e4298d91d6 13 msg << "Hello World!" << 0xfa74c309; // Add some data to the message
hudakz 0:85e4298d91d6 14 msg << crc16.calc(msg.data, msg.len); // Append CRC16 to the message
hudakz 0:85e4298d91d6 15 man.transmit(msg); // Transmit the message
hudakz 0:85e4298d91d6 16 wait_ms(1000);
hudakz 0:85e4298d91d6 17 led = !led;
hudakz 0:85e4298d91d6 18 }
hudakz 0:85e4298d91d6 19 }
hudakz 0:85e4298d91d6 20