From ae1e9cdb06f42b5d23b96e3943d0e81f4abf561a Mon Sep 17 00:00:00 2001 From: Martijn Braam Date: Mon, 26 Sep 2022 19:45:43 +0200 Subject: [PATCH] Disable the UART lines while in power-down mode When the device is powered off but the UART is attached the little bit of power from the UART line can keep parts of the test device awake, making the next boot act weird. This puts the UART pins in input mode while in the poweroff state to prevent power leakage. --- src/main.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main.c b/src/main.c index dd24d33..216674d 100644 --- a/src/main.c +++ b/src/main.c @@ -39,9 +39,20 @@ handle_control_rx() switch (cmd) { case 'p': gpio_put(POWER_PIN, 0); + + // Make the uart passthrough high impedance when the device is supposed + // to be off to prevent power leaking into the test device through uart + gpio_set_dir(UART_RX_PIN, GPIO_IN); + gpio_set_dir(UART_TX_PIN, GPIO_IN); + gpio_set_function(UART_RX_PIN, GPIO_FUNC_SIO); + gpio_set_function(UART_TX_PIN, GPIO_FUNC_SIO); break; case 'P': gpio_put(POWER_PIN, 1); + + // Make sure the passthrough uart is enabled again + gpio_set_function(UART_RX_PIN, GPIO_FUNC_UART); + gpio_set_function(UART_TX_PIN, GPIO_FUNC_UART); break; case 'b': // Float the pin -- 2.45.2