![](/media/cache/profiles/7c39a5f991bef4a1e34187677a65871d.jpg.50x50_q85.jpg)
Manchester transmitter demo.
Dependencies: Manchester mbed CRC16 ManchesterMsg
Diff: main.cpp
- Revision:
- 1:cc6d7d370126
- Parent:
- 0:f58990cef4fe
- Child:
- 2:0ab7d3335571
--- a/main.cpp Wed May 17 07:54:14 2017 +0000 +++ b/main.cpp Thu May 18 10:47:08 2017 +0000 @@ -1,15 +1,21 @@ #include "mbed.h" #include "Manchester.h" +#include "CRC16.h" DigitalOut led(LED1); -Manchester man(p11, p12, 9600); // Tx pin, Rx pin, speed [bps] -ManchesterMsg msg(255); // Message container (max bytes) +Manchester man(p11, p12, 9600); // Tx pin, Rx pin, speed [bps] +ManchesterMsg msg(255); // Message container (max bytes) +CRC16 crc16; // CRC16 object +unsigned short calcCRC16; // CRC16 calculated int main(void) { while(1) { - msg.clear(); // Clear message - msg << "Hello World!" << 0xfa74c309; // Add data to message - man.transmit(msg); // Transmit message + msg.clear(); // Clear message + msg << "Hello World!" << 0xfa74c309; // Add some data to message + calcCRC16 = crc16.calc(msg.data, msg.len); // Calculate CRC16 + printf("calculated CRC16 = %d\r\n", calcCRC16); + msg << calcCRC16; // Append CRC16 to message + man.transmit(msg); // Transmit message wait_ms(1000); led = !led; }