Hardware target reset support
This commit is contained in:
parent
218bd5f50a
commit
0ff8b5530b
|
@ -52,6 +52,9 @@
|
||||||
#define PROBE_PIN_SWCLK PROBE_PIN_OFFSET + 0 // 2
|
#define PROBE_PIN_SWCLK PROBE_PIN_OFFSET + 0 // 2
|
||||||
#define PROBE_PIN_SWDIO PROBE_PIN_OFFSET + 1 // 3
|
#define PROBE_PIN_SWDIO PROBE_PIN_OFFSET + 1 // 3
|
||||||
|
|
||||||
|
// Target reset config
|
||||||
|
#define PROBE_PIN_RESET 6
|
||||||
|
|
||||||
// UART config
|
// UART config
|
||||||
#define PICOPROBE_UART_TX 4
|
#define PICOPROBE_UART_TX 4
|
||||||
#define PICOPROBE_UART_RX 5
|
#define PICOPROBE_UART_RX 5
|
||||||
|
|
24
src/probe.c
24
src/probe.c
|
@ -68,11 +68,12 @@ struct _probe {
|
||||||
static struct _probe probe;
|
static struct _probe probe;
|
||||||
|
|
||||||
enum PROBE_CMDS {
|
enum PROBE_CMDS {
|
||||||
PROBE_INVALID = 0, // Invalid command
|
PROBE_INVALID = 0, // Invalid command
|
||||||
PROBE_WRITE_BITS = 1, // Host wants us to write bits
|
PROBE_WRITE_BITS = 1, // Host wants us to write bits
|
||||||
PROBE_READ_BITS = 2, // Host wants us to read bits
|
PROBE_READ_BITS = 2, // Host wants us to read bits
|
||||||
PROBE_SET_FREQ = 3, // Set TCK
|
PROBE_SET_FREQ = 3, // Set TCK
|
||||||
PROBE_RESET = 4, // Reset all state
|
PROBE_RESET = 4, // Reset all state
|
||||||
|
PROBE_TARGET_RESET = 5, // Reset target
|
||||||
};
|
};
|
||||||
|
|
||||||
struct __attribute__((__packed__)) probe_cmd_hdr {
|
struct __attribute__((__packed__)) probe_cmd_hdr {
|
||||||
|
@ -93,6 +94,12 @@ void probe_set_swclk_freq(uint freq_khz) {
|
||||||
pio_sm_set_clkdiv_int_frac(pio0, PROBE_SM, divider, 0);
|
pio_sm_set_clkdiv_int_frac(pio0, PROBE_SM, divider, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void probe_assert_reset(bool state)
|
||||||
|
{
|
||||||
|
/* Change the direction to out to drive pin to 0 or to in to emulate open drain */
|
||||||
|
gpio_set_dir(PROBE_PIN_RESET, state);
|
||||||
|
}
|
||||||
|
|
||||||
static inline void probe_write_bits(uint bit_count, uint8_t data_byte) {
|
static inline void probe_write_bits(uint bit_count, uint8_t data_byte) {
|
||||||
DEBUG_PINS_SET(probe_timing, DBG_PIN_WRITE);
|
DEBUG_PINS_SET(probe_timing, DBG_PIN_WRITE);
|
||||||
pio_sm_put_blocking(pio0, PROBE_SM, bit_count - 1);
|
pio_sm_put_blocking(pio0, PROBE_SM, bit_count - 1);
|
||||||
|
@ -137,6 +144,11 @@ void probe_init() {
|
||||||
// Make sure SWDIO has a pullup on it. Idle state is high
|
// Make sure SWDIO has a pullup on it. Idle state is high
|
||||||
gpio_pull_up(PROBE_PIN_SWDIO);
|
gpio_pull_up(PROBE_PIN_SWDIO);
|
||||||
|
|
||||||
|
// Target reset pin: pull up, input to emulate open drain pin
|
||||||
|
gpio_pull_up(PROBE_PIN_RESET);
|
||||||
|
// gpio_init will leave the pin cleared and set as input
|
||||||
|
gpio_init(PROBE_PIN_RESET);
|
||||||
|
|
||||||
uint offset = pio_add_program(pio0, &probe_program);
|
uint offset = pio_add_program(pio0, &probe_program);
|
||||||
probe.offset = offset;
|
probe.offset = offset;
|
||||||
|
|
||||||
|
@ -251,6 +263,8 @@ void probe_handle_pkt(void) {
|
||||||
// TODO: Is there anything to do after a reset?
|
// TODO: Is there anything to do after a reset?
|
||||||
// tx len and rx len should already be 0
|
// tx len and rx len should already be 0
|
||||||
;
|
;
|
||||||
|
} else if (hdr->cmd == PROBE_TARGET_RESET) {
|
||||||
|
probe_assert_reset(hdr->bits);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
probe.rx_len = 0;
|
probe.rx_len = 0;
|
||||||
|
|
Loading…
Reference in New Issue