Skip to content

Commit 65613ae

Browse files
committed
lpc176x: Enable watchdog
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
1 parent 83d3c17 commit 65613ae

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

‎src/lpc176x/main.c‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,29 @@
1111
DECL_CONSTANT(MCU, "lpc176x");
1212

1313

14+
/****************************************************************
15+
* watchdog handler
16+
****************************************************************/
17+
18+
void
19+
watchdog_reset(void)
20+
{
21+
LPC_WDT->WDFEED = 0xaa;
22+
LPC_WDT->WDFEED = 0x55;
23+
}
24+
DECL_TASK(watchdog_reset);
25+
26+
void
27+
watchdog_init(void)
28+
{
29+
LPC_WDT->WDTC = 4000000 / 2; // 500ms timeout
30+
LPC_WDT->WDCLKSEL = 1<<31; // Lock to internal RC
31+
LPC_WDT->WDMOD = 0x03; // select reset and enable
32+
watchdog_reset();
33+
}
34+
DECL_INIT(watchdog_init);
35+
36+
1437
/****************************************************************
1538
* misc functions
1639
****************************************************************/

0 commit comments

Comments
 (0)