mirror of https://github.com/ARMmbed/mbed-os.git
STM32 LPTICKER with LPTIM : Fix tickless and lp wrapper
This fixes issue with mbed_hal/lp_ticker/lp_ticker_early_match_race_testpull/8341/head
parent
357e126d56
commit
3d0acbc866
|
@ -145,9 +145,6 @@ void lp_ticker_init(void)
|
||||||
|
|
||||||
__HAL_LPTIM_ENABLE_IT(&LptimHandle, LPTIM_IT_CMPM);
|
__HAL_LPTIM_ENABLE_IT(&LptimHandle, LPTIM_IT_CMPM);
|
||||||
HAL_LPTIM_Counter_Start(&LptimHandle, 0xFFFF);
|
HAL_LPTIM_Counter_Start(&LptimHandle, 0xFFFF);
|
||||||
|
|
||||||
/* Need to write a compare value in order to get LPTIM_FLAG_CMPOK in set_interrupt */
|
|
||||||
__HAL_LPTIM_COMPARE_SET(&LptimHandle, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LPTIM1_IRQHandler(void)
|
static void LPTIM1_IRQHandler(void)
|
||||||
|
@ -194,14 +191,14 @@ void lp_ticker_set_interrupt(timestamp_t timestamp)
|
||||||
LptimHandle.Instance = LPTIM1;
|
LptimHandle.Instance = LPTIM1;
|
||||||
irq_handler = (void (*)(void))lp_ticker_irq_handler;
|
irq_handler = (void (*)(void))lp_ticker_irq_handler;
|
||||||
|
|
||||||
|
__HAL_LPTIM_CLEAR_FLAG(&LptimHandle, LPTIM_FLAG_CMPOK);
|
||||||
|
__HAL_LPTIM_COMPARE_SET(&LptimHandle, timestamp);
|
||||||
/* CMPOK is set by hardware to inform application that the APB bus write operation to the LPTIM_CMP register has been successfully completed */
|
/* CMPOK is set by hardware to inform application that the APB bus write operation to the LPTIM_CMP register has been successfully completed */
|
||||||
/* Any successive write before the CMPOK flag be set, will lead to unpredictable results */
|
/* Any successive write before the CMPOK flag be set, will lead to unpredictable results */
|
||||||
while (__HAL_LPTIM_GET_FLAG(&LptimHandle, LPTIM_FLAG_CMPOK) == RESET) {
|
while (__HAL_LPTIM_GET_FLAG(&LptimHandle, LPTIM_FLAG_CMPOK) == RESET) {
|
||||||
}
|
}
|
||||||
|
|
||||||
__HAL_LPTIM_CLEAR_FLAG(&LptimHandle, LPTIM_FLAG_CMPOK);
|
lp_ticker_clear_interrupt();
|
||||||
__HAL_LPTIM_CLEAR_FLAG(&LptimHandle, LPTIM_FLAG_CMPM);
|
|
||||||
__HAL_LPTIM_COMPARE_SET(&LptimHandle, timestamp);
|
|
||||||
|
|
||||||
NVIC_EnableIRQ(LPTIM1_IRQn);
|
NVIC_EnableIRQ(LPTIM1_IRQn);
|
||||||
}
|
}
|
||||||
|
@ -209,6 +206,7 @@ void lp_ticker_set_interrupt(timestamp_t timestamp)
|
||||||
void lp_ticker_fire_interrupt(void)
|
void lp_ticker_fire_interrupt(void)
|
||||||
{
|
{
|
||||||
lp_Fired = 1;
|
lp_Fired = 1;
|
||||||
|
irq_handler = (void (*)(void))lp_ticker_irq_handler;
|
||||||
NVIC_SetPendingIRQ(LPTIM1_IRQn);
|
NVIC_SetPendingIRQ(LPTIM1_IRQn);
|
||||||
NVIC_EnableIRQ(LPTIM1_IRQn);
|
NVIC_EnableIRQ(LPTIM1_IRQn);
|
||||||
}
|
}
|
||||||
|
@ -217,9 +215,6 @@ void lp_ticker_disable_interrupt(void)
|
||||||
{
|
{
|
||||||
NVIC_DisableIRQ(LPTIM1_IRQn);
|
NVIC_DisableIRQ(LPTIM1_IRQn);
|
||||||
LptimHandle.Instance = LPTIM1;
|
LptimHandle.Instance = LPTIM1;
|
||||||
/* Waiting last write operation completion */
|
|
||||||
while (__HAL_LPTIM_GET_FLAG(&LptimHandle, LPTIM_FLAG_CMPOK) == RESET) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void lp_ticker_clear_interrupt(void)
|
void lp_ticker_clear_interrupt(void)
|
||||||
|
|
Loading…
Reference in New Issue