From a30dab19d21aa2017b40ebab9da6656ad644ba52 Mon Sep 17 00:00:00 2001 From: Pontus Andersson Date: Fri, 29 Aug 2025 08:31:06 +0200 Subject: [PATCH] Add method to disable automatic retransmission To support time-triggered communication as described in ISO 11898-1:2015, automatic retransmission can be disabled through the DynAux trait. --- mcan/CHANGELOG.md | 5 ++++- mcan/src/bus.rs | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/mcan/CHANGELOG.md b/mcan/CHANGELOG.md index a073e12..caf63f1 100644 --- a/mcan/CHANGELOG.md +++ b/mcan/CHANGELOG.md @@ -3,7 +3,10 @@ Tagging in git follows a pattern: `mcan/`. ## [Unreleased] -- Added support for fractional baudrates (#59) + +### Added +- Add support for fractional baudrates (#59) +- Add method to disable automatic retransmission (#60) ## [0.7.0] - 2025-04-23 diff --git a/mcan/src/bus.rs b/mcan/src/bus.rs index 751ca25..76b9fd3 100644 --- a/mcan/src/bus.rs +++ b/mcan/src/bus.rs @@ -205,6 +205,12 @@ pub trait DynAux { /// Returns `true` if the TX FIFO/Queue is full. fn tx_buffer_full(&self) -> bool; + + /// Enable or disable automatic retransmission of messages that are not + /// transmitted successfully. + /// + /// Note: This is enabled by default. + fn automatic_retransmission(&self, enabled: bool); } impl> Aux<'_, Id, D> { @@ -256,6 +262,10 @@ impl> DynAux for Aux<'_, Id fn tx_buffer_full(&self) -> bool { self.reg.txfqs.read().tfqf().bit_is_set() } + + fn automatic_retransmission(&self, enabled: bool) { + self.reg.cccr.modify(|_, w| w.dar().variant(!enabled)); + } } /// A CAN bus in configuration mode. Before messages can be sent and received,