Merge pull request #2631 from MaxiluxSystems/small-fdcan-fixes
stm32: can: fd: fix SID read/write and BRS setting for TX
This commit is contained in:
commit
62c5df7e5b
1 changed files with 5 additions and 3 deletions
|
@ -721,13 +721,15 @@ fn make_id(id: u32, extended: bool) -> embedded_can::Id {
|
||||||
if extended {
|
if extended {
|
||||||
embedded_can::Id::from(unsafe { embedded_can::ExtendedId::new_unchecked(id & 0x1FFFFFFF) })
|
embedded_can::Id::from(unsafe { embedded_can::ExtendedId::new_unchecked(id & 0x1FFFFFFF) })
|
||||||
} else {
|
} 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) {
|
fn put_tx_header(mailbox: &mut TxBufferElement, header: &Header) {
|
||||||
let (id, id_type) = match header.id() {
|
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),
|
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 {
|
} else {
|
||||||
FrameFormat::Classic
|
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| {
|
mailbox.header.write(|w| {
|
||||||
unsafe { w.id().bits(id) }
|
unsafe { w.id().bits(id) }
|
||||||
|
|
Loading…
Add table
Reference in a new issue