File tree Expand file tree Collapse file tree 2 files changed +12
-11
lines changed
Expand file tree Collapse file tree 2 files changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -120,7 +120,7 @@ MP_DECLARE_CONST_FUN_OBJ_0(pyb_irq_stats_obj);
120120
121121#if __CORTEX_M == 0
122122
123- //#def IRQ_PRI_SYSTICK 0
123+ #define IRQ_PRI_SYSTICK 0
124124#define IRQ_PRI_UART 1
125125#define IRQ_PRI_SDIO 1
126126#define IRQ_PRI_DMA 1
@@ -136,7 +136,7 @@ MP_DECLARE_CONST_FUN_OBJ_0(pyb_irq_stats_obj);
136136
137137#else
138138
139- //#def IRQ_PRI_SYSTICK NVIC_EncodePriority(NVIC_PRIORITYGROUP_4, 0, 0)
139+ #define IRQ_PRI_SYSTICK NVIC_EncodePriority(NVIC_PRIORITYGROUP_4, 0, 0)
140140
141141// The UARTs have no FIFOs, so if they don't get serviced quickly then characters
142142// get dropped. The handling for each character only consumes about 0.5 usec
Original file line number Diff line number Diff line change 2727#include "py/mphal.h"
2828#include "powerctrl.h"
2929
30+ static inline void powerctrl_config_systick (void ) {
31+ // Configure SYSTICK to run at 1kHz (1ms interval)
32+ SysTick -> CTRL |= SYSTICK_CLKSOURCE_HCLK ;
33+ SysTick_Config (HAL_RCC_GetHCLKFreq () / 1000 );
34+ NVIC_SetPriority (SysTick_IRQn , IRQ_PRI_SYSTICK );
35+ }
36+
3037#if defined(STM32F0 )
3138
3239void SystemClock_Config (void ) {
@@ -88,9 +95,7 @@ void SystemClock_Config(void) {
8895 }
8996
9097 SystemCoreClockUpdate ();
91-
92- HAL_SYSTICK_Config (HAL_RCC_GetHCLKFreq () / 1000 );
93- HAL_SYSTICK_CLKSourceConfig (SYSTICK_CLKSOURCE_HCLK );
98+ powerctrl_config_systick ();
9499}
95100
96101#elif defined(STM32L0 )
@@ -122,9 +127,7 @@ void SystemClock_Config(void) {
122127 }
123128
124129 SystemCoreClockUpdate ();
125-
126- HAL_SYSTICK_Config (HAL_RCC_GetHCLKFreq () / 1000 );
127- HAL_SYSTICK_CLKSourceConfig (SYSTICK_CLKSOURCE_HCLK );
130+ powerctrl_config_systick ();
128131
129132 #if MICROPY_HW_ENABLE_RNG || MICROPY_HW_ENABLE_USB
130133 // Enable the 48MHz internal oscillator
@@ -189,9 +192,7 @@ void SystemClock_Config(void) {
189192 RCC -> CCIPR = 2 << RCC_CCIPR_CLK48SEL_Pos ;
190193
191194 SystemCoreClockUpdate ();
192-
193- HAL_SYSTICK_Config (HAL_RCC_GetHCLKFreq () / 1000 );
194- HAL_SYSTICK_CLKSourceConfig (SYSTICK_CLKSOURCE_HCLK );
195+ powerctrl_config_systick ();
195196}
196197
197198#endif
You can’t perform that action at this time.
0 commit comments