Add stdio_uart_deinit() #811

Closed
bruelltuete wants to merge 5 commits from stdio_uart_deinit into develop
bruelltuete commented 2022-05-04 19:15:22 -05:00 (Migrated from github.com)

Fixes #810 by adding stdio_uart_deinit.

I would have liked to undo the pin init from stdio_uart_init_full() as well but we dont keep track of the pins. Could probably go through all pins, check which ones have uart as function and deinit those. But is that something we want?

Fixes #810 by adding stdio_uart_deinit. I would have liked to undo the pin init from `stdio_uart_init_full()` as well but we dont keep track of the pins. Could probably go through all pins, check which ones have uart as function and deinit those. But is that something we want?
a-gavin commented 2022-05-05 17:02:17 -05:00 (Migrated from github.com)

Changing this prototype to void stdio_uart_deinit(void); should fix the build error

Changing [this prototype](https://github.com/raspberrypi/pico-sdk/blob/93472b84c6fb08c184af984f948b045e4dba9edc/src/rp2_common/pico_stdio_uart/include/pico/stdio_uart.h#L71) to `void stdio_uart_deinit(void);` should fix the build error
lurch commented 2022-05-07 04:43:35 -05:00 (Migrated from github.com)

I would have liked to undo the pin init from stdio_uart_init_full() as well but we dont keep track of the pins.

I guess that would apply if the function you were adding was named stdio_uart_deinit_full(); but given that you're adding stdio_uart_deinit(), perhaps it's safe to assume that it's the inverse of stdio_uart_init(), and therefore you could use the same logic to determine which pins are set up as TX and RX, and "deinit" those? 🤷

(and I guess if you wanted to be completionist, you could also add stdout_uart_deinit(), stdin_uart_deinit() and stdout_uart_deinit_full(int tx_pin, int rx_pin) ?)

> I would have liked to undo the pin init from `stdio_uart_init_full()` as well but we dont keep track of the pins. I guess that would apply if the function you were adding was named `stdio_uart_deinit_full()`; but given that you're adding `stdio_uart_deinit()`, perhaps it's safe to assume that it's the inverse of `stdio_uart_init()`, and therefore you could use the same [logic](https://github.com/raspberrypi/pico-sdk/blob/develop/src/rp2_common/pico_stdio_uart/stdio_uart.c#L20) to determine which pins are set up as TX and RX, and "deinit" those? :shrug: (and I guess if you wanted to be completionist, you could also add `stdout_uart_deinit()`, `stdin_uart_deinit()` and `stdout_uart_deinit_full(int tx_pin, int rx_pin)` ?)
bruelltuete (Migrated from github.com) reviewed 2022-05-10 17:37:39 -05:00
@ -84,0 +103,4 @@
gpio_deinit((uint)rx_pin);
}
}
bruelltuete (Migrated from github.com) commented 2022-05-10 17:37:39 -05:00

this needs a uart_tx_wait_blocking(uart_instance); here, otherwise we'll start loosing output (and wsl's minicom goes all wonky)

this needs a `uart_tx_wait_blocking(uart_instance);` here, otherwise we'll start loosing output (and wsl's minicom goes all wonky)
bruelltuete commented 2022-05-10 17:40:00 -05:00 (Migrated from github.com)

I would have liked to undo the pin init from stdio_uart_init_full() as well but we dont keep track of the pins.

I guess that would apply if the function you were adding was named stdio_uart_deinit_full(); but given that you're adding stdio_uart_deinit(), perhaps it's safe to assume that it's the inverse of stdio_uart_init(), and therefore you could use the same logic to determine which pins are set up as TX and RX, and "deinit" those? 🤷

Indeed!

> > I would have liked to undo the pin init from `stdio_uart_init_full()` as well but we dont keep track of the pins. > > I guess that would apply if the function you were adding was named `stdio_uart_deinit_full()`; but given that you're adding `stdio_uart_deinit()`, perhaps it's safe to assume that it's the inverse of `stdio_uart_init()`, and therefore you could use the same [logic](https://github.com/raspberrypi/pico-sdk/blob/develop/src/rp2_common/pico_stdio_uart/stdio_uart.c#L20) to determine which pins are set up as TX and RX, and "deinit" those? 🤷 Indeed!
kilograham commented 2026-04-15 11:19:24 -05:00 (Migrated from github.com)

there is a stdio_uart_deinit in SDK 2.0.0

there is a `stdio_uart_deinit` in SDK 2.0.0

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-raspberrypi/pico-sdk!811
No description provided.