Struct LiteXAlarm

Source
pub struct LiteXAlarm<'t, 'c, R: LiteXSoCRegisterConfiguration, F: Frequency> { /* private fields */ }
Expand description

LiteX alarm implementation, based on LiteXTimer and LiteXTimerUptime

LiteX does not have an Alarm compatible hardware peripheral, so an Alarm is emulated using a repeatedly set LiteXTimer, comparing the current time against the LiteXTimerUptime (which is also exposed as Time::now.

Implementations§

Source§

impl<'t, 'c, R: LiteXSoCRegisterConfiguration, F: Frequency> LiteXAlarm<'t, 'c, R, F>

Source

pub fn new( uptime: &'t LiteXTimerUptime<'t, R, F>, timer: &'t LiteXTimer<'t, R, F>, ) -> LiteXAlarm<'t, 'c, R, F>

Source

pub fn initialize(&'t self)

Initialize the LiteXAlarm

This will register itself as a client for the underlying LiteXTimer.

Trait Implementations§

Source§

impl<'c, R: LiteXSoCRegisterConfiguration, F: Frequency> Alarm<'c> for LiteXAlarm<'_, 'c, R, F>

Source§

fn set_alarm_client(&self, client: &'c dyn AlarmClient)

Specify the callback for when the counter reaches the alarm value. If there was a previously installed callback this call replaces it.
Source§

fn set_alarm(&self, reference: Self::Ticks, dt: Self::Ticks)

Specify when the callback should be called and enable it. The callback will be enqueued when Time::now() == reference + dt. The callback itself may not run exactly at this time, due to delays. However, it it assured to execute after reference + dt: it can be delayed but will never fire early. The method takes reference and dt rather than a single value denoting the counter value so it can distinguish between alarms which have very recently already passed and those in the far far future (see #1651).
Source§

fn get_alarm(&self) -> Self::Ticks

Return the current alarm value. This is undefined at boot and otherwise returns now + dt from the last call to set_alarm.
Source§

fn is_armed(&self) -> bool

Returns whether the alarm is currently armed. Note that this does not reliably indicate whether there will be a future callback: it is possible that the alarm has triggered (and disarmed) and a callback is pending and has not been called yet. In this case it possible for is_armed to return false yet to receive a callback.
Source§

fn disarm(&self) -> Result<(), ErrorCode>

Disable the alarm and stop it from firing in the future. Valid Result<(), ErrorCode> codes are: Read more
Source§

fn minimum_dt(&self) -> Self::Ticks

Return the minimum dt value that is supported. Any dt smaller than this will automatically be increased to this minimum value.
Source§

impl<'t, R: LiteXSoCRegisterConfiguration, F: Frequency> Time for LiteXAlarm<'t, '_, R, F>

Source§

type Frequency = F

The number of ticks per second
Source§

type Ticks = <LiteXTimerUptime<'t, R, F> as Time>::Ticks

The width of a time value
Source§

fn now(&self) -> Self::Ticks

Returns a timestamp. Depending on the implementation of Time, this could represent either a static timestamp or a sample of a counter; if an implementation relies on it being constant or changing it should use Timestamp or Counter.
Source§

impl<R: LiteXSoCRegisterConfiguration, F: Frequency> TimerClient for LiteXAlarm<'_, '_, R, F>

Source§

fn timer(&self)

Auto Trait Implementations§

§

impl<'t, 'c, R, F> !Freeze for LiteXAlarm<'t, 'c, R, F>

§

impl<'t, 'c, R, F> !RefUnwindSafe for LiteXAlarm<'t, 'c, R, F>

§

impl<'t, 'c, R, F> !Send for LiteXAlarm<'t, 'c, R, F>

§

impl<'t, 'c, R, F> !Sync for LiteXAlarm<'t, 'c, R, F>

§

impl<'t, 'c, R, F> Unpin for LiteXAlarm<'t, 'c, R, F>

§

impl<'t, 'c, R, F> !UnwindSafe for LiteXAlarm<'t, 'c, R, F>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.