Fixed watchdog support for the MSP430. It now works as intended

This commit is contained in:
adamdunkels 2007-11-17 10:16:48 +00:00
parent e1affe5e72
commit 19b7bd9217

View file

@ -28,27 +28,39 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* @(#)$Id: watchdog.c,v 1.1 2006/06/17 22:41:21 adamdunkels Exp $ * @(#)$Id: watchdog.c,v 1.2 2007/11/17 10:16:48 adamdunkels Exp $
*/ */
#include <io.h> #include <io.h>
#include "dev/watchdog.h" #include "dev/watchdog.h"
/*------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void
watchdog_init(void) watchdog_init(void)
{ {
WDTCTL = WDT_ARST_1000 + WDTNMI + WDTNMIES; /* The MSP430 watchdog is enabled at boot-up, so we stop it during
initialization. */
watchdog_stop();
} }
/*------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void
watchdog_restart(void) watchdog_start(void)
{ {
WDTCTL = WDT_ARST_1000 + WDTNMI + WDTNMIES; /* We setup the watchdog to reset the device after one second,
unless watchdog_periodic() is called. */
WDTCTL = WDTPW | WDTCNTCL | WDT_ARST_1000;
} }
/*------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void
watchdog_periodic(void)
{
/* This function is called periodically to restart the watchdog
timer. */
WDTCTL = (WDTCTL & 0xff) | WDTPW | WDTCNTCL;
}
/*---------------------------------------------------------------------------*/
void void
watchdog_stop(void) watchdog_stop(void)
{ {
WDTCTL = WDTPW + WDTHOLD + WDTNMI + WDTNMIES; WDTCTL = WDTPW | WDTHOLD;
} }
/*------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/