RTEMS: Clocks

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
Files | Macros | Functions
Clocks
API » Classic

## Files
file | clock.h
file | clockgetsecondssinceepoch.c
| Obtain Seconds Since Epoch.
file | clockgettickspersecond.c
| Obtain Ticks Per Seconds.
file | clockgettod.c
| Obtain Current Time of Day (Classic TOD)
file | clockgettodtimeval.c
| Obtain TOD in struct timeval Format.
file | clockgetuptime.c
| Obtain the System Uptime.
file | clockgetuptimenanoseconds.c
| Returns the system uptime in seconds.
file | clockgetuptimeseconds.c
file | clockgetuptimetimeval.c
| Gets the System Uptime in the Struct Timeval Format.
file | clockset.c
| Set the Current TOD.
file | clocktick.c
| Announce a Clock Tick.
file | clocktodtoseconds.c
| TOD to Seconds.
file | clocktodvalidate.c
| TOD Validate.
file | rtclock.c
| No Initialization Routine.

## Macros
#define | rtems_clock_get_ticks_per_second(void) ( _Watchdog_Ticks_per_second )
| Obtain Ticks Per Seconds.

## Functions
rtems_status_code | rtems_clock_get_tod (rtems_time_of_day *time_buffer)
| Obtain Current Time of Day (Classic TOD)
rtems_status_code | rtems_clock_get_tod_timeval (struct timeval *time)
| Obtain TOD in struct timeval Format.
rtems_status_code | rtems_clock_get_seconds_since_epoch (rtems_interval *the_interval)
| Obtain Seconds Since Epoch.
RTEMS_INLINE_ROUTINE rtems_interval | rtems_clock_get_ticks_since_boot (void)
| Gets the current ticks counter value.
RTEMS_INLINE_ROUTINE rtems_interval | rtems_clock_tick_later (rtems_interval delta)
| Returns the ticks counter value delta ticks in the future.
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.
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 tick value and false otherwise.
rtems_status_code | rtems_clock_set (const rtems_time_of_day *time_buffer)
| Set the Current TOD.
rtems_status_code | rtems_clock_tick (void)
| Announce a Clock Tick.
rtems_status_code | rtems_clock_get_uptime (struct timespec *uptime)
| Obtain the System Uptime.
void | rtems_clock_get_uptime_timeval (struct timeval *uptime)
| Gets the System Uptime in the Struct Timeval Format.
time_t | rtems_clock_get_uptime_seconds (void)
| Returns the system uptime in seconds.
uint64_t | rtems_clock_get_uptime_nanoseconds (void)
| Returns the system uptime in nanoseconds.
bool | _TOD_Validate (const rtems_time_of_day *the_tod)
| TOD Validate.
Watchdog_Interval | _TOD_To_seconds (const rtems_time_of_day *the_tod)
| TOD to Seconds.

## Detailed Description

This encapsulates functionality related to the Classic API Clock Manager.

## Macro Definition Documentation

## ◆ rtems_clock_get_ticks_per_second

rtems_interval rtems_clock_get_ticks_per_second | ( |  | void | ) | ( _Watchdog_Ticks_per_second )

Obtain Ticks Per Seconds.

This routine implements the rtems_clock_get_ticks_per_second directive.

Return values

  This | method returns the number of ticks per second. It cannot fail since RTEMS is always configured to know the number of ticks per second.

## Function Documentation

## ◆ _TOD_To_seconds()

Watchdog_Interval _TOD_To_seconds | ( | const rtems_time_of_day * | the_tod | ) |

TOD to Seconds.

This function returns the number seconds between the epoch and the_tod.

Parameters

  [in] | the_tod | is the TOD structure to convert to seconds

Return values

  This | method returns the number of seconds since epoch represented by the_tod

## ◆ _TOD_Validate()

bool _TOD_Validate | ( | const rtems_time_of_day * | the_tod | ) |

TOD Validate.

This support function returns true if the_tod contains a valid time of day, and false otherwise.

Parameters

  [in] | the_tod | is the TOD structure to validate

Return values

  This | method returns true if the TOD is valid and false otherwise.

Note
  This routine only works for leap-years through 2099.

## ◆ rtems_clock_get_seconds_since_epoch()

rtems_status_code rtems_clock_get_seconds_since_epoch | ( | rtems_interval * | the_interval | ) |

Obtain Seconds Since Epoch.

This routine implements the rtems_clock_get_seconds_since_epoch directive.

Parameters

  [in] | the_interval | points to the interval variable to fill in

Return values

  This | method returns RTEMS_SUCCESSFUL if there was not an error. Otherwise, a status code is returned indicating the source of the error. If successful, the time_buffer will be filled in with the current time of day.

