RTEMS 6.1-rc6
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables

This header file provides the interfaces of the Time of Day Handler and the Time of Day Handler Action Hooks. More...

#include <rtems/score/status.h>
#include <rtems/score/timestamp.h>
#include <rtems/score/timecounterimpl.h>
#include <rtems/score/watchdog.h>
#include <rtems/score/watchdogticks.h>
#include <sys/time.h>
#include <time.h>

Go to the source code of this file.

Data Structures

struct  TOD_Control
 TOD control. More...
 
struct  TOD_Hook
 Structure to manage each TOD action hook. 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_SECONDS_1970_THROUGH_1988
 
#define TOD_SECONDS_1970_THROUGH_2400   13569465600
 Seconds from 1970-01-01T00:00:00Z to 2400-01-01T00:00:00Z.
 
#define TOD_BASE_YEAR   1988
 Earliest year to which an time of day can be initialized.
 
#define TOD_LATEST_YEAR   2099
 Latest year to which a time of day can be initialized.
 
#define TOD_TICKS_PER_SECOND   _Watchdog_Ticks_per_second
 Gets number of ticks in a second.
 

Typedefs

typedef struct TOD_Hook TOD_Hook
 Structure to manage each TOD action hook.
 

Enumerations

enum  TOD_Action { TOD_ACTION_SET_CLOCK }
 Possible actions where a registered hook could be invoked. More...
 

Functions

void _TOD_Lock (void)
 Locks the time of day mutex.
 
void _TOD_Unlock (void)
 Unlocks the time of day mutex.
 
Status_Control _TOD_Is_valid_new_time_of_day (const struct timespec *tod)
 Checks the time point is a valid new time of day for _TOD_Set().
 
Status_Control _TOD_Set (const struct timespec *tod, ISR_lock_Context *lock_context)
 Sets the time of day.
 
void _TOD_Hook_Register (TOD_Hook *hook)
 Add a TOD Action Hook.
 
void _TOD_Hook_Unregister (TOD_Hook *hook)
 Remove a TOD Action Hook.
 
Status_Control _TOD_Hook_Run (TOD_Action action, const struct timespec *tod)
 Run the TOD Action Hooks.
 

Variables

TOD_Control _TOD
 TOD Management information.
 
const uint16_t _TOD_Days_to_date [2][13]
 This array contains the number of days in all months up to the month indicated by the index of the second dimension.
 
Chain_Control _TOD_Hooks
 Set of registered methods for TOD Actions.
 

Detailed Description

This header file provides the interfaces of the Time of Day Handler and the Time of Day Handler Action Hooks.

Macro Definition Documentation

◆ TOD_BASE_YEAR

#define TOD_BASE_YEAR   1988

Earliest year to which an time of day can be initialized.

The following constant define the earliest year to which an time of day can be initialized. This is considered the epoch.

◆ TOD_LATEST_YEAR

#define TOD_LATEST_YEAR   2099

Latest year to which a time of day can be initialized.

The following constant defines the latest year to which an RTEMS time of day can be set using rtems_clock_set().

32 bits can accept as latest point in time 2106-Feb-7 6:28:15 but to simplify the implementation, is was decided to only check that the year is not greater than the year of this constant. The year 2099 was chosen because all years evenly divisible by 4 from 1988 to 2099 are leap years. In this time frame, years evenly divisible by 100 are no leap years unless they are evenly divisible by 400. Thus the year 2000 is a leap year.

The internal CLOCK_REALTIME can run centuries longer but in contrast to the POSIX API, the RTEMS Classic API does not support this for efficiency reasons.

◆ TOD_SECONDS_1970_THROUGH_1988

#define TOD_SECONDS_1970_THROUGH_1988
Value:
(((1987 - 1970 + 1) * TOD_SECONDS_PER_NON_LEAP_YEAR) + \
#define TOD_SECONDS_PER_NON_LEAP_YEAR
Definition: todimpl.h:104
#define TOD_SECONDS_PER_DAY
Definition: todimpl.h:97

Seconds from January 1, 1970 to January 1, 1988. Used to account for differences between POSIX API and RTEMS core. The timespec format time is kept in POSIX compliant form.

◆ TOD_SECONDS_1970_THROUGH_2400

#define TOD_SECONDS_1970_THROUGH_2400   13569465600

Seconds from 1970-01-01T00:00:00Z to 2400-01-01T00:00:00Z.

This is the latest time of day which should be set by _TOD_Set(). The year 2400 was chosen to guarantee a defined CLOCK_REALTIME within the range of a system uptime of about 114 years.