[bsp][pico] Add flowcontrol and parity settings

This commit is contained in:
1ridic 2023-09-30 14:36:09 +08:00 committed by Meco Man
parent 11367953d2
commit 91f273f3c9
1 changed files with 11 additions and 3 deletions

View File

@ -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->rx_pin, GPIO_FUNC_UART);
gpio_set_function(uart->tx_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 // Set UART flow control CTS/RTS
uart_set_hw_flow(uart->instance, false, false); 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 // 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 // Turn off FIFO's - we want to do this character by character
uart_set_fifo_enabled(uart->instance, false); uart_set_fifo_enabled(uart->instance, false);