[riot-notifications] [RIOT-OS/RIOT] drivers/include: add header definition for wdt (#11527)

Kaspar Schleiser notifications at github.com
Thu May 16 11:50:22 CEST 2019


kaspar030 commented on this pull request.



> +void wdt_setup_reboot(uint32_t min_time, uint32_t max_time);
+
+#ifdef MODULE_PERIPH_WDT_CB
+/**
+ * @brief    Set up the wdt timer, only use max_time if normal operation
+ *           set min_time and max_time for windowed timer.
+ *
+ * @param[in] min_time       lower bound for windowed watchdog in ms, has to be 0
+ *                           for normal mode operation
+ * @param[in] max_time       upper bound for windowed watchdog in ms, time before
+ *                           reset for normal watchdog
+ * @param[in] wdt_cb         wdt callback, can be NULL
+ * @param[in] arg            optional argument which is passed to the
+ *                           callback, can be NULL
+ */
+void wdt_setup_callback(uint32_t min_time, uint32_t max_time, wdt_cb_t wdt_cb, void* arg);

> I think this can be misleading: The watchdog will still trigger a reboot and behave just like with wdt_setup_reboot, the only difference being that wdt_cb is executed before the watchdog timer expires.

Maybe call it ```wdt_setup_reset_with_warning()```?

BTW, we need an additional define for the time difference between warning callback and actual reset.
 
> Having two functions for it make it seem like `wdt_setup_callback` would cause the callback to be called _instead_ of the reboot, not in addition to it.

If this is one function, the functionality cannot be guarded properly. When supported, all callback handling code must be compiled in, even if unused.
In practice, ```wdt_setup_reset_with_warning()``` will probably look like

```
wdt_setup_reset_with_warning() {
 wdt_setup_reset();
// set callback
}
```

> Also it would be good if the function can return an error code if an invalid configuration is requested.

Would be good for what? Can we get away with asserts and log messages?

```
if (wdt_setup_reset() == EINVAL) {
  // now what? set a flag disabling wdt_kick()?
  // let the user know?
}
```


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/11527#discussion_r284627083
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190516/b8f856d0/attachment.html>


More information about the notifications mailing list