mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-25 16:23:10 +00:00
stm32/time-driver: always use CC interrupt.
This avoids cfg's, because it works both for timers that have a a dedicated CC interrupt line, and timers where all interrupts go to a single interrupt line.
This commit is contained in:
parent
5dc3738bc2
commit
3d7d3e0286
@ -15,7 +15,7 @@ use crate::pac::timer::vals;
|
||||
use crate::rcc::SealedRccPeripheral;
|
||||
#[cfg(feature = "low-power")]
|
||||
use crate::rtc::Rtc;
|
||||
use crate::timer::CoreInstance;
|
||||
use crate::timer::{CoreInstance, GeneralInstance1Channel};
|
||||
use crate::{interrupt, peripherals};
|
||||
|
||||
// NOTE regarding ALARM_COUNT:
|
||||
@ -67,7 +67,7 @@ type T = peripherals::TIM23;
|
||||
type T = peripherals::TIM24;
|
||||
|
||||
foreach_interrupt! {
|
||||
(TIM1, timer, $block:ident, UP, $irq:ident) => {
|
||||
(TIM1, timer, $block:ident, CC, $irq:ident) => {
|
||||
#[cfg(time_driver_tim1)]
|
||||
#[cfg(feature = "rt")]
|
||||
#[interrupt]
|
||||
@ -83,7 +83,7 @@ foreach_interrupt! {
|
||||
DRIVER.on_interrupt()
|
||||
}
|
||||
};
|
||||
(TIM2, timer, $block:ident, UP, $irq:ident) => {
|
||||
(TIM2, timer, $block:ident, CC, $irq:ident) => {
|
||||
#[cfg(time_driver_tim2)]
|
||||
#[cfg(feature = "rt")]
|
||||
#[interrupt]
|
||||
@ -91,7 +91,7 @@ foreach_interrupt! {
|
||||
DRIVER.on_interrupt()
|
||||
}
|
||||
};
|
||||
(TIM3, timer, $block:ident, UP, $irq:ident) => {
|
||||
(TIM3, timer, $block:ident, CC, $irq:ident) => {
|
||||
#[cfg(time_driver_tim3)]
|
||||
#[cfg(feature = "rt")]
|
||||
#[interrupt]
|
||||
@ -99,7 +99,7 @@ foreach_interrupt! {
|
||||
DRIVER.on_interrupt()
|
||||
}
|
||||
};
|
||||
(TIM4, timer, $block:ident, UP, $irq:ident) => {
|
||||
(TIM4, timer, $block:ident, CC, $irq:ident) => {
|
||||
#[cfg(time_driver_tim4)]
|
||||
#[cfg(feature = "rt")]
|
||||
#[interrupt]
|
||||
@ -107,7 +107,7 @@ foreach_interrupt! {
|
||||
DRIVER.on_interrupt()
|
||||
}
|
||||
};
|
||||
(TIM5, timer, $block:ident, UP, $irq:ident) => {
|
||||
(TIM5, timer, $block:ident, CC, $irq:ident) => {
|
||||
#[cfg(time_driver_tim5)]
|
||||
#[cfg(feature = "rt")]
|
||||
#[interrupt]
|
||||
@ -115,7 +115,7 @@ foreach_interrupt! {
|
||||
DRIVER.on_interrupt()
|
||||
}
|
||||
};
|
||||
(TIM8, timer, $block:ident, UP, $irq:ident) => {
|
||||
(TIM8, timer, $block:ident, CC, $irq:ident) => {
|
||||
#[cfg(time_driver_tim8)]
|
||||
#[cfg(feature = "rt")]
|
||||
#[interrupt]
|
||||
@ -131,7 +131,7 @@ foreach_interrupt! {
|
||||
DRIVER.on_interrupt()
|
||||
}
|
||||
};
|
||||
(TIM9, timer, $block:ident, UP, $irq:ident) => {
|
||||
(TIM9, timer, $block:ident, CC, $irq:ident) => {
|
||||
#[cfg(time_driver_tim9)]
|
||||
#[cfg(feature = "rt")]
|
||||
#[interrupt]
|
||||
@ -139,7 +139,7 @@ foreach_interrupt! {
|
||||
DRIVER.on_interrupt()
|
||||
}
|
||||
};
|
||||
(TIM12, timer, $block:ident, UP, $irq:ident) => {
|
||||
(TIM12, timer, $block:ident, CC, $irq:ident) => {
|
||||
#[cfg(time_driver_tim12)]
|
||||
#[cfg(feature = "rt")]
|
||||
#[interrupt]
|
||||
@ -147,7 +147,7 @@ foreach_interrupt! {
|
||||
DRIVER.on_interrupt()
|
||||
}
|
||||
};
|
||||
(TIM15, timer, $block:ident, UP, $irq:ident) => {
|
||||
(TIM15, timer, $block:ident, CC, $irq:ident) => {
|
||||
#[cfg(time_driver_tim15)]
|
||||
#[cfg(feature = "rt")]
|
||||
#[interrupt]
|
||||
@ -155,7 +155,7 @@ foreach_interrupt! {
|
||||
DRIVER.on_interrupt()
|
||||
}
|
||||
};
|
||||
(TIM20, timer, $block:ident, UP, $irq:ident) => {
|
||||
(TIM20, timer, $block:ident, CC, $irq:ident) => {
|
||||
#[cfg(time_driver_tim20)]
|
||||
#[cfg(feature = "rt")]
|
||||
#[interrupt]
|
||||
@ -171,7 +171,7 @@ foreach_interrupt! {
|
||||
DRIVER.on_interrupt()
|
||||
}
|
||||
};
|
||||
(TIM21, timer, $block:ident, UP, $irq:ident) => {
|
||||
(TIM21, timer, $block:ident, CC, $irq:ident) => {
|
||||
#[cfg(time_driver_tim21)]
|
||||
#[cfg(feature = "rt")]
|
||||
#[interrupt]
|
||||
@ -179,7 +179,7 @@ foreach_interrupt! {
|
||||
DRIVER.on_interrupt()
|
||||
}
|
||||
};
|
||||
(TIM22, timer, $block:ident, UP, $irq:ident) => {
|
||||
(TIM22, timer, $block:ident, CC, $irq:ident) => {
|
||||
#[cfg(time_driver_tim22)]
|
||||
#[cfg(feature = "rt")]
|
||||
#[interrupt]
|
||||
@ -187,7 +187,7 @@ foreach_interrupt! {
|
||||
DRIVER.on_interrupt()
|
||||
}
|
||||
};
|
||||
(TIM23, timer, $block:ident, UP, $irq:ident) => {
|
||||
(TIM23, timer, $block:ident, CC, $irq:ident) => {
|
||||
#[cfg(time_driver_tim23)]
|
||||
#[cfg(feature = "rt")]
|
||||
#[interrupt]
|
||||
@ -195,7 +195,7 @@ foreach_interrupt! {
|
||||
DRIVER.on_interrupt()
|
||||
}
|
||||
};
|
||||
(TIM24, timer, $block:ident, UP, $irq:ident) => {
|
||||
(TIM24, timer, $block:ident, CC, $irq:ident) => {
|
||||
#[cfg(time_driver_tim24)]
|
||||
#[cfg(feature = "rt")]
|
||||
#[interrupt]
|
||||
@ -306,17 +306,8 @@ impl RtcDriver {
|
||||
w.set_ccie(0, true);
|
||||
});
|
||||
|
||||
<T as CoreInstance>::UpdateInterrupt::unpend();
|
||||
unsafe { <T as CoreInstance>::UpdateInterrupt::enable() };
|
||||
|
||||
#[cfg(any(time_driver_tim1, time_driver_tim8, time_driver_tim20))]
|
||||
{
|
||||
use crate::timer::GeneralInstance1Channel;
|
||||
<T as GeneralInstance1Channel>::CaptureCompareInterrupt::unpend();
|
||||
unsafe {
|
||||
<T as GeneralInstance1Channel>::CaptureCompareInterrupt::enable();
|
||||
}
|
||||
}
|
||||
<T as GeneralInstance1Channel>::CaptureCompareInterrupt::unpend();
|
||||
unsafe { <T as GeneralInstance1Channel>::CaptureCompareInterrupt::enable() };
|
||||
|
||||
r.cr1().modify(|w| w.set_cen(true));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user