mbed library sources. Supersedes mbed-src.
Dependents: Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more
Diff: targets/TARGET_STM/lp_ticker.c
- Revision:
- 188:bcfe06ba3d64
- Parent:
- 187:0387e8f68319
- Child:
- 189:f392fc9709a3
--- a/targets/TARGET_STM/lp_ticker.c Thu Sep 06 13:40:20 2018 +0100 +++ b/targets/TARGET_STM/lp_ticker.c Thu Nov 08 11:46:34 2018 +0000 @@ -145,9 +145,6 @@ __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 @@ 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_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 @@ { 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) @@ -229,7 +224,10 @@ NVIC_ClearPendingIRQ(LPTIM1_IRQn); } - +void lp_ticker_free(void) +{ + lp_ticker_disable_interrupt(); +} /*****************************************************************/ /* lpticker_lptim config is 0 or not defined in json config file */ @@ -260,7 +258,6 @@ void lp_ticker_set_interrupt(timestamp_t timestamp) { - lp_ticker_disable_interrupt(); rtc_set_wake_up_timer(timestamp); } @@ -276,7 +273,12 @@ void lp_ticker_clear_interrupt(void) { - NVIC_DisableIRQ(RTC_WKUP_IRQn); + lp_ticker_disable_interrupt(); +} + +void lp_ticker_free(void) +{ + lp_ticker_disable_interrupt(); } #endif /* MBED_CONF_TARGET_LPTICKER_LPTIM */