Francesco Pistone
/
FORIGO_Modula_V4_R2_DE_BOX_ARGENTO_LAVORO
faefa
Embed:
(wiki syntax)
Show/hide line numbers
watchdog.h
00001 /// @file Watchdog.h provides the interface to the Watchdog module 00002 /// 00003 /// This provides basic Watchdog service for the mbed. You can configure 00004 /// various timeout intervals that meet your system needs. Additionally, 00005 /// it is possible to identify if the Watchdog was the cause of any 00006 /// system restart, permitting the application code to take appropriate 00007 /// behavior. 00008 /// 00009 /// Adapted from Simon's Watchdog code from http://mbed.org/forum/mbed/topic/508/ 00010 /// 00011 /// @note Copyright © 2011 by Smartware Computing, all rights reserved. 00012 /// This software may be used to derive new software, as long as 00013 /// this copyright statement remains in the source file. 00014 /// @author David Smart 00015 /// 00016 /// History 00017 /// \li v1.00 - 20110616: initial release with some documentation improvements 00018 /// 00019 #ifndef WATCHDOG_H 00020 #define WATCHDOG_H 00021 #include "mbed.h" 00022 00023 /// The Watchdog class provides the interface to the Watchdog feature 00024 /// 00025 /// Embedded programs, by their nature, are usually unattended. If things 00026 /// go wrong, it is usually important that the system attempts to recover. 00027 /// Aside from robust software, a hardware watchdog can monitor the 00028 /// system and initiate a system reset when appropriate. 00029 /// 00030 /// This Watchdog is patterned after one found elsewhere on the mbed site, 00031 /// however this one also provides a method for the application software 00032 /// to determine the cause of the reset - watchdog or otherwise. 00033 /// 00034 /// example: 00035 /// @code 00036 /// Watchdog wd; 00037 /// 00038 /// ... 00039 /// main() { 00040 /// if (wd.WatchdogCausedReset()) 00041 /// pc.printf("Watchdog caused reset.\r\n"); 00042 /// 00043 /// wd.Configure(3.0); // sets the timeout interval 00044 /// for (;;) { 00045 /// wd.Service(); // kick the dog before the timeout 00046 /// // do other work 00047 /// } 00048 /// } 00049 /// @endcode 00050 /// 00051 class Watchdog { 00052 public: 00053 /// Create a Watchdog object 00054 /// 00055 /// example: 00056 /// @code 00057 /// Watchdog wd; // placed before main 00058 /// @endcode 00059 Watchdog(); 00060 00061 /// Configure the timeout for the Watchdog 00062 /// 00063 /// This configures the Watchdog service and starts it. It must 00064 /// be serviced before the timeout, or the system will be restarted. 00065 /// 00066 /// example: 00067 /// @code 00068 /// ... 00069 /// wd.Configure(1.4); // configure for a 1.4 second timeout 00070 /// ... 00071 /// @endcode 00072 /// 00073 /// @param[in] timeout in seconds, as a floating point number 00074 /// @returns none 00075 /// 00076 void Configure(float timeout); 00077 00078 /// Service the Watchdog so it does not cause a system reset 00079 /// 00080 /// example: 00081 /// @code 00082 /// wd.Service(); 00083 /// @endcode 00084 /// @returns none 00085 void Service(); 00086 00087 /// WatchdogCausedReset identifies if the cause of the system 00088 /// reset was the Watchdog 00089 /// 00090 /// example: 00091 /// @code 00092 /// if (wd.WatchdogCausedReset())) { 00093 /// @endcode 00094 /// 00095 /// @returns true if the Watchdog was the cause of the reset 00096 bool WatchdogCausedReset(); 00097 private: 00098 bool wdreset; 00099 }; 00100 00101 #endif // WATCHDOG_H
Generated on Wed Jul 13 2022 14:16:11 by 1.7.2