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>
diff --git a/include/board_pico_config.h b/include/board_pico_config.h
index 1f96d36..d695dc6 100644
--- a/include/board_pico_config.h
+++ b/include/board_pico_config.h
@@ -49,4 +49,4 @@
 
 #define PROBE_PRODUCT_STRING "Debugprobe on Pico (CMSIS-DAP)"
 
-#endif
\ No newline at end of file
+#endif
diff --git a/src/main.c b/src/main.c
index 0886b6d..3f4804e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -85,9 +85,9 @@
     usb_serial_init();
     cdc_uart_init();
     tusb_init();
+    stdio_uart_init();
 
     DAP_Setup();
-    stdio_uart_init();
 
     led_init();
 
diff --git a/src/probe.c b/src/probe.c
index ff2239c..a6ef404 100644
--- a/src/probe.c
+++ b/src/probe.c
@@ -72,7 +72,7 @@
 {
 #if defined(PROBE_PIN_RESET)
     /* Change the direction to out to drive pin to 0 or to in to emulate open drain */
-    gpio_set_dir(PROBE_PIN_RESET, state);
+    gpio_set_dir(PROBE_PIN_RESET, state == 0 ? GPIO_OUT : GPIO_IN);
 #endif
 }
 
@@ -170,6 +170,9 @@
     probe_read_mode();
     pio_sm_set_enabled(pio0, PROBE_SM, 0);
     pio_remove_program(pio0, &probe_program, probe.offset);
+
+    probe_assert_reset(1);	// de-assert nRESET
+
     probe.initted = 0;
   }
 }