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.
*
* @(#)$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 "dev/watchdog.h"
static int stopped = 0;
/*---------------------------------------------------------------------------*/
void
watchdog_init(void)
@ -48,6 +49,7 @@ watchdog_start(void)
/* We setup the watchdog to reset the device after one second,
unless watchdog_periodic() is called. */
WDTCTL = WDTPW | WDTCNTCL | WDT_ARST_1000;
stopped = 0;
}
/*---------------------------------------------------------------------------*/
void
@ -55,13 +57,16 @@ watchdog_periodic(void)
{
/* This function is called periodically to restart the watchdog
timer. */
WDTCTL = (WDTCTL & 0xff) | WDTPW | WDTCNTCL;
if(!stopped) {
WDTCTL = (WDTCTL & 0xff) | WDTPW | WDTCNTCL;
}
}
/*---------------------------------------------------------------------------*/
void
watchdog_stop(void)
{
WDTCTL = WDTPW | WDTHOLD;
stopped = 1;
}
/*---------------------------------------------------------------------------*/
void