Skip to content

Commit 91f273f

Browse files
1ridicmysterywolf
authored andcommitted
[bsp][pico] Add flowcontrol and parity settings
1 parent 1136795 commit 91f273f

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

bsp/raspberry-pico/drivers/drv_uart.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,19 @@ static rt_err_t pico_uart_configure(struct rt_serial_device *serial, struct seri
117117
gpio_set_function(uart->rx_pin, GPIO_FUNC_UART);
118118
gpio_set_function(uart->tx_pin, GPIO_FUNC_UART);
119119

120-
// Set UART flow control CTS/RTS, we don't want these, so turn them off
121-
uart_set_hw_flow(uart->instance, false, false);
120+
// Set UART flow control CTS/RTS
121+
if (cfg->flowcontrol == RT_SERIAL_FLOWCONTROL_CTSRTS)
122+
uart_set_hw_flow(uart->instance, true, true);
123+
else
124+
uart_set_hw_flow(uart->instance, false, false);
122125

123126
// Set our data format
124-
uart_set_format(uart->instance, cfg->data_bits, cfg->stop_bits, UART_PARITY_NONE);
127+
uart_parity_t uart_parity = UART_PARITY_NONE;
128+
if (cfg->parity == PARITY_ODD)
129+
uart_parity = UART_PARITY_ODD;
130+
else if (cfg->parity == PARITY_EVEN)
131+
uart_parity = UART_PARITY_EVEN;
132+
uart_set_format(uart->instance, cfg->data_bits, cfg->stop_bits, uart_parity);
125133

126134
// Turn off FIFO's - we want to do this character by character
127135
uart_set_fifo_enabled(uart->instance, false);

0 commit comments

Comments
 (0)