Skip to content

Enable PWR clock systematically when available #1311

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

Merged
merged 1 commit into from
Mar 2, 2021
Merged
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
12 changes: 0 additions & 12 deletions cores/arduino/stm32/backup.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,6 @@ static inline void resetBackupDomain(void)

static inline void enableBackupDomain(void)
{
/* Enable Power Clock */
#ifdef __HAL_RCC_PWR_IS_CLK_DISABLED
if (__HAL_RCC_PWR_IS_CLK_DISABLED()) {
__HAL_RCC_PWR_CLK_ENABLE();
}
#endif
#ifdef HAL_PWR_MODULE_ENABLED
/* Allow access to Backup domain */
HAL_PWR_EnableBkUpAccess();
Expand Down Expand Up @@ -110,12 +104,6 @@ static inline void disableBackupDomain(void)
#ifdef __HAL_RCC_BKP_CLK_DISABLE
/* Disable BKP CLK for backup registers */
__HAL_RCC_BKP_CLK_DISABLE();
#endif
/* Disable Power Clock */
#ifdef __HAL_RCC_PWR_IS_CLK_DISABLED
if (!__HAL_RCC_PWR_IS_CLK_DISABLED()) {
__HAL_RCC_PWR_CLK_DISABLE();
}
#endif
}

Expand Down
11 changes: 1 addition & 10 deletions cores/arduino/stm32/usb/usbd_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,7 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
const PinMap *map = NULL;
#if defined(PWR_CR2_USV)
/* Enable VDDUSB on Pwrctrl CR2 register*/
#if !defined(STM32WBxx)
if (__HAL_RCC_PWR_IS_CLK_DISABLED()) {
__HAL_RCC_PWR_CLK_ENABLE();
HAL_PWREx_EnableVddUSB();
__HAL_RCC_PWR_CLK_DISABLE();
} else
#endif
{
HAL_PWREx_EnableVddUSB();
}
HAL_PWREx_EnableVddUSB();
#endif
#ifdef STM32H7xx
if (!LL_PWR_IsActiveFlag_USB()) {
Expand Down
1 change: 0 additions & 1 deletion libraries/SrcWrapper/src/stm32/PortNames.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ GPIO_TypeDef *set_GPIO_Port_Clock(uint32_t port_idx)
case PortG:
#if defined(STM32L4xx) && defined(PWR_CR2_IOSV)
// Enable VDDIO2 supply for 14 I/Os (Port G[15:2])
__HAL_RCC_PWR_CLK_ENABLE();
HAL_PWREx_EnableVddIO2();
#endif
gpioPort = (GPIO_TypeDef *)GPIOG_BASE;
Expand Down
5 changes: 5 additions & 0 deletions libraries/SrcWrapper/src/stm32/hw_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ void hw_config_init(void)

configHSECapacitorTuning();

#if defined(__HAL_RCC_PWR_CLK_ENABLE)
/* Enable PWR clock, needed for example: voltage scaling, low power ... */
__HAL_RCC_PWR_CLK_ENABLE();
#endif

/* Configure the system clock */
SystemClock_Config();

Expand Down