From 91f273f3c90d30c6bc8fbdb5a66b81836f790db0 Mon Sep 17 00:00:00 2001 From: 1ridic Date: Sat, 30 Sep 2023 14:36:09 +0800 Subject: [PATCH] [bsp][pico] Add flowcontrol and parity settings --- bsp/raspberry-pico/drivers/drv_uart.c | 14 +++++++++++--- 1 file 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);