mirror of
https://github.com/embassy-rs/embassy.git
synced 2025-09-28 21:01:06 +00:00
Merge pull request #4305 from annie444/main
Add helper methods for the low-power interrupt timer.
This commit is contained in:
commit
4e9d38fef0
@ -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));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user