stm32/can: cleanup interrupt traits.

This commit is contained in:
Dario Nieuwenhuis 2023-12-18 18:43:01 +01:00
parent 91e107ea07
commit d709aa231b

View File

@ -585,30 +585,18 @@ pub(crate) mod sealed {
pub trait Instance { pub trait Instance {
const REGISTERS: *mut bxcan::RegisterBlock; const REGISTERS: *mut bxcan::RegisterBlock;
fn regs() -> &'static crate::pac::can::Can; fn regs() -> crate::pac::can::Can;
fn state() -> &'static State; fn state() -> &'static State;
} }
} }
pub trait TXInstance { pub trait Instance: sealed::Instance + RccPeripheral + 'static {
type TXInterrupt: crate::interrupt::typelevel::Interrupt; type TXInterrupt: crate::interrupt::typelevel::Interrupt;
}
pub trait RX0Instance {
type RX0Interrupt: crate::interrupt::typelevel::Interrupt; type RX0Interrupt: crate::interrupt::typelevel::Interrupt;
}
pub trait RX1Instance {
type RX1Interrupt: crate::interrupt::typelevel::Interrupt; type RX1Interrupt: crate::interrupt::typelevel::Interrupt;
}
pub trait SCEInstance {
type SCEInterrupt: crate::interrupt::typelevel::Interrupt; type SCEInterrupt: crate::interrupt::typelevel::Interrupt;
} }
pub trait InterruptableInstance: TXInstance + RX0Instance + RX1Instance + SCEInstance {}
pub trait Instance: sealed::Instance + RccPeripheral + InterruptableInstance + 'static {}
pub struct BxcanInstance<'a, T>(PeripheralRef<'a, T>); pub struct BxcanInstance<'a, T>(PeripheralRef<'a, T>);
unsafe impl<'d, T: Instance> bxcan::Instance for BxcanInstance<'d, T> { unsafe impl<'d, T: Instance> bxcan::Instance for BxcanInstance<'d, T> {
@ -620,8 +608,8 @@ foreach_peripheral!(
impl sealed::Instance for peripherals::$inst { impl sealed::Instance for peripherals::$inst {
const REGISTERS: *mut bxcan::RegisterBlock = crate::pac::$inst.as_ptr() as *mut _; const REGISTERS: *mut bxcan::RegisterBlock = crate::pac::$inst.as_ptr() as *mut _;
fn regs() -> &'static crate::pac::can::Can { fn regs() -> crate::pac::can::Can {
&crate::pac::$inst crate::pac::$inst
} }
fn state() -> &'static sealed::State { fn state() -> &'static sealed::State {
@ -630,32 +618,12 @@ foreach_peripheral!(
} }
} }
impl Instance for peripherals::$inst {} impl Instance for peripherals::$inst {
type TXInterrupt = crate::_generated::peripheral_interrupts::$inst::TX;
foreach_interrupt!( type RX0Interrupt = crate::_generated::peripheral_interrupts::$inst::RX0;
($inst,can,CAN,TX,$irq:ident) => { type RX1Interrupt = crate::_generated::peripheral_interrupts::$inst::RX1;
impl TXInstance for peripherals::$inst { type SCEInterrupt = crate::_generated::peripheral_interrupts::$inst::SCE;
type TXInterrupt = crate::interrupt::typelevel::$irq; }
}
};
($inst,can,CAN,RX0,$irq:ident) => {
impl RX0Instance for peripherals::$inst {
type RX0Interrupt = crate::interrupt::typelevel::$irq;
}
};
($inst,can,CAN,RX1,$irq:ident) => {
impl RX1Instance for peripherals::$inst {
type RX1Interrupt = crate::interrupt::typelevel::$irq;
}
};
($inst,can,CAN,SCE,$irq:ident) => {
impl SCEInstance for peripherals::$inst {
type SCEInterrupt = crate::interrupt::typelevel::$irq;
}
};
);
impl InterruptableInstance for peripherals::$inst {}
}; };
); );