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