From 04b51e381e2ff3f4c7aba662e1c817ce5daa931d Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 14 Nov 2021 05:23:14 +1100 Subject: 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 * Simplify a uart_write() loop * Update platforms/avr/drivers/uart.c Co-authored-by: Joel Challis Co-authored-by: Sergey Vlasov Co-authored-by: Joel Challis --- docs/uart_driver.md | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) (limited to 'docs/uart_driver.md') diff --git a/docs/uart_driver.md b/docs/uart_driver.md index 4d1716975f..340b648189 100644 --- a/docs/uart_driver.md +++ b/docs/uart_driver.md @@ -60,30 +60,56 @@ Initialize the UART driver. This function must be called only once, before any o --- -### `void uart_putchar(uint8_t c)` +### `void uart_write(uint8_t data)` Transmit a single byte. #### Arguments - - `uint8_t c` - The byte (character) to send, from 0 to 255. + - `uint8_t data` + The byte to write. --- -### `uint8_t uart_getchar(void)` +### `uint8_t uart_read(void)` Receive a single byte. #### Return Value -The byte read from the receive buffer. +The byte read from the receive buffer. This function will block if the buffer is empty (ie. no data to read). + +--- + +### `void uart_transmit(const uint8_t *data, uint16_t length)` + +Transmit multiple bytes. + +#### Arguments + + - `const uint8_t *data` + A pointer to the data to write from. + - `uint16_t length` + The number of bytes to write. Take care not to overrun the length of `data`. + +--- + +### `void uart_receive(char *data, uint16_t length)` + +Receive multiple bytes. + +#### Arguments + + - `uint8_t *data` + A pointer to the buffer to read into. + - `uint16_t length` + The number of bytes to read. Take care not to overrun the length of `data`. --- ### `bool uart_available(void)` -Return whether the receive buffer contains data. Call this function to determine if `uart_getchar()` will return meaningful data. +Return whether the receive buffer contains data. Call this function to determine if `uart_read()` will return data immediately. #### Return Value -- cgit v1.2.3