Skip to content
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

Actually pull up nRESET on STM32F103 #1031

Open
wants to merge 1 commit 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
11 changes: 7 additions & 4 deletions 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_in_init(nRESET_PIN_PORT, nRESET_PIN_Bit, 1); // input with pullup
nRESET_PIN_PORT->BSRR = nRESET_PIN;
}

Expand Down Expand Up @@ -436,10 +436,13 @@ __STATIC_FORCEINLINE uint32_t PIN_nRESET_IN(void)

__STATIC_FORCEINLINE void PIN_nRESET_OUT(uint32_t bit)
{
if (bit & 1)
if (bit & 1) { // set to input pullup mode, since open-drain doesn't support pullup
pin_in_init(nRESET_PIN_PORT, nRESET_PIN_Bit, 1);
nRESET_PIN_PORT->BSRR = nRESET_PIN;
else
} else { // set to open-drain mode
pin_out_od_init(nRESET_PIN_PORT, nRESET_PIN_Bit);
nRESET_PIN_PORT->BRR = nRESET_PIN;
}
}

//**************************************************************************************************
Expand Down Expand Up @@ -536,7 +539,7 @@ __STATIC_INLINE void DAP_SETUP(void)

pin_in_init(SWDIO_IN_PIN_PORT, SWDIO_IN_PIN_Bit, 1);

pin_out_od_init(nRESET_PIN_PORT, nRESET_PIN_Bit);
pin_in_init(nRESET_PIN_PORT, nRESET_PIN_Bit, 1); // input with pullup
nRESET_PIN_PORT->BSRR = nRESET_PIN;

pin_out_init(CONNECTED_LED_PORT, CONNECTED_LED_PIN_Bit);
Expand Down
4 changes: 2 additions & 2 deletions source/hic_hal/stm32/stm32f103xb/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ 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
// reset button configured as input for pullup, since pullup is not supported with open drain
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.Mode = GPIO_MODE_INPUT;
GPIO_InitStructure.Pull = GPIO_PULLUP;
HAL_GPIO_Init(nRESET_PIN_PORT, &GPIO_InitStructure);

Expand Down