1
0
Fork 0

Update UART driver API (#14839)

* Add uart_puts() and uart_gets()

* Add some docs

* Rework API

* Formatting

* Update docs/uart_driver.md

Co-authored-by: Sergey Vlasov <sigprof@gmail.com>

* Simplify a uart_write() loop

* Update platforms/avr/drivers/uart.c

Co-authored-by: Joel Challis <git@zvecr.com>

Co-authored-by: Sergey Vlasov <sigprof@gmail.com>
Co-authored-by: Joel Challis <git@zvecr.com>
This commit is contained in:
Ryan 2021-11-14 05:23:14 +11:00 committed by GitHub
parent 7e86c37962
commit 04b51e381e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 72 additions and 25 deletions

View file

@ -63,9 +63,7 @@ static void send_msg(uint16_t keycode, bool pressed) {
msg[IDX_PRESSED] = pressed;
msg[IDX_CHECKSUM] = chksum8(msg, UART_MSG_LEN-1);
for (int i=0; i<UART_MSG_LEN; i++) {
uart_putchar(msg[i]);
}
uart_transmit(msg, UART_MSG_LEN);
}
static void print_message_buffer(void) {
@ -103,7 +101,7 @@ static void process_uart(void) {
static void get_msg(void) {
while (uart_available()) {
msg[msg_idx] = uart_getchar();
msg[msg_idx] = uart_read();
dprintf("idx: %u, recv: %u\n", msg_idx, msg[msg_idx]);
if (msg_idx == 0 && (msg[msg_idx] != UART_PREAMBLE)) {
dprintf("Byte sync error!\n");