rtems: Add rtems_clock_get_uptime_seconds()

This commit is contained in:
Sebastian Huber
2012-11-21 16:29:40 +01:00
parent bfddb0478c
commit 90733a86b8
6 changed files with 77 additions and 0 deletions
+1
View File
@@ -155,6 +155,7 @@ librtems_a_SOURCES += src/clockgettod.c
librtems_a_SOURCES += src/clockgettodtimeval.c
librtems_a_SOURCES += src/clockgetuptime.c
librtems_a_SOURCES += src/clockgetuptimetimeval.c
librtems_a_SOURCES += src/clockgetuptimeseconds.c
librtems_a_SOURCES += src/clockset.c
librtems_a_SOURCES += src/clocksetnsecshandler.c
librtems_a_SOURCES += src/clocktick.c
+7
View File
@@ -234,6 +234,13 @@ rtems_status_code rtems_clock_get_uptime(
*/
void rtems_clock_get_uptime_timeval( struct timeval *uptime );
/**
* @brief Returns the system uptime in seconds.
*
* @return The system uptime in seconds.
*/
time_t rtems_clock_get_uptime_seconds( void );
/**
* @brief _TOD_Validate
*
+34
View File
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2012 embedded brains GmbH. All rights reserved.
*
* embedded brains GmbH
* Obere Lagerstr. 30
* 82178 Puchheim
* Germany
* <rtems@embedded-brains.de>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*/
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include <rtems/rtems/clock.h>
time_t rtems_clock_get_uptime_seconds( void )
{
Timestamp_Control snapshot_as_timestamp;
struct timespec snapshot_as_timespec;
ISR_Level level;
_ISR_Disable( level );
snapshot_as_timestamp = _TOD.uptime;
_ISR_Enable( level );
_Timestamp_To_timespec( &snapshot_as_timestamp, &snapshot_as_timespec );
return snapshot_as_timespec.tv_sec;
}
+31
View File
@@ -23,6 +23,7 @@ the clock manager are:
@item @code{@value{DIRPREFIX}clock_get_ticks_since_boot} - Get ticks since boot
@item @code{@value{DIRPREFIX}clock_get_uptime} - Get time since boot
@item @code{@value{DIRPREFIX}clock_get_uptime_timeval} - Get time since boot in timeval format
@item @code{@value{DIRPREFIX}clock_get_uptime_seconds} - Get seconds since boot
@item @code{@value{DIRPREFIX}clock_set_nanoseconds_extension} - Install the nanoseconds since last tick handler
@item @code{@value{DIRPREFIX}clock_tick} - Announce a clock tick
@end itemize
@@ -701,6 +702,36 @@ call.
This directive may be called from an ISR.
@c
@c
@c
@page
@subsection CLOCK_GET_UPTIME_SECONDS - Get the seconds since boot
@cindex clock get uptime
@cindex uptime
@subheading CALLING SEQUENCE:
@ifset is-C
@findex rtems_clock_get_uptime_seconds
@example
time_t rtems_clock_get_uptime_seconds(void);
@end example
@end ifset
@subheading DIRECTIVE STATUS CODES:
The system uptime in seconds.
@subheading DESCRIPTION:
This directive returns the seconds since the system was booted.
@subheading NOTES:
This directive may be called from an ISR.
@c
@c
@c
+3
View File
@@ -86,6 +86,9 @@ void Screen2()
puts( "TA1 - rtems_clock_get_uptime_timeval" );
rtems_clock_get_uptime_timeval( &tv );
puts( "TA1 - rtems_clock_get_uptime_seconds" );
rtems_clock_get_uptime_seconds();
puts( "TA1 - rtems_clock_get_tod_timeval - RTEMS_INVALID_ADDRESS" );
status = rtems_clock_get_tod_timeval( NULL );
fatal_directive_status(
+1
View File
@@ -32,6 +32,7 @@ TA1 - rtems_clock_get_seconds_since_epoch - RTEMS_INVALID_ADDRESS
TA1 - rtems_clock_get_seconds_since_epoch - RTEMS_NOT_DEFINED
TA1 - rtems_clock_get_uptime - RTEMS_INVALID_ADDRESS
TA1 - rtems_clock_get_uptime_timeval
TA1 - rtems_clock_get_uptime_seconds
TA1 - rtems_clock_get_tod_timeval - RTEMS_INVALID_ADDRESS
TA1 - rtems_clock_get_tod_timeval - RTEMS_NOT_DEFINED
TA1 - rtems_clock_set_nanoseconds_extension - RTEMS_INVALID_ADDRESS