Created
March 16, 2019 14:58
-
-
Save martinandrovich/905d4145b6bc4922bb729c0cb162ec86 to your computer and use it in GitHub Desktop.
Demo of UART module.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// uart.h | |
// version 1.0.1 | |
// create new UART instance with BAUDRATE 9600 | |
// currently not implemented | |
UART* uart1 = uart.new(2); | |
// construct UART frame | |
UART_FRAME frm = | |
{ | |
0, | |
0, | |
(uint8_t[14]){0}, | |
0 | |
}; | |
// construct and data array | |
uint8_t tx_array[4] = {120, 0x22, 0, 'f'}; | |
// send some data of type 'MSG' | |
uart.send(uart1, UART_MSG, tx_array, 4); | |
// infinite loop of reading from UART | |
for(;;) | |
{ | |
uart.read(uart1, &frm, true); | |
for (int i = 0; i < 1000; i++); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment