added main and defined M_PI

Dependencies:   BNOWrapper

Committer:
t1jain
Date:
Wed Aug 07 18:50:14 2019 +0000
Revision:
10:14374b492f1d
Parent:
8:729ad465d6c9
Updated Wrapper to be compatible with new code

Who changed what in which revision?

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