Skip to content

Commit de6016c

Browse files
authored
STM: init timer once
1 parent c657a66 commit de6016c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

targets/TARGET_STM/hal_tick_overrides.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ extern int mbed_sdk_inited;
2828
void init_16bit_timer(void);
2929
void init_32bit_timer(void);
3030

31+
static bool initialized;
32+
3133
#if TIM_MST_BIT_WIDTH <= 16
3234
static uint16_t prev_time;
3335
#else
@@ -40,11 +42,15 @@ static uint16_t prev_tick_remainder;
4042

4143
HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
4244
{
45+
if (initialized) {
46+
return HAL_OK;
47+
}
4348
#if TIM_MST_BIT_WIDTH == 16
4449
init_16bit_timer();
4550
#else
4651
init_32bit_timer();
4752
#endif
53+
initialized = true;
4854
return HAL_OK;
4955
}
5056

0 commit comments

Comments
 (0)