From f9138d4b168d3d02a8af7d22ce31d227259a7f52 Mon Sep 17 00:00:00 2001 From: Jonathan Reichelt Gjertsen Date: Sun, 23 May 2021 16:17:22 +0200 Subject: [PATCH] Implement `uart_write_blocking` and `uart_read_blocking` for host --- src/host/hardware_uart/uart.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/host/hardware_uart/uart.c b/src/host/hardware_uart/uart.c index 2e5dae3f4..074919268 100644 --- a/src/host/hardware_uart/uart.c +++ b/src/host/hardware_uart/uart.c @@ -88,10 +88,18 @@ size_t uart_is_readable(uart_inst_t *uart) { } // Write len bytes directly from src to the UART -//void uart_write_blocking(uart_inst_t uart, const uint8_t *src, size_t len); +void uart_write_blocking(uart_inst_t *uart, const uint8_t *src, size_t len) { + for (size_t i = 0; i < len; i++) { + uart_putc(uart, src[i]); + } +} // Read len bytes directly from the UART to dst -//void uart_read_blocking(uart_inst_t uart, uint8_t *dst, size_t len); +void uart_read_blocking(uart_inst_t *uart, uint8_t *dst, size_t len) { + for (size_t i = 0; i < len; i++) { + dst[i] = uart_getc(uart); + } +} // ---------------------------------------------------------------------------- // UART-specific operations and aliases