Struct LiteXTimer

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

LiteX hardware timer core

Defined in litex/soc/cores/timer.py.

This peripheral supports counting down a certain interval, either as a oneshot timer or in a repeated fashion.

§Uptime extension

LiteX timers can optionally be extended to feature an uptime register integrated into the timer peripheral, monotonically counting the clock ticks and wrapping at the maximum value.

The uptime register may have a different width as the Timer peripheral itself, hence it must be implemented using a separate type. The type must contain a reference to this Timer instance, since the register is located on this register bank.

Since this extension is not always configured, the Timer features an unsafe function to read the uptime. It must only be called by LiteXTimerUptime struct and only if the uptime has been configured.

Implementations§

Trait Implementations§

Source§

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

Source§

type Frequency = F

The number of ticks per second
Source§

type Ticks = Ticks32

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<'a, R: LiteXSoCRegisterConfiguration, F: Frequency> Timer<'a> for LiteXTimer<'a, R, F>

Source§

fn set_timer_client(&self, client: &'a dyn TimerClient)

Specify the callback to invoke when the timer interval expires. If there was a previously installed callback this call replaces it.
Source§

fn oneshot(&self, interval: Self::Ticks) -> Self::Ticks

Start a one-shot timer that will invoke the callback at least interval ticks in the future. If there is a timer currently pending, calling this cancels that previous timer. After a callback is invoked for a one shot timer, the timer MUST NOT invoke the callback again unless a new timer is started (either with repeating or one shot). Returns the actual interval for the timer that was registered. This MUST NOT be smaller than interval but MAY be larger.
Source§

fn repeating(&self, interval: Self::Ticks) -> Self::Ticks

Start a repeating timer that will invoke the callback every interval ticks in the future. If there is a timer currently pending, calling this cancels that previous timer. Returns the actual interval for the timer that was registered. This MUST NOT be smaller than interval but MAY be larger.
Source§

fn interval(&self) -> Option<Self::Ticks>

Return the interval of the last requested timer.
Source§

fn is_repeating(&self) -> bool

Return if the last requested timer is a repeating timer.
Source§

fn is_oneshot(&self) -> bool

Return if the last requested timer is a one-shot timer.
Source§

fn time_remaining(&self) -> Option<Self::Ticks>

Return how many ticks are remaining until the next callback, or None if the timer is disabled. This call is useful because there may be non-negligible delays between when a timer was requested and it was actually scheduled. Therefore, since a timer’s start might be delayed slightly, the time remaining might be slightly higher than one would expect if one calculated it right before the call to start the timer.
Source§

fn is_enabled(&self) -> bool

Returns whether there is currently a timer enabled and so a callback will be expected in the future. If is_enabled returns false then the implementation MUST NOT invoke a callback until a call to oneshot or repeating restarts the timer.
Source§

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

Cancel the current timer, if any. Value Result<(), ErrorCode> values are: Read more

Auto Trait Implementations§

§

impl<'a, R, F> !Freeze for LiteXTimer<'a, R, F>

§

impl<'a, R, F> !RefUnwindSafe for LiteXTimer<'a, R, F>

§

impl<'a, R, F> !Send for LiteXTimer<'a, R, F>

§

impl<'a, R, F> !Sync for LiteXTimer<'a, R, F>

§

impl<'a, R, F> Unpin for LiteXTimer<'a, R, F>
where F: Unpin,

§

impl<'a, R, F> !UnwindSafe for LiteXTimer<'a, 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.