From ac8f3e5522cd6fb46f6c7cd052eb437c78cf17cb Mon Sep 17 00:00:00 2001 From: Rohit Grover Date: Wed, 25 Feb 2015 12:19:27 +0000 Subject: [PATCH] add a helper method: INVOKE_CALLBACK() --- .../TARGET_NORDIC/TARGET_MCU_NRF51822/us_ticker.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/us_ticker.c b/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/us_ticker.c index 49272e1ca8..b66dedd152 100644 --- a/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/us_ticker.c +++ b/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/us_ticker.c @@ -47,6 +47,12 @@ static volatile uint32_t overflowBits; /**< static volatile bool us_ticker_callbackPending = false; static uint32_t us_ticker_callbackTimestamp; +#define INVOKE_CALLBACK() { \ + us_ticker_callbackPending = false; \ + rtc1_disableCompareInterrupt(); \ + us_ticker_irq_handler(); \ + } + static __INLINE void rtc1_enableCompareInterrupt(void) { NRF_RTC1->EVTENCLR = RTC_EVTEN_COMPARE0_Msk; @@ -140,9 +146,7 @@ void RTC1_IRQHandler(void) ((int)(us_ticker_callbackTimestamp - rtc1_getCounter()) <= 0)) { NRF_RTC1->EVENTS_COMPARE[0] = 0; NRF_RTC1->EVTENCLR = RTC_EVTEN_COMPARE0_Msk; - us_ticker_callbackPending = false; - rtc1_disableCompareInterrupt(); - us_ticker_irq_handler(); + INVOKE_CALLBACK(); } } @@ -189,9 +193,7 @@ void us_ticker_set_interrupt(timestamp_t timestamp) uint32_t newCallbackTime = MICROSECONDS_TO_RTC_UNITS(timestamp); if (newCallbackTime == rtc1_getCounter()) { - us_ticker_callbackPending = false; - rtc1_disableCompareInterrupt(); - us_ticker_irq_handler(); + INVOKE_CALLBACK(); return; } if (us_ticker_callbackPending && (newCallbackTime == us_ticker_callbackTimestamp)) {