stm32: can: fd: allow TX buffers in FIFO mode

This commit is contained in:
Torin Cooper-Bennun 2024-02-27 14:59:02 +00:00 committed by Corey Schuhen
parent 64890498ca
commit 30606f9782
2 changed files with 23 additions and 4 deletions

View file

@ -287,6 +287,24 @@ impl Default for GlobalFilter {
}
}
/// TX buffer operation mode
#[derive(Clone, Copy, Debug)]
pub enum TxBufferMode {
/// TX FIFO operation
Fifo,
/// TX queue operation
Queue,
}
impl From<TxBufferMode> for crate::pac::can::vals::Tfqm {
fn from(value: TxBufferMode) -> Self {
match value {
TxBufferMode::Queue => Self::QUEUE,
TxBufferMode::Fifo => Self::FIFO,
}
}
}
/// FdCan Config Struct
#[derive(Clone, Copy, Debug)]
pub struct FdCanConfig {
@ -327,6 +345,8 @@ pub struct FdCanConfig {
pub timestamp_source: TimestampSource,
/// Configures the Global Filter
pub global_filter: GlobalFilter,
/// TX buffer mode (FIFO or queue)
pub tx_buffer_mode: TxBufferMode,
}
impl FdCanConfig {
@ -433,6 +453,7 @@ impl Default for FdCanConfig {
clock_divider: ClockDivider::_1,
timestamp_source: TimestampSource::None,
global_filter: GlobalFilter::default(),
tx_buffer_mode: TxBufferMode::Queue,
}
}
}

View file

@ -302,10 +302,8 @@ impl Registers {
// Framework specific settings are set here
// set TxBuffer to Queue Mode
self.regs
.txbc()
.write(|w| w.set_tfqm(crate::pac::can::vals::Tfqm::QUEUE));
// set TxBuffer Mode
self.regs.txbc().write(|w| w.set_tfqm(_config.tx_buffer_mode.into()));
// set standard filters list size to 28
// set extended filters list size to 8