µOS++ IIIe Reference 7.0.0
The third edition of µOS++, a POSIX inspired open source framework, written in C++
Loading...
Searching...
No Matches

C API clocks definitions. More...

Classes

struct  os_clock_s
 Clock object storage. More...
 

Typedefs

typedef struct os_clock_s os_clock_t
 Clock object storage.
 

Clock Functions

const char * os_clock_get_name (os_clock_t *clock)
 Get the clock name.
 
os_clock_timestamp_t os_clock_now (os_clock_t *clock)
 Tell the current time, possibly adjusted for epoch.
 
os_clock_timestamp_t os_clock_steady_now (os_clock_t *clock)
 Tell the current time since startup.
 
os_result_t os_clock_sleep_for (os_clock_t *clock, os_clock_duration_t duration)
 Sleep for a relative duration.
 
os_result_t os_clock_sleep_until (os_clock_t *clock, os_clock_timestamp_t timestamp)
 Sleep until an absolute timestamp.
 
os_result_t os_clock_wait_for (os_clock_t *clock, os_clock_duration_t timeout)
 Timed wait for an event.
 
os_clock_offset_t os_clock_get_offset (os_clock_t *clock)
 Get adjustment offset.
 
os_clock_offset_t os_clock_set_offset (os_clock_t *clock, os_clock_offset_t offset)
 Set adjustment offset.
 
os_clock_tos_clock_get_sysclock (void)
 Get sysclock (the system clock).
 
os_clock_tos_clock_get_rtclock (void)
 Get rtclock (the real-time clock).
 
os_clock_tos_clock_get_hrclock (void)
 Get hrclock (the high resolution clock).
 
os_clock_timestamp_t os_sysclock_now (void)
 Tell the current time since startup.
 
os_result_t os_sysclock_sleep_for (os_clock_duration_t duration)
 Sleep for a relative duration.
 
os_result_t os_sysclock_sleep_until (os_clock_timestamp_t timestamp)
 Sleep until an absolute timestamp.
 
os_result_t os_sysclock_wait_for (os_clock_duration_t timeout)
 Timed wait for an event.
 
os_clock_duration_t os_sysclock_ticks_cast (uint32_t microsec)
 Convert microseconds to ticks.
 
os_clock_duration_t os_sysclock_ticks_cast_long (uint64_t microsec)
 Convert microseconds to ticks.
 

Clock handlers

void os_systick_handler (void)
 SysTick interrupt handler.
 
void os_rtc_handler (void)
 RTC interrupt handler.
 

Detailed Description

C API clocks definitions.

For the complete definition, see
RTOS C++ API
Examples
int
os_main (int argc, char* argv[])
{
{
// Return number of ticks since epoch, or, if epoch not set, from startup.
ts = os_sysclock_now ();
// Return the number of ticks since startup.
ts = os_sysclock_steady_now ();
// An event may resume the thread before the timeout expire.
}
}
os_result_t os_sysclock_wait_for(os_clock_duration_t timeout)
Timed wait for an event.
os_clock_timestamp_t os_sysclock_now(void)
Tell the current time since startup.
os_result_t os_sysclock_sleep_until(os_clock_timestamp_t timestamp)
Sleep until an absolute timestamp.
os_result_t os_sysclock_sleep_for(os_clock_duration_t duration)
Sleep for a relative duration.
os_port_clock_timestamp_t os_clock_timestamp_t
Type of variables holding clock time stamps.
Definition os-c-decls.h:199
int os_main(int argc, char *argv[])
Application entry point, running on the main thread context.

Typedef Documentation

◆ os_clock_t

typedef struct os_clock_s os_clock_t

Clock object storage.

This C structure has the same size as the C++ os::rtos::clock object.

The members of this structure are hidden and should not be used directly, but only through specific functions.

See also
os::rtos::clock

Function Documentation

◆ os_clock_get_hrclock()

os_clock_t * os_clock_get_hrclock ( void  )

Get hrclock (the high resolution clock).

Returns
The address of the clock_highres instance.
Note
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::hrclock

Definition at line 1208 of file os-c-wrapper.cpp.

◆ os_clock_get_name()

const char * os_clock_get_name ( os_clock_t clock)

Get the clock name.

Parameters
[in]clockPointer to clock object instance.
Returns
Null terminated string.
Note
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::clock::name()

Definition at line 1073 of file os-c-wrapper.cpp.

◆ os_clock_get_offset()

os_clock_offset_t os_clock_get_offset ( os_clock_t clock)

Get adjustment offset.

Parameters
[in]clockPointer to clock object instance.
Returns
Integer value representing the offset to epoch.
Note
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::adjustable_clock::offset()

Definition at line 1154 of file os-c-wrapper.cpp.

◆ os_clock_get_rtclock()

os_clock_t * os_clock_get_rtclock ( void  )

Get rtclock (the real-time clock).

Returns
The address of the clock_rtc instance.
Note
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::rtclock

Definition at line 1196 of file os-c-wrapper.cpp.

◆ os_clock_get_sysclock()

os_clock_t * os_clock_get_sysclock ( void  )

Get sysclock (the system clock).

Returns
The address of the clock_systick instance.
Note
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::sysclock

Definition at line 1184 of file os-c-wrapper.cpp.

◆ os_clock_now()

os_clock_timestamp_t os_clock_now ( os_clock_t clock)

Tell the current time, possibly adjusted for epoch.

