stm32: Modify RCC->APB2ENR directly instead of HAL API.

Also, it is needed only when USB is enabled.

Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
This commit is contained in:
Yuuki NAGAO 2023-06-27 22:20:12 +09:00
parent 7ca3c1d892
commit a2c02014cd
1 changed files with 4 additions and 2 deletions

View File

@ -348,8 +348,6 @@ void SystemClock_Config(void) {
#elif defined(STM32L1) #elif defined(STM32L1)
void SystemClock_Config(void) { void SystemClock_Config(void) {
// Enable SYSCFG clock
__HAL_RCC_SYSCFG_CLK_ENABLE();
// Enable power control peripheral // Enable power control peripheral
__HAL_RCC_PWR_CLK_ENABLE(); __HAL_RCC_PWR_CLK_ENABLE();
@ -390,6 +388,10 @@ void SystemClock_Config(void) {
SystemCoreClockUpdate(); SystemCoreClockUpdate();
powerctrl_config_systick(); powerctrl_config_systick();
#if MICROPY_HW_ENABLE_USB
RCC->APB2ENR |= RCC_APB2ENR_SYSCFGEN;
#endif
// Disable the Debug Module in low-power mode due to prevent // Disable the Debug Module in low-power mode due to prevent
// unexpected HardFault after __WFI(). // unexpected HardFault after __WFI().
#if !defined(NDEBUG) #if !defined(NDEBUG)