Skip to content

Commit

Permalink
Small embassy cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Sep 20, 2024
1 parent 4814252 commit 87b9ae2
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions esp-hal-embassy/src/time_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,13 @@ impl EmbassyTimer {
fn on_interrupt(&self, id: usize) {
let cb = critical_section::with(|cs| {
let mut timers = TIMERS.borrow_ref_mut(cs);
let timers = timers.as_mut().expect("Time driver not initialized");
let timers = unwrap!(timers.as_mut(), "Time driver not initialized");
let timer = &mut timers[id];

timer.clear_interrupt();

let alarm = &self.alarms.borrow(cs)[id];

if let Some((f, ctx)) = alarm.callback.get() {
Some((f, ctx))
} else {
None
}
alarm.callback.get()
});

if let Some((f, ctx)) = cb {
Expand All @@ -120,7 +115,7 @@ impl EmbassyTimer {
let ts = timestamp.micros();
// if the TS is already in the past make the timer fire immediately
let timeout = if ts > now { ts - now } else { 0.micros() };
timer.schedule(timeout).unwrap();
unwrap!(timer.schedule(timeout));
timer.enable_interrupt(true);
}
}
Expand Down Expand Up @@ -168,7 +163,7 @@ impl Driver for EmbassyTimer {
// soon as possible, but not synchronously.)
critical_section::with(|cs| {
let mut timers = TIMERS.borrow_ref_mut(cs);
let timers = timers.as_mut().expect("Time driver not initialized");
let timers = unwrap!(timers.as_mut(), "Time driver not initialized");
let timer = &mut timers[alarm.id() as usize];

Self::arm(timer, timestamp);
Expand Down

0 comments on commit 87b9ae2

Please sign in to comment.