From 53bee3f4ad501f121a42aa57806062ab40258edb Mon Sep 17 00:00:00 2001 From: Arne Edholm Date: Mon, 9 Oct 2023 23:11:58 +0200 Subject: [PATCH] Expose initialization mode Added initialization_mode method to DynAux trait, to enable software support for disabling of the CAN bus. --- mcan/CHANGELOG.md | 1 + mcan/src/bus.rs | 8 ++++++++ mcan/src/reg.rs | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/mcan/CHANGELOG.md b/mcan/CHANGELOG.md index cb6805c..67e26a7 100644 --- a/mcan/CHANGELOG.md +++ b/mcan/CHANGELOG.md @@ -3,6 +3,7 @@ Tagging in git follows a pattern: `mcan/`. ## [Unreleased] +- Add Can::aux::initialization_mode ## [0.3.0] - 2023-04-24 diff --git a/mcan/src/bus.rs b/mcan/src/bus.rs index c09a701..0762b4e 100644 --- a/mcan/src/bus.rs +++ b/mcan/src/bus.rs @@ -153,6 +153,10 @@ pub trait DynAux { /// CAN dependencies type type Deps; + /// Enters Initialization mode, without enabling configuration, to + /// disable CAN operation. + fn initialization_mode(&self); + /// Re-enters "Normal Operation" if in "Software Initialization" mode. /// In Software Initialization, messages are not received or transmitted. /// Configuration cannot be changed. In Normal Operation, messages can @@ -186,6 +190,10 @@ impl<'a, Id: mcan_core::CanId, D: mcan_core::Dependencies> DynAux for Aux<'a type Id = Id; type Deps = D; + fn initialization_mode(&self) { + self.reg.initialization_mode(); + } + fn operational_mode(&self) { self.reg.operational_mode(); } diff --git a/mcan/src/reg.rs b/mcan/src/reg.rs index 926d1d1..4fe667f 100644 --- a/mcan/src/reg.rs +++ b/mcan/src/reg.rs @@ -49,6 +49,10 @@ impl Can { self.enable_cce(); } + pub(crate) fn initialization_mode(&self) { + self.set_init(true); + } + pub(crate) fn operational_mode(&self) { self.set_init(false); }