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:
parent
70b3c4374d
commit
200ace566f
@ -88,12 +88,12 @@ pub type FDF_R = generic::R<bool, FrameFormat>;
|
|||||||
impl FDF_R {
|
impl FDF_R {
|
||||||
pub fn frame_format(&self) -> FrameFormat {
|
pub fn frame_format(&self) -> FrameFormat {
|
||||||
match self.bits() {
|
match self.bits() {
|
||||||
false => FrameFormat::Standard,
|
false => FrameFormat::Classic,
|
||||||
true => FrameFormat::Fdcan,
|
true => FrameFormat::Fdcan,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn is_standard_format(&self) -> bool {
|
pub fn is_classic_format(&self) -> bool {
|
||||||
*self == FrameFormat::Standard
|
*self == FrameFormat::Classic
|
||||||
}
|
}
|
||||||
pub fn is_fdcan_format(&self) -> bool {
|
pub fn is_fdcan_format(&self) -> bool {
|
||||||
*self == FrameFormat::Fdcan
|
*self == FrameFormat::Fdcan
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
pub enum DataLength {
|
pub enum DataLength {
|
||||||
Standard(u8),
|
Classic(u8),
|
||||||
Fdcan(u8),
|
Fdcan(u8),
|
||||||
}
|
}
|
||||||
impl DataLength {
|
impl DataLength {
|
||||||
@ -14,8 +14,8 @@ impl DataLength {
|
|||||||
/// Uses the byte length and Type of frame as input
|
/// Uses the byte length and Type of frame as input
|
||||||
pub fn new(len: u8, ff: FrameFormat) -> DataLength {
|
pub fn new(len: u8, ff: FrameFormat) -> DataLength {
|
||||||
match ff {
|
match ff {
|
||||||
FrameFormat::Standard => match len {
|
FrameFormat::Classic => match len {
|
||||||
0..=8 => DataLength::Standard(len),
|
0..=8 => DataLength::Classic(len),
|
||||||
_ => panic!("DataLength > 8"),
|
_ => panic!("DataLength > 8"),
|
||||||
},
|
},
|
||||||
FrameFormat::Fdcan => match len {
|
FrameFormat::Fdcan => match len {
|
||||||
@ -24,9 +24,9 @@ impl DataLength {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// Specialised function to create standard frames
|
/// Specialised function to create classic frames
|
||||||
pub fn new_standard(len: u8) -> DataLength {
|
pub fn new_classic(len: u8) -> DataLength {
|
||||||
Self::new(len, FrameFormat::Standard)
|
Self::new(len, FrameFormat::Classic)
|
||||||
}
|
}
|
||||||
/// Specialised function to create FDCAN frames
|
/// Specialised function to create FDCAN frames
|
||||||
pub fn new_fdcan(len: u8) -> DataLength {
|
pub fn new_fdcan(len: u8) -> DataLength {
|
||||||
@ -36,13 +36,13 @@ impl DataLength {
|
|||||||
/// returns the length in bytes
|
/// returns the length in bytes
|
||||||
pub fn len(&self) -> u8 {
|
pub fn len(&self) -> u8 {
|
||||||
match self {
|
match self {
|
||||||
DataLength::Standard(l) | DataLength::Fdcan(l) => *l,
|
DataLength::Classic(l) | DataLength::Fdcan(l) => *l,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn dlc(&self) -> u8 {
|
pub(crate) fn dlc(&self) -> u8 {
|
||||||
match self {
|
match self {
|
||||||
DataLength::Standard(l) => *l,
|
DataLength::Classic(l) => *l,
|
||||||
// See RM0433 Rev 7 Table 475. DLC coding
|
// See RM0433 Rev 7 Table 475. DLC coding
|
||||||
DataLength::Fdcan(l) => match l {
|
DataLength::Fdcan(l) => match l {
|
||||||
0..=8 => *l,
|
0..=8 => *l,
|
||||||
@ -61,7 +61,7 @@ impl DataLength {
|
|||||||
impl From<DataLength> for FrameFormat {
|
impl From<DataLength> for FrameFormat {
|
||||||
fn from(dl: DataLength) -> FrameFormat {
|
fn from(dl: DataLength) -> FrameFormat {
|
||||||
match dl {
|
match dl {
|
||||||
DataLength::Standard(_) => FrameFormat::Standard,
|
DataLength::Classic(_) => FrameFormat::Classic,
|
||||||
DataLength::Fdcan(_) => FrameFormat::Fdcan,
|
DataLength::Fdcan(_) => FrameFormat::Fdcan,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -121,7 +121,7 @@ impl From<ErrorStateIndicator> for bool {
|
|||||||
/// Type of frame, standard (classic) or FdCAN
|
/// Type of frame, standard (classic) or FdCAN
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
pub enum FrameFormat {
|
pub enum FrameFormat {
|
||||||
Standard = 0,
|
Classic = 0,
|
||||||
Fdcan = 1,
|
Fdcan = 1,
|
||||||
}
|
}
|
||||||
impl From<FrameFormat> for bool {
|
impl From<FrameFormat> for bool {
|
||||||
|
|||||||
@ -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 config;
|
||||||
pub mod filter;
|
pub mod filter;
|
||||||
|
|||||||
@ -167,7 +167,7 @@ impl Registers {
|
|||||||
|
|
||||||
let len = match header_reg.to_data_length() {
|
let len = match header_reg.to_data_length() {
|
||||||
DataLength::Fdcan(len) => len,
|
DataLength::Fdcan(len) => len,
|
||||||
DataLength::Standard(len) => len,
|
DataLength::Classic(len) => len,
|
||||||
};
|
};
|
||||||
if len as usize > ClassicFrame::MAX_DATA_LEN {
|
if len as usize > ClassicFrame::MAX_DATA_LEN {
|
||||||
return None;
|
return None;
|
||||||
@ -202,7 +202,7 @@ impl Registers {
|
|||||||
|
|
||||||
let len = match header_reg.to_data_length() {
|
let len = match header_reg.to_data_length() {
|
||||||
DataLength::Fdcan(len) => len,
|
DataLength::Fdcan(len) => len,
|
||||||
DataLength::Standard(len) => len,
|
DataLength::Classic(len) => len,
|
||||||
};
|
};
|
||||||
if len as usize > FdFrame::MAX_DATA_LEN {
|
if len as usize > FdFrame::MAX_DATA_LEN {
|
||||||
return None;
|
return None;
|
||||||
@ -683,7 +683,7 @@ fn put_tx_header(mailbox: &mut TxBufferElement, header: &Header) {
|
|||||||
let frame_format = if header.len() > 8 || header.fdcan() {
|
let frame_format = if header.len() > 8 || header.fdcan() {
|
||||||
FrameFormat::Fdcan
|
FrameFormat::Fdcan
|
||||||
} else {
|
} else {
|
||||||
FrameFormat::Standard
|
FrameFormat::Classic
|
||||||
};
|
};
|
||||||
let brs = header.len() > 8 || header.bit_rate_switching();
|
let brs = header.len() > 8 || header.bit_rate_switching();
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user