Trait CanId

Source
pub unsafe trait CanId {
    const ADDRESS: *const ();
}
Expand description

Trait representing CAN peripheral identity

Types implementing this trait are expected to be used as a marker types that serve the purpose of identifying specific instances of CAN peripherals available on the platform (as there might be more than one). It only conveys where the CAN peripheral HW register is located, not necessarily that it can be accessed. The latter is expressed by the Dependencies trait.

It is also useful for associating Dependencies with specific CanId and setting up additional type constraints preventing application developers from constructing CAN abstractions with incompatible sets of dependencies.

More details in Dependencies documentation.

§Safety

CanId::ADDRESS points to the start of a valid HW register of a CAN peripheral

§Examples

use mcan_core::CanId;

pub enum Can0 {}

unsafe impl CanId for Can0 {
    const ADDRESS: *const () = 0xDEAD0000 as *const _;
}

pub enum Can1 {}

unsafe impl CanId for Can1 {
    const ADDRESS: *const () = 0xBEEF0000 as *const _;
}

Required Associated Constants§

Source

const ADDRESS: *const ()

Static address of HW register controlling corresponding CAN peripheral

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§