Merge pull request #4222 from felipebalbi/fix-ostimer

timer: ostimer: wait for match write ready
This commit is contained in:
Dario Nieuwenhuis 2025-05-21 17:31:37 +02:00 committed by GitHub
commit 9409afb02e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -336,6 +336,10 @@ impl OsTimer {
let alarm = self.alarms.borrow(cs);
alarm.timestamp.set(timestamp);
// Wait until we're allowed to write to MATCH_L/MATCH_H
// registers
while os().osevent_ctrl().read().match_wr_rdy().bit_is_set() {}
let t = self.now();
if timestamp <= t {
os().osevent_ctrl().modify(|_, w| w.ostimer_intena().clear_bit());
@ -366,7 +370,8 @@ impl OsTimer {
fn on_interrupt(&self) {
critical_section::with(|cs| {
if os().osevent_ctrl().read().ostimer_intrflag().bit_is_set() {
os().osevent_ctrl().modify(|_, w| w.ostimer_intena().clear_bit());
os().osevent_ctrl()
.modify(|_, w| w.ostimer_intena().clear_bit().ostimer_intrflag().set_bit());
self.trigger_alarm(cs);
}
});