Skip to content
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
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
Loading