Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
main: implement watchdog timer
Signed-off-by: Sean Cross <sean@xobs.io>
  • Loading branch information
xobs committed Jan 21, 2018
1 parent 08d0c15 commit 92e5c0f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions efm32hg-blinky/main.c
Expand Up @@ -21,6 +21,7 @@
#include "em_device.h"
#include "em_emu.h"
#include "em_gpio.h"
#include "em_wdog.h"

// The uptime of this application in milliseconds, maintained by the SysTick
// timer.
Expand All @@ -31,6 +32,7 @@ volatile uint32_t uptime_millis;
// main() further below).
void SysTick_Handler() {
uptime_millis++;
WDOG->CMD = WDOG_CMD_CLEAR;
}

void SpinDelay(uint32_t millis) {
Expand All @@ -46,6 +48,8 @@ int main() {
// errata (implements workarounds, etc).
CHIP_Init();

WDOG->CTRL = WDOG_CTRL_CLKSEL_ULFRCO | WDOG_CTRL_EN | (1 << _WDOG_CTRL_PERSEL_SHIFT);

// Switch on the clock for GPIO. Even though there's no immediately obvious
// timing stuff going on beyond the SysTick below, it still needs to be
// enabled for the GPIO to work.
Expand Down

0 comments on commit 92e5c0f

Please sign in to comment.