+++

Fork of Watchdog by David Smart

Committer:
WiredHome
Date:
Sun Mar 20 23:24:36 2011 +0000
Revision:
1:5a1ff72b5915
Parent:
0:7a316f14da9c
Child:
2:2873f068f325

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
WiredHome 0:7a316f14da9c 1 /// @file Watchdog.h provides the interface to the Watchdog module
WiredHome 0:7a316f14da9c 2 ///
WiredHome 0:7a316f14da9c 3 /// This provides basic Watchdog service for the mbed. You can configure
WiredHome 0:7a316f14da9c 4 /// various timeout intervals that meet your system needs. Additionally,
WiredHome 0:7a316f14da9c 5 /// it is possible to identify if the Watchdog was the cause of any
WiredHome 0:7a316f14da9c 6 /// system restart.
WiredHome 0:7a316f14da9c 7 ///
WiredHome 0:7a316f14da9c 8 /// Adapted from Simon's Watchdog code from http://mbed.org/forum/mbed/topic/508/
WiredHome 0:7a316f14da9c 9 ///
WiredHome 0:7a316f14da9c 10 /// @note Copyright © 2011 by Smartware Computing, all rights reserved.
WiredHome 0:7a316f14da9c 11 /// This software may be used to derive new software, as long as
WiredHome 0:7a316f14da9c 12 /// this copyright statement remains in the source file.
WiredHome 0:7a316f14da9c 13 /// @author David Smart
WiredHome 0:7a316f14da9c 14 ///
WiredHome 0:7a316f14da9c 15 #ifndef WATCHDOG_H
WiredHome 0:7a316f14da9c 16 #define WATCHDOG_H
WiredHome 0:7a316f14da9c 17 #include "mbed.h"
WiredHome 0:7a316f14da9c 18
WiredHome 0:7a316f14da9c 19 /// Watchdog provides the interface to the Watchdog feature
WiredHome 0:7a316f14da9c 20 ///
WiredHome 0:7a316f14da9c 21 /// example:
WiredHome 0:7a316f14da9c 22 /// @code
WiredHome 0:7a316f14da9c 23 /// Watchdog wd;
WiredHome 0:7a316f14da9c 24 ///
WiredHome 0:7a316f14da9c 25 /// ...
WiredHome 0:7a316f14da9c 26 /// main() {
WiredHome 0:7a316f14da9c 27 /// if (wd.WatchdogCausedReset())
WiredHome 0:7a316f14da9c 28 /// pc.printf("Watchdog caused reset. WD being armed for 30s cycle.\r\n");
WiredHome 0:7a316f14da9c 29 ///
WiredHome 0:7a316f14da9c 30 /// wd.Configure(30.0); // sets the timeout interval
WiredHome 0:7a316f14da9c 31 /// for (;;) {
WiredHome 1:5a1ff72b5915 32 /// wd.Service(); // kick the dog before the timeout
WiredHome 0:7a316f14da9c 33 /// @endcode
WiredHome 0:7a316f14da9c 34 ///
WiredHome 0:7a316f14da9c 35 class Watchdog {
WiredHome 0:7a316f14da9c 36 public:
WiredHome 0:7a316f14da9c 37 /// Create a Watchdog object
WiredHome 0:7a316f14da9c 38 ///
WiredHome 0:7a316f14da9c 39 /// example:
WiredHome 0:7a316f14da9c 40 /// @code
WiredHome 0:7a316f14da9c 41 /// Watchdog wd; // placed before main
WiredHome 0:7a316f14da9c 42 /// @endcode
WiredHome 0:7a316f14da9c 43 Watchdog();
WiredHome 0:7a316f14da9c 44
WiredHome 0:7a316f14da9c 45 /// Configure the timeout for the Watchdog
WiredHome 0:7a316f14da9c 46 ///
WiredHome 0:7a316f14da9c 47 /// This configures the Watchdog service and starts it. It must
WiredHome 0:7a316f14da9c 48 /// be serviced before the timeout, or the system will be restarted.
WiredHome 0:7a316f14da9c 49 ///
WiredHome 0:7a316f14da9c 50 /// example:
WiredHome 0:7a316f14da9c 51 /// @code
WiredHome 0:7a316f14da9c 52 /// ...
WiredHome 0:7a316f14da9c 53 /// wd.Configure(1.4); // configure for a 1.4 second timeout
WiredHome 0:7a316f14da9c 54 /// ...
WiredHome 0:7a316f14da9c 55 /// @endcode
WiredHome 0:7a316f14da9c 56 ///
WiredHome 0:7a316f14da9c 57 /// @param timeout in seconds, as a floating point number
WiredHome 0:7a316f14da9c 58 /// @returns none
WiredHome 0:7a316f14da9c 59 ///
WiredHome 0:7a316f14da9c 60 void Configure(float timeout);
WiredHome 0:7a316f14da9c 61
WiredHome 0:7a316f14da9c 62 /// Service the Watchdog so it does not cause a system reset
WiredHome 0:7a316f14da9c 63 ///
WiredHome 1:5a1ff72b5915 64 /// example:
WiredHome 1:5a1ff72b5915 65 /// @code
WiredHome 1:5a1ff72b5915 66 /// wd.Service();
WiredHome 1:5a1ff72b5915 67 /// @endcode
WiredHome 0:7a316f14da9c 68 /// @returns none
WiredHome 0:7a316f14da9c 69 void Service();
WiredHome 0:7a316f14da9c 70
WiredHome 0:7a316f14da9c 71 /// WatchdogCausedReset identifies if the cause of the system
WiredHome 0:7a316f14da9c 72 /// reset was the Watchdog
WiredHome 0:7a316f14da9c 73 ///
WiredHome 0:7a316f14da9c 74 /// example:
WiredHome 0:7a316f14da9c 75 /// @code
WiredHome 0:7a316f14da9c 76 /// if (wd.WatchdogCausedReset())) {
WiredHome 0:7a316f14da9c 77 /// @endcode
WiredHome 0:7a316f14da9c 78 ///
WiredHome 0:7a316f14da9c 79 /// @returns true if the Watchdog was the cause of the reset
WiredHome 0:7a316f14da9c 80 bool WatchdogCausedReset();
WiredHome 0:7a316f14da9c 81 private:
WiredHome 0:7a316f14da9c 82 bool wdreset;
WiredHome 0:7a316f14da9c 83 };
WiredHome 0:7a316f14da9c 84
WiredHome 0:7a316f14da9c 85 #endif // WATCHDOG_H