Merge pull request #4305 from annie444/main

Add helper methods for the low-power interrupt timer.
This commit is contained in:
Dario Nieuwenhuis 2025-07-24 21:52:36 +00:00 committed by GitHub
commit 4e9d38fef0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -115,6 +115,31 @@ impl<'d, T: Instance> Timer<'d, T> {
.ccmr(0)
.modify(|w| w.set_ccsel(channel.index(), direction.into()));
}
/// Enable the timer interrupt.
pub fn enable_interrupt(&self) {
T::regs().dier().modify(|w| w.set_arrmie(true));
}
/// Disable the timer interrupt.
pub fn disable_interrupt(&self) {
T::regs().dier().modify(|w| w.set_arrmie(false));
}
/// Check if the timer interrupt is enabled.
pub fn is_interrupt_enabled(&self) -> bool {
T::regs().dier().read().arrmie()
}
/// Check if the timer interrupt is pending.
pub fn is_interrupt_pending(&self) -> bool {
T::regs().isr().read().arrm()
}
/// Clear the timer interrupt.
pub fn clear_interrupt(&self) {
T::regs().icr().write(|w| w.set_arrmcf(true));
}
}
#[cfg(not(any(lptim_v2a, lptim_v2b)))]
@ -128,4 +153,29 @@ impl<'d, T: Instance> Timer<'d, T> {
pub fn get_compare_value(&self) -> u16 {
T::regs().cmp().read().cmp()
}
/// Enable the timer interrupt.
pub fn enable_interrupt(&self) {
T::regs().ier().modify(|w| w.set_arrmie(true));
}
/// Disable the timer interrupt.
pub fn disable_interrupt(&self) {
T::regs().ier().modify(|w| w.set_arrmie(false));
}
/// Check if the timer interrupt is enabled.
pub fn is_interrupt_enabled(&self) -> bool {
T::regs().ier().read().arrmie()
}
/// Check if the timer interrupt is pending.
pub fn is_interrupt_pending(&self) -> bool {
T::regs().isr().read().arrm()
}
/// Clear the timer interrupt.
pub fn clear_interrupt(&self) {
T::regs().icr().write(|w| w.set_arrmcf(true));
}
}