Made stack printout on reboot configurable.
Added the ability to turn on watchdog multiple times - the watchdog registers are touched only when the watchdog goes from off to on state to avoid retriggering the watchdog when it shouldn't.
This commit is contained in:
parent
0261af4af2
commit
7c14899eeb
|
@ -28,13 +28,16 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* @(#)$Id: watchdog.c,v 1.9 2010/08/24 16:23:20 joxe Exp $
|
||||
* @(#)$Id: watchdog.c,v 1.10 2010/09/22 22:12:37 adamdunkels Exp $
|
||||
*/
|
||||
#include <io.h>
|
||||
#include <signal.h>
|
||||
#include "dev/watchdog.h"
|
||||
|
||||
static int stopped = 0;
|
||||
static int counter = 0;
|
||||
|
||||
#define PRINT_STACK_ON_REBOOT 1
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifdef CONTIKI_TARGET_SKY
|
||||
static void
|
||||
|
@ -69,15 +72,13 @@ interrupt(WDT_VECTOR)
|
|||
watchdog_interrupt(void)
|
||||
{
|
||||
#ifdef CONTIKI_TARGET_SKY
|
||||
#if PRINT_STACK_ON_REBOOT
|
||||
uint8_t dummy;
|
||||
static uint8_t *ptr;
|
||||
static int i;
|
||||
|
||||
ptr = &dummy;
|
||||
printstring("Watchdog reset");
|
||||
/* printstring("Watchdog reset at PC $");
|
||||
hexprint(ptr[3]);
|
||||
hexprint(ptr[2]);*/
|
||||
printstring("\nStack at $");
|
||||
hexprint(((int)ptr) >> 8);
|
||||
hexprint(((int)ptr) & 0xff);
|
||||
|
@ -91,7 +92,8 @@ watchdog_interrupt(void)
|
|||
}
|
||||
}
|
||||
printchar('\n');
|
||||
#endif
|
||||
#endif /* PRINT_STACK_ON_REBOOT */
|
||||
#endif /* CONTIKI_TARGET_SKY */
|
||||
|
||||
watchdog_reboot();
|
||||
}
|
||||
|
@ -101,7 +103,7 @@ watchdog_init(void)
|
|||
{
|
||||
/* The MSP430 watchdog is enabled at boot-up, so we stop it during
|
||||
initialization. */
|
||||
stopped = 0;
|
||||
counter = 0;
|
||||
watchdog_stop();
|
||||
|
||||
IFG1 &= ~WDTIFG;
|
||||
|
@ -113,8 +115,8 @@ watchdog_start(void)
|
|||
{
|
||||
/* We setup the watchdog to reset the device after one second,
|
||||
unless watchdog_periodic() is called. */
|
||||
stopped--;
|
||||
if(!stopped) {
|
||||
counter--;
|
||||
if(counter == 0) {
|
||||
WDTCTL = WDTPW | WDTCNTCL | WDT_ARST_1000 | WDTTMSEL;
|
||||
}
|
||||
}
|
||||
|
@ -124,16 +126,18 @@ watchdog_periodic(void)
|
|||
{
|
||||
/* This function is called periodically to restart the watchdog
|
||||
timer. */
|
||||
if(!stopped) {
|
||||
WDTCTL = (WDTCTL & 0xff) | WDTPW | WDTCNTCL | WDTTMSEL;;
|
||||
}
|
||||
/* if(counter < 0) {*/
|
||||
WDTCTL = (WDTCTL & 0xff) | WDTPW | WDTCNTCL | WDTTMSEL;
|
||||
/* }*/
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
watchdog_stop(void)
|
||||
{
|
||||
counter++;
|
||||
if(counter == 1) {
|
||||
WDTCTL = WDTPW | WDTHOLD;
|
||||
stopped++;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
|
|
Loading…
Reference in a new issue