From 053c64cf54c785960773799fb14421c34cb76f63 Mon Sep 17 00:00:00 2001 From: Pontus Andersson <pontus.andersson@volvocars.com> Date: Mon, 4 Mar 2024 10:05:45 +0100 Subject: [PATCH] Add method to finalize config into initialization mode It is useful for applications to be able to decide when to bring MCAN into operational mode. Therefore, add the option for user to finalize the configuration into initialization mode rather than operational mode directly. --- mcan/CHANGELOG.md | 1 + mcan/src/bus.rs | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/mcan/CHANGELOG.md b/mcan/CHANGELOG.md index 7f6bbdc..4635277 100644 --- a/mcan/CHANGELOG.md +++ b/mcan/CHANGELOG.md @@ -5,6 +5,7 @@ Tagging in git follows a pattern: `mcan/<version>`. ## [Unreleased] - *Breaking* Update the register mappings with svd2rust 0.30.2 and form 0.10.0 (#46) - Add safe way to shutdown the bus when actively transmitting/receiving (#45) +- Add method to finalize configuration into initialization mode (#ChangeMe) ## [0.4.0] - 2023-10-24 diff --git a/mcan/src/bus.rs b/mcan/src/bus.rs index c60ddf2..f366ac1 100644 --- a/mcan/src/bus.rs +++ b/mcan/src/bus.rs @@ -575,6 +575,16 @@ impl<'a, Id: mcan_core::CanId, D: mcan_core::Dependencies<Id>, C: Capacities> Ok(can) } + /// Locks the configuration and enters initialization mode. + pub fn finalize_initialized(mut self) -> Result<Can<'a, Id, D, C>, ConfigurationError> { + self.apply_configuration()?; + + let can = self.0; + can.aux.initialization_mode(); + + Ok(can) + } + /// Locks the configuration and enters normal operation. pub fn finalize(mut self) -> Result<Can<'a, Id, D, C>, ConfigurationError> { self.apply_configuration()?;