RTEMS: cpukit/include/rtems/rtems/clock.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
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
44extern "C" {
45#endif
46
62 rtems_status_code rtems_clock_get_tod(
63 rtems_time_of_day *time_buffer
64);
65
79 rtems_status_code rtems_clock_get_tod_timeval(
80 struct timeval *time
81);
82
96 rtems_status_code rtems_clock_get_seconds_since_epoch(
97 rtems_interval *the_interval
98);
99
106 RTEMS_INLINE_ROUTINE rtems_interval rtems_clock_get_ticks_since_boot(void)
107{
108 return _Watchdog_Ticks_since_boot;
109}
110
118 RTEMS_INLINE_ROUTINE rtems_interval rtems_clock_tick_later(
119 rtems_interval delta
120)
121{
122 return _Watchdog_Ticks_since_boot + delta;
123}
124
133 RTEMS_INLINE_ROUTINE rtems_interval rtems_clock_tick_later_usec(
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 */
143 return _Watchdog_Ticks_since_boot
144 + (delta_in_usec + us_per_tick - 1) / us_per_tick + 1;
145}
146
174 RTEMS_INLINE_ROUTINE bool rtems_clock_tick_before(
175 rtems_interval tick
176)
177{
178 return (int32_t) ( tick - _Watchdog_Ticks_since_boot ) > 0;
179}
180
191 rtems_interval rtems_clock_get_ticks_per_second(void);
192
193/* Optimized variant for C/C++ without function call overhead */
194#define rtems_clock_get_ticks_per_second() ( _Watchdog_Ticks_per_second )
195
211 rtems_status_code rtems_clock_set(
212 const rtems_time_of_day *time_buffer
213);
214
227 rtems_status_code rtems_clock_tick( void );
228
241 rtems_status_code rtems_clock_get_uptime(
242 struct timespec *uptime
243);
244
254void rtems_clock_get_uptime_timeval( struct timeval *uptime );
255
261time_t rtems_clock_get_uptime_seconds( void );
262
268uint64_t rtems_clock_get_uptime_nanoseconds( void );
269
282bool _TOD_Validate(
283 const rtems_time_of_day *the_tod
284);
285
296 Watchdog_Interval _TOD_To_seconds(
297 const rtems_time_of_day *the_tod
298);
299
300#ifdef __cplusplus
301}
302#endif
303
306#endif
307/* end of include file */
types.h
rtems_clock_get_uptime_nanoseconds
uint64_t rtems_clock_get_uptime_nanoseconds(void)
Returns the system uptime in nanoseconds.
Definition: clockgetuptimenanoseconds.c:25
rtems_clock_get_seconds_since_epoch
rtems_status_code rtems_clock_get_seconds_since_epoch(rtems_interval *the_interval)
Obtain Seconds Since Epoch.
Definition: clockgetsecondssinceepoch.c:24
rtems_clock_get_ticks_per_second
#define rtems_clock_get_ticks_per_second()
Obtain Ticks Per Seconds.
Definition: clock.h:194
rtems_clock_get_uptime_seconds
time_t rtems_clock_get_uptime_seconds(void)
Returns the system uptime in seconds.
Definition: clockgetuptimeseconds.c:28
rtems_clock_get_uptime_timeval
void rtems_clock_get_uptime_timeval(struct timeval *uptime)
Gets the System Uptime in the Struct Timeval Format.
Definition: clockgetuptimetimeval.c:30
rtems_clock_set
rtems_status_code rtems_clock_set(const rtems_time_of_day *time_buffer)
Set the Current TOD.
Definition: clockset.c:25
rtems_clock_tick
rtems_status_code rtems_clock_tick(void)
Announce a Clock Tick.
Definition: clocktick.c:25
rtems_clock_get_tod_timeval
rtems_status_code rtems_clock_get_tod_timeval(struct timeval *time)
Obtain TOD in struct timeval Format.
Definition: clockgettodtimeval.c:24
rtems_clock_get_uptime
rtems_status_code rtems_clock_get_uptime(struct timespec *uptime)
Obtain the System Uptime.
Definition: clockgetuptime.c:39
rtems_clock_tick_later_usec
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_clock_get_ticks_since_boot
RTEMS_INLINE_ROUTINE rtems_interval rtems_clock_get_ticks_since_boot(void)
Gets the current ticks counter value.
Definition: clock.h:106
_TOD_Validate
bool _TOD_Validate(const rtems_time_of_day *the_tod)
TOD Validate.
Definition: clocktodvalidate.c:36
rtems_clock_get_tod
rtems_status_code rtems_clock_get_tod(rtems_time_of_day *time_buffer)
Obtain Current Time of Day (Classic TOD)
Definition: clockgettod.c:84
_TOD_To_seconds
Watchdog_Interval _TOD_To_seconds(const rtems_time_of_day *the_tod)
TOD to Seconds.
Definition: clocktodtoseconds.c:45
rtems_clock_tick_later
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
rtems_clock_tick_before
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_status_code
Classic API Status.
Definition: status.h:43
rtems_interval
Watchdog_Interval rtems_interval
Used to manage and manipulate intervals specified by clock ticks.
Definition: types.h:127
RTEMS_INLINE_ROUTINE
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:66
_Watchdog_Ticks_since_boot
volatile Watchdog_Interval _Watchdog_Ticks_since_boot
The watchdog ticks counter.
Definition: watchdogtickssinceboot.c:29
Watchdog_Interval
uint32_t Watchdog_Interval
Type is used to specify the length of intervals.
Definition: watchdogticks.h:38
status.h
rtems_time_of_day
Data structure to manage and manipulate calendar time.
Definition: types.h:141