Manchester transmitter demo.

Dependencies:   Manchester mbed CRC16 ManchesterMsg

Committer:
hudakz
Date:
Thu May 18 10:47:08 2017 +0000
Revision:
1:cc6d7d370126
Parent:
0:f58990cef4fe
Child:
2:0ab7d3335571
Updated.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hudakz 0:f58990cef4fe 1 #include "mbed.h"
hudakz 0:f58990cef4fe 2 #include "Manchester.h"
hudakz 1:cc6d7d370126 3 #include "CRC16.h"
hudakz 0:f58990cef4fe 4
hudakz 0:f58990cef4fe 5 DigitalOut led(LED1);
hudakz 1:cc6d7d370126 6 Manchester man(p11, p12, 9600); // Tx pin, Rx pin, speed [bps]
hudakz 1:cc6d7d370126 7 ManchesterMsg msg(255); // Message container (max bytes)
hudakz 1:cc6d7d370126 8 CRC16 crc16; // CRC16 object
hudakz 1:cc6d7d370126 9 unsigned short calcCRC16; // CRC16 calculated
hudakz 0:f58990cef4fe 10
hudakz 0:f58990cef4fe 11 int main(void) {
hudakz 0:f58990cef4fe 12 while(1) {
hudakz 1:cc6d7d370126 13 msg.clear(); // Clear message
hudakz 1:cc6d7d370126 14 msg << "Hello World!" << 0xfa74c309; // Add some data to message
hudakz 1:cc6d7d370126 15 calcCRC16 = crc16.calc(msg.data, msg.len); // Calculate CRC16
hudakz 1:cc6d7d370126 16 printf("calculated CRC16 = %d\r\n", calcCRC16);
hudakz 1:cc6d7d370126 17 msg << calcCRC16; // Append CRC16 to message
hudakz 1:cc6d7d370126 18 man.transmit(msg); // Transmit message
hudakz 0:f58990cef4fe 19 wait_ms(1000);
hudakz 0:f58990cef4fe 20 led = !led;
hudakz 0:f58990cef4fe 21 }
hudakz 0:f58990cef4fe 22 }
hudakz 0:f58990cef4fe 23