mirror of
https://github.com/italicsjenga/rp-hal-boards.git
synced 2025-02-23 23:57:43 +11:00
Fix alarm schedule() race condition.
This commit is contained in:
parent
0e3136da11
commit
7a23247ca1
1 changed files with 12 additions and 10 deletions
|
@ -249,6 +249,7 @@ macro_rules! impl_alarm {
|
||||||
if duration < MIN_MICROSECONDS {
|
if duration < MIN_MICROSECONDS {
|
||||||
return Err(ScheduleAlarmError::AlarmTooSoon);
|
return Err(ScheduleAlarmError::AlarmTooSoon);
|
||||||
} else {
|
} else {
|
||||||
|
cortex_m::interrupt::free(|_| {
|
||||||
// safety: This is a read action and should not have any UB
|
// safety: This is a read action and should not have any UB
|
||||||
let target_time = unsafe { &*TIMER::ptr() }
|
let target_time = unsafe { &*TIMER::ptr() }
|
||||||
.timelr
|
.timelr
|
||||||
|
@ -260,6 +261,7 @@ macro_rules! impl_alarm {
|
||||||
unsafe { &*TIMER::ptr() }
|
unsafe { &*TIMER::ptr() }
|
||||||
.$timer_alarm
|
.$timer_alarm
|
||||||
.write(|w| unsafe { w.bits(target_time) });
|
.write(|w| unsafe { w.bits(target_time) });
|
||||||
|
});
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue