Watchdog device

The watchdog device allows applications to make use of a timer facility. First the application should register an action routine with the watchdog device, and start the watchdog running. After this the application must call a watchdog reset function at regular intervals, or else the device will cause the installed action routines to be invoked. The assumption is that the watchdog timer should never trigger unless there has been a serious fault in either the hardware or the software, and the application's action routine should perform an appropriate reset operation.

The main reason for having a watchdog timer is to guard against software and certain hardware failures that may cause the system to stop working, but can be cured by a reset or some other form of restart.

The watchdog device is either implemented by interfacing to a hardware watchdog device, or it is emulated using an alarm on the kernel real-time clock.

Cyg_Watchdog class

The Watchdog device is implemented by the Cyg_Watchdog class. It has the following members.

Cyg_Watchdog::start()

This causes the watchdog to start operation. Once this function has been called, the reset() function must be called to prevent the watchdog timer from firing.

Cyg_Watchdog::reset()

This function must be called frequently to prevent the watchdog from triggering. The maximum time allowed between calls depends on the underlying hardware. All devices are currently configured for this maximum time to be approximately one second.

This function should be called from a thread context or some other relatively high level part of the system. Calling it from an interrupt or DSR is not a good idea since the interrupt and DSR system may continue to run even when the rest of the system is broken.

Cyg_Watchdog::trigger()

This function causes the watchdog to trigger immediately. It causes all of the watchdog actions to be called. This may be useful if a system restart is needed before the watchdog timer expires.

Cyg_Watchdog::install_action()

This function installs a Cyg_Watchdog_Action object into the list of actions to be performed when the watchdog triggers. See below for further information.

Cyg_Watchdog::uninstall_action()

This function removes a Cyg_Watchdog_Action object from the trigger list.

Cyg_Watchdog::watchdog

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

Cyg_Watchdog_Action class

This class is a carrier for watchdog trigger functions. Each function is installed by creating an instance of this class and installing it into the watchdog device.

Cyg_Watchdog_Action::Cyg_Watchdog_Action()

This is the constructor for this class. It takes two arguments. The first is a pointer to an action function that has the following prototype:


void trigger_function( CYG_ADDRWORD data )

The second argument is of type CYG_ADDRWORD and is a data value or pointer that is passed to the trigger function when it is called.

The action object is not installed into the watchdog at this point.

Cyg_Watchdog_Action::install()

This function installs this watchdog action object into the watchdog device.

Cyg_Watchdog_Action:uninstall()

This function uninstalls the watchdog action object from the watchdog device.

Cyg_Watchdog_Action::~Cyg_Watchdog_Action()

This is the destructor for this class. It will automatically uninstall the action object from the watchdog if it is still installed.