~martijnbraam/pts-pico-firmware

ae1e9cdb06f42b5d23b96e3943d0e81f4abf561a — Martijn Braam 2 months ago c22c413
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.
1 files changed, 11 insertions(+), 0 deletions(-)

M src/main.c
M src/main.c => src/main.c +11 -0
@@ 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