Update the periodic watchdog only if it is not stopped

This commit is contained in:
adamdunkels 2008-01-21 10:39:23 +00:00
parent bed0963769
commit a4d5ca833c

View File

@ -28,11 +28,12 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* @(#)$Id: watchdog.c,v 1.3 2008/01/08 08:03:02 adamdunkels Exp $ * @(#)$Id: watchdog.c,v 1.4 2008/01/21 10:39:23 adamdunkels Exp $
*/ */
#include <io.h> #include <io.h>
#include "dev/watchdog.h" #include "dev/watchdog.h"
static int stopped = 0;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void
watchdog_init(void) watchdog_init(void)
@ -48,6 +49,7 @@ watchdog_start(void)
/* We setup the watchdog to reset the device after one second, /* We setup the watchdog to reset the device after one second,
unless watchdog_periodic() is called. */ unless watchdog_periodic() is called. */
WDTCTL = WDTPW | WDTCNTCL | WDT_ARST_1000; WDTCTL = WDTPW | WDTCNTCL | WDT_ARST_1000;
stopped = 0;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void
@ -55,13 +57,16 @@ watchdog_periodic(void)
{ {
/* This function is called periodically to restart the watchdog /* This function is called periodically to restart the watchdog
timer. */ timer. */
WDTCTL = (WDTCTL & 0xff) | WDTPW | WDTCNTCL; if(!stopped) {
WDTCTL = (WDTCTL & 0xff) | WDTPW | WDTCNTCL;
}
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void
watchdog_stop(void) watchdog_stop(void)
{ {
WDTCTL = WDTPW | WDTHOLD; WDTCTL = WDTPW | WDTHOLD;
stopped = 1;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void