SFBWatchdog.h File Reference

'Platform independent' watchdog timer routines. More...

#include "SFBTypes.h"

Include dependency graph for SFBWatchdog.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool watchdogActive ()
 Returns true iff the hardware watchdog timer is enabled.
void watchdogSetInterval (u32 feedIntervalMs)
 Set or reset the time period within with the hardware watchdog must be 'fed' (by calling watchdogFeed()) to avoid a watchdog reset.
u32 watchdogGetInterval ()
 Get the current watchdog timer interval, in milliseconds.
bool watchdogStart (u32 feedIntervalMs)
 Start the watchdog timer, with a(n initial) period of feedIntervalMs.
bool watchdogFeed ()
 Feed the watchdog, if it is enabled.
bool watchdogGetTimeoutFlag ()
 Access the hardware watchdog timeout flag.
void watchdogClearTimeoutFlag ()
 Clear the hardware watchdog timeout flag, if it was set.
void watchdogSuicide () __attribute__((noreturn))
 Force a watchdog timeout to kill the system.
bool watchdogItWasSuicide ()
 True if watchdogGetTimeoutFlag() is only true because of a deliberate crash.


Detailed Description

'Platform independent' watchdog timer routines.

Author:
David H. Ackley.
Date:
(C) 2009 All rights reserved.
Code License:
The GNU Lesser General Public License
License Note:
All code samples shown in documentation are placed into the public domain.

Function Documentation

bool watchdogFeed (  ) 

Feed the watchdog, if it is enabled.

Does nothing and returns false if the watchdog timer has not been started with watchdogStart. Otherwise, resets the watchdog timer and returns true. This function must be called at intervals of less that 'feedIntervalMs' milliseconds, for whatever value was provided to watchdogStart(u32), to avoid a board reset.

Note that it is okay to call this function (much) more frequently than that, if desired, but be aware that for mysterious hardware reasons watchdog feedings cannot more frequently than once every 50 microseconds (not milliseconds) -- so if watchdogFeed is called more frequently than that, it will add the necessary delays itself.

u32 watchdogGetInterval (  ) 

Get the current watchdog timer interval, in milliseconds.

Not necessarily meaningful unless watchdogActive() returns true.

bool watchdogGetTimeoutFlag (  ) 

Access the hardware watchdog timeout flag.

This flag is set if the hardware reset that started the current program execution was due to a watchdog timeout on the previous execution.

void watchdogSetInterval ( u32  feedIntervalMs  ) 

Set or reset the time period within with the hardware watchdog must be 'fed' (by calling watchdogFeed()) to avoid a watchdog reset.

Note this function feeds the watchdog itself after setting the interval.

Parameters:
feedIntervalMs maximum number of milliseconds between watchdogFeed() calls.

bool watchdogStart ( u32  feedIntervalMs  ) 

Start the watchdog timer, with a(n initial) period of feedIntervalMs.

Does nothing (and returns false) if the timer is already running -- in particular, watch out: If already running, this function does not change the existing feed interval to the supplied interval. Otherwise, it sets the feed interval to the supplied interval, enables the timer to reset the system if the watchdog timeout fails, and feeds the watchdog once.

Parameters:
feedIntervalMs the maximum delay between watchdogFeed() calls, in milliseconds.
Returns:
true if the watchdog timer was just started, false if it was already running (and feedIntervalMs was therefore ignored).

void watchdogSuicide (  ) 

Force a watchdog timeout to kill the system.

This method first starts the watchdog if it's not already going. Then it resets the watchdog timeout to a short time special code (which watchdogItWasSuicide looks for), and then blocks until the watchdog timeout fires.


Generated on Fri Apr 22 06:57:02 2011 for SFB by doxygen 1.5.9