Parameters
[in]clockPointer to clock object instance.
Returns
The clock current timestamp (time units from startup plus the epoch offset).
Note
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::clock::now()

Definition at line 1086 of file os-c-wrapper.cpp.

◆ os_clock_set_offset()

os_clock_offset_t os_clock_set_offset ( os_clock_t clock,
os_clock_offset_t  offset 
)

Set adjustment offset.

Parameters
[in]clockPointer to clock object instance.
[in]offsetInteger representing the offset to epoch (positive).
Returns
Integer value representing the previous offset to epoch.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::adjustable_clock::offset(os::rtos::clock::offset_t)

Definition at line 1168 of file os-c-wrapper.cpp.

◆ os_clock_sleep_for()

os_result_t os_clock_sleep_for ( os_clock_t clock,
os_clock_duration_t  duration 
)

Sleep for a relative duration.

Parameters
[in]clockPointer to clock object instance.
[in]durationThe number of clock units (ticks or seconds) to sleep.
Return values
ETIMEDOUTThe sleep lasted the entire duration.
EPERMCannot be invoked from an Interrupt Service Routines.
EINTRThe sleep was interrupted.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::clock::sleep_for()

Definition at line 1112 of file os-c-wrapper.cpp.

◆ os_clock_sleep_until()

os_result_t os_clock_sleep_until ( os_clock_t clock,
os_clock_timestamp_t  timestamp 
)

Sleep until an absolute timestamp.

Parameters
[in]clockPointer to clock object instance.
[in]timestampThe absolute moment in time, in clock units.
Return values
ETIMEDOUTThe sleep lasted the entire duration.
EPERMCannot be invoked from an Interrupt Service Routines.
EINTRThe sleep was interrupted.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::clock::sleep_until()

Definition at line 1126 of file os-c-wrapper.cpp.

◆ os_clock_steady_now()

os_clock_timestamp_t os_clock_steady_now ( os_clock_t clock)

Tell the current time since startup.

Parameters
[in]clockPointer to clock object instance.
Returns
The clock current timestamp (time units from startup).
Note
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::clock::steady_now()

Definition at line 1099 of file os-c-wrapper.cpp.

◆ os_clock_wait_for()

os_result_t os_clock_wait_for ( os_clock_t clock,
os_clock_duration_t  timeout 
)

Timed wait for an event.

Parameters
[in]clockPointer to clock object instance.
[in]timeoutThe timeout in clock units.
Return values
os_okAn event occurred before the timeout.
ETIMEDOUTThe wait lasted the entire duration.
EPERMCannot be invoked from an Interrupt Service Routines.
EINTRThe sleep was interrupted.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::clock::wait_for()

Definition at line 1140 of file os-c-wrapper.cpp.

◆ os_rtc_handler()

void os_rtc_handler ( void  )

RTC interrupt handler.

Must be called from the physical RTC interrupt handler.

Definition at line 105 of file os-clocks.cpp.

◆ os_sysclock_now()

os_clock_timestamp_t os_sysclock_now ( void  )

Tell the current time since startup.

Parameters
None.
Returns
The number of SysTick input clocks since startup.
Note
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::clock::now()

Definition at line 1222 of file os-c-wrapper.cpp.

◆ os_sysclock_sleep_for()

os_result_t os_sysclock_sleep_for ( os_clock_duration_t  duration)

Sleep for a relative duration.

Parameters
[in]durationThe number of clock units (ticks or seconds) to sleep.
Return values
ETIMEDOUTThe sleep lasted the entire duration.
EPERMCannot be invoked from an Interrupt Service Routines.
EINTRThe sleep was interrupted.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::clock::sleep_for()

Definition at line 1234 of file os-c-wrapper.cpp.

◆ os_sysclock_sleep_until()

os_result_t os_sysclock_sleep_until ( os_clock_timestamp_t  timestamp)

Sleep until an absolute timestamp.

Parameters
[in]timestampThe absolute moment in time, in clock units.
Return values
ETIMEDOUTThe sleep lasted the entire duration.
EPERMCannot be invoked from an Interrupt Service Routines.
EINTRThe sleep was interrupted.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::clock::sleep_until()

Definition at line 1246 of file os-c-wrapper.cpp.

◆ os_sysclock_ticks_cast()

os_clock_duration_t os_sysclock_ticks_cast ( uint32_t  microsec)
inline

Convert microseconds to ticks.

Parameters
[in]microsecThe number of microseconds.
Returns
The number of ticks.

Definition at line 983 of file os-c-api.h.

◆ os_sysclock_ticks_cast_long()

os_clock_duration_t os_sysclock_ticks_cast_long ( uint64_t  microsec)
inline

Convert microseconds to ticks.

Parameters
[in]microsecThe number of microseconds.
Returns
The number of ticks.

Definition at line 997 of file os-c-api.h.

◆ os_sysclock_wait_for()

os_result_t os_sysclock_wait_for ( os_clock_duration_t  timeout)

Timed wait for an event.

Parameters
[in]timeoutThe timeout in clock units.
Return values
os_okAn event occurred before the timeout.
ETIMEDOUTThe wait lasted the entire duration.
EPERMCannot be invoked from an Interrupt Service Routines.
EINTRThe sleep was interrupted.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::clock::wait_for()

Definition at line 1258 of file os-c-wrapper.cpp.

◆ os_systick_handler()

void os_systick_handler ( void  )

SysTick interrupt handler.

Must be called from the physical interrupt handler.

Definition at line 48 of file os-clocks.cpp.