Struct xous_api_ticktimer::Ticktimer
source · pub struct Ticktimer { /* private fields */ }
Implementations§
source§impl Ticktimer
impl Ticktimer
pub fn new() -> Result<Self, Error>
sourcepub fn elapsed_ms(&self) -> u64
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.
sourcepub fn sleep_ms(&self, ms: usize) -> Result<(), Error>
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
sourcepub fn ping_wdt(&self)
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.
sourcepub fn get_version(&self) -> String
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
pub fn get_version_semver(&self) -> SemVer
sourcepub fn lock_mutex(&self, mtx: usize)
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`
sourcepub fn unlock_mutex(&self, mtx: usize)
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`
sourcepub fn wait_condition(&self, condvar: usize, duration: Option<Duration>) -> bool
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
sourcepub fn notify_condition(&self, condvar: usize, count: usize)
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