mirror of https://github.com/ARMmbed/mbed-os.git
add a helper method: INVOKE_CALLBACK()
parent
2e892c6c0d
commit
ac8f3e5522
|
@ -47,6 +47,12 @@ static volatile uint32_t overflowBits; /**<
|
||||||
static volatile bool us_ticker_callbackPending = false;
|
static volatile bool us_ticker_callbackPending = false;
|
||||||
static uint32_t us_ticker_callbackTimestamp;
|
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)
|
static __INLINE void rtc1_enableCompareInterrupt(void)
|
||||||
{
|
{
|
||||||
NRF_RTC1->EVTENCLR = RTC_EVTEN_COMPARE0_Msk;
|
NRF_RTC1->EVTENCLR = RTC_EVTEN_COMPARE0_Msk;
|
||||||
|
@ -140,9 +146,7 @@ void RTC1_IRQHandler(void)
|
||||||
((int)(us_ticker_callbackTimestamp - rtc1_getCounter()) <= 0)) {
|
((int)(us_ticker_callbackTimestamp - rtc1_getCounter()) <= 0)) {
|
||||||
NRF_RTC1->EVENTS_COMPARE[0] = 0;
|
NRF_RTC1->EVENTS_COMPARE[0] = 0;
|
||||||
NRF_RTC1->EVTENCLR = RTC_EVTEN_COMPARE0_Msk;
|
NRF_RTC1->EVTENCLR = RTC_EVTEN_COMPARE0_Msk;
|
||||||
us_ticker_callbackPending = false;
|
INVOKE_CALLBACK();
|
||||||
rtc1_disableCompareInterrupt();
|
|
||||||
us_ticker_irq_handler();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,9 +193,7 @@ void us_ticker_set_interrupt(timestamp_t timestamp)
|
||||||
|
|
||||||
uint32_t newCallbackTime = MICROSECONDS_TO_RTC_UNITS(timestamp);
|
uint32_t newCallbackTime = MICROSECONDS_TO_RTC_UNITS(timestamp);
|
||||||
if (newCallbackTime == rtc1_getCounter()) {
|
if (newCallbackTime == rtc1_getCounter()) {
|
||||||
us_ticker_callbackPending = false;
|
INVOKE_CALLBACK();
|
||||||
rtc1_disableCompareInterrupt();
|
|
||||||
us_ticker_irq_handler();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (us_ticker_callbackPending && (newCallbackTime == us_ticker_callbackTimestamp)) {
|
if (us_ticker_callbackPending && (newCallbackTime == us_ticker_callbackTimestamp)) {
|
||||||
|
|
Loading…
Reference in New Issue