RTEMS
Modules | Files | Classes | Macros | Functions | Variables
Time of Day Handler

Time of Day Handler. More...

Modules

 Time of Day Handler Action Hooks
 Time of Day Handler Action Hooks.
 

Files

file  todimpl.h
 Time of Day Handler API.
 
file  coretod.c
 Initializes the Time of Day Handler.
 

Classes

struct  TOD_Control
 TOD control. More...
 

Macros

#define TOD_SECONDS_PER_MINUTE   (uint32_t)60
 
#define TOD_MINUTES_PER_HOUR   (uint32_t)60
 
#define TOD_MONTHS_PER_YEAR   (uint32_t)12
 
#define TOD_DAYS_PER_YEAR   (uint32_t)365
 
#define TOD_HOURS_PER_DAY   (uint32_t)24
 
#define TOD_SECONDS_PER_DAY
 
#define TOD_SECONDS_PER_NON_LEAP_YEAR   (365 * TOD_SECONDS_PER_DAY)
 
#define TOD_MILLISECONDS_PER_SECOND   (uint32_t)1000
 
#define TOD_MICROSECONDS_PER_SECOND   (uint32_t)1000000
 
#define TOD_NANOSECONDS_PER_SECOND   (uint32_t)1000000000
 
#define TOD_NANOSECONDS_PER_MICROSECOND   (uint32_t)1000
 
#define TOD_TICKS_PER_SECOND   TOD_TICKS_PER_SECOND_method()
 Gets number of ticks in a second. More...
 

Functions

void _TOD_Lock (void)
 Locks the time of day mutex.
 
void _TOD_Unlock (void)
 Unlocks the time of day mutex.
 
static void _TOD_Acquire (ISR_lock_Context *lock_context)
 Checks if api mutex is owner of the time of day mutex. More...
 
static void _TOD_Release (ISR_lock_Context *lock_context)
 Releases the lock context for the timecounter. More...
 
Status_Control _TOD_Set (const struct timespec *tod, ISR_lock_Context *lock_context)
 Sets the time of day. More...
 
static void _TOD_Get (struct timespec *tod)
 Gets the current time in the timespec format. More...
 
static void _TOD_Get_uptime (Timestamp_Control *time)
 Gets the system uptime with potential accuracy to the nanosecond. More...
 
static void _TOD_Get_zero_based_uptime (Timestamp_Control *time)
 Gets the system uptime with potential accuracy to the nanosecond. More...
 
static void _TOD_Get_zero_based_uptime_as_timespec (struct timespec *time)
 Gets the system uptime with potential accuracy to the nanosecond. More...
 
static uint32_t _TOD_Seconds_since_epoch (void)
 Returns Number of seconds Since RTEMS epoch. More...
 
uint32_t TOD_TICKS_PER_SECOND_method (void)
 Gets number of ticks in a second. More...
 
static __inline__ void _TOD_Get_timeval (struct timeval *time)
 This routine returns a timeval based upon the internal timespec format TOD. More...
 
void _TOD_Adjust (const struct timespec *delta)
 Adjusts the Time of Time. More...
 
static __inline__ bool _TOD_Is_set (void)
 Check if the TOD is Set. More...
 

Variables

TOD_Control _TOD
 TOD Management information.
 

Detailed Description

Time of Day Handler.

The following constants are related to the time of day and are independent of RTEMS.

This handler encapsulates functionality used to manage time of day.

Macro Definition Documentation

◆ TOD_DAYS_PER_YEAR

#define TOD_DAYS_PER_YEAR   (uint32_t)365

This constant represents the number of days in a non-leap year.

Definition at line 64 of file todimpl.h.

◆ TOD_HOURS_PER_DAY

#define TOD_HOURS_PER_DAY   (uint32_t)24

This constant represents the number of hours per day.

Definition at line 69 of file todimpl.h.

◆ TOD_MICROSECONDS_PER_SECOND

#define TOD_MICROSECONDS_PER_SECOND   (uint32_t)1000000

This constant represents the number of microseconds in a second.

Definition at line 92 of file todimpl.h.

◆ TOD_MILLISECONDS_PER_SECOND

#define TOD_MILLISECONDS_PER_SECOND   (uint32_t)1000

This constant represents the number of millisecond in a second.

Definition at line 87 of file todimpl.h.

◆ TOD_MINUTES_PER_HOUR

#define TOD_MINUTES_PER_HOUR   (uint32_t)60

This constant represents the number of minutes per hour.

Definition at line 54 of file todimpl.h.

◆ TOD_MONTHS_PER_YEAR

#define TOD_MONTHS_PER_YEAR   (uint32_t)12

This constant represents the number of months in a year.

Definition at line 59 of file todimpl.h.

◆ TOD_NANOSECONDS_PER_MICROSECOND

#define TOD_NANOSECONDS_PER_MICROSECOND   (uint32_t)1000

This constant represents the number of nanoseconds in a mircosecond.

Definition at line 102 of file todimpl.h.

◆ TOD_NANOSECONDS_PER_SECOND

#define TOD_NANOSECONDS_PER_SECOND   (uint32_t)1000000000

This constant represents the number of nanoseconds in a second.

Definition at line 97 of file todimpl.h.

◆ TOD_SECONDS_PER_DAY

