30
30
namespace mbed {
31
31
32
32
/* * \addtogroup drivers */
33
- /* * Hardware system timer that will reset the system in the case of system failures or
34
- * malfunctions. There is only one instance in the system.
33
+ /* * A hardware watchdog timer that will reset the system in the case of system
34
+ * failures or malfunctions. If you fail to refresh the Watchdog periodically,
35
+ * it will reset the system after a set period of time.
36
+ *
37
+ * There is only one instance in the system. Use Watchdog::get_instance to
38
+ * obtain a reference.
39
+ *
40
+ * Watchdog::start initializes a system timer with a time period specified in
41
+ * @a timeout param. This timer counts down and triggers a system reset
42
+ * when it wraps. To prevent the system reset, the timer must be continually
43
+ * kicked/refreshed by calling Watchdog::kick, which will reset the countdown
44
+ * to the user specified reset value.
35
45
*
36
46
* Example:
37
47
* @code
38
- *
39
48
* Watchdog &watchdog = Watchdog::get_instance();
40
- * watchdog.start();
49
+ * watchdog.start(500 );
41
50
*
42
51
* while (true) {
43
52
// kick watchdog regularly within provided timeout
@@ -52,9 +61,13 @@ namespace mbed {
52
61
class Watchdog : private NonCopyable <Watchdog> {
53
62
public:
54
63
55
- /* * As Watchdog might not stop ever, there is just one instance - we use single instance.
56
- * This ensures we keep Watchdog alive. To operate watchdog, use start/stop methods.
57
- */
64
+ /* * Get a reference to the single Watchdog instance in the system.
65
+ *
66
+ * There is only one watchdog peripheral and only one Watchdog instance
67
+ * to control it.
68
+ *
69
+ * @return A reference to the single Watchdog instance present in the system.
70
+ */
58
71
static Watchdog &get_instance ()
59
72
{
60
73
// Use this implementation of singleton (Meyer's) rather than the one that allocates
@@ -64,61 +77,71 @@ class Watchdog : private NonCopyable<Watchdog> {
64
77
return instance;
65
78
}
66
79
67
- /* * Start the watchdog timer with the maximum timeout available on a target
80
+ /* * Start the Watchdog timer with the maximum timeout value available for
81
+ * the target.
82
+ *
83
+ * @note The timeout is set to a value returned by Watchdog::get_max_timeout.
68
84
*
69
- * Timeout is defined as get_max_timeout()
85
+ * If the Watchdog is already running, this function does nothing.
70
86
*
71
- * @return status true if the watchdog timer was started
72
- * successfully. assert if one of the input parameters is out of range for the current platform.
73
- * false if watchdog timer was not started
87
+ * @return true, if the Watchdog timer was started successfully,
88
+ * false, if Watchdog timer was not started or if the Watchdog
89
+ * is already running.
74
90
*/
75
91
bool start ();
76
92
77
- /* * Start the watchdog timer
93
+ /* * Start the Watchdog timer.
78
94
*
79
- * @param timeout Watchdog timeout
95
+ * @note Asset that the timeout param is supported by the target
96
+ * (0 < timeout <= Watchdog::get_max_timeout).
80
97
*
81
- * @return status true if the watchdog timer was started
82
- * successfully. assert if one of the input parameters is out of range for the current platform.
83
- * false if watchdog timer was not started
98
+ * @param timeout Watchdog timeout in milliseconds.
99
+ *
100
+ * @return true, if the Watchdog timer was started successfully,
101
+ * false, if Watchdog timer was not started or if the Watchdog
102
+ * is already running.
84
103
*/
85
104
bool start (uint32_t timeout);
86
105
87
- /* * Stops the watchdog timer
106
+ /* * Stop the Watchdog timer.
88
107
*
89
- * Calling this function will attempt to disable any currently running
90
- * watchdog timers if supported by the current platform.
108
+ * Calling this function will attempt to disable a running Watchdog
109
+ * peripheral if supported by the platform.
91
110
*
92
- * @return Returns true if the watchdog timer was successfully
93
- * stopped, Returns false if the watchdog cannot be disabled
94
- * on the current platform or if the timer was never started.
111
+ * @return true, if the Watchdog timer was successfully stopped,
112
+ * false, if the Watchdog cannot be disabled on this platform
113
+ * or if the Watchdog has not been started.
95
114
*/
96
115
bool stop ();
97
116
98
- /* * Get the watchdog timer refresh value
117
+ /* * Get the Watchdog timer refresh value.
99
118
*
100
- * This function returns the refresh timeout of the watchdog timer .
119
+ * This function returns the refresh timeout of the watchdog peripheral .
101
120
*
102
- * @return Reload value for the watchdog timer in milliseconds.
121
+ * @return Reload value for the Watchdog timer in milliseconds.
103
122
*/
104
123
uint32_t get_timeout () const ;
105
124
106
- /* * Get the maximum refresh value for the current platform in milliseconds
125
+ /* * Get the maximum Watchdog refresh value for this platform.
107
126
*
108
- * @return Maximum refresh value supported by the watchdog for the current
109
- * platform in milliseconds
127
+ * @return Maximum reload value supported by the Watchdog timer for this
128
+ * platform in milliseconds.
110
129
*/
111
130
uint32_t get_max_timeout () const ;
112
131
113
- /* * Check if watchdog is already running
132
+ /* * Check if the Watchdog is already running.
114
133
*
115
- * @return true if watchdog is running, false otherwise
134
+ * @return true, if the Watchdog is running,
135
+ * false, otherwise.
116
136
*/
117
137
bool is_running () const ;
118
138
119
- /* * Kick watchdog
139
+ /* * Refresh the Watchdog timer.
140
+ *
141
+ * Call this function periodically before the Watchdog times out.
142
+ * Otherwise, the system is reset.
120
143
*
121
- * This method is useful to control kicking by application in ticker callback periodically
144
+ * If the Watchdog is not running, this function does nothing.
122
145
*/
123
146
void kick ();
124
147
0 commit comments