RTEMS  5.1
clock.h
Go to the documentation of this file.
1 
18 /* COPYRIGHT (c) 1989-2013.
19  * On-Line Applications Research Corporation (OAR).
20  *
21  * The license and distribution terms for this file may be
22  * found in the file LICENSE in this distribution or at
23  * http://www.rtems.org/license/LICENSE.
24  */
25 
26 #ifndef _RTEMS_RTEMS_CLOCK_H
27 #define _RTEMS_RTEMS_CLOCK_H
28 
29 #include <rtems/rtems/status.h>
30 #include <rtems/rtems/types.h>
31 #include <rtems/config.h>
32 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
63  rtems_time_of_day *time_buffer
64 );
65 
80  struct timeval *time
81 );
82 
97  rtems_interval *the_interval
98 );
99 
107 {
109 }
110 
119  rtems_interval delta
120 )
121 {
122  return _Watchdog_Ticks_since_boot + delta;
123 }
124 
134  rtems_interval delta_in_usec
135 )
136 {
137  rtems_interval us_per_tick = rtems_configuration_get_microseconds_per_tick();
138 
139  /*
140  * Add one additional tick, since we don't know the time to the clock next
141  * tick.
142  */
144  + (delta_in_usec + us_per_tick - 1) / us_per_tick + 1;
145 }
146 
175  rtems_interval tick
176 )
177 {
178  return (int32_t) ( tick - _Watchdog_Ticks_since_boot ) > 0;
179 }
180 
192 
193 /* Optimized variant for C/C++ without function call overhead */
194 #define rtems_clock_get_ticks_per_second() ( _Watchdog_Ticks_per_second )
195 
212  const rtems_time_of_day *time_buffer
213 );
214 
228 
242  struct timespec *uptime
243 );
244 
254 void rtems_clock_get_uptime_timeval( struct timeval *uptime );
255 
261 time_t rtems_clock_get_uptime_seconds( void );
262 
268 uint64_t rtems_clock_get_uptime_nanoseconds( void );
269 
282 bool _TOD_Validate(
283  const rtems_time_of_day *the_tod
284 );
285 
297  const rtems_time_of_day *the_tod
298 );
299 
300 #ifdef __cplusplus
301 }
302 #endif
303 
306 #endif
307 /* end of include file */
rtems_status_code rtems_clock_get_seconds_since_epoch(rtems_interval *the_interval)
Obtain Seconds Since Epoch.
Definition: clockgetsecondssinceepoch.c:24
bool _TOD_Validate(const rtems_time_of_day *the_tod)
TOD Validate.
Definition: clocktodvalidate.c:36
uint32_t Watchdog_Interval
Type is used to specify the length of intervals.
Definition: watchdogticks.h:38
Watchdog_Interval rtems_interval
Used to manage and manipulate intervals specified by clock ticks.
Definition: types.h:127
RTEMS_INLINE_ROUTINE rtems_interval rtems_clock_get_ticks_since_boot(void)
Gets the current ticks counter value.
Definition: clock.h:106
RTEMS_INLINE_ROUTINE rtems_interval rtems_clock_tick_later_usec(rtems_interval delta_in_usec)
Returns the ticks counter value at least delta microseconds in the future.
Definition: clock.h:133
rtems_status_code rtems_clock_get_tod(rtems_time_of_day *time_buffer)
Obtain Current Time of Day (Classic TOD)
Definition: clockgettod.c:84
rtems_status_code rtems_clock_tick(void)
Announce a Clock Tick.
Definition: clocktick.c:25
rtems_status_code rtems_clock_get_tod_timeval(struct timeval *time)
Obtain TOD in struct timeval Format.
Definition: clockgettodtimeval.c:24
Data structure to manage and manipulate calendar time.
Definition: types.h:141
rtems_status_code
Classic API Status.
Definition: status.h:43
#define rtems_clock_get_ticks_per_second()
Obtain Ticks Per Seconds.
Definition: clock.h:194
RTEMS_INLINE_ROUTINE bool rtems_clock_tick_before(rtems_interval tick)
Returns true if the current ticks counter value indicates a time before the time specified by the tic...
Definition: clock.h:174
rtems_status_code rtems_clock_set(const rtems_time_of_day *time_buffer)
Set the Current TOD.
Definition: clockset.c:25
Watchdog_Interval _TOD_To_seconds(const rtems_time_of_day *the_tod)
TOD to Seconds.
Definition: clocktodtoseconds.c:45
uint64_t rtems_clock_get_uptime_nanoseconds(void)
Returns the system uptime in nanoseconds.
Definition: clockgetuptimenanoseconds.c:25
rtems_status_code rtems_clock_get_uptime(struct timespec *uptime)
Obtain the System Uptime.
Definition: clockgetuptime.c:39
RTEMS_INLINE_ROUTINE rtems_interval rtems_clock_tick_later(rtems_interval delta)
Returns the ticks counter value delta ticks in the future.
Definition: clock.h:118
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:66
volatile Watchdog_Interval _Watchdog_Ticks_since_boot
The watchdog ticks counter.
Definition: watchdogtickssinceboot.c:29
void rtems_clock_get_uptime_timeval(struct timeval *uptime)
Gets the System Uptime in the Struct Timeval Format.
Definition: clockgetuptimetimeval.c:30
time_t rtems_clock_get_uptime_seconds(void)
Returns the system uptime in seconds.
Definition: clockgetuptimeseconds.c:28