Skip to content

Commit

Permalink
atsamd21: unmask TC4 interrupt
Browse files Browse the repository at this point in the history
  • Loading branch information
maximeborges committed Nov 11, 2024
1 parent 03ace97 commit d71ef67
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion rtic-monotonics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ imxrt_gpt2 = ["imxrt"]
esp32c3-systimer = ["dep:esp32c3", "dep:riscv"]

# ATSAMD21 Timer
atsamd21g = ["dep:atsamd21g"]
atsamd21g = ["dep:cortex-m", "dep:atsamd21g"]


# STM32 timers
Expand Down
13 changes: 5 additions & 8 deletions rtic-monotonics/src/atsamd21.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@
//! Mono::delay(100.millis()).await;
//! }
//! }
//!
//! // FIXME: the interrupt handler is not working, but re-implementing it in a RTIC task does
//! // Comment the interrupt handler `unsafe extern "C" fn TC4()` and add the following RTIC task
//! #[task(binds = TC4)]
//! fn tc4(_cx: tc4::Context) {
//! use rtic_time::timer_queue::TimerQueueBackend;
//! unsafe { Tc4Tc5Backend::timer_queue().on_monotonic_interrupt() };
//! }
//! ```
/// Common definitions and traits for using the ATSAMD21 TC4/5 monotonic
Expand Down Expand Up @@ -114,6 +106,11 @@ impl Tc4Tc5Backend {
// Enable the timer
tc4.ctrla().modify(|_, w| w.enable().set_bit());
Self::sync();

unsafe {
crate::set_monotonic_prio(pac::NVIC_PRIO_BITS, pac::Interrupt::TC4);
pac::NVIC::unmask(pac::Interrupt::TC4);
}
}
}

Expand Down
1 change: 1 addition & 0 deletions rtic-monotonics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ pub(crate) const fn cortex_logical2hw(logical: u8, nvic_prio_bits: u8) -> u8 {
feature = "nrf5340-net",
feature = "nrf9160",
feature = "imxrt",
feature = "atsamd21g",
stm32,
))]
pub(crate) unsafe fn set_monotonic_prio(
Expand Down

0 comments on commit d71ef67

Please sign in to comment.