Chapter 10. Wallclock and watchdog devices

Table of Contents
Wallclock device
Watchdog device

Wallclock device

The wallclock device provides real time stamps, as opposed to the eCos kernel timers which typically just count the number of clock ticks since the hardware was powered up. Depending on the target platform this device may involve interacting with a suitable clock chip, or it may be emulated by using the kernel timers.

This device maintains a standard UNIX style timestamp consisting of a count of seconds since an epoch. The conventional UNIX epoch is 1970-1-1 00:00, but any base time may be used.

At present the Wallclock device is emulated by using the kernel real-time clock with an initial epoch of the system startup time. In future systems, where CMOS clocks or the equivalent hardware are available, it will make use of this to track the passage of time.

Cyg_WallClock class

The wallclock device is implemented in C++ by the class Cyg_WallClock. It has the following class members.

Cyg_WallClock::get_current_time(void)

This returns the current value of the timestamp.

Cyg_WallClock::set_current_time(cyg_uint32 time_stamp)

This sets the internal timestamp for the current second. Setting it to zero makes the point at which it was called the epoch. Setting it to some non-zero value establishes the epoch to be time_stamp seconds in the past.

In the absence of underlying hardware to provide a time base, the Wallclock device can only track real-time if this function is called with a real-time value derived from elsewhere (i.e. user input, network time protocol etc.).

Cyg_WallClock::wallclock

This is a static pointer to the single instance of the Wallclock device.