@@ -96,28 +96,14 @@ uint8_t SetSysClock_PLL_HSE(uint8_t bypass)
96
96
RCC_OscInitTypeDef RCC_OscInitStruct = {0 };
97
97
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0 };
98
98
99
- __HAL_RCC_SYSCFG_CLK_ENABLE (); // Mandatory for I/O Compensation Cell
100
- MODIFY_REG (PWR -> CR3 , PWR_CR3_SCUEN , 0 );
101
-
102
-
103
- /*!< Supply configuration update enable */
104
- // HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY);
105
- /* The voltage scaling allows optimizing the power consumption when the device is
106
- clocked below the maximum system frequency, to update the voltage scaling value
107
- regarding system frequency refer to product datasheet. */
99
+ /* Supply configuration update enable */
100
+ HAL_PWREx_ConfigSupply (PWR_LDO_SUPPLY );
101
+ /* Configure the main internal regulator output voltage */
108
102
__HAL_PWR_VOLTAGESCALING_CONFIG (PWR_REGULATOR_VOLTAGE_SCALE1 );
109
- while (!__HAL_PWR_GET_FLAG (PWR_FLAG_VOSRDY )) {}
110
103
111
- // NEEDED ???
112
- /* Select CSI as system clock source to allow modification of the PLL configuration */
113
- //RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK;
114
- //RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_CSI;
115
- //if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) {
116
- // return 0; // FAIL
117
- //}
104
+ while (!__HAL_PWR_GET_FLAG (PWR_FLAG_VOSRDY )) {}
118
105
119
106
/* Enable HSE Oscillator and activate PLL with HSE as source */
120
- //RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI48;
121
107
RCC_OscInitStruct .OscillatorType = RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI48 ;
122
108
if (bypass ) {
123
109
RCC_OscInitStruct .HSEState = RCC_HSE_BYPASS ;
@@ -161,19 +147,6 @@ uint8_t SetSysClock_PLL_HSE(uint8_t bypass)
161
147
return 0 ; // FAIL
162
148
}
163
149
164
- /* Disable CSI Oscillator */
165
- //RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_CSI;
166
- //RCC_OscInitStruct.CSIState = RCC_CSI_OFF;
167
- //RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
168
- //if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
169
- // return 0;
170
- //}
171
-
172
- // NEEDED ???
173
- /* Enables the I/O Compensation Cell */
174
- // __HAL_RCC_CSI_ENABLE(); // Mandatory for I/O Compensation Cell
175
- // HAL_EnableCompensationCell();
176
-
177
150
return 1 ; // OK
178
151
}
179
152
#endif /* ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) || ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) */
0 commit comments