pub struct LiteXEventManager<'a, T, S, P, E>{ /* private fields */ }
Expand description
LiteX event manager abstraction
A LiteX event manager combines and manages event sources of a LiteX core / peripheral. The event manager itself is connected to an interrupt source in the CPU.
This is an abstraction over an instance of a LiteX EventManager, which is exposed to the operating system using three configuration status registers (LiteX CSRs), as part of the core’s / peripheral’s configuration status registers bank.
Implementations§
Source§impl<'a, T, S, P, E> LiteXEventManager<'a, T, S, P, E>
impl<'a, T, S, P, E> LiteXEventManager<'a, T, S, P, E>
pub const fn new( status: &'a S, pending: &'a P, enable: &'a E, ) -> LiteXEventManager<'a, T, S, P, E>
Sourcepub fn disable_all(&self)
pub fn disable_all(&self)
Disable / suppress all event sources connected to the LiteX event manager.
This will prevent any of the event sources from asserting the event manager’s CPU interrupt.
Sourcepub fn enable_all(&self)
pub fn enable_all(&self)
Enable all event sources connected to the LiteX event manager.
This will make any asserted (pending) event source assert the event manager’s CPU interrupt.
Sourcepub fn disable_event(&self, index: usize)
pub fn disable_event(&self, index: usize)
Disable / suppress an event source connected to the LiteX event manager.
This will prevent the specific event source from asserting the event manager’s CPU interrupt.
The event is addressed by its index in the event manager’s registers (starting at 0).
Sourcepub fn enable_event(&self, index: usize)
pub fn enable_event(&self, index: usize)
Enable an event source connected to the LiteX event manager
This will assert the event manager’s CPU interrupt if this or any other event source is asserted (pending).
The event is addressed by its index in the event manager’s registers (starting at 0).
Sourcepub fn event_enabled(&self, index: usize) -> bool
pub fn event_enabled(&self, index: usize) -> bool
Check whether an event is enabled.
This checks whether an event source may assert the event manager’s CPU interrupt.
The event is addressed by its index in the event manager’s registers (starting at 0).
Sourcepub fn events_enabled(&self) -> T
pub fn events_enabled(&self) -> T
Get all enabled events.
The enabled events are encoded as bits in the returned integer
type, starting from the least significant bit for the first
event source (index 0), where a 1
means enabled and 0
means disabled (suppressed).
Sourcepub fn event_source_input(&self, index: usize) -> bool
pub fn event_source_input(&self, index: usize) -> bool
Get the input signal to an event source.
This returns whether an event source input is currently asserted. This is independent of whether the event is actually enabled or pending.
The event source is addressed by its index in the event manager’s registers (starting at 0).
Sourcepub fn any_event_pending(&self) -> bool
pub fn any_event_pending(&self) -> bool
Check whether any event source is pending.
This returns whether any event source is claiming to be pending. This is irrespective of whether an event source has a specific input or is enabled.
An example for an event source which can be pending irrespective of the current input is an “EventSourceProcess”, which triggers on a falling edge of the input and stays pending until cleared.
Sourcepub fn event_pending(&self, index: usize) -> bool
pub fn event_pending(&self, index: usize) -> bool
Check whether an event source is pending.
This returns whether an event source is claiming to be pending. This is irrespective of whether an event source has a specific input or is enabled.
An example for an event source which can be pending irrespective of the current input is an “EventSourceProcess”, which triggers on a falling edge of the input and stays pending until cleared.
The event source is addressed by its index in the event manager’s registers (starting at 0).
Sourcepub fn events_pending(&self) -> T
pub fn events_pending(&self) -> T
Get all pending events.
The pending events are encoded as bits in the returned integer
type, starting from the least significant bit for the first
event source (index 0), where a 1
means that the event
source is pending.
Sourcepub fn event_asserted(&self, index: usize) -> bool
pub fn event_asserted(&self, index: usize) -> bool
Check whether an event source is asserting the event manager’s CPU interrupt (both enabled and pending).
The event source is addressed by its index in the event manager’s registers (starting at 0).
Sourcepub fn next_asserted(&self) -> Option<usize>
pub fn next_asserted(&self) -> Option<usize>
Get the next asserted event, starting from 0.
If an asserted event was found, its index is returned. Otherwise, None is returned.
This method works by ANDing the enabled and pending bits and using the trailing_zeros intrinsic (of which there may be an optimized version with special instructions). Thus this is faster than a naive, loop-based version.
Sourcepub fn clear_event(&self, index: usize)
pub fn clear_event(&self, index: usize)
Clear a pending event source.
This operation may have side effects in the device (for instance, acknowledge the reception of a UART data word).
It is not guaranteed that the event source will be no longer pending after clearing (for instance when used with FIFOs and pending data, or with an “EventSourceLevel” which can only be cleared by driving the input signal low).
Sourcepub fn clear_all(&self)
pub fn clear_all(&self)
Clear all pending event sources.
This operation may have side effects in the device (for instance, acknowledge the reception of a UART data word).
It is not guaranteed that the event sources will be no longer pending after clearing (for instance when used with FIFOs and pending data, or with an “EventSourceLevel” which can only be cleared by driving the input signal low).