Don't use word Standard for frame format because it can be confused with ID format. Use Classic instead to mean CAN 2.0B frames.

This commit is contained in:
Corey Schuhen 2024-02-17 10:51:31 +10:00
parent 70b3c4374d
commit 200ace566f
4 changed files with 17 additions and 17 deletions
embassy-stm32/src/can/fd

View file

@ -88,12 +88,12 @@ pub type FDF_R = generic::R<bool, FrameFormat>;
impl FDF_R {
pub fn frame_format(&self) -> FrameFormat {
match self.bits() {
false => FrameFormat::Standard,
false => FrameFormat::Classic,
true => FrameFormat::Fdcan,
}
}
pub fn is_standard_format(&self) -> bool {
*self == FrameFormat::Standard
pub fn is_classic_format(&self) -> bool {
*self == FrameFormat::Classic
}
pub fn is_fdcan_format(&self) -> bool {
*self == FrameFormat::Fdcan

View file

@ -5,7 +5,7 @@
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum DataLength {
Standard(u8),
Classic(u8),
Fdcan(u8),
}
impl DataLength {
@ -14,8 +14,8 @@ impl DataLength {
/// Uses the byte length and Type of frame as input
pub fn new(len: u8, ff: FrameFormat) -> DataLength {
match ff {
FrameFormat::Standard => match len {
0..=8 => DataLength::Standard(len),
FrameFormat::Classic => match len {
0..=8 => DataLength::Classic(len),
_ => panic!("DataLength > 8"),
},
FrameFormat::Fdcan => match len {
@ -24,9 +24,9 @@ impl DataLength {
},
}
}
/// Specialised function to create standard frames
pub fn new_standard(len: u8) -> DataLength {
Self::new(len, FrameFormat::Standard)
/// Specialised function to create classic frames
pub fn new_classic(len: u8) -> DataLength {
Self::new(len, FrameFormat::Classic)
}
/// Specialised function to create FDCAN frames
pub fn new_fdcan(len: u8) -> DataLength {
@ -36,13 +36,13 @@ impl DataLength {
/// returns the length in bytes
pub fn len(&self) -> u8 {
match self {
DataLength::Standard(l) | DataLength::Fdcan(l) => *l,
DataLength::Classic(l) | DataLength::Fdcan(l) => *l,
}
}
pub(crate) fn dlc(&self) -> u8 {
match self {
DataLength::Standard(l) => *l,
DataLength::Classic(l) => *l,
// See RM0433 Rev 7 Table 475. DLC coding
DataLength::Fdcan(l) => match l {
0..=8 => *l,
@ -61,7 +61,7 @@ impl DataLength {
impl From<DataLength> for FrameFormat {
fn from(dl: DataLength) -> FrameFormat {
match dl {
DataLength::Standard(_) => FrameFormat::Standard,
DataLength::Classic(_) => FrameFormat::Classic,
DataLength::Fdcan(_) => FrameFormat::Fdcan,
}
}
@ -121,7 +121,7 @@ impl From<ErrorStateIndicator> for bool {
/// Type of frame, standard (classic) or FdCAN
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum FrameFormat {
Standard = 0,
Classic = 0,
Fdcan = 1,
}
impl From<FrameFormat> for bool {

View file

@ -1,4 +1,4 @@
//! Module containing that which is speciffic to fdcan hardware variant
//! Module containing that which is specific to fdcan hardware variant
pub mod config;
pub mod filter;

View file

@ -167,7 +167,7 @@ impl Registers {
let len = match header_reg.to_data_length() {
DataLength::Fdcan(len) => len,
DataLength::Standard(len) => len,
DataLength::Classic(len) => len,
};
if len as usize > ClassicFrame::MAX_DATA_LEN {
return None;
@ -202,7 +202,7 @@ impl Registers {
let len = match header_reg.to_data_length() {
DataLength::Fdcan(len) => len,
DataLength::Standard(len) => len,
DataLength::Classic(len) => len,
};
if len as usize > FdFrame::MAX_DATA_LEN {
return None;
@ -683,7 +683,7 @@ fn put_tx_header(mailbox: &mut TxBufferElement, header: &Header) {
let frame_format = if header.len() > 8 || header.fdcan() {
FrameFormat::Fdcan
} else {
FrameFormat::Standard
FrameFormat::Classic
};
let brs = header.len() > 8 || header.bit_rate_switching();