@@ -110,30 +110,19 @@ void SetSysClock(void)
110
110
/******************************************************************************/
111
111
/* PLL (clocked by HSE) used as System clock source */
112
112
/******************************************************************************/
113
- uint8_t SetSysClock_PLL_HSE (uint8_t bypass )
113
+ MBED_WEAK uint8_t SetSysClock_PLL_HSE (uint8_t bypass )
114
114
{
115
115
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0 };
116
116
RCC_OscInitTypeDef RCC_OscInitStruct = {0 };
117
117
RCC_PeriphCLKInitTypeDef RCC_PeriphClkInit = {0 };
118
118
119
- // Used to gain time after DeepSleep in case HSI is used
120
- if (__HAL_RCC_GET_FLAG (RCC_FLAG_HSIRDY ) != RESET ) {
121
- return 0 ;
122
- }
123
-
124
- // Select MSI as system clock source to allow modification of the PLL configuration
125
- RCC_ClkInitStruct .ClockType = RCC_CLOCKTYPE_SYSCLK ;
126
- RCC_ClkInitStruct .SYSCLKSource = RCC_SYSCLKSOURCE_MSI ;
127
- HAL_RCC_ClockConfig (& RCC_ClkInitStruct , FLASH_LATENCY_0 );
128
-
129
119
// Enable HSE oscillator and activate PLL with HSE as source
130
- RCC_OscInitStruct .OscillatorType = RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI ;
120
+ RCC_OscInitStruct .OscillatorType = RCC_OSCILLATORTYPE_HSE ;
131
121
if (bypass == 0 ) {
132
122
RCC_OscInitStruct .HSEState = RCC_HSE_ON ; // External 8 MHz xtal on OSC_IN/OSC_OUT
133
123
} else {
134
124
RCC_OscInitStruct .HSEState = RCC_HSE_BYPASS ; // External 8 MHz clock on OSC_IN
135
125
}
136
- RCC_OscInitStruct .HSIState = RCC_HSI_OFF ;
137
126
RCC_OscInitStruct .PLL .PLLSource = RCC_PLLSOURCE_HSE ; // 8 MHz
138
127
RCC_OscInitStruct .PLL .PLLState = RCC_PLL_ON ;
139
128
RCC_OscInitStruct .PLL .PLLM = 1 ; // VCO input clock = 8 MHz (8 MHz / 1)
@@ -171,12 +160,6 @@ uint8_t SetSysClock_PLL_HSE(uint8_t bypass)
171
160
}
172
161
#endif /* DEVICE_USBDEVICE */
173
162
174
- // Disable MSI Oscillator
175
- RCC_OscInitStruct .OscillatorType = RCC_OSCILLATORTYPE_MSI ;
176
- RCC_OscInitStruct .MSIState = RCC_MSI_OFF ;
177
- RCC_OscInitStruct .PLL .PLLState = RCC_PLL_NONE ; // No PLL update
178
- HAL_RCC_OscConfig (& RCC_OscInitStruct );
179
-
180
163
// Output clock on MCO1 pin(PA8) for debugging purpose
181
164
#if DEBUG_MCO == 2
182
165
if (bypass == 0 ) {
@@ -200,14 +183,8 @@ uint8_t SetSysClock_PLL_HSI(void)
200
183
RCC_OscInitTypeDef RCC_OscInitStruct = {0 };
201
184
RCC_PeriphCLKInitTypeDef RCC_PeriphClkInit = {0 };
202
185
203
- // Select MSI as system clock source to allow modification of the PLL configuration
204
- RCC_ClkInitStruct .ClockType = RCC_CLOCKTYPE_SYSCLK ;
205
- RCC_ClkInitStruct .SYSCLKSource = RCC_SYSCLKSOURCE_MSI ;
206
- HAL_RCC_ClockConfig (& RCC_ClkInitStruct , FLASH_LATENCY_0 );
207
-
208
186
// Enable HSI oscillator and activate PLL with HSI as source
209
- RCC_OscInitStruct .OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSE ;
210
- RCC_OscInitStruct .HSEState = RCC_HSE_OFF ;
187
+ RCC_OscInitStruct .OscillatorType = RCC_OSCILLATORTYPE_HSI ;
211
188
RCC_OscInitStruct .HSIState = RCC_HSI_ON ;
212
189
RCC_OscInitStruct .HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT ;
213
190
RCC_OscInitStruct .PLL .PLLState = RCC_PLL_ON ;
@@ -246,12 +223,6 @@ uint8_t SetSysClock_PLL_HSI(void)
246
223
}
247
224
#endif /* DEVICE_USBDEVICE */
248
225
249
- // Disable MSI Oscillator
250
- RCC_OscInitStruct .OscillatorType = RCC_OSCILLATORTYPE_MSI ;
251
- RCC_OscInitStruct .MSIState = RCC_MSI_OFF ;
252
- RCC_OscInitStruct .PLL .PLLState = RCC_PLL_NONE ; // No PLL update
253
- HAL_RCC_OscConfig (& RCC_OscInitStruct );
254
-
255
226
// Output clock on MCO1 pin(PA8) for debugging purpose
256
227
#if DEBUG_MCO == 3
257
228
HAL_RCC_MCOConfig (RCC_MCO1 , RCC_MCO1SOURCE_HSI , RCC_MCODIV_1 ); // 16 MHz
0 commit comments