Skip to content

Commit

Permalink
Expose initialization mode
Browse files Browse the repository at this point in the history
Added initialization_mode method to DynAux trait, to enable software
support for disabling of the CAN bus.
  • Loading branch information
vccaedholm authored and evading committed Oct 24, 2023
1 parent 7de90dc commit 520e9bd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions mcan/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Tagging in git follows a pattern: `mcan/<version>`.

## [Unreleased]
- Add Can::aux::initialization_mode
- Adhere to `filter_map_bool_then` clippy lint (#42)

## [0.3.0] - 2023-04-24
Expand Down
8 changes: 8 additions & 0 deletions mcan/src/bus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -186,6 +190,10 @@ impl<'a, Id: mcan_core::CanId, D: mcan_core::Dependencies<Id>> 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();
}
Expand Down
4 changes: 4 additions & 0 deletions mcan/src/reg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ impl<Id: mcan_core::CanId> Can<Id> {
self.enable_cce();
}

pub(crate) fn initialization_mode(&self) {
self.set_init(true);
}

pub(crate) fn operational_mode(&self) {
self.set_init(false);
}
Expand Down

0 comments on commit 520e9bd

Please sign in to comment.