#include "u.h" #include "../port/lib.h" #include "mem.h" #include "dat.h" #include "fns.h" #include "io.h" /* roughly 16 seconds, should be enough time to boot */ void enable(void) { /* CLK/16, RTCCLK */ *IO(u16int, WDTTCSR) = (1<<4) | (1<<1); /* compare */ *IO(u16int, WDTTDR) = 32768; /* count */ *IO(u16int, WDTTCNT) = 0; /* enable */ *IO(u8int, WDTTCER) = 1; } void disable(void) { *IO(u8int, WDTTCER) = 0; } void restart(void) { *IO(u16int, WDTTCNT) = 0; } void stat(char *s, char *e) { seprint(s, e, ""); } Watchdog wdci20 = { .enable = enable, .disable = disable, .restart = restart, .stat = stat, }; void wdci20link(void) { addwatchdog(&wdci20); }