Skip to content

Commit a7aa076

Browse files
geekmanxobs
andauthored
Make target reset functionality work out-of-the-box (#123)
* Fix up target reset functionality. - Correct GPIO direction logic error in `probe_assert_reset` - Remember to de-assert nRESET on deinit * board_pico_config: use pin 1 for reset This pin is normally used for UART debug output, but that is undocumented. Repurpose it as reset output. Signed-off-by: Sean Cross <sean@xobs.io> * main: move stdio_uart_init() before DAP_Setup() When using GP1 as a reset line, this is necessary to overwrite the stdio function call from reusing the pin as a debug output. Signed-off-by: Sean Cross <sean@xobs.io> --------- Signed-off-by: Sean Cross <sean@xobs.io> Co-authored-by: Sean Cross <sean@xobs.io>
1 parent b09854c commit a7aa076

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

include/board_pico_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@
4949

5050
#define PROBE_PRODUCT_STRING "Debugprobe on Pico (CMSIS-DAP)"
5151

52-
#endif
52+
#endif

src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ int main(void) {
8585
usb_serial_init();
8686
cdc_uart_init();
8787
tusb_init();
88+
stdio_uart_init();
8889

8990
DAP_Setup();
90-
stdio_uart_init();
9191

9292
led_init();
9393

src/probe.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void probe_assert_reset(bool state)
7272
{
7373
#if defined(PROBE_PIN_RESET)
7474
/* Change the direction to out to drive pin to 0 or to in to emulate open drain */
75-
gpio_set_dir(PROBE_PIN_RESET, state);
75+
gpio_set_dir(PROBE_PIN_RESET, state == 0 ? GPIO_OUT : GPIO_IN);
7676
#endif
7777
}
7878

@@ -170,6 +170,9 @@ void probe_deinit(void)
170170
probe_read_mode();
171171
pio_sm_set_enabled(pio0, PROBE_SM, 0);
172172
pio_remove_program(pio0, &probe_program, probe.offset);
173+
174+
probe_assert_reset(1);// de-assert nRESET
175+
173176
probe.initted = 0;
174177
}
175178
}

0 commit comments

Comments
 (0)