µOS++ IIIe / CMSIS++ / POSIX++ Reference  v6.3.11
“Perfekt ist nicht gut genug”
The third edition of µOS++ and CMSIS++, a proposal for the next generation CMSIS, written in C++.

C API clocks definitions. More...

Classes

struct  os_clock_s
 Clock object storage. More...
 

Types

typedef struct os_clock_s os_clock_t
 Clock object storage. More...
 

Clock Functions

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

Clock handlers

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

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.
}
}

Types

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_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 1293 of file os-c-wrapper.cpp.

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 1138 of file os-c-wrapper.cpp.

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 1231 of file os-c-wrapper.cpp.

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 1279 of file os-c-wrapper.cpp.

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 1265 of file os-c-wrapper.cpp.

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 1153 of file os-c-wrapper.cpp.

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(offset_t)

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

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 1183 of file os-c-wrapper.cpp.

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 1199 of file os-c-wrapper.cpp.

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 1168 of file os-c-wrapper.cpp.

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 1215 of file os-c-wrapper.cpp.

void os_rtc_handler ( void  )

RTC interrupt handler.

Must be called from the physical RTC interrupt handler.

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

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 1309 of file os-c-wrapper.cpp.

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 1323 of file os-c-wrapper.cpp.

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 1337 of file os-c-wrapper.cpp.

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 974 of file os-c-api.h.

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 988 of file os-c-api.h.

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 1351 of file os-c-wrapper.cpp.

void os_systick_handler ( void  )

SysTick interrupt handler.

Must be called from the physical interrupt handler.

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