RTEMS CPU Kit with SuperCore  4.11.3
clock.h
Go to the documentation of this file.
1 
21 /* COPYRIGHT (c) 1989-2013.
22  * On-Line Applications Research Corporation (OAR).
23  *
24  * The license and distribution terms for this file may be
25  * found in the file LICENSE in this distribution or at
26  * http://www.rtems.org/license/LICENSE.
27  */
28 
29 #ifndef _RTEMS_RTEMS_CLOCK_H
30 #define _RTEMS_RTEMS_CLOCK_H
31 
32 #include <rtems/score/watchdog.h>
33 #include <rtems/score/tod.h>
34 #include <rtems/rtems/status.h>
35 #include <rtems/rtems/types.h>
36 #include <rtems/config.h>
38 
39 #include <sys/time.h> /* struct timeval */
40 
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54 
58 typedef enum {
70 
92  rtems_clock_get_options option,
93  void *time_buffer
95 
112  rtems_time_of_day *time_buffer
113 );
114 
129  struct timeval *time
130 );
131 
146  rtems_interval *the_interval
147 );
148 
156 {
158 }
159 
168  rtems_interval delta
169 )
170 {
171  return _Watchdog_Ticks_since_boot + delta;
172 }
173 
183  rtems_interval delta_in_usec
184 )
185 {
186  rtems_interval us_per_tick = rtems_configuration_get_microseconds_per_tick();
187 
188  /*
189  * Add one additional tick, since we don't know the time to the clock next
190  * tick.
191  */
193  + (delta_in_usec + us_per_tick - 1) / us_per_tick + 1;
194 }
195 
224  rtems_interval tick
225 )
226 {
227  return (int32_t) ( tick - _Watchdog_Ticks_since_boot ) > 0;
228 }
229 
241 
258  const rtems_time_of_day *time_buffer
259 );
260 
274 
288  struct timespec *uptime
289 );
290 
300 void rtems_clock_get_uptime_timeval( struct timeval *uptime );
301 
308 {
309  return _Timecounter_Time_uptime - 1;
310 }
311 
317 uint64_t rtems_clock_get_uptime_nanoseconds( void );
318 
331 bool _TOD_Validate(
332  const rtems_time_of_day *the_tod
333 );
334 
346  const rtems_time_of_day *the_tod
347 );
348 
349 #ifdef __cplusplus
350 }
351 #endif
352 
355 #endif
356 /* 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
RTEMS_INLINE_ROUTINE time_t rtems_clock_get_uptime_seconds(void)
Returns the system uptime in seconds.
Definition: clock.h:307
rtems_status_code rtems_clock_get(rtems_clock_get_options option, void *time_buffer)
Obtain Current Time of Day.
Definition: clockget.c:34
#define RTEMS_INLINE_ROUTINE
The following (in conjunction with compiler arguments) are used to choose between the use of static i...
Definition: basedefs.h:135
RTEMS_INLINE_ROUTINE rtems_interval rtems_clock_get_ticks_since_boot(void)
Gets the current ticks counter value.
Definition: clock.h:155
volatile time_t _Timecounter_Time_uptime
The uptime in seconds.
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:182
Constants and Structures Associated with Watchdog Timers.
rtems_status_code rtems_clock_get_tod(rtems_time_of_day *time_buffer)
Obtain Current Time of Day (Classic TOD)
Definition: clockgettod.c:83
rtems_status_code rtems_clock_tick(void)
Announce a Clock Tick.
Definition: clocktick.c:24
rtems_status_code rtems_clock_get_tod_timeval(struct timeval *time)
Obtain TOD in struct timeval Format.
Definition: clockgettodtimeval.c:24
Watchdog_Interval rtems_interval
Used to manage and manipulate intervals specified by clock ticks.
Definition: types.h:119
Data structure to manage and manipulate calendar time.
Definition: types.h:133
rtems_status_code
Classic API Status.
Definition: status.h:46
Timecounter Implementation.
This value indicates obtain TOD in Classic API format.
Definition: clock.h:60
rtems_interval rtems_clock_get_ticks_per_second(void)
Obtain Ticks Per Seconds.
Definition: clockgettickspersecond.c:25
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:223
rtems_status_code rtems_clock_set(const rtems_time_of_day *time_buffer)
Set the Current TOD.
Definition: clockset.c:26
Watchdog_Interval _TOD_To_seconds(const rtems_time_of_day *the_tod)
TOD to Seconds.
Definition: clocktodtoseconds.c:45
This value indicates obtain the number of seconds since the epoch.
Definition: clock.h:62
#define RTEMS_COMPILER_DEPRECATED_ATTRIBUTE
Instructs the compiler to issue a warning whenever a variable or function with this attribute will be...
Definition: basedefs.h:186
uint32_t Watchdog_Interval
Type is used to specify the length of intervals.
Definition: watchdog.h:47
Time of Day Handler API.
This value indicates obtain the number of ticks since system boot.
Definition: clock.h:64
This value indicates obtain the TOD in struct timeval format.
Definition: clock.h:68
uint64_t rtems_clock_get_uptime_nanoseconds(void)
Returns the system uptime in nanoseconds.
Definition: clockgetuptimenanoseconds.c:23
rtems_status_code rtems_clock_get_uptime(struct timespec *uptime)
Obtain the System Uptime.
Definition: clockgetuptime.c:38
This value indicates obtain the number of ticks per second.
Definition: clock.h:66
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:167
rtems_clock_get_options
List of things which can be returned by the rtems_clock_get directive.
Definition: clock.h:58
void rtems_clock_get_uptime_timeval(struct timeval *uptime)
Gets the System Uptime in the Struct Timeval Format.
Definition: clockgetuptimetimeval.c:29
volatile Watchdog_Interval _Watchdog_Ticks_since_boot
The watchdog ticks counter.
Definition: watchdogtickssinceboot.c:29