Skip to content

Actually pull up nRESET on STM32F103 #1031

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/hic_hal/stm32/stm32f103xb/DAP_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
20 changes: 14 additions & 6 deletions source/hic_hal/stm32/stm32f103xb/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down