STM32: full GPIO reset during mbed init

pull/13777/head
jeromecoutant 2020-10-15 15:42:01 +02:00
parent 6d89500dfe
commit 59fc99bf50
1 changed files with 69 additions and 0 deletions

View File

@ -94,6 +94,72 @@ MBED_WEAK void TargetBSP_Init(void) {
/** Do nothing */
}
void GPIO_Full_Init(void) {
GPIO_InitTypeDef GPIO_InitStruct;
GPIO_InitStruct.Pin = GPIO_PIN_All;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
#if !TARGET_STM32F1
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Alternate = 0;
#endif
#if defined(GPIOA)
__HAL_RCC_GPIOA_CLK_ENABLE();
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
__HAL_RCC_GPIOA_CLK_DISABLE();
#endif
#if defined(GPIOB)
__HAL_RCC_GPIOB_CLK_ENABLE();
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
__HAL_RCC_GPIOB_CLK_DISABLE();
#endif
#if defined(GPIOC)
__HAL_RCC_GPIOC_CLK_ENABLE();
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
__HAL_RCC_GPIOC_CLK_DISABLE();
#endif
#if defined(GPIOD)
__HAL_RCC_GPIOD_CLK_ENABLE();
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
__HAL_RCC_GPIOD_CLK_DISABLE();
#endif
#if defined(GPIOE)
__HAL_RCC_GPIOE_CLK_ENABLE();
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
__HAL_RCC_GPIOE_CLK_DISABLE();
#endif
#if defined(GPIOF)
__HAL_RCC_GPIOF_CLK_ENABLE();
HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
__HAL_RCC_GPIOF_CLK_DISABLE();
#endif
#if defined(GPIOG)
__HAL_RCC_GPIOG_CLK_ENABLE();
HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
__HAL_RCC_GPIOG_CLK_DISABLE();
#endif
#if defined(GPIOH)
__HAL_RCC_GPIOH_CLK_ENABLE();
HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);
__HAL_RCC_GPIOH_CLK_DISABLE();
#endif
#if defined(GPIOI)
__HAL_RCC_GPIOI_CLK_ENABLE();
HAL_GPIO_Init(GPIOI, &GPIO_InitStruct);
__HAL_RCC_GPIOI_CLK_DISABLE();
#endif
#if defined(GPIOJ)
__HAL_RCC_GPIOJ_CLK_ENABLE();
HAL_GPIO_Init(GPIOJ, &GPIO_InitStruct);
__HAL_RCC_GPIOJ_CLK_DISABLE();
#endif
#if defined(GPIOK)
__HAL_RCC_GPIOK_CLK_ENABLE();
HAL_GPIO_Init(GPIOK, &GPIO_InitStruct);
__HAL_RCC_GPIOK_CLK_DISABLE();
#endif
}
// This function is called after RAM initialization and before main.
void mbed_sdk_init()
@ -226,6 +292,9 @@ void mbed_sdk_init()
#endif /* ! MBED_CONF_TARGET_LSE_AVAILABLE */
#endif /* DEVICE_RTC */
/* Reset all GPIO */
GPIO_Full_Init();
/* BSP initialization hook (external RAM, etc) */
TargetBSP_Init();