cleaned version of TFT + Ethernet

Dependents:   XPL-App4_cleanup XPL-App5

Committer:
richnash
Date:
Sun Oct 28 11:36:31 2018 +0000
Revision:
1:e4a6f3f88b56
Parent:
0:9688737bf8cd
app5 good base

Who changed what in which revision?

UserRevisionLine numberNew contents of line
richnash 0:9688737bf8cd 1 /// @file Watchdog.h provides the interface to the Watchdog module
richnash 0:9688737bf8cd 2 ///
richnash 0:9688737bf8cd 3 /// This provides basic Watchdog service for the mbed. You can configure
richnash 0:9688737bf8cd 4 /// various timeout intervals that meet your system needs. Additionally,
richnash 0:9688737bf8cd 5 /// it is possible to identify if the Watchdog was the cause of any
richnash 0:9688737bf8cd 6 /// system restart, permitting the application code to take appropriate
richnash 0:9688737bf8cd 7 /// behavior.
richnash 0:9688737bf8cd 8 ///
richnash 0:9688737bf8cd 9 /// Adapted from Simon's Watchdog code from http://mbed.org/forum/mbed/topic/508/
richnash 0:9688737bf8cd 10 ///
richnash 0:9688737bf8cd 11 /// @note Copyright © 2011 by Smartware Computing, all rights reserved.
richnash 0:9688737bf8cd 12 /// This software may be used to derive new software, as long as
richnash 0:9688737bf8cd 13 /// this copyright statement remains in the source file.
richnash 0:9688737bf8cd 14 /// @author David Smart
richnash 0:9688737bf8cd 15 ///
richnash 0:9688737bf8cd 16 /// History
richnash 0:9688737bf8cd 17 /// \li v1.00 - 20110616: initial release with some documentation improvements
richnash 0:9688737bf8cd 18 ///
richnash 0:9688737bf8cd 19 #ifndef WATCHDOG_H
richnash 0:9688737bf8cd 20 #define WATCHDOG_H
richnash 0:9688737bf8cd 21 #include "mbed.h"
richnash 0:9688737bf8cd 22
richnash 0:9688737bf8cd 23 /// The Watchdog class provides the interface to the Watchdog feature
richnash 0:9688737bf8cd 24 ///
richnash 0:9688737bf8cd 25 /// Embedded programs, by their nature, are usually unattended. If things
richnash 0:9688737bf8cd 26 /// go wrong, it is usually important that the system attempts to recover.
richnash 0:9688737bf8cd 27 /// Aside from robust software, a hardware watchdog can monitor the
richnash 0:9688737bf8cd 28 /// system and initiate a system reset when appropriate.
richnash 0:9688737bf8cd 29 ///
richnash 0:9688737bf8cd 30 /// This Watchdog is patterned after one found elsewhere on the mbed site,
richnash 0:9688737bf8cd 31 /// however this one also provides a method for the application software
richnash 0:9688737bf8cd 32 /// to determine the cause of the reset - watchdog or otherwise.
richnash 0:9688737bf8cd 33 ///
richnash 0:9688737bf8cd 34 /// example:
richnash 0:9688737bf8cd 35 /// @code
richnash 0:9688737bf8cd 36 /// Watchdog wd;
richnash 0:9688737bf8cd 37 ///
richnash 0:9688737bf8cd 38 /// ...
richnash 0:9688737bf8cd 39 /// main() {
richnash 0:9688737bf8cd 40 /// if (wd.WatchdogCausedReset())
richnash 0:9688737bf8cd 41 /// pc.printf("Watchdog caused reset.\r\n");
richnash 0:9688737bf8cd 42 ///
richnash 0:9688737bf8cd 43 /// wd.Configure(3.0); // sets the timeout interval
richnash 0:9688737bf8cd 44 /// for (;;) {
richnash 0:9688737bf8cd 45 /// wd.Service(); // kick the dog before the timeout
richnash 0:9688737bf8cd 46 /// // do other work
richnash 0:9688737bf8cd 47 /// }
richnash 0:9688737bf8cd 48 /// }
richnash 0:9688737bf8cd 49 /// @endcode
richnash 0:9688737bf8cd 50 ///
richnash 0:9688737bf8cd 51 class Watchdog {
richnash 0:9688737bf8cd 52 public:
richnash 0:9688737bf8cd 53 /// Create a Watchdog object
richnash 0:9688737bf8cd 54 ///
richnash 0:9688737bf8cd 55 /// example:
richnash 0:9688737bf8cd 56 /// @code
richnash 0:9688737bf8cd 57 /// Watchdog wd; // placed before main
richnash 0:9688737bf8cd 58 /// @endcode
richnash 0:9688737bf8cd 59 Watchdog();
richnash 0:9688737bf8cd 60
richnash 0:9688737bf8cd 61 /// Configure the timeout for the Watchdog
richnash 0:9688737bf8cd 62 ///
richnash 0:9688737bf8cd 63 /// This configures the Watchdog service and starts it. It must
richnash 0:9688737bf8cd 64 /// be serviced before the timeout, or the system will be restarted.
richnash 0:9688737bf8cd 65 ///
richnash 0:9688737bf8cd 66 /// example:
richnash 0:9688737bf8cd 67 /// @code
richnash 0:9688737bf8cd 68 /// ...
richnash 0:9688737bf8cd 69 /// wd.Configure(1.4); // configure for a 1.4 second timeout
richnash 0:9688737bf8cd 70 /// ...
richnash 0:9688737bf8cd 71 /// @endcode
richnash 0:9688737bf8cd 72 ///
richnash 0:9688737bf8cd 73 /// @param[in] timeout in seconds, as a floating point number
richnash 0:9688737bf8cd 74 /// @returns none
richnash 0:9688737bf8cd 75 ///
richnash 0:9688737bf8cd 76 void Configure(float timeout);
richnash 0:9688737bf8cd 77
richnash 0:9688737bf8cd 78 /// Service the Watchdog so it does not cause a system reset
richnash 0:9688737bf8cd 79 ///
richnash 0:9688737bf8cd 80 /// example:
richnash 0:9688737bf8cd 81 /// @code
richnash 0:9688737bf8cd 82 /// wd.Service();
richnash 0:9688737bf8cd 83 /// @endcode
richnash 0:9688737bf8cd 84 /// @returns none
richnash 0:9688737bf8cd 85 void Service();
richnash 0:9688737bf8cd 86
richnash 0:9688737bf8cd 87 /// WatchdogCausedReset identifies if the cause of the system
richnash 0:9688737bf8cd 88 /// reset was the Watchdog
richnash 0:9688737bf8cd 89 ///
richnash 0:9688737bf8cd 90 /// example:
richnash 0:9688737bf8cd 91 /// @code
richnash 0:9688737bf8cd 92 /// if (wd.WatchdogCausedReset())) {
richnash 0:9688737bf8cd 93 /// @endcode
richnash 0:9688737bf8cd 94 ///
richnash 0:9688737bf8cd 95 /// @returns true if the Watchdog was the cause of the reset
richnash 0:9688737bf8cd 96 bool WatchdogCausedReset();
richnash 0:9688737bf8cd 97 private:
richnash 0:9688737bf8cd 98 bool wdreset;
richnash 0:9688737bf8cd 99 };
richnash 0:9688737bf8cd 100
richnash 0:9688737bf8cd 101 #endif // WATCHDOG_H