David-OConnor / stm32-hal

This library provides access to STM32 peripherals in Rust.
MIT License
166 stars 44 forks source link

CAN read_status() not cross compatible #97

Closed revilo196 closed 7 months ago

revilo196 commented 8 months ago

The CAN Peripheral function

    pub fn read_status(&self) -> u32 {
        unsafe { self.regs.psr.read().bits() }
    }

is not compatible with F1, L4, ... and similar chips that use the older bxCAN peripheral they don't have a PSR register. The PSR is only present in the much larger FDCAN Hardware like in H7 chips.

bxCAN has the following status registers. msr master status register tsr transmit status register

maybe its just as easy as to check for the feature and use msr instead. for my quick lookup only G4 H5 H7 L5 U5 use FDCAN