µOS++ IIIe Reference  v6.3.15
“Perfekt ist nicht gut genug”
The third edition of µOS++, a POSIX inspired open source system, written in C++.
os::rtos::clock Class Referenceabstract

Generic clock. More...

#include <cmsis-plus/rtos/os.h>

Inherits os::rtos::internal::object_named.

Inherited by os::rtos::adjustable_clock, os::rtos::clock_highres, and os::rtos::clock_systick.

Public Types

Types & Constants
using duration_t = port::clock::duration_t
 Type of variables holding clock durations. More...
 
using timestamp_t = port::clock::timestamp_t
 Type of variables holding clock time stamps. More...
 
using offset_t = port::clock::offset_t
 Type of variables holding clock offsets. More...
 

Public Member Functions

Constructors & Destructor
virtual ~clock ()
 Destruct the clock object instance. More...
 
Public Member Functions
virtual void start (void)=0
 Start the clock. More...
 
virtual timestamp_t now (void)
 Tell the current time, possibly adjusted for epoch. More...
 
timestamp_t steady_now (void)
 Tell the current time since startup. More...
 
result_t sleep_for (duration_t duration)
 Sleep for a relative duration. More...
 
virtual result_t sleep_until (timestamp_t timestamp)
 Sleep until an absolute timestamp. More...
 
result_t wait_for (duration_t timeout)
 Timed wait for an event. More...
 
timestamp_t update_for_slept_time (duration_t duration)
 Increase the internal count after a deep sleep. More...
 
Public Member Functions
const char * name (void) const
 Get object name. More...
 

Detailed Description

Generic clock.

Used as base class for all clocks.

Definition at line 54 of file os-clocks.h.

Constructor & Destructor Documentation

◆ ~clock()

os::rtos::clock::~clock ( )
virtual

Destruct the clock object instance.

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

Member Function Documentation

◆ name()

const char * os::rtos::internal::object_named::name ( void  ) const
inlineinherited

Get object name.

Parameters
None.
Returns
A null terminated string.

All objects return a non-null string; anonymous objects return "-".

Note
Can be invoked from Interrupt Service Routines.

Definition at line 760 of file os-decls.h.

◆ now()

clock::timestamp_t os::rtos::clock::now ( void  )
virtual

Tell the current time, possibly adjusted for epoch.

Parameters
None.
Returns
The clock current timestamp (time units from startup plus the epoch offset).
Note
Can be invoked from Interrupt Service Routines.

Reimplemented in os::rtos::clock_highres, and os::rtos::adjustable_clock.

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

◆ sleep_for()

result_t os::rtos::clock::sleep_for ( 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.

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

◆ sleep_until()

result_t os::rtos::clock::sleep_until ( timestamp_t  timestamp)
virtual

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.

Reimplemented in os::rtos::adjustable_clock.

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

◆ start()

void os::rtos::clock::start ( void  )
pure virtual

Start the clock.

Parameters
None.
Returns
Nothing.

For system clocks it is called from the system startup code.

Implemented in os::rtos::clock_highres, os::rtos::clock_rtc, and os::rtos::clock_systick.

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

◆ steady_now()

clock::timestamp_t os::rtos::clock::steady_now ( void  )

Tell the current time since startup.

Parameters
None.
Returns
The clock current steady timestamp (time units from startup).
Note
Can be invoked from Interrupt Service Routines.

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

◆ update_for_slept_time()

clock::timestamp_t os::rtos::clock::update_for_slept_time ( duration_t  duration)

Increase the internal count after a deep sleep.

Parameters
durationNumber of ticks lost during sleep.
Returns
The clock current steady timestamp (time units from startup).

During deep sleep the interrupts used to count clock ticks are usually disabled and an external RTC is configured to wake-up the device, so a number of clock ticks are lost.

To keep the clocks accurate, it is recommended to sample the external RTC before entering deep sleep and again when the device is back to life, compute the time slept as difference, and use this function to update the internal clock counter.

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

◆ wait_for()

result_t os::rtos::clock::wait_for ( duration_t  timeout)

Timed wait for an event.

Parameters
[in]timeoutThe timeout in clock units.
Return values
result::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.

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


The documentation for this class was generated from the following files: