diff --git a/firmware/common/cpld_jtag.c b/firmware/common/cpld_jtag.c index 478626c3..5edcc67a 100644 --- a/firmware/common/cpld_jtag.c +++ b/firmware/common/cpld_jtag.c @@ -29,37 +29,19 @@ static refill_buffer_cb refill_buffer; static uint32_t xsvf_buffer_len, xsvf_pos; static unsigned char* xsvf_buffer; -void cpld_jtag_init(jtag_t* const jtag) { - /* Initialize pin GPIOs in "released" state. */ - cpld_jtag_release(jtag); - - /* TDI and TMS pull-ups are required in all JTAG-compliant devices. - * - * The HackRF CPLD is always present, so let the CPLD pull up its TDI and TMS. - * - * The PortaPack may not be present, so pull up the PortaPack TMS pin from the - * microcontroller. - * - * TCK is recommended to be held low, so use microcontroller pull-down. - * - * TDO is undriven except when in Shift-IR or Shift-DR phases. - * Use the microcontroller to pull down to keep from floating. - * - * LPC43xx pull-up and pull-down resistors are approximately 53K. - */ -#ifdef USER_INTERFACE_PORTAPACK - scu_pinmux(SCU_PINMUX_PP_TMS, SCU_GPIO_PUP | SCU_CONF_FUNCTION0); - scu_pinmux(SCU_PINMUX_PP_TDO, SCU_GPIO_PDN | SCU_CONF_FUNCTION0); -#endif - scu_pinmux(SCU_PINMUX_CPLD_TMS, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION0); - scu_pinmux(SCU_PINMUX_CPLD_TDI, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION0); - scu_pinmux(SCU_PINMUX_CPLD_TDO, SCU_GPIO_PDN | SCU_CONF_FUNCTION4); - scu_pinmux(SCU_PINMUX_CPLD_TCK, SCU_GPIO_PDN | SCU_CONF_FUNCTION0); -} - void cpld_jtag_take(jtag_t* const jtag) { const jtag_gpio_t* const gpio = jtag->gpio; + /* Set initial GPIO state to the voltages of the internal or external pull-ups/downs, + * to avoid any glitches. + */ +#ifdef USER_INTERFACE_PORTAPACK + gpio_set(gpio->gpio_pp_tms); +#endif + gpio_set(gpio->gpio_tms); + gpio_set(gpio->gpio_tdi); + gpio_clear(gpio->gpio_tck); + #ifdef USER_INTERFACE_PORTAPACK /* Do not drive PortaPack-specific TMS pin initially, just to be cautious. */ gpio_input(gpio->gpio_pp_tms); @@ -86,16 +68,6 @@ void cpld_jtag_release(jtag_t* const jtag) { gpio_input(gpio->gpio_tdi); gpio_input(gpio->gpio_tck); gpio_input(gpio->gpio_tdo); - - /* Set initial GPIO state to the voltages of the internal or external pull-ups/downs, - * to avoid any glitches. - */ -#ifdef USER_INTERFACE_PORTAPACK - gpio_set(gpio->gpio_pp_tms); -#endif - gpio_set(gpio->gpio_tms); - gpio_set(gpio->gpio_tdi); - gpio_clear(gpio->gpio_tck); } /* return 0 if success else return error code see xsvfExecute() */ diff --git a/firmware/common/cpld_jtag.h b/firmware/common/cpld_jtag.h index 012b0516..14500824 100644 --- a/firmware/common/cpld_jtag.h +++ b/firmware/common/cpld_jtag.h @@ -43,7 +43,6 @@ typedef struct jtag_t { typedef void (*refill_buffer_cb)(void); -void cpld_jtag_init(jtag_t* const jtag); void cpld_jtag_take(jtag_t* const jtag); void cpld_jtag_release(jtag_t* const jtag); diff --git a/firmware/common/hackrf_core.c b/firmware/common/hackrf_core.c index d363b2ac..5ca74b7d 100644 --- a/firmware/common/hackrf_core.c +++ b/firmware/common/hackrf_core.c @@ -763,7 +763,28 @@ void pin_setup(void) { /* Configure all GPIO as Input (safe state) */ gpio_init(); - cpld_jtag_init(&jtag_cpld); + /* TDI and TMS pull-ups are required in all JTAG-compliant devices. + * + * The HackRF CPLD is always present, so let the CPLD pull up its TDI and TMS. + * + * The PortaPack may not be present, so pull up the PortaPack TMS pin from the + * microcontroller. + * + * TCK is recommended to be held low, so use microcontroller pull-down. + * + * TDO is undriven except when in Shift-IR or Shift-DR phases. + * Use the microcontroller to pull down to keep from floating. + * + * LPC43xx pull-up and pull-down resistors are approximately 53K. + */ +#ifdef USER_INTERFACE_PORTAPACK + scu_pinmux(SCU_PINMUX_PP_TMS, SCU_GPIO_PUP | SCU_CONF_FUNCTION0); + scu_pinmux(SCU_PINMUX_PP_TDO, SCU_GPIO_PDN | SCU_CONF_FUNCTION0); +#endif + scu_pinmux(SCU_PINMUX_CPLD_TMS, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION0); + scu_pinmux(SCU_PINMUX_CPLD_TDI, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION0); + scu_pinmux(SCU_PINMUX_CPLD_TDO, SCU_GPIO_PDN | SCU_CONF_FUNCTION4); + scu_pinmux(SCU_PINMUX_CPLD_TCK, SCU_GPIO_PDN | SCU_CONF_FUNCTION0); /* Configure SCU Pin Mux as GPIO */ scu_pinmux(SCU_PINMUX_LED1, SCU_GPIO_NOPULL);