## ◆ rtems_clock_get_ticks_since_boot()

RTEMS_INLINE_ROUTINE rtems_interval rtems_clock_get_ticks_since_boot | ( | void |  | ) |

Gets the current ticks counter value.

Returns
  The current tick counter value. With a 1ms clock tick, this counter overflows after 50 days since boot.

## ◆ rtems_clock_get_tod()

rtems_status_code rtems_clock_get_tod | ( | rtems_time_of_day * | time_buffer | ) |

Obtain Current Time of Day (Classic TOD)

This routine implements the rtems_clock_get_tod directive. It returns the current time of day in the format defined by RTEID.

Clock Manager - rtems_clock_get_tod

Parameters

  [in] | time_buffer | points to the time of day structure

Return values

  This | method returns RTEMS_SUCCESSFUL if there was not an error. Otherwise, a status code is returned indicating the source of the error. If successful, the time_buffer will be filled in with the current time of day.

## ◆ rtems_clock_get_tod_timeval()

rtems_status_code rtems_clock_get_tod_timeval | ( | struct timeval * | time | ) |

Obtain TOD in struct timeval Format.

This routine implements the rtems_clock_get_tod_timeval directive.

Parameters

  [in] | time | points to the struct timeval variable to fill in

Return values

  This | method returns RTEMS_SUCCESSFUL if there was not an error. Otherwise, a status code is returned indicating the source of the error. If successful, the time will be filled in with the current time of day.

## ◆ rtems_clock_get_uptime()

rtems_status_code rtems_clock_get_uptime | ( | struct timespec * | uptime | ) |

Obtain the System Uptime.

This directive returns the system uptime.

Parameters

  [in] | uptime | is a pointer to the time structure

Return values

  This | method returns RTEMS_SUCCESSFUL if there was not an error. Otherwise, a status code is returned indicating the source of the error. If successful, the uptime will be filled in.

## ◆ rtems_clock_get_uptime_nanoseconds()

uint64_t rtems_clock_get_uptime_nanoseconds | ( | void |  | ) |

Returns the system uptime in nanoseconds.

Return values

  The | system uptime in nanoseconds.

## ◆ rtems_clock_get_uptime_seconds()

time_t rtems_clock_get_uptime_seconds | ( | void |  | ) |

Returns the system uptime in seconds.

Return values

  The | system uptime in seconds.

## ◆ rtems_clock_get_uptime_timeval()

void rtems_clock_get_uptime_timeval | ( | struct timeval * | uptime | ) |

Gets the System Uptime in the Struct Timeval Format.

Parameters

  [out] | uptime | is a pointer to a struct timeval structure.

Return values

  This | methods returns the system uptime.

Note
  Pointer must not be NULL.

## ◆ rtems_clock_set()

rtems_status_code rtems_clock_set | ( | const rtems_time_of_day * | time_buffer | ) |

Set the Current TOD.

This routine implements the rtems_clock_set directive. It sets the current time of day to that in the time_buffer record.

Parameters

  [in] | time_buffer | points to the new TOD

Return values

  This | method returns RTEMS_SUCCESSFUL if there was not an error. Otherwise, a status code is returned indicating the source of the error.

Note
  Activities scheduled based upon the current time of day may be executed immediately if the time is moved forward.

## ◆ rtems_clock_tick()

rtems_status_code rtems_clock_tick | ( | void |  | ) |

Announce a Clock Tick.

This routine implements the rtems_clock_tick directive. It is invoked to inform RTEMS of the occurrence of a clock tick.

Return values

  This | directive always returns RTEMS_SUCCESSFUL.

Note
  This method is typically called from an ISR and is the basis for all timeouts and delays. This routine only works for leap-years through 2099.

## ◆ 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 tick value and false otherwise.

Parameters

  [in] | tick | The tick value.

This can be used to write busy loops with a timeout.

status busy( void )
{
rtems_interval timeout = rtems_clock_tick_later_usec( 10000 );
do {
if ( ok() ) {
return success;
}
} while ( rtems_clock_tick_before( timeout ) );
return timeout;
}
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_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_interval
Watchdog_Interval rtems_interval
Used to manage and manipulate intervals specified by clock ticks.
Definition: types.h:127

Return values

  true | The current ticks counter value indicates a time before the time specified by the tick value.
  false | Otherwise.

## ◆ 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.

Parameters

  [in] | delta | The ticks delta value.

Returns
  The tick counter value delta ticks in the future.

## ◆ 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.

Parameters

  [in] | delta_in_usec | The delta value in microseconds.

Returns
  The tick counter value at least delta microseconds in the future.