Skip to content

Commit cdec32c

Browse files
committed
STM32: lp_ticker optim: remove irq_handler variable
1 parent 638d640 commit cdec32c

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

targets/TARGET_STM/lp_ticker.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ volatile bool sleep_manager_locked = false;
7979

8080
static int LPTICKER_inited = 0;
8181
static void LPTIM1_IRQHandler(void);
82-
static void (*irq_handler)(void);
8382

8483
void lp_ticker_init(void)
8584
{
@@ -211,19 +210,15 @@ static void LPTIM1_IRQHandler(void)
211210
/* We're already in handler and interrupt might be pending,
212211
* so clear the flag, to avoid calling irq_handler twice */
213212
__HAL_LPTIM_CLEAR_FLAG(&LptimHandle, LPTIM_FLAG_CMPM);
214-
if (irq_handler) {
215-
irq_handler();
216-
}
213+
lp_ticker_irq_handler();
217214
}
218215

219216
/* Compare match interrupt */
220217
if (__HAL_LPTIM_GET_FLAG(&LptimHandle, LPTIM_FLAG_CMPM) != RESET) {
221218
if (__HAL_LPTIM_GET_IT_SOURCE(&LptimHandle, LPTIM_IT_CMPM) != RESET) {
222219
/* Clear Compare match flag */
223220
__HAL_LPTIM_CLEAR_FLAG(&LptimHandle, LPTIM_FLAG_CMPM);
224-
if (irq_handler) {
225-
irq_handler();
226-
}
221+
lp_ticker_irq_handler();
227222
}
228223
}
229224

@@ -265,7 +260,6 @@ uint32_t lp_ticker_read(void)
265260
void lp_ticker_set_interrupt(timestamp_t timestamp)
266261
{
267262
LptimHandle.Instance = LPTIM1;
268-
irq_handler = (void (*)(void))lp_ticker_irq_handler;
269263
core_util_critical_section_enter();
270264

271265
/* Always store the last requested timestamp */
@@ -330,7 +324,6 @@ void lp_ticker_fire_interrupt(void)
330324
lp_Fired = 1;
331325
/* In case we fire interrupt now, then cancel pending programing */
332326
lp_delayed_prog = false;
333-
irq_handler = (void (*)(void))lp_ticker_irq_handler;
334327
NVIC_SetPendingIRQ(LPTIM1_IRQn);
335328
NVIC_EnableIRQ(LPTIM1_IRQn);
336329
core_util_critical_section_exit();
@@ -351,8 +344,8 @@ void lp_ticker_disable_interrupt(void)
351344
sleep_manager_unlock_deep_sleep();
352345
sleep_manager_locked = false;
353346
}
354-
irq_handler = NULL;
355347
lp_delayed_prog = false;
348+
lp_Fired = 0;
356349
NVIC_DisableIRQ(LPTIM1_IRQn);
357350
NVIC_ClearPendingIRQ(LPTIM1_IRQn);
358351
LptimHandle.Instance = LPTIM1;

0 commit comments

Comments
 (0)