#define TOD_SECONDS_PER_DAY
Value:
(uint32_t) (TOD_SECONDS_PER_MINUTE * \
#define TOD_HOURS_PER_DAY
Definition: todimpl.h:69
#define TOD_SECONDS_PER_MINUTE
Definition: todimpl.h:49
#define TOD_MINUTES_PER_HOUR
Definition: todimpl.h:54

This constant represents the number of seconds in a day which does not include a leap second.

Definition at line 75 of file todimpl.h.

◆ TOD_SECONDS_PER_MINUTE

#define TOD_SECONDS_PER_MINUTE   (uint32_t)60

This constant represents the number of seconds in a minute.

Definition at line 49 of file todimpl.h.

◆ TOD_SECONDS_PER_NON_LEAP_YEAR

#define TOD_SECONDS_PER_NON_LEAP_YEAR   (365 * TOD_SECONDS_PER_DAY)

This constant represents the number of seconds in a non-leap year.

Definition at line 82 of file todimpl.h.

◆ TOD_TICKS_PER_SECOND

#define TOD_TICKS_PER_SECOND   TOD_TICKS_PER_SECOND_method()

Gets number of ticks in a second.

This method exists to hide the fact that TOD_TICKS_PER_SECOND can not be implemented as a macro in a .h file due to visibility issues. The Configuration Table is not available to SuperCore .h files but is available to their .c files.

Definition at line 300 of file todimpl.h.

Function Documentation

◆ _TOD_Acquire()

static void _TOD_Acquire ( ISR_lock_Context lock_context)
inlinestatic

Checks if api mutex is owner of the time of day mutex.

Return values
trueIt is owner of the time of day mutex.
falseIt is not owner of the time of day mutex. Acquires the lock context for the timecounter.
Parameters
lock_contextThe lock to acquire.

Definition at line 175 of file todimpl.h.

◆ _TOD_Adjust()

void _TOD_Adjust ( const struct timespec *  delta)

Adjusts the Time of Time.

This method is used to adjust the current time of day by the specified amount.

Parameters
deltais the amount to adjust.

◆ _TOD_Get()

static void _TOD_Get ( struct timespec *  tod)
inlinestatic

Gets the current time in the timespec format.

Parameters
[out]timeThe value gathered by the request.

Definition at line 214 of file todimpl.h.

◆ _TOD_Get_timeval()

static __inline__ void _TOD_Get_timeval ( struct timeval *  time)
static

This routine returns a timeval based upon the internal timespec format TOD.

Parameters
[out]timeThe timeval to be filled in by the method.

Definition at line 308 of file todimpl.h.

◆ _TOD_Get_uptime()

static void _TOD_Get_uptime ( Timestamp_Control time)
inlinestatic

Gets the system uptime with potential accuracy to the nanosecond.

This routine returns the system uptime with potential accuracy to the nanosecond.

The initial uptime value is undefined.

Parameters
[out]timeIs a pointer to the uptime after the method call.

Definition at line 231 of file todimpl.h.

◆ _TOD_Get_zero_based_uptime()

static void _TOD_Get_zero_based_uptime ( Timestamp_Control time)
inlinestatic

Gets the system uptime with potential accuracy to the nanosecond.

The initial uptime value is zero.

Parameters
[out]timeIs a pointer to the uptime after the method call.

Definition at line 245 of file todimpl.h.

◆ _TOD_Get_zero_based_uptime_as_timespec()

static void _TOD_Get_zero_based_uptime_as_timespec ( struct timespec *  time)
inlinestatic

Gets the system uptime with potential accuracy to the nanosecond.

The initial uptime value is zero.

Parameters
[out]timeIs a pointer to the uptime after the method call.

Definition at line 259 of file todimpl.h.

◆ _TOD_Is_set()

static __inline__ bool _TOD_Is_set ( void  )
static

Check if the TOD is Set.

Return values
trueThe time is set.
falseThe time is not set.

Definition at line 333 of file todimpl.h.

◆ _TOD_Release()

static void _TOD_Release ( ISR_lock_Context lock_context)
inlinestatic

Releases the lock context for the timecounter.

Parameters
lock_contextThe lock to release.

Definition at line 185 of file todimpl.h.

◆ _TOD_Seconds_since_epoch()

static uint32_t _TOD_Seconds_since_epoch ( void  )
inlinestatic

Returns Number of seconds Since RTEMS epoch.

The following contains the number of seconds from 00:00:00 January 1, TOD_BASE_YEAR until the current time of day.

Returns
The number of seconds since RTEMS epoch.

Definition at line 275 of file todimpl.h.

◆ _TOD_Set()

Status_Control _TOD_Set ( const struct timespec *  tod,
ISR_lock_Context lock_context 
)

Sets the time of day.

The caller must be the owner of the TOD lock.

Parameters
todThe new time of day in timespec format representing the time since UNIX Epoch.
lock_contextThe ISR lock context used for the corresponding _TOD_Acquire(). The caller must be the owner of the TOD lock. This function will release the TOD lock.
Return values
STATUS_SUCCESSFULSuccessful operation.
otherSome error occurred.

◆ TOD_TICKS_PER_SECOND_method()

uint32_t TOD_TICKS_PER_SECOND_method ( void  )

Gets number of ticks in a second.

This method returns the number of ticks in a second.

Note
If the clock tick value does not multiply evenly into a second then this number of ticks will be slightly shorter than a second.
Returns
The number of ticks in a second.