summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author1ridic <[email protected]>2023-09-30 14:36:09 +0800
committerMeco Man <[email protected]>2023-10-04 11:12:19 -0400
commit91f273f3c90d30c6bc8fbdb5a66b81836f790db0 (patch)
tree79efb4a8e746a0f7862d50e0eeeebd44c2ef001c
parent11367953d2de3568c25875040f58fcc0cc182131 (diff)
[bsp][pico] Add flowcontrol and parity settings
-rw-r--r--bsp/raspberry-pico/drivers/drv_uart.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/bsp/raspberry-pico/drivers/drv_uart.c b/bsp/raspberry-pico/drivers/drv_uart.c
index 64f572b883..9d51dc05c2 100644
--- a/bsp/raspberry-pico/drivers/drv_uart.c
+++ b/bsp/raspberry-pico/drivers/drv_uart.c
@@ -117,11 +117,19 @@ static rt_err_t pico_uart_configure(struct rt_serial_device *serial, struct seri
gpio_set_function(uart->rx_pin, GPIO_FUNC_UART);
gpio_set_function(uart->tx_pin, GPIO_FUNC_UART);
- // Set UART flow control CTS/RTS, we don't want these, so turn them off
- uart_set_hw_flow(uart->instance, false, false);
+ // Set UART flow control CTS/RTS
+ if (cfg->flowcontrol == RT_SERIAL_FLOWCONTROL_CTSRTS)
+ uart_set_hw_flow(uart->instance, true, true);
+ else
+ uart_set_hw_flow(uart->instance, false, false);
// Set our data format
- uart_set_format(uart->instance, cfg->data_bits, cfg->stop_bits, UART_PARITY_NONE);
+ uart_parity_t uart_parity = UART_PARITY_NONE;
+ if (cfg->parity == PARITY_ODD)
+ uart_parity = UART_PARITY_ODD;
+ else if (cfg->parity == PARITY_EVEN)
+ uart_parity = UART_PARITY_EVEN;
+ uart_set_format(uart->instance, cfg->data_bits, cfg->stop_bits, uart_parity);
// Turn off FIFO's - we want to do this character by character
uart_set_fifo_enabled(uart->instance, false);