Merge pull request from MaxiluxSystems/small-fdcan-fixes

stm32: can: fd: fix SID read/write and BRS setting for TX
This commit is contained in:
Dario Nieuwenhuis 2024-02-27 12:19:03 +00:00 committed by GitHub
commit 62c5df7e5b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -721,13 +721,15 @@ fn make_id(id: u32, extended: bool) -> embedded_can::Id {
if extended {
embedded_can::Id::from(unsafe { embedded_can::ExtendedId::new_unchecked(id & 0x1FFFFFFF) })
} else {
embedded_can::Id::from(unsafe { embedded_can::StandardId::new_unchecked((id & 0x000007FF) as u16) })
// A standard identifier is stored into ID[28:18].
embedded_can::Id::from(unsafe { embedded_can::StandardId::new_unchecked(((id >> 18) & 0x000007FF) as u16) })
}
}
fn put_tx_header(mailbox: &mut TxBufferElement, header: &Header) {
let (id, id_type) = match header.id() {
embedded_can::Id::Standard(id) => (id.as_raw() as u32, IdType::StandardId),
// A standard identifier has to be written to ID[28:18].
embedded_can::Id::Standard(id) => ((id.as_raw() as u32) << 18, IdType::StandardId),
embedded_can::Id::Extended(id) => (id.as_raw() as u32, IdType::ExtendedId),
};
@ -737,7 +739,7 @@ fn put_tx_header(mailbox: &mut TxBufferElement, header: &Header) {
} else {
FrameFormat::Classic
};
let brs = header.len() > 8 || header.bit_rate_switching();
let brs = (frame_format == FrameFormat::Fdcan) && header.bit_rate_switching();
mailbox.header.write(|w| {
unsafe { w.id().bits(id) }