Skip to content

Commit

Permalink
firmware: correctly clear TSC interrupt when turned off
Browse files Browse the repository at this point in the history
  • Loading branch information
afilini committed Aug 17, 2024
1 parent 59c7a53 commit 3db53fe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
4 changes: 4 additions & 0 deletions firmware/src/hw/tsc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ where
}
}

pub fn clear_interrupt(&mut self) {
self.tsc.clear(hal::tsc::Event::EndOfAcquisition);
}

pub fn perform_read(&self) -> bool {
self.tsc.read_unchecked() < TSC_THRESHOLD
}
Expand Down
13 changes: 6 additions & 7 deletions firmware/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,14 +377,13 @@ mod app {

#[task(binds = TSC, local = [tsc])]
fn tsc_interrupt(_cx: tsc_interrupt::Context) {
#[cfg(feature = "device")]
{
let (ref mut tsc, ref mut channel) = _cx.local.tsc;
let (ref mut tsc, ref mut channel) = _cx.local.tsc;

if tsc.is_enabled() {
let _ = channel.try_send(tsc.perform_read());
tsc.start_acquisition();
}
if tsc.is_enabled() {
let _ = channel.try_send(tsc.perform_read());
tsc.start_acquisition();
} else {
tsc.clear_interrupt();
}
}
}
Expand Down

0 comments on commit 3db53fe

Please sign in to comment.