Skip to content

Commit 83a31fe

Browse files
committed
merge LPTICKER fixes from official ARMmbed#8771
1 parent 6d59673 commit 83a31fe

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

targets/TARGET_STM/lp_ticker.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,10 @@ void lp_ticker_init(void)
151151
HAL_LPTIM_Counter_Start(&LptimHandle, 0xFFFF);
152152

153153
/* Need to write a compare value in order to get LPTIM_FLAG_CMPOK in set_interrupt */
154+
__HAL_LPTIM_CLEAR_FLAG(&LptimHandle, LPTIM_FLAG_CMPOK);
154155
__HAL_LPTIM_COMPARE_SET(&LptimHandle, 0);
156+
while (__HAL_LPTIM_GET_FLAG(&LptimHandle, LPTIM_FLAG_CMPOK) == RESET) {
157+
}
155158
}
156159

157160
static void LPTIM1_IRQHandler(void)
@@ -200,10 +203,8 @@ void lp_ticker_set_interrupt(timestamp_t timestamp)
200203

201204
/* CMPOK is set by hardware to inform application that the APB bus write operation to the LPTIM_CMP register has been successfully completed */
202205
/* Any successive write before the CMPOK flag be set, will lead to unpredictable results */
203-
if (__HAL_LPTIM_GET_FLAG(&LptimHandle, LPTIM_FLAG_CMPOK) == RESET) {
204-
return;
205-
}
206-
206+
/* LPTICKER_DELAY_TICKS value prevents OS to call this set interrupt function before CMPOK */
207+
MBED_ASSERT(__HAL_LPTIM_GET_FLAG(&LptimHandle, LPTIM_FLAG_CMPOK) == SET);
207208
__HAL_LPTIM_CLEAR_FLAG(&LptimHandle, LPTIM_FLAG_CMPOK);
208209
__HAL_LPTIM_COMPARE_SET(&LptimHandle, timestamp);
209210

0 commit comments

Comments
 (0)