drivers/timer/nrf_rtc_timer: clarify intent of ZLI compensation
The variable enabling entry to the zero latency interrupt compensation loop was named generically, and its logic inverted, making the code difficult to understand. Change the name and initial value to more clearly indicate its role. Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
parent
4a470114fa
commit
d28e65a784
1 changed files with 13 additions and 11 deletions
|
@ -119,7 +119,7 @@ void z_clock_set_timeout(s32_t ticks, bool idle)
|
||||||
|
|
||||||
k_spinlock_key_t key = k_spin_lock(&lock);
|
k_spinlock_key_t key = k_spin_lock(&lock);
|
||||||
u32_t cyc, dt, t = counter();
|
u32_t cyc, dt, t = counter();
|
||||||
bool flagged = false;
|
bool zli_fixup = IS_ENABLED(CONFIG_ZERO_LATENCY_IRQS);
|
||||||
|
|
||||||
/* Round up to next tick boundary */
|
/* Round up to next tick boundary */
|
||||||
cyc = ticks * CYC_PER_TICK + 1 + counter_sub(t, last_count);
|
cyc = ticks * CYC_PER_TICK + 1 + counter_sub(t, last_count);
|
||||||
|
@ -162,7 +162,7 @@ void z_clock_set_timeout(s32_t ticks, bool idle)
|
||||||
/* Missed it! */
|
/* Missed it! */
|
||||||
NVIC_SetPendingIRQ(RTC1_IRQn);
|
NVIC_SetPendingIRQ(RTC1_IRQn);
|
||||||
if (IS_ENABLED(CONFIG_ZERO_LATENCY_IRQS)) {
|
if (IS_ENABLED(CONFIG_ZERO_LATENCY_IRQS)) {
|
||||||
flagged = true;
|
zli_fixup = false;
|
||||||
}
|
}
|
||||||
} else if (dt == 1) {
|
} else if (dt == 1) {
|
||||||
/* Too soon, interrupt won't arrive. */
|
/* Too soon, interrupt won't arrive. */
|
||||||
|
@ -173,16 +173,18 @@ void z_clock_set_timeout(s32_t ticks, bool idle)
|
||||||
|
|
||||||
#ifdef CONFIG_ZERO_LATENCY_IRQS
|
#ifdef CONFIG_ZERO_LATENCY_IRQS
|
||||||
/* Failsafe. ZLIs can preempt us even though interrupts are
|
/* Failsafe. ZLIs can preempt us even though interrupts are
|
||||||
* masked, blowing up the sensitive timing above. If enabled,
|
* masked, blowing up the sensitive timing above. If the
|
||||||
* we need a final check (in a loop! because this too can be
|
* feature is enabled and we haven't recorded the presence of
|
||||||
* interrupted) to see that the comparator is still in the
|
* a pending interrupt then we need a final check (in a loop!
|
||||||
* future. Don't bother being fancy with cycle counting here,
|
* because this too can be interrupted) to confirm that the
|
||||||
* just set an interrupt "soon" that we know will get the
|
* comparator is still in the future. Don't bother being
|
||||||
* timer back to a known state. This handles (via some hairy
|
* fancy with cycle counting here, just set an interrupt
|
||||||
* modular expressions) the wraparound cases where we are
|
* "soon" that we know will get the timer back to a known
|
||||||
* preempted for as much as half the counter space.
|
* state. This handles (via some hairy modular expressions)
|
||||||
|
* the wraparound cases where we are preempted for as much as
|
||||||
|
* half the counter space.
|
||||||
*/
|
*/
|
||||||
if (!flagged && counter_sub(cyc, counter()) <= 0x7fffff) {
|
if (zli_fixup && counter_sub(cyc, counter()) <= 0x7fffff) {
|
||||||
while (counter_sub(cyc, counter() + 2) > 0x7fffff) {
|
while (counter_sub(cyc, counter() + 2) > 0x7fffff) {
|
||||||
cyc = counter() + 3;
|
cyc = counter() + 3;
|
||||||
set_comparator(cyc);
|
set_comparator(cyc);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue