bxcan: Cleanup
Older families like F1 and F4 have a consistent naming for the CAN peripherals: CAN when there is only one instance, CAN1/CAN2/CAN2 if there are multiple instances. Newer families like L4 and F7 use the name CAN1 even if there is only one instance. The number of filter banks is incorrect for those. Affected chips: * STM32F722 * STM32F723 * STM32F730 * STM32F732 * STM32F733 * STM32L4P5 * STM32L4Q5 * STM32L4R5 * STM32L4R7 * STM32L4R9 * STM32L4S5 * STM32L4S7 * STM32L4S9 * STM32L431 * STM32L432 * STM32L433 * STM32L442 * STM32L443 * STM32L451 * STM32L452 * STM32L462 * STM32L471 * STM32L475 * STM32L476 * STM32L485 * STM32L486
This commit is contained in:
parent
0c3bede64f
commit
f141b98741
@ -17,7 +17,6 @@ pub struct Can<'d, T: Instance + bxcan::Instance> {
|
||||
impl<'d, T: Instance + bxcan::Instance> Can<'d, T> {
|
||||
pub fn new(
|
||||
peri: impl Unborrow<Target = T> + 'd,
|
||||
// irq: impl Unborrow<Target = T::Interrupt> + 'd,
|
||||
rx: impl Unborrow<Target = impl RxPin<T>> + 'd,
|
||||
tx: impl Unborrow<Target = impl TxPin<T>> + 'd,
|
||||
) -> Self {
|
||||
@ -30,7 +29,6 @@ impl<'d, T: Instance + bxcan::Instance> Can<'d, T> {
|
||||
|
||||
T::enable();
|
||||
T::reset();
|
||||
// TODO: CAN2 also required CAN1 clock
|
||||
|
||||
Self {
|
||||
phantom: PhantomData,
|
||||
@ -101,21 +99,27 @@ crate::pac::peripherals!(
|
||||
);
|
||||
|
||||
crate::pac::peripherals!(
|
||||
// TODO: rename CAN to CAN1 on yaml level??
|
||||
(can, CAN) => {
|
||||
unsafe impl bxcan::FilterOwner for peripherals::CAN {
|
||||
unsafe impl bxcan::FilterOwner for peripherals::$inst {
|
||||
const NUM_FILTER_BANKS: u8 = 14;
|
||||
}
|
||||
};
|
||||
// Only correct when CAN2 also exists… Fix on yaml level?
|
||||
// There are only 14 filter banks when CAN2 is not available.
|
||||
(can, CAN1) => {
|
||||
unsafe impl bxcan::FilterOwner for peripherals::CAN1 {
|
||||
const NUM_FILTER_BANKS: u8 = 14;
|
||||
const NUM_FILTER_BANKS: u8 = 28;
|
||||
}
|
||||
};
|
||||
(can, CAN2) => {
|
||||
// TODO: when CAN2 existis, we have 28 filter banks
|
||||
// CAN2 is always a slave instance where CAN1 is the master instance
|
||||
unsafe impl bxcan::MasterInstance for peripherals::CAN1 {}
|
||||
};
|
||||
(can, CAN3) => {
|
||||
unsafe impl bxcan::FilterOwner for peripherals::$inst {
|
||||
const NUM_FILTER_BANKS: u8 = 14;
|
||||
}
|
||||
};
|
||||
);
|
||||
|
||||
macro_rules! impl_pin {
|
||||
|
Loading…
Reference in New Issue
Block a user