Skip to content

Commit 3361124

Browse files
ABOSTMfpistm
authored andcommitted
Enable PWR clock systematically when available
This avoid to miss it in system clock configuration, as it is not systematically done by cubeMX Signed-off-by: Alexandre Bourdiol <[email protected]>
1 parent 0cf5751 commit 3361124

File tree

4 files changed

+6
-23
lines changed

4 files changed

+6
-23
lines changed

cores/arduino/stm32/backup.h

-12
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,6 @@ static inline void resetBackupDomain(void)
7777

7878
static inline void enableBackupDomain(void)
7979
{
80-
/* Enable Power Clock */
81-
#ifdef __HAL_RCC_PWR_IS_CLK_DISABLED
82-
if (__HAL_RCC_PWR_IS_CLK_DISABLED()) {
83-
__HAL_RCC_PWR_CLK_ENABLE();
84-
}
85-
#endif
8680
#ifdef HAL_PWR_MODULE_ENABLED
8781
/* Allow access to Backup domain */
8882
HAL_PWR_EnableBkUpAccess();
@@ -110,12 +104,6 @@ static inline void disableBackupDomain(void)
110104
#ifdef __HAL_RCC_BKP_CLK_DISABLE
111105
/* Disable BKP CLK for backup registers */
112106
__HAL_RCC_BKP_CLK_DISABLE();
113-
#endif
114-
/* Disable Power Clock */
115-
#ifdef __HAL_RCC_PWR_IS_CLK_DISABLED
116-
if (!__HAL_RCC_PWR_IS_CLK_DISABLED()) {
117-
__HAL_RCC_PWR_CLK_DISABLE();
118-
}
119107
#endif
120108
}
121109

cores/arduino/stm32/usb/usbd_conf.c

+1-10
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,7 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
5353
const PinMap *map = NULL;
5454
#if defined(PWR_CR2_USV)
5555
/* Enable VDDUSB on Pwrctrl CR2 register*/
56-
#if !defined(STM32WBxx)
57-
if (__HAL_RCC_PWR_IS_CLK_DISABLED()) {
58-
__HAL_RCC_PWR_CLK_ENABLE();
59-
HAL_PWREx_EnableVddUSB();
60-
__HAL_RCC_PWR_CLK_DISABLE();
61-
} else
62-
#endif
63-
{
64-
HAL_PWREx_EnableVddUSB();
65-
}
56+
HAL_PWREx_EnableVddUSB();
6657
#endif
6758
#ifdef STM32H7xx
6859
if (!LL_PWR_IsActiveFlag_USB()) {

libraries/SrcWrapper/src/stm32/PortNames.c

-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ GPIO_TypeDef *set_GPIO_Port_Clock(uint32_t port_idx)
105105
case PortG:
106106
#if defined(STM32L4xx) && defined(PWR_CR2_IOSV)
107107
// Enable VDDIO2 supply for 14 I/Os (Port G[15:2])
108-
__HAL_RCC_PWR_CLK_ENABLE();
109108
HAL_PWREx_EnableVddIO2();
110109
#endif
111110
gpioPort = (GPIO_TypeDef *)GPIOG_BASE;

libraries/SrcWrapper/src/stm32/hw_config.c

+5
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ void hw_config_init(void)
4040

4141
configHSECapacitorTuning();
4242

43+
#if defined(__HAL_RCC_PWR_CLK_ENABLE)
44+
/* Enable PWR clock, needed for example: voltage scaling, low power ... */
45+
__HAL_RCC_PWR_CLK_ENABLE();
46+
#endif
47+
4348
/* Configure the system clock */
4449
SystemClock_Config();
4550

0 commit comments

Comments
 (0)