Manchester transmitter demo.
Dependencies: Manchester mbed CRC16 ManchesterMsg
main.cpp@3:28ae6f223bed, 2018-10-14 (annotated)
- Committer:
- hudakz
- Date:
- Sun Oct 14 09:43:23 2018 +0000
- Revision:
- 3:28ae6f223bed
- Parent:
- 2:0ab7d3335571
Number of sunc pulses in preamble can be set.
Who changed what in which revision?
User | Revision | Line number | New 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 | 0:f58990cef4fe | 9 | |
hudakz | 0:f58990cef4fe | 10 | int main(void) { |
hudakz | 3:28ae6f223bed | 11 | man.setPreamble(5); // Number of sync pulses in preamble |
hudakz | 0:f58990cef4fe | 12 | while(1) { |
hudakz | 2:0ab7d3335571 | 13 | msg.clear(); // Clear the message |
hudakz | 2:0ab7d3335571 | 14 | msg << "Hello World!" << 0xfa74c309; // Add some data to the message |
hudakz | 2:0ab7d3335571 | 15 | msg << crc16.calc(msg.data, msg.len); // Append CRC16 to the message |
hudakz | 2:0ab7d3335571 | 16 | man.transmit(msg); // Transmit the message |
hudakz | 0:f58990cef4fe | 17 | wait_ms(1000); |
hudakz | 0:f58990cef4fe | 18 | led = !led; |
hudakz | 0:f58990cef4fe | 19 | } |
hudakz | 0:f58990cef4fe | 20 | } |
hudakz | 0:f58990cef4fe | 21 |