add a cachedInterruptTimestamp to us_ticker_set_interrupt() to short-circuit duplicate calls.

pull/467/merge
Rohit Grover 2014-08-15 13:17:00 +01:00
parent 88e2e4e369
commit 7555d7411c
1 changed files with 8 additions and 0 deletions

View File

@ -58,6 +58,8 @@ static void us_ticker_app_timer_callback(void *context)
void us_ticker_set_interrupt(unsigned int timestamp)
{
static unsigned cachedInterruptTimestamp;
if (!us_ticker_inited) {
us_ticker_init();
}
@ -67,7 +69,13 @@ void us_ticker_set_interrupt(unsigned int timestamp)
/* placeholder to do something to recover from error */
return;
}
} else {
/* we want to avoid taking action on duplicate requests */
if (timestamp == cachedInterruptTimestamp) {
return;
}
}
cachedInterruptTimestamp = timestamp;
uint32_t currentCounter;
app_timer_cnt_get(&currentCounter);