Skip to content

Commit

Permalink
Move safeguard if compare irq is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
lulf committed Jan 2, 2025
1 parent 06901c3 commit 4229387
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions embassy-nrf/src/time_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,16 @@ impl RtcDriver {
let diff = timestamp - t;
if diff < 0xc00000 {
r.intenset().write(|w| w.0 = compare_n(n));

// If we have not passed the timestamp, we can be sure the alarm will be invoked. Otherwise,
// we need to retry setting the alarm.
if self.now() + 3 <= timestamp {
return true;
}
} else {
// If it's too far in the future, don't setup the compare channel yet.
// It will be setup later by `next_period`.
r.intenclr().write(|w| w.0 = compare_n(n));
}

// If we have not passed the timestamp, we can be sure the alarm will be invoked. Otherwise,
// we need to retry setting the alarm.
if self.now() + 3 <= timestamp {
return true;
}
}
Expand Down

0 comments on commit 4229387

Please sign in to comment.