Mbed OS Reference
Loading...
Searching...
No Matches
Mbed Thread

Functions

uint64_t get_ms_count (void)
 Generic thread functions. More...
 
void thread_sleep_for (uint32_t millisec)
 Sleep for a specified time period in millisec: More...
 
void thread_sleep_until (uint64_t millisec)
 Sleep until a specified time in millisec The specified time is according to Kernel::get_ms_count(). More...
 

Detailed Description

Function Documentation

◆ get_ms_count()

uint64_t get_ms_count ( void  )

Generic thread functions.

These are C versions of functions provided in C++ via rtos::Thread and rtos::ThisThread Read the current RTOS kernel millisecond tick count. The tick count corresponds to the tick count the RTOS uses for timing purposes. It increments monotonically from 0 at boot, so it effectively never wraps. If the underlying RTOS only provides a 32-bit tick count, this method expands it to 64 bits.

Returns
RTOS kernel current tick count
Note
Mbed OS always uses millisecond RTOS ticks, and this could only wrap after half a billion years.
In a non-RTOS build, this computes an equivalent time in milliseconds, based on a HAL timer. The time may be referenced as 0 on first call.
You cannot call this function from ISR context.
The equivalent functionality is accessible in C++ via rtos::Kernel::get_ms_count.

◆ thread_sleep_for()

void thread_sleep_for ( uint32_t  millisec)

Sleep for a specified time period in millisec:

Parameters
millisectime delay value
Note
You cannot call this function from ISR context.
The equivalent functionality is accessible in C++ via rtos::ThisThread::sleep_for.

◆ thread_sleep_until()

void thread_sleep_until ( uint64_t  millisec)

Sleep until a specified time in millisec The specified time is according to Kernel::get_ms_count().

Parameters
millisecabsolute time in millisec
Note
You cannot call this function from ISR context.
if millisec is equal to or lower than the current tick count, this returns immediately.
The equivalent functionality is accessible in C++ via ThisThread::sleep_until.