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 /platforms/chibios | |
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 'platforms/chibios')
-rw-r--r-- | platforms/chibios/drivers/uart.c | 8 | ||||
-rw-r--r-- | platforms/chibios/drivers/uart.h | 8 |
2 files changed, 12 insertions, 4 deletions
diff --git a/platforms/chibios/drivers/uart.c b/platforms/chibios/drivers/uart.c index 0e8e0515a..297c1892c 100644 --- a/platforms/chibios/drivers/uart.c +++ b/platforms/chibios/drivers/uart.c | |||
@@ -39,12 +39,16 @@ void uart_init(uint32_t baud) { | |||
39 | } | 39 | } |
40 | } | 40 | } |
41 | 41 | ||
42 | void uart_putchar(uint8_t c) { sdPut(&SERIAL_DRIVER, c); } | 42 | void uart_write(uint8_t data) { sdPut(&SERIAL_DRIVER, c); } |
43 | 43 | ||
44 | uint8_t uart_getchar(void) { | 44 | uint8_t uart_read(void) { |
45 | msg_t res = sdGet(&SERIAL_DRIVER); | 45 | msg_t res = sdGet(&SERIAL_DRIVER); |
46 | 46 | ||
47 | return (uint8_t)res; | 47 | return (uint8_t)res; |
48 | } | 48 | } |
49 | 49 | ||
50 | void uart_transmit(const uint8_t *data, uint16_t length) { sdWrite(&SERIAL_DRIVER, data, length); } | ||
51 | |||
52 | void uart_receive(uint8_t *data, uint16_t length) { sdRead(&SERIAL_DRIVER, data, length); } | ||
53 | |||
50 | bool uart_available(void) { return !sdGetWouldBlock(&SERIAL_DRIVER); } | 54 | bool uart_available(void) { return !sdGetWouldBlock(&SERIAL_DRIVER); } |
diff --git a/platforms/chibios/drivers/uart.h b/platforms/chibios/drivers/uart.h index b4e20e9fd..5bc487590 100644 --- a/platforms/chibios/drivers/uart.h +++ b/platforms/chibios/drivers/uart.h | |||
@@ -70,8 +70,12 @@ | |||
70 | 70 | ||
71 | void uart_init(uint32_t baud); | 71 | void uart_init(uint32_t baud); |
72 | 72 | ||
73 | void uart_putchar(uint8_t c); | 73 | void uart_write(uint8_t data); |
74 | 74 | ||
75 | uint8_t uart_getchar(void); | 75 | uint8_t uart_read(void); |
76 | |||
77 | void uart_transmit(const uint8_t *data, uint16_t length); | ||
78 | |||
79 | void uart_receive(uint8_t *data, uint16_t length); | ||
76 | 80 | ||
77 | bool uart_available(void); | 81 | bool uart_available(void); |