Transmitter demo for the Manchester encoding library using UART's hardware.

Dependencies:   CRC16 ManchesterMsg ManchesterUART mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "ManchesterUART.h"
00003 #include "CRC16.h"
00004 
00005 static ManchesterUART   man(D8, D2, 115200);    // Tx pin name, Rx pin name, speed [bps]
00006 static ManchesterMsg    msg(256);               // Message container (max bytes)
00007 static CRC16            crc16;                  // CRC16 object
00008 static DigitalOut       led(LED1);
00009 
00010 /**
00011  * @brief
00012  * @note
00013  * @param
00014  * @retval
00015  */
00016 int main(void)
00017 {
00018     man.setPreamble(20);                        // Set number of start patterns
00019     while (1)
00020     {
00021         msg.clear();                            // Clear the message
00022         msg << 0xfa74c309;                      // Add some binary data to the message
00023         msg << "Hello, World!";                 // Add some string to the message
00024         msg << crc16.calc(msg.data, msg.len);   // Append CRC16 to the message
00025         man.transmit(msg);                      // Transmit the message
00026         led = !led;
00027         wait_ms(1000);
00028     }
00029 }
00030