pub trait PeripheralManagement<C>where
C: ClockInterface,{
type RegisterType;
// Required methods
fn get_registers(&self) -> &Self::RegisterType;
fn get_clock(&self) -> &C;
fn before_peripheral_access(&self, _: &C, _: &Self::RegisterType);
fn after_peripheral_access(&self, _: &C, _: &Self::RegisterType);
}Expand description
A structure encapsulating a peripheral should implement this trait.
Required Associated Types§
type RegisterType
Required Methods§
Sourcefn get_registers(&self) -> &Self::RegisterType
fn get_registers(&self) -> &Self::RegisterType
How to get a reference to the physical hardware registers (the MMIO struct).
Sourcefn get_clock(&self) -> &C
fn get_clock(&self) -> &C
Which clock feeds this peripheral.
For peripherals with no clock, use
&::kernel::platform::chip::NO_CLOCK_CONTROL.
Sourcefn before_peripheral_access(&self, _: &C, _: &Self::RegisterType)
fn before_peripheral_access(&self, _: &C, _: &Self::RegisterType)
Called before peripheral access.
Responsible for ensure the peripheral can be safely accessed, e.g. that its clock is powered on.
Sourcefn after_peripheral_access(&self, _: &C, _: &Self::RegisterType)
fn after_peripheral_access(&self, _: &C, _: &Self::RegisterType)
Called after peripheral access.
Currently used primarily for power management to check whether the peripheral can be powered off.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".