diff --git a/source/hic_hal/stm32/stm32f103xb/DAP_config.h b/source/hic_hal/stm32/stm32f103xb/DAP_config.h index 34013e77d7..5e54ed1421 100644 --- a/source/hic_hal/stm32/stm32f103xb/DAP_config.h +++ b/source/hic_hal/stm32/stm32f103xb/DAP_config.h @@ -260,7 +260,7 @@ __STATIC_INLINE void PORT_SWD_SETUP(void) pin_in_init(SWDIO_IN_PIN_PORT, SWDIO_IN_PIN_Bit, 1); // Set RESET HIGH - pin_out_od_init(nRESET_PIN_PORT, nRESET_PIN_Bit);//TODO - fix reset logic + pin_out_od_init(nRESET_PIN_PORT, nRESET_PIN_Bit); nRESET_PIN_PORT->BSRR = nRESET_PIN; } diff --git a/source/hic_hal/stm32/stm32f103xb/gpio.c b/source/hic_hal/stm32/stm32f103xb/gpio.c index 376cf35817..3c82b4ba15 100644 --- a/source/hic_hal/stm32/stm32f103xb/gpio.c +++ b/source/hic_hal/stm32/stm32f103xb/gpio.c @@ -157,12 +157,20 @@ void gpio_init(void) GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; HAL_GPIO_Init(PIN_MSC_LED_PORT, &GPIO_InitStructure); - // reset button configured as gpio open drain output with a pullup - HAL_GPIO_WritePin(nRESET_PIN_PORT, nRESET_PIN, GPIO_PIN_SET); - GPIO_InitStructure.Pin = nRESET_PIN; - GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_OD; - GPIO_InitStructure.Pull = GPIO_PULLUP; - HAL_GPIO_Init(nRESET_PIN_PORT, &GPIO_InitStructure); + #ifdef DAPLINK_BL + // since bootloader checks nRESET_PIN for boot mode, use the pull-up resistor to avoid bootlooping + GPIO_InitStructure.Pin = nRESET_PIN; + GPIO_InitStructure.Mode = GPIO_MODE_INPUT; + GPIO_InitStructure.Pull = GPIO_PULLUP; + HAL_GPIO_Init(nRESET_PIN_PORT, &GPIO_InitStructure); + #else + // reset button configured as gpio open drain output without pullup + HAL_GPIO_WritePin(nRESET_PIN_PORT, nRESET_PIN, GPIO_PIN_SET); + GPIO_InitStructure.Pin = nRESET_PIN; + GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_OD; + GPIO_InitStructure.Pull = GPIO_PULLUP; + HAL_GPIO_Init(nRESET_PIN_PORT, &GPIO_InitStructure); + #endif // Turn on power to the board. When the target is unpowered // it holds the reset line low.