Messa in campo 4 file - 26/06/2020 Francia

Dependencies:   mbed X_NUCLEO_IHM03A1_for

Fork of FORIGO_Modula_V7_3_VdcStep_maggio2020 by Francesco Pistone

Committer:
nerit
Date:
Mon Jul 20 09:06:29 2020 +0000
Revision:
45:162116db828a
Parent:
3:a469bbd294b5
versione di prova per verifica accelerazione tamburo

Who changed what in which revision?

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