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
Failed to generate hash of commit
8 changed files with 72 additions and 25 deletions

View file

@ -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