STM32 LPTICKER with LPTIM : Fix tickless and lp wrapper

This fixes issue with mbed_hal/lp_ticker/lp_ticker_early_match_race_test
pull/8242/head
jeromecoutant 2018-09-19 14:17:30 +02:00
parent 45f59f88c3
commit b1d23e5ec5
1 changed files with 4 additions and 9 deletions

View File

@ -145,9 +145,6 @@ void lp_ticker_init(void)
__HAL_LPTIM_ENABLE_IT(&LptimHandle, LPTIM_IT_CMPM);
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)
@ -194,14 +191,14 @@ void lp_ticker_set_interrupt(timestamp_t timestamp)
LptimHandle.Instance = LPTIM1;
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 */
/* Any successive write before the CMPOK flag be set, will lead to unpredictable results */
while (__HAL_LPTIM_GET_FLAG(&LptimHandle, LPTIM_FLAG_CMPOK) == RESET) {
}
__HAL_LPTIM_CLEAR_FLAG(&LptimHandle, LPTIM_FLAG_CMPOK);
__HAL_LPTIM_CLEAR_FLAG(&LptimHandle, LPTIM_FLAG_CMPM);
__HAL_LPTIM_COMPARE_SET(&LptimHandle, timestamp);
lp_ticker_clear_interrupt();
NVIC_EnableIRQ(LPTIM1_IRQn);
}
@ -209,6 +206,7 @@ void lp_ticker_set_interrupt(timestamp_t timestamp)
void lp_ticker_fire_interrupt(void)
{
lp_Fired = 1;
irq_handler = (void (*)(void))lp_ticker_irq_handler;
NVIC_SetPendingIRQ(LPTIM1_IRQn);
NVIC_EnableIRQ(LPTIM1_IRQn);
}
@ -217,9 +215,6 @@ void lp_ticker_disable_interrupt(void)
{
NVIC_DisableIRQ(LPTIM1_IRQn);
LptimHandle.Instance = LPTIM1;
/* Waiting last write operation completion */
while (__HAL_LPTIM_GET_FLAG(&LptimHandle, LPTIM_FLAG_CMPOK) == RESET) {
}
}
void lp_ticker_clear_interrupt(void)