Skip to content

Commit d71ef67

Browse files
committed
atsamd21: unmask TC4 interrupt
1 parent 03ace97 commit d71ef67

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

rtic-monotonics/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ imxrt_gpt2 = ["imxrt"]
118118
esp32c3-systimer = ["dep:esp32c3", "dep:riscv"]
119119

120120
# ATSAMD21 Timer
121-
atsamd21g = ["dep:atsamd21g"]
121+
atsamd21g = ["dep:cortex-m", "dep:atsamd21g"]
122122

123123

124124
# STM32 timers

rtic-monotonics/src/atsamd21.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,6 @@
2525
//! Mono::delay(100.millis()).await;
2626
//! }
2727
//! }
28-
//!
29-
//! // FIXME: the interrupt handler is not working, but re-implementing it in a RTIC task does
30-
//! // Comment the interrupt handler `unsafe extern "C" fn TC4()` and add the following RTIC task
31-
//! #[task(binds = TC4)]
32-
//! fn tc4(_cx: tc4::Context) {
33-
//! use rtic_time::timer_queue::TimerQueueBackend;
34-
//! unsafe { Tc4Tc5Backend::timer_queue().on_monotonic_interrupt() };
35-
//! }
3628
//! ```
3729
3830
/// Common definitions and traits for using the ATSAMD21 TC4/5 monotonic
@@ -114,6 +106,11 @@ impl Tc4Tc5Backend {
114106
// Enable the timer
115107
tc4.ctrla().modify(|_, w| w.enable().set_bit());
116108
Self::sync();
109+
110+
unsafe {
111+
crate::set_monotonic_prio(pac::NVIC_PRIO_BITS, pac::Interrupt::TC4);
112+
pac::NVIC::unmask(pac::Interrupt::TC4);
113+
}
117114
}
118115
}
119116

rtic-monotonics/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ pub(crate) const fn cortex_logical2hw(logical: u8, nvic_prio_bits: u8) -> u8 {
9999
feature = "nrf5340-net",
100100
feature = "nrf9160",
101101
feature = "imxrt",
102+
feature = "atsamd21g",
102103
stm32,
103104
))]
104105
pub(crate) unsafe fn set_monotonic_prio(

0 commit comments

Comments
 (0)