Avoid generating garbage input due to initialization (#1125)

First mapping the GPIO pins to the UART peripheral before enabling the UART peripheral avoids generation of garbage character on the UART's input.
This commit is contained in:
DipSwitch 2023-01-19 23:39:19 +01:00 committed by GitHub
parent 13a171a971
commit 35787255af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -70,9 +70,9 @@ void stdin_uart_init() {
void stdio_uart_init_full(struct uart_inst *uart, uint baud_rate, int tx_pin, int rx_pin) {
uart_instance = uart;
uart_init(uart_instance, baud_rate);
if (tx_pin >= 0) gpio_set_function((uint)tx_pin, GPIO_FUNC_UART);
if (rx_pin >= 0) gpio_set_function((uint)rx_pin, GPIO_FUNC_UART);
uart_init(uart_instance, baud_rate);
stdio_set_driver_enabled(&stdio_uart, true);
}