"separate CC interrupt" is for AdvCh4 only

This commit is contained in:
eZio Pan 2024-03-25 19:29:59 +08:00 committed by Dario Nieuwenhuis
parent 348a46b110
commit 78b9cb98d4
2 changed files with 24 additions and 23 deletions

View File

@ -15,8 +15,6 @@ use crate::pac::timer::vals;
use crate::rcc::SealedRccPeripheral;
#[cfg(feature = "low-power")]
use crate::rtc::Rtc;
#[cfg(any(time_driver_tim1, time_driver_tim8, time_driver_tim20))]
use crate::timer::AdvancedInstance1Channel;
use crate::timer::CoreInstance;
use crate::{interrupt, peripherals};
@ -263,6 +261,7 @@ pub(crate) struct RtcDriver {
rtc: Mutex<CriticalSectionRawMutex, Cell<Option<&'static Rtc>>>,
}
#[allow(clippy::declare_interior_mutable_const)]
const ALARM_STATE_NEW: AlarmState = AlarmState::new();
embassy_time_driver::time_driver_impl!(static DRIVER: RtcDriver = RtcDriver {
@ -312,9 +311,10 @@ impl RtcDriver {
#[cfg(any(time_driver_tim1, time_driver_tim8, time_driver_tim20))]
{
<T as AdvancedInstance1Channel>::CaptureCompareInterrupt::unpend();
use crate::timer::AdvancedInstance4Channel;
<T as AdvancedInstance4Channel>::CaptureCompareInterrupt::unpend();
unsafe {
<T as AdvancedInstance1Channel>::CaptureCompareInterrupt::enable();
<T as AdvancedInstance4Channel>::CaptureCompareInterrupt::enable();
}
}

View File

@ -93,16 +93,16 @@ pub trait GeneralInstance4Channel: BasicInstance + GeneralInstance2Channel + Gen
pub trait GeneralInstance32bit4Channel: GeneralInstance4Channel {}
/// Advanced 16-bit timer with 1 channel instance.
pub trait AdvancedInstance1Channel: BasicNoCr2Instance + GeneralInstance1Channel {
/// Capture compare interrupt for this timer.
type CaptureCompareInterrupt: interrupt::typelevel::Interrupt;
}
pub trait AdvancedInstance1Channel: BasicNoCr2Instance + GeneralInstance1Channel {}
/// Advanced 16-bit timer with 2 channels instance.
pub trait AdvancedInstance2Channel: BasicInstance + GeneralInstance2Channel + AdvancedInstance1Channel {}
/// Advanced 16-bit timer with 4 channels instance.
pub trait AdvancedInstance4Channel: AdvancedInstance2Channel + GeneralInstance4Channel {}
pub trait AdvancedInstance4Channel: AdvancedInstance2Channel + GeneralInstance4Channel {
/// Capture compare interrupt for this timer.
type CaptureCompareInterrupt: interrupt::typelevel::Interrupt;
}
pin_trait!(Channel1Pin, GeneralInstance4Channel);
pin_trait!(Channel2Pin, GeneralInstance4Channel);
@ -162,6 +162,15 @@ macro_rules! impl_general_4ch_blank_sealed {
};
}
#[allow(unused)]
macro_rules! impl_adv_4ch {
($inst:ident) => {
impl AdvancedInstance4Channel for crate::peripherals::$inst {
type CaptureCompareInterrupt = crate::_generated::peripheral_interrupts::$inst::CC;
}
};
}
foreach_interrupt! {
($inst:ident, timer, TIM_BASIC, UP, $irq:ident) => {
impl_core_timer!($inst, TimerBits::Bits16);
@ -218,9 +227,9 @@ foreach_interrupt! {
impl GeneralInstance2Channel for crate::peripherals::$inst {}
impl GeneralInstance4Channel for crate::peripherals::$inst {}
impl_general_4ch_blank_sealed!($inst);
impl AdvancedInstance1Channel for crate::peripherals::$inst { type CaptureCompareInterrupt = crate::_generated::peripheral_interrupts::$inst::CC; }
impl AdvancedInstance1Channel for crate::peripherals::$inst {}
impl AdvancedInstance2Channel for crate::peripherals::$inst {}
impl AdvancedInstance4Channel for crate::peripherals::$inst {}
impl_adv_4ch!($inst);
};
($inst:ident, timer, TIM_2CH_CMP, UP, $irq:ident) => {
@ -231,9 +240,9 @@ foreach_interrupt! {
impl GeneralInstance2Channel for crate::peripherals::$inst {}
impl GeneralInstance4Channel for crate::peripherals::$inst {}
impl_general_4ch_blank_sealed!($inst);
impl AdvancedInstance1Channel for crate::peripherals::$inst { type CaptureCompareInterrupt = crate::_generated::peripheral_interrupts::$inst::CC; }
impl AdvancedInstance1Channel for crate::peripherals::$inst {}
impl AdvancedInstance2Channel for crate::peripherals::$inst {}
impl AdvancedInstance4Channel for crate::peripherals::$inst {}
impl_adv_4ch!($inst);
};
($inst:ident, timer, TIM_ADV, UP, $irq:ident) => {
@ -244,16 +253,8 @@ foreach_interrupt! {
impl GeneralInstance2Channel for crate::peripherals::$inst {}
impl GeneralInstance4Channel for crate::peripherals::$inst {}
impl_general_4ch_blank_sealed!($inst);
impl AdvancedInstance1Channel for crate::peripherals::$inst { type CaptureCompareInterrupt = crate::_generated::peripheral_interrupts::$inst::CC; }
impl AdvancedInstance1Channel for crate::peripherals::$inst {}
impl AdvancedInstance2Channel for crate::peripherals::$inst {}
impl AdvancedInstance4Channel for crate::peripherals::$inst {}
impl_adv_4ch!($inst);
};
}
#[cfg(not(stm32l0))]
#[allow(unused)]
fn set_moe<T: GeneralInstance4Channel>() {
unsafe { crate::pac::timer::Tim1chCmp::from_ptr(T::regs()) }
.bdtr()
.modify(|w| w.set_moe(true));
}