@@ -23,6 +23,8 @@ WEAK void SystemClock_Config(void)
23
23
{
24
24
RCC_OscInitTypeDef RCC_OscInitStruct = {};
25
25
RCC_ClkInitTypeDef RCC_ClkInitStruct = {};
26
+ RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {};
27
+ RCC_CRSInitTypeDef RCC_CRSInitStruct = {};
26
28
27
29
/** Supply configuration update enable
28
30
*/
@@ -71,5 +73,44 @@ WEAK void SystemClock_Config(void)
71
73
if (HAL_RCC_ClockConfig (& RCC_ClkInitStruct , FLASH_LATENCY_3 ) != HAL_OK ) {
72
74
Error_Handler ();
73
75
}
76
+
77
+ /** Initializes the peripherals clock
78
+ */
79
+ PeriphClkInitStruct .PeriphClockSelection = RCC_PERIPHCLK_SDMMC | RCC_PERIPHCLK_USB ;
80
+ PeriphClkInitStruct .PLL2 .PLL2M = 32 ;
81
+ PeriphClkInitStruct .PLL2 .PLL2N = 96 ;
82
+ PeriphClkInitStruct .PLL2 .PLL2P = 2 ;
83
+ PeriphClkInitStruct .PLL2 .PLL2Q = 2 ;
84
+ PeriphClkInitStruct .PLL2 .PLL2R = 4 ;
85
+ PeriphClkInitStruct .PLL2 .PLL2RGE = RCC_PLL2VCIRANGE_1 ;
86
+ PeriphClkInitStruct .PLL2 .PLL2VCOSEL = RCC_PLL2VCOWIDE ;
87
+ PeriphClkInitStruct .PLL2 .PLL2FRACN = 0.0 ;
88
+ PeriphClkInitStruct .SdmmcClockSelection = RCC_SDMMCCLKSOURCE_PLL2 ;
89
+ PeriphClkInitStruct .UsbClockSelection = RCC_USBCLKSOURCE_HSI48 ;
90
+ if (HAL_RCCEx_PeriphCLKConfig (& PeriphClkInitStruct ) != HAL_OK ) {
91
+ Error_Handler ();
92
+ }
93
+
94
+ /*Configure the clock recovery system (CRS)**********************************/
95
+
96
+ /*Enable CRS Clock*/
97
+ __HAL_RCC_CRS_CLK_ENABLE ();
98
+
99
+ /* Default Synchro Signal division factor (not divided) */
100
+ RCC_CRSInitStruct .Prescaler = RCC_CRS_SYNC_DIV1 ;
101
+
102
+ /* Set the SYNCSRC[1:0] bits according to CRS_Source value */
103
+ RCC_CRSInitStruct .Source = RCC_CRS_SYNC_SOURCE_USB1 ;
104
+
105
+ /* HSI48 is synchronized with USB SOF at 1KHz rate */
106
+ RCC_CRSInitStruct .ReloadValue = RCC_CRS_RELOADVALUE_DEFAULT ;
107
+ RCC_CRSInitStruct .ErrorLimitValue = RCC_CRS_ERRORLIMIT_DEFAULT ;
108
+ RCC_CRSInitStruct .Polarity = RCC_CRS_SYNC_POLARITY_RISING ;
109
+
110
+ /* Set the TRIM[5:0] to the default value */
111
+ RCC_CRSInitStruct .HSI48CalibrationValue = RCC_CRS_HSI48CALIBRATION_DEFAULT ;
112
+
113
+ /* Start automatic synchronization */
114
+ HAL_RCCEx_CRSConfig (& RCC_CRSInitStruct );
74
115
}
75
116
#endif /* ARDUINO_GENERIC_* */
0 commit comments