Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 method to check if bus is dominant (#51)

## [0.5.0] - 2024-03-04

Expand Down
7 changes: 7 additions & 0 deletions mcan/src/bus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Id: mcan_core::CanId, D: mcan_core::Dependencies<Id>> Aux<'_, Id, D> {
Expand Down Expand Up @@ -242,6 +245,10 @@ impl<Id: mcan_core::CanId, D: mcan_core::Dependencies<Id>> 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,
Expand Down