Struct xous_api_ticktimer::Ticktimer

source ·
pub struct Ticktimer { /* private fields */ }

Implementations§

source§

impl Ticktimer

source

pub fn new() -> Result<Self, Error>

source

pub fn elapsed_ms(&self) -> u64

Return the number of milliseconds that have elapsed since boot. The returned value is guaranteed to always be the same or greater than the previous value, even through suspend/resume cycles. During suspend, the counter does not advance, so loops which rely on this value will not perceive any extra time passing through a suspend/resume cycle.

This call is expected to be infalliable, and removing the error handling path makes it a little more efficient in a tight loop.

§Returns:
* A `u64` that is the number of milliseconds elapsed since boot.
source

pub fn sleep_ms(&self, ms: usize) -> Result<(), Error>

Sleep for at least ms milliseconds. Blocks until the requested time has passed.

§Arguments:
* ms: A `usize` specifying how many milliseconds to sleep for
source

pub fn ping_wdt(&self)

Ping the watchdog timer. Processes may use this to periodically ping the WDT to prevent the system from resetting itself. Note that every call to sleep_ms() also implicitly pings the WDT, so in more complicated systems an explicit call is not needed.

source

pub fn get_version(&self) -> String

Query version information embedded in this implementation crate by the build system.

§Returns:
* A `String` containing the version information of the latest build
source

pub fn get_version_semver(&self) -> SemVer

source

pub fn lock_mutex(&self, mtx: usize)

Lock the given Mutex. Blocks until the Mutex is locked.

Note that Mutexes start out in a Locked state and move into an Unlocked state by calling Unlock on their pointer. For example, the following will probably block forever:

`TickTimer.lock_mutex(1)`

In order to create a new Mutex, you must first Unlock it. For example, the following is allowed:

`TickTimer.unlock_mutex(1)`
`TickTimer.lock_mutex(1)`
`TickTimer.unlock_mutex(1)`
§Arguments:
* mtx: A `usize` referring to the Mutex. This is probably a pointer, but can be any `usize`
source

pub fn unlock_mutex(&self, mtx: usize)

Unlock the given Mutex. Does not block. If the Mutex is not locked, then it will be “doubly-unlocked”. That is, if you Unlock a mutex twice, then you can Lock it twice without blocking.

§Arguments:
* mtx: A `usize` referring to the Mutex. This is probably a pointer, but can be any `usize`
source

pub fn wait_condition(&self, condvar: usize, duration: Option<Duration>) -> bool

Wait for a Condition on the given condvar, with an optional Duration

§Arguments:
* condvar: A `usize` referring to the Condvar. This is probably a pointer, but can be any `usize`
* duration: The amount of time to wait for a signal, if any
§Returns:
* true: the condition was successfully received
* false: the condition was not received and the operation itmed out
source

pub fn notify_condition(&self, condvar: usize, count: usize)

Notify a condition to one or more Waiters

§Arguments:
* condvar: A `usize` referring to the Condvar. This is probably a pointer, but can be any `usize`
* count: The number of Waiters to wake up

Trait Implementations§

source§

impl Debug for Ticktimer

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for Ticktimer

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

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> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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> Pointee for T

§

type Metadata = ()

The type for metadata in pointers and references to Self.
source§

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

§

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>,

§

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.