Skip to content

Commit

Permalink
Merge pull request stm32duino#2619 from ALTracer/fix/variant_WEACT_G4…
Browse files Browse the repository at this point in the history
…74CE

variant(g4): Fix clock config of WeAct STM32G474CoreBoard
  • Loading branch information
fpistm authored Jan 6, 2025
2 parents 65677a2 + b940809 commit 91b29fb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ WEAK void SystemClock_Config(void)
RCC_OscInitTypeDef RCC_OscInitStruct = {};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {};
#ifdef USBCON
RCC_CRSInitTypeDef RCC_CRSInitStruct = {};
RCC_PeriphCLKInitTypeDef PeriphClkInit = {};
#endif

Expand All @@ -111,7 +112,7 @@ WEAK void SystemClock_Config(void)
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV4;
RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV2;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLN = 85;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
Expand All @@ -133,6 +134,19 @@ WEAK void SystemClock_Config(void)
}

#ifdef USBCON
/* Enable the SYSCFG APB clock */
__HAL_RCC_CRS_CLK_ENABLE();

/* Configures CRS */
RCC_CRSInitStruct.Prescaler = RCC_CRS_SYNC_DIV1;
RCC_CRSInitStruct.Source = RCC_CRS_SYNC_SOURCE_USB;
RCC_CRSInitStruct.Polarity = RCC_CRS_SYNC_POLARITY_RISING;
RCC_CRSInitStruct.ReloadValue = __HAL_RCC_CRS_RELOADVALUE_CALCULATE(48000000, 1000);
RCC_CRSInitStruct.ErrorLimitValue = RCC_CRS_ERRORLIMIT_DEFAULT;
RCC_CRSInitStruct.HSI48CalibrationValue = RCC_CRS_HSI48CALIBRATION_DEFAULT;

HAL_RCCEx_CRSConfig(&RCC_CRSInitStruct);

/* Initializes the peripherals clocks */
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
Expand All @@ -146,4 +160,4 @@ WEAK void SystemClock_Config(void)
} // extern "C"
#endif

#endif /* ARDUINO_NUCLEO_G431RB */
#endif /* ARDUINO_WEACT_G474CE */
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@
#define HAL_QSPI_MODULE_ENABLED
#endif

#ifndef HSE_VALUE
#define HSE_VALUE 8000000U
#endif

/*----------------------------------------------------------------------------
* Arduino objects - C++ only
*----------------------------------------------------------------------------*/
Expand Down

0 comments on commit 91b29fb

Please sign in to comment.