Move safeguard if compare irq is enabled

This commit is contained in:
Ulf Lilleengen 2025-01-02 12:53:55 +01:00
parent 06901c3279
commit 422938745a

View File

@ -244,17 +244,18 @@ impl RtcDriver {
let diff = timestamp - t; let diff = timestamp - t;
if diff < 0xc00000 { if diff < 0xc00000 {
r.intenset().write(|w| w.0 = compare_n(n)); r.intenset().write(|w| w.0 = compare_n(n));
} 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, // If we have not passed the timestamp, we can be sure the alarm will be invoked. Otherwise,
// we need to retry setting the alarm. // we need to retry setting the alarm.
if self.now() + 3 <= timestamp { if self.now() + 3 <= timestamp {
return true; 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));
return true;
}
} }
} }
} }