@@ -68,9 +68,9 @@ uint8_t SetSysClock_PLL_HSI(void);
68
68
void SetSysClock (void )
69
69
{
70
70
71
- bool lowspeed = false;
71
+ bool lowspeed = false;
72
72
#if defined(LOWSPEED ) && (LOWSPEED == 1 )
73
- lowspeed = true;
73
+ lowspeed = true;
74
74
#endif
75
75
76
76
#if ((CLOCK_SOURCE ) & USE_PLL_HSE_EXTC )
@@ -95,17 +95,19 @@ void SetSysClock(void)
95
95
}
96
96
97
97
static const uint32_t _keep ;
98
- bool isBootloader () {
99
- return ((uint32_t )& _keep < 0x8040000 );
98
+ bool isBootloader ()
99
+ {
100
+ return ((uint32_t )& _keep < 0x8040000 );
100
101
}
101
102
102
- bool isBetaBoard () {
103
- uint8_t * bootloader_data = (uint8_t * )(0x801F000 );
104
- if (bootloader_data [0 ] != 0xA0 || bootloader_data [1 ] < 14 ) {
105
- return true;
106
- } else {
107
- return (bootloader_data [10 ] == 27 );
108
- }
103
+ bool isBetaBoard ()
104
+ {
105
+ uint8_t * bootloader_data = (uint8_t * )(0x801F000 );
106
+ if (bootloader_data [0 ] != 0xA0 || bootloader_data [1 ] < 14 ) {
107
+ return true;
108
+ } else {
109
+ return (bootloader_data [10 ] == 27 );
110
+ }
109
111
}
110
112
111
113
#if ( ((CLOCK_SOURCE ) & USE_PLL_HSE_XTAL ) || ((CLOCK_SOURCE ) & USE_PLL_HSE_EXTC ) )
@@ -118,14 +120,13 @@ uint8_t SetSysClock_PLL_HSE(uint8_t bypass, bool lowspeed)
118
120
RCC_OscInitTypeDef RCC_OscInitStruct = {0 };
119
121
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0 };
120
122
121
- // If we are reconfiguring the clock, select CSI as system clock source to allow modification of the PLL configuration
123
+ // If we are reconfiguring the clock, select CSI as system clock source to allow modification of the PLL configuration
122
124
if (__HAL_RCC_GET_PLL_OSCSOURCE () == RCC_PLLSOURCE_HSE ) {
123
- RCC_ClkInitStruct .ClockType = RCC_CLOCKTYPE_SYSCLK ;
124
- RCC_ClkInitStruct .SYSCLKSource = RCC_SYSCLKSOURCE_CSI ;
125
- if (HAL_RCC_ClockConfig (& RCC_ClkInitStruct , FLASH_LATENCY_1 ) != HAL_OK )
126
- {
127
- return 0 ;
128
- }
125
+ RCC_ClkInitStruct .ClockType = RCC_CLOCKTYPE_SYSCLK ;
126
+ RCC_ClkInitStruct .SYSCLKSource = RCC_SYSCLKSOURCE_CSI ;
127
+ if (HAL_RCC_ClockConfig (& RCC_ClkInitStruct , FLASH_LATENCY_1 ) != HAL_OK ) {
128
+ return 0 ;
129
+ }
129
130
}
130
131
131
132
/* Enable oscillator pin */
@@ -148,9 +149,9 @@ uint8_t SetSysClock_PLL_HSE(uint8_t bypass, bool lowspeed)
148
149
/* Configure the main internal regulator output voltage */
149
150
150
151
if (lowspeed ) {
151
- __HAL_PWR_VOLTAGESCALING_CONFIG (PWR_REGULATOR_VOLTAGE_SCALE3 );
152
+ __HAL_PWR_VOLTAGESCALING_CONFIG (PWR_REGULATOR_VOLTAGE_SCALE3 );
152
153
} else {
153
- __HAL_PWR_VOLTAGESCALING_CONFIG (PWR_REGULATOR_VOLTAGE_SCALE1 );
154
+ __HAL_PWR_VOLTAGESCALING_CONFIG (PWR_REGULATOR_VOLTAGE_SCALE1 );
154
155
}
155
156
156
157
while (!__HAL_PWR_GET_FLAG (PWR_FLAG_VOSRDY )) {}
@@ -167,17 +168,17 @@ uint8_t SetSysClock_PLL_HSE(uint8_t bypass, bool lowspeed)
167
168
RCC_OscInitStruct .PLL .PLLSource = RCC_PLLSOURCE_HSE ;
168
169
RCC_OscInitStruct .PLL .PLLM = 5 ;
169
170
if (lowspeed ) {
170
- RCC_OscInitStruct .PLL .PLLN = 40 ;
171
+ RCC_OscInitStruct .PLL .PLLN = 40 ;
171
172
} else {
172
- RCC_OscInitStruct .PLL .PLLN = 160 ;
173
+ RCC_OscInitStruct .PLL .PLLN = 160 ;
173
174
}
174
175
175
176
#if HSE_VALUE == 27000000
176
177
RCC_OscInitStruct .PLL .PLLM = 9 ;
177
178
if (lowspeed ) {
178
- RCC_OscInitStruct .PLL .PLLN = 80 ;
179
+ RCC_OscInitStruct .PLL .PLLN = 80 ;
179
180
} else {
180
- RCC_OscInitStruct .PLL .PLLN = 300 ;
181
+ RCC_OscInitStruct .PLL .PLLN = 300 ;
181
182
}
182
183
#endif
183
184
@@ -203,11 +204,13 @@ uint8_t SetSysClock_PLL_HSE(uint8_t bypass, bool lowspeed)
203
204
RCC_ClkInitStruct .APB3CLKDivider = RCC_APB3_DIV2 ;
204
205
RCC_ClkInitStruct .APB4CLKDivider = RCC_APB4_DIV2 ;
205
206
if (lowspeed ) {
206
- if (HAL_RCC_ClockConfig (& RCC_ClkInitStruct , FLASH_LATENCY_0 ) != HAL_OK )
207
- return 0 ; // FAIL
207
+ if (HAL_RCC_ClockConfig (& RCC_ClkInitStruct , FLASH_LATENCY_0 ) != HAL_OK ) {
208
+ return 0 ; // FAIL
209
+ }
208
210
} else {
209
- if (HAL_RCC_ClockConfig (& RCC_ClkInitStruct , FLASH_LATENCY_4 ) != HAL_OK )
210
- return 0 ; // FAIL
211
+ if (HAL_RCC_ClockConfig (& RCC_ClkInitStruct , FLASH_LATENCY_4 ) != HAL_OK ) {
212
+ return 0 ; // FAIL
213
+ }
211
214
}
212
215
213
216
// HAL_RCCEx_EnableBootCore(RCC_BOOT_C2);
@@ -294,13 +297,13 @@ uint8_t SetSysClock_PLL_HSI(void)
294
297
#if defined (CORE_CM4 )
295
298
void HSEM2_IRQHandler (void )
296
299
{
297
- HAL_HSEM_IRQHandler ();
300
+ HAL_HSEM_IRQHandler ();
298
301
}
299
302
#endif
300
303
301
304
#if defined (CORE_CM7 )
302
305
void HSEM1_IRQHandler (void )
303
306
{
304
- HAL_HSEM_IRQHandler ();
307
+ HAL_HSEM_IRQHandler ();
305
308
}
306
309
#endif
0 commit comments