diff options
author | Ryan <fauxpark@gmail.com> | 2021-11-14 05:23:14 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-13 18:23:14 +0000 |
commit | 04b51e381e2ff3f4c7aba662e1c817ce5daa931d (patch) | |
tree | 3b5c4415b94184f182d11e2629b405af9b3f0c57 /docs/uart_driver.md | |
parent | 7e86c37962935e2f791864201b684345995f0b82 (diff) | |
download | qmk_firmware-04b51e381e2ff3f4c7aba662e1c817ce5daa931d.tar.gz qmk_firmware-04b51e381e2ff3f4c7aba662e1c817ce5daa931d.zip |
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>
Diffstat (limited to 'docs/uart_driver.md')
-rw-r--r-- | docs/uart_driver.md | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/docs/uart_driver.md b/docs/uart_driver.md index 4d1716975..340b64818 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 | |||
60 | 60 | ||
61 | --- | 61 | --- |
62 | 62 | ||
63 | ### `void uart_putchar(uint8_t c)` | 63 | ### `void uart_write(uint8_t data)` |
64 | 64 | ||
65 | Transmit a single byte. | 65 | Transmit a single byte. |
66 | 66 | ||
67 | #### Arguments | 67 | #### Arguments |
68 | 68 | ||
69 | - `uint8_t c` | 69 | - `uint8_t data` |
70 | The byte (character) to send, from 0 to 255. | 70 | The byte to write. |
71 | 71 | ||
72 | --- | 72 | --- |
73 | 73 | ||
74 | ### `uint8_t uart_getchar(void)` | 74 | ### `uint8_t uart_read(void)` |
75 | 75 | ||
76 | Receive a single byte. | 76 | Receive a single byte. |
77 | 77 | ||
78 | #### Return Value | 78 | #### Return Value |
79 | 79 | ||
80 | The byte read from the receive buffer. | 80 | The byte read from the receive buffer. This function will block if the buffer is empty (ie. no data to read). |
81 | |||
82 | --- | ||
83 | |||
84 | ### `void uart_transmit(const uint8_t *data, uint16_t length)` | ||
85 | |||
86 | Transmit multiple bytes. | ||
87 | |||
88 | #### Arguments | ||
89 | |||
90 | - `const uint8_t *data` | ||
91 | A pointer to the data to write from. | ||
92 | - `uint16_t length` | ||
93 | The number of bytes to write. Take care not to overrun the length of `data`. | ||
94 | |||
95 | --- | ||
96 | |||
97 | ### `void uart_receive(char *data, uint16_t length)` | ||
98 | |||
99 | Receive multiple bytes. | ||
100 | |||
101 | #### Arguments | ||
102 | |||
103 | - `uint8_t *data` | ||
104 | A pointer to the buffer to read into. | ||
105 | - `uint16_t length` | ||
106 | The number of bytes to read. Take care not to overrun the length of `data`. | ||
81 | 107 | ||
82 | --- | 108 | --- |
83 | 109 | ||
84 | ### `bool uart_available(void)` | 110 | ### `bool uart_available(void)` |
85 | 111 | ||
86 | Return whether the receive buffer contains data. Call this function to determine if `uart_getchar()` will return meaningful data. | 112 | Return whether the receive buffer contains data. Call this function to determine if `uart_read()` will return data immediately. |
87 | 113 | ||
88 | #### Return Value | 114 | #### Return Value |
89 | 115 | ||