![](/media/cache/profiles/7c39a5f991bef4a1e34187677a65871d.jpg.50x50_q85.jpg)
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.
main.cpp
- Committer:
- hudakz
- Date:
- 2018-10-17
- Revision:
- 2:2b031e7e30e9
- Parent:
- 1:1d2b38950e98
File content as of revision 2:2b031e7e30e9:
#include "mbed.h" #include "ManchesterUART.h" #include "CRC16.h" 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); } }