@@ -68,9 +68,9 @@ uint8_t SetSysClock_PLL_HSI(void);
6868void SetSysClock (void )
6969{
7070
71- bool lowspeed = false;
71+ bool lowspeed = false;
7272#if defined(LOWSPEED ) && (LOWSPEED == 1 )
73- lowspeed = true;
73+ lowspeed = true;
7474#endif
7575
7676#if ((CLOCK_SOURCE ) & USE_PLL_HSE_EXTC )
@@ -95,17 +95,19 @@ void SetSysClock(void)
9595}
9696
9797static const uint32_t _keep ;
98- bool isBootloader () {
99- return ((uint32_t )& _keep < 0x8040000 );
98+ bool isBootloader ()
99+ {
100+ return ((uint32_t )& _keep < 0x8040000 );
100101}
101102
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+ }
109111}
110112
111113#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)
118120 RCC_OscInitTypeDef RCC_OscInitStruct = {0 };
119121 RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0 };
120122
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
122124 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+ }
129130 }
130131
131132 /* Enable oscillator pin */
@@ -148,9 +149,9 @@ uint8_t SetSysClock_PLL_HSE(uint8_t bypass, bool lowspeed)
148149 /* Configure the main internal regulator output voltage */
149150
150151 if (lowspeed ) {
151- __HAL_PWR_VOLTAGESCALING_CONFIG (PWR_REGULATOR_VOLTAGE_SCALE3 );
152+ __HAL_PWR_VOLTAGESCALING_CONFIG (PWR_REGULATOR_VOLTAGE_SCALE3 );
152153 } else {
153- __HAL_PWR_VOLTAGESCALING_CONFIG (PWR_REGULATOR_VOLTAGE_SCALE1 );
154+ __HAL_PWR_VOLTAGESCALING_CONFIG (PWR_REGULATOR_VOLTAGE_SCALE1 );
154155 }
155156
156157 while (!__HAL_PWR_GET_FLAG (PWR_FLAG_VOSRDY )) {}
@@ -167,17 +168,17 @@ uint8_t SetSysClock_PLL_HSE(uint8_t bypass, bool lowspeed)
167168 RCC_OscInitStruct .PLL .PLLSource = RCC_PLLSOURCE_HSE ;
168169 RCC_OscInitStruct .PLL .PLLM = 5 ;
169170 if (lowspeed ) {
170- RCC_OscInitStruct .PLL .PLLN = 40 ;
171+ RCC_OscInitStruct .PLL .PLLN = 40 ;
171172 } else {
172- RCC_OscInitStruct .PLL .PLLN = 160 ;
173+ RCC_OscInitStruct .PLL .PLLN = 160 ;
173174 }
174175
175176#if HSE_VALUE == 27000000
176177 RCC_OscInitStruct .PLL .PLLM = 9 ;
177178 if (lowspeed ) {
178- RCC_OscInitStruct .PLL .PLLN = 80 ;
179+ RCC_OscInitStruct .PLL .PLLN = 80 ;
179180 } else {
180- RCC_OscInitStruct .PLL .PLLN = 300 ;
181+ RCC_OscInitStruct .PLL .PLLN = 300 ;
181182 }
182183#endif
183184
@@ -203,11 +204,13 @@ uint8_t SetSysClock_PLL_HSE(uint8_t bypass, bool lowspeed)
203204 RCC_ClkInitStruct .APB3CLKDivider = RCC_APB3_DIV2 ;
204205 RCC_ClkInitStruct .APB4CLKDivider = RCC_APB4_DIV2 ;
205206 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+ }
208210 } 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+ }
211214 }
212215
213216 // HAL_RCCEx_EnableBootCore(RCC_BOOT_C2);
@@ -294,13 +297,13 @@ uint8_t SetSysClock_PLL_HSI(void)
294297#if defined (CORE_CM4 )
295298void HSEM2_IRQHandler (void )
296299{
297- HAL_HSEM_IRQHandler ();
300+ HAL_HSEM_IRQHandler ();
298301}
299302#endif
300303
301304#if defined (CORE_CM7 )
302305void HSEM1_IRQHandler (void )
303306{
304- HAL_HSEM_IRQHandler ();
307+ HAL_HSEM_IRQHandler ();
305308}
306309#endif
0 commit comments