application: improve JTAG clock rising edge

This commit is contained in:
King Kévin 2021-03-22 18:49:10 +01:00
parent 1b7ffaf432
commit e37dfe81eb
1 changed files with 5 additions and 0 deletions

View File

@ -411,7 +411,9 @@ static void jtag_transaction(uint32_t tms, uint32_t tdi, uint8_t nb)
}
gpio_clear(channel_ports[jtag_tck_ch], channel_pins[jtag_tck_ch]); // clock falling edge
sleep_us(JTAG_SPEED); // wait for clock rising edge
gpio_set_output_options(channel_ports[jtag_tck_ch], GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, channel_pins[jtag_tck_ch]); // set clock as push pull for a fast rising edge
gpio_set(channel_ports[jtag_tck_ch], channel_pins[jtag_tck_ch]); // clock rising edge
gpio_set_output_options(channel_ports[jtag_tck_ch], GPIO_OTYPE_OD, GPIO_OSPEED_50MHZ, channel_pins[jtag_tck_ch]); // set clock back to open drain
for (uint8_t tdo = channel_start; tdo < channel_stop && tdo < CHANNEL_NUMBERS; tdo++) { // read TDO
if (tdo == jtag_tms_ch || tdo == jtag_tck_ch || tdo == jtag_tdi_ch) { // channel is already used
continue; // ignore output signal
@ -550,12 +552,15 @@ static void command_jtag_scan(void* argument)
}
bool tdi_found = false; // if we found a TDI pin in this combination
gpio_set(channel_ports[tck], channel_pins[tck]); // clock is idle high
gpio_set_output_options(channel_ports[tck], GPIO_OTYPE_OD, GPIO_OSPEED_50MHZ, channel_pins[tck]); // set clock as output open-drain, with hard edge
gpio_mode_setup(channel_ports[tck], GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, channel_pins[tck]); // set channel for TCK as output
jtag_tck_ch = tck; // remember which channel we use for TCK for the transaction
gpio_set(channel_ports[tms], channel_pins[tms]); // start high (to go to reset state)
gpio_set_output_options(channel_ports[tms], GPIO_OTYPE_OD, GPIO_OSPEED_2MHZ, channel_pins[tms]); // set mode select as output open-drain (no need to hard edge)
gpio_mode_setup(channel_ports[tms], GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, channel_pins[tms]); // set channel for TMS as output
jtag_tms_ch = tms; // remember which channel we use for TMS for the transaction
gpio_set(channel_ports[tdi], channel_pins[tdi]); // start high (idle state)
gpio_set_output_options(channel_ports[tdi], GPIO_OTYPE_OD, GPIO_OSPEED_2MHZ, channel_pins[tdi]); // set mode select as output open-drain (no need to hard edge)
gpio_mode_setup(channel_ports[tdi], GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, channel_pins[tdi]); // set channel for TMS back to input
jtag_tdi_ch = tdi; // remember which channel we use for TDI for the transaction
// all other channels are already inputs (to check TDO)