diff --git a/mcan/CHANGELOG.md b/mcan/CHANGELOG.md index 4210429..24c8716 100644 --- a/mcan/CHANGELOG.md +++ b/mcan/CHANGELOG.md @@ -3,6 +3,7 @@ Tagging in git follows a pattern: `mcan/`. ## [Unreleased] +- Add method to check if bus is dominant (#51) ## [0.5.0] - 2024-03-04 diff --git a/mcan/src/bus.rs b/mcan/src/bus.rs index 17d6084..4fd3038 100644 --- a/mcan/src/bus.rs +++ b/mcan/src/bus.rs @@ -199,6 +199,9 @@ pub trait DynAux { /// /// If timestamping is disabled, its value is zero. fn timestamp(&self) -> u16; + + /// Returns `true` if the CAN bus is dominant. + fn is_dominant(&self) -> bool; } impl> Aux<'_, Id, D> { @@ -242,6 +245,10 @@ impl> DynAux for Aux<'_, Id fn timestamp(&self) -> u16 { self.reg.tscv.read().tsc().bits() } + + fn is_dominant(&self) -> bool { + self.reg.test.read().rx().bit_is_clear() + } } /// A CAN bus in configuration mode. Before messages can be sent and received,