Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of GA-Berkay_Alex by
Diff: Watchdog/Watchdog.cpp
- Revision:
- 0:a3b83d366423
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Watchdog/Watchdog.cpp Wed Dec 06 21:35:45 2017 +0000
@@ -0,0 +1,25 @@
+#include "Watchdog.h"
+
+
+Watchdog::Watchdog() {
+}
+
+// Load timeout value in watchdog timer and enable
+void Watchdog::kick(float s) {
+
+ uint32_t clk = SystemCoreClock / 3; // found by trying. TODO: exakt values
+ hiwdg.Instance = IWDG;
+ hiwdg.Init.Prescaler = IWDG_PRESCALER_16;
+ hiwdg.Init.Reload = s * (float)clk;
+ if (HAL_IWDG_Init(&hiwdg) != HAL_OK)
+ {
+ // Error Handler
+ }
+}
+
+// "kick" or "feed" the dog - reset the watchdog timer
+// by writing this required bit pattern
+void Watchdog::kick() {
+ HAL_IWDG_Refresh(&hiwdg);
+}
+
