Issue with creating new instance of can for STM32F429 Discovery board in rust when using stm32f4xx_hal

Problem while executing the example file from the stm32f4xx_hal crate [] for stm32f429 Discovery board, cannot find any way to instantiate can using new(), the compiler shows error saying there is no such function like new(). I have been facing this issue since a while. It would be great if you could help.

The error log is like this:

          let can = dp.CAN1.can((tx, rx));
|                           ^^^ method not found in `CAN1`

I wanted to initialize the can bus however there seems to be a problem doing that. This is from the stm32f4xx_hal examples

    use panic_halt as _;

    use bxcan::filter::Mask32;
    use bxcan::{Fifo, Frame, StandardId};
    use cortex_m_rt::entry;
    use nb::block;
    use stm32f4xx_hal::{pac, prelude::*};

    fn main() -> ! {
    let dp = pac::Peripherals::take().unwrap();

    let rcc = dp.RCC.constrain();

    // To meet CAN clock accuracy requirements an external crystal or ceramic
    // resonator must be used. The blue pill has a 8MHz external crystal.
    // Other boards might have a crystal with another frequency or none at all.

    let gpiob = dp.GPIOB.split();
    let mut can1 = {
        let rx = gpiob.pb8.into_alternate::<9>();
        let tx = gpiob.pb9.into_alternate::<9>();

         let can = Can::new(dp.CAN1, (tx, rx));
        // or
        //let can = dp.CAN1.can((tx, rx));

            // APB1 (PCLK1): 8MHz, Bit rate: 500kBit/s, Sample Point 87.5%
            // Value was calculated with

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.