3030namespace mbed {
3131
3232/* * \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 resets the system in the case of system
34+ * failures or malfunctions. If you fail to refresh the Watchdog timer periodically,
35+ * it resets the system after a set period of time.
36+ *
37+ * There is only one instance of the Watchdog class in the system, which directly maps to the hardware.
38+ * Use Watchdog::get_instance to 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, you must periodically kick or refresh
43+ * the timer by calling Watchdog::kick, which resets the countdown
44+ * to the initial value.
3545 *
3646 * Example:
3747 * @code
38- *
3948 * Watchdog &watchdog = Watchdog::get_instance();
40- * watchdog.start();
49+ * watchdog.start(500 );
4150 *
4251 * while (true) {
4352 // kick watchdog regularly within provided timeout
@@ -52,9 +61,10 @@ namespace mbed {
5261class Watchdog : private NonCopyable <Watchdog> {
5362public:
5463
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+ * @return A reference to the single Watchdog instance present in the system.
67+ */
5868 static Watchdog &get_instance ()
5969 {
6070 // Use this implementation of singleton (Meyer's) rather than the one that allocates
@@ -64,61 +74,71 @@ class Watchdog : private NonCopyable<Watchdog> {
6474 return instance;
6575 }
6676
67- /* * Start the watchdog timer with the maximum timeout available on a target
77+ /* * Start the Watchdog timer with the maximum timeout value available for
78+ * the target.
79+ *
80+ * @note The timeout is set to a value returned by Watchdog::get_max_timeout.
6881 *
69- * Timeout is defined as get_max_timeout()
82+ * If the Watchdog timer is already running, this function does nothing.
7083 *
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
84+ * @return true if the Watchdog timer was started successfully;
85+ * false if the Watchdog timer was not started or if the Watchdog
86+ * timer is already running.
7487 */
7588 bool start ();
7689
77- /* * Start the watchdog timer
90+ /* * Start the Watchdog timer.
7891 *
79- * @param timeout Watchdog timeout
92+ * @note Asset that the timeout param is supported by the target
93+ * (0 < timeout <= Watchdog::get_max_timeout).
8094 *
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
95+ * @param timeout Watchdog timeout in milliseconds.
96+ *
97+ * @return true if the Watchdog timer was started successfully;
98+ * false if Watchdog timer was not started or if the Watchdog
99+ * timer is already running.
84100 */
85101 bool start (uint32_t timeout);
86102
87- /* * Stops the watchdog timer
103+ /* * Stop the Watchdog timer.
88104 *
89- * Calling this function will attempt to disable any currently running
90- * watchdog timers if supported by the current platform.
105+ * Calling this function disables a running Watchdog
106+ * peripheral if the platform supports it .
91107 *
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.
108+ * @return true if the Watchdog timer was successfully stopped;
109+ * false if the Watchdog timer cannot be disabled on this platform
110+ * or if the Watchdog timer has not been started.
95111 */
96112 bool stop ();
97113
98- /* * Get the watchdog timer refresh value
114+ /* * Get the Watchdog timer refresh value.
99115 *
100- * This function returns the refresh timeout of the watchdog timer .
116+ * This function returns the refresh timeout of the watchdog peripheral .
101117 *
102- * @return Reload value for the watchdog timer in milliseconds.
118+ * @return Reload value for the Watchdog timer in milliseconds.
103119 */
104120 uint32_t get_timeout () const ;
105121
106- /* * Get the maximum refresh value for the current platform in milliseconds
122+ /* * Get the maximum Watchdog refresh value for this platform.
107123 *
108- * @return Maximum refresh value supported by the watchdog for the current
109- * platform in milliseconds
124+ * @return Maximum reload value supported by the Watchdog timer for this
125+ * platform in milliseconds.
110126 */
111127 uint32_t get_max_timeout () const ;
112128
113- /* * Check if watchdog is already running
129+ /* * Check if the Watchdog timer is already running.
114130 *
115- * @return true if watchdog is running, false otherwise
131+ * @return true if the Watchdog timer is running and
132+ * false otherwise.
116133 */
117134 bool is_running () const ;
118135
119- /* * Kick watchdog
136+ /* * Refresh the Watchdog timer.
137+ *
138+ * Call this function periodically before the Watchdog times out.
139+ * Otherwise, the system resets.
120140 *
121- * This method is useful to control kicking by application in ticker callback periodically
141+ * If the Watchdog timer is not running, this function does nothing.
122142 */
123143 void kick ();
124144
0 commit comments