Skip to content

Commit 3979543

Browse files
jeplertannewt
andauthored
Apply suggestions from code review
Eliminates the "pet" function Co-authored-by: Scott Shawcroft <[email protected]>
1 parent d38cf05 commit 3979543

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,8 @@
3434

3535
#include "component/wdt.h"
3636

37-
void pet(void) {
38-
WDT->CLEAR.reg = WDT_CLEAR_CLEAR_KEY;
39-
}
40-
4137
void common_hal_watchdog_feed(watchdog_watchdogtimer_obj_t *self) {
42-
pet();
38+
WDT->CLEAR.reg = WDT_CLEAR_CLEAR_KEY;
4339
}
4440

4541
void common_hal_watchdog_deinit(watchdog_watchdogtimer_obj_t *self) {
@@ -54,7 +50,7 @@ mp_float_t common_hal_watchdog_get_timeout(watchdog_watchdogtimer_obj_t *self) {
5450
return self->timeout;
5551
}
5652

57-
void setup_wdt(int setting) {
53+
void setup_wdt(watchdog_watchdogtimer_obj_t *self, int setting) {
5854
OSC32KCTRL->OSCULP32K.bit.EN1K = 1; // Enable out 1K (for WDT)
5955

6056
// disable watchdog for config
@@ -67,7 +63,7 @@ void setup_wdt(int setting) {
6763
WDT->CTRLA.bit.WEN = 0; // Disable window mode
6864
while (WDT->SYNCBUSY.reg) { // Sync CTRL write
6965
}
70-
pet(); // Clear watchdog interval
66+
common_hal_watchdog_feed(self); // Clear watchdog interval
7167
WDT->CTRLA.bit.ENABLE = 1; // Start watchdog now!
7268
while (WDT->SYNCBUSY.reg) {
7369
}
@@ -87,7 +83,7 @@ void common_hal_watchdog_set_timeout(watchdog_watchdogtimer_obj_t *self, mp_floa
8783
float timeout = (8 << setting) / 1024.f;
8884

8985
if (self->mode == WATCHDOGMODE_RESET) {
90-
setup_wdt(setting);
86+
setup_wdt(self, setting);
9187
}
9288
self->timeout = timeout;
9389
}

0 commit comments

Comments
 (0)