Skip to content

Commit fc50e28

Browse files
committed
stm32 ticker: corrections in order to pass tests
1 parent 7097e07 commit fc50e28

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

targets/TARGET_STM/hal_tick_overrides.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
2525

2626
uint32_t HAL_GetTick()
2727
{
28-
return ticker_read_us(get_us_ticker_data()) / 1000; // 1 ms tick is required for ST HAL_Delay function
28+
return 0;
2929
}
3030

3131
void HAL_SuspendTick(void)

targets/TARGET_STM/us_ticker.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
TIM_HandleTypeDef TimMasterHandle;
2222

23+
bool us_ticker_initialized = false;
24+
2325
const ticker_info_t *us_ticker_get_info()
2426
{
2527
static const ticker_info_t info = {
@@ -53,7 +55,7 @@ void timer_oc_irq_handler(void)
5355
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
5456
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
5557
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
56-
us_ticker_irq_handler();
58+
us_ticker_irq_handler();
5759
}
5860
}
5961
}
@@ -76,6 +78,11 @@ void timer_irq_handler(void)
7678

7779
void us_ticker_init(void)
7880
{
81+
if (us_ticker_initialized) {
82+
__HAL_TIM_DISABLE_IT(&TimMasterHandle, TIM_IT_CC1);
83+
__HAL_TIM_CLEAR_FLAG(&TimMasterHandle, TIM_FLAG_CC1);
84+
return;
85+
}
7986

8087
// ************************************ 16-bit timer ************************************
8188
#if TIM_MST_BIT_WIDTH == 16
@@ -195,6 +202,8 @@ void us_ticker_init(void)
195202

196203
#endif // 16-bit/32-bit timer
197204

205+
us_ticker_initialized = true;
206+
198207
}
199208

200209
uint32_t us_ticker_read()

0 commit comments

Comments
 (0)