diff options
| author | Corey Schuhen <[email protected]> | 2024-03-02 09:45:30 +1000 |
|---|---|---|
| committer | Corey Schuhen <[email protected]> | 2024-03-02 14:00:56 +1000 |
| commit | bf06d10534fcf6e6f2fd34c1517500a59ed4b626 (patch) | |
| tree | 958a83767d48e04e5b7066fd4c9b17d16162c353 | |
| parent | 9e403fa89aae1d13948fcc15d1cc1f3c709dca88 (diff) | |
Delay setting TX buffer mode until user had a chance to configure it.
| -rw-r--r-- | embassy-stm32/src/can/fd/config.rs | 4 | ||||
| -rw-r--r-- | embassy-stm32/src/can/fd/peripheral.rs | 12 |
2 files changed, 9 insertions, 7 deletions
diff --git a/embassy-stm32/src/can/fd/config.rs b/embassy-stm32/src/can/fd/config.rs index 338e4979d..adaffe9cc 100644 --- a/embassy-stm32/src/can/fd/config.rs +++ b/embassy-stm32/src/can/fd/config.rs | |||
| @@ -290,9 +290,9 @@ impl Default for GlobalFilter { | |||
| 290 | /// TX buffer operation mode | 290 | /// TX buffer operation mode |
| 291 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] | 291 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] |
| 292 | pub enum TxBufferMode { | 292 | pub enum TxBufferMode { |
| 293 | /// TX FIFO operation | 293 | /// TX FIFO operation - In this mode CAN frames are trasmitted strictly in write order. |
| 294 | Fifo, | 294 | Fifo, |
| 295 | /// TX queue operation | 295 | /// TX queue operation - In this mode CAN frames are transmitted according to CAN priority. |
| 296 | Queue, | 296 | Queue, |
| 297 | } | 297 | } |
| 298 | 298 | ||
diff --git a/embassy-stm32/src/can/fd/peripheral.rs b/embassy-stm32/src/can/fd/peripheral.rs index 3a95b2659..f0aab132b 100644 --- a/embassy-stm32/src/can/fd/peripheral.rs +++ b/embassy-stm32/src/can/fd/peripheral.rs | |||
| @@ -307,11 +307,6 @@ impl Registers { | |||
| 307 | "Error reading endianness test value from FDCAN core" | 307 | "Error reading endianness test value from FDCAN core" |
| 308 | ); | 308 | ); |
| 309 | 309 | ||
| 310 | // Framework specific settings are set here | ||
| 311 | |||
| 312 | // set TxBuffer Mode | ||
| 313 | self.regs.txbc().write(|w| w.set_tfqm(_config.tx_buffer_mode.into())); | ||
| 314 | |||
| 315 | // set standard filters list size to 28 | 310 | // set standard filters list size to 28 |
| 316 | // set extended filters list size to 8 | 311 | // set extended filters list size to 8 |
| 317 | // REQUIRED: we use the memory map as if these settings are set | 312 | // REQUIRED: we use the memory map as if these settings are set |
| @@ -357,6 +352,7 @@ impl Registers { | |||
| 357 | /// Applies the settings of a new FdCanConfig See [`FdCanConfig`] | 352 | /// Applies the settings of a new FdCanConfig See [`FdCanConfig`] |
| 358 | #[inline] | 353 | #[inline] |
| 359 | pub fn apply_config(&mut self, config: FdCanConfig) { | 354 | pub fn apply_config(&mut self, config: FdCanConfig) { |
| 355 | self.set_tx_buffer_mode(config.tx_buffer_mode); | ||
| 360 | self.set_data_bit_timing(config.dbtr); | 356 | self.set_data_bit_timing(config.dbtr); |
| 361 | self.set_nominal_bit_timing(config.nbtr); | 357 | self.set_nominal_bit_timing(config.nbtr); |
| 362 | self.set_automatic_retransmit(config.automatic_retransmit); | 358 | self.set_automatic_retransmit(config.automatic_retransmit); |
| @@ -504,6 +500,12 @@ impl Registers { | |||
| 504 | self.regs.cccr().modify(|w| w.set_efbi(enabled)); | 500 | self.regs.cccr().modify(|w| w.set_efbi(enabled)); |
| 505 | } | 501 | } |
| 506 | 502 | ||
| 503 | /// Configures TX Buffer Mode | ||
| 504 | #[inline] | ||
| 505 | pub fn set_tx_buffer_mode(&mut self, tbm: TxBufferMode) { | ||
| 506 | self.regs.txbc().write(|w| w.set_tfqm(tbm.into())); | ||
| 507 | } | ||
| 508 | |||
| 507 | /// Configures frame transmission mode. See | 509 | /// Configures frame transmission mode. See |
| 508 | /// [`FdCanConfig::set_frame_transmit`] | 510 | /// [`FdCanConfig::set_frame_transmit`] |
| 509 | #[inline] | 511 | #[inline] |
