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
1 changed files with 19 additions and 15 deletions
|
@ -28,13 +28,16 @@
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* 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 <io.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include "dev/watchdog.h"
|
#include "dev/watchdog.h"
|
||||||
|
|
||||||
static int stopped = 0;
|
static int counter = 0;
|
||||||
|
|
||||||
|
#define PRINT_STACK_ON_REBOOT 1
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#ifdef CONTIKI_TARGET_SKY
|
#ifdef CONTIKI_TARGET_SKY
|
||||||
static void
|
static void
|
||||||
|
@ -69,15 +72,13 @@ interrupt(WDT_VECTOR)
|
||||||
watchdog_interrupt(void)
|
watchdog_interrupt(void)
|
||||||
{
|
{
|
||||||
#ifdef CONTIKI_TARGET_SKY
|
#ifdef CONTIKI_TARGET_SKY
|
||||||
|
#if PRINT_STACK_ON_REBOOT
|
||||||
uint8_t dummy;
|
uint8_t dummy;
|
||||||
static uint8_t *ptr;
|
static uint8_t *ptr;
|
||||||
static int i;
|
static int i;
|
||||||
|
|
||||||
ptr = &dummy;
|
ptr = &dummy;
|
||||||
printstring("Watchdog reset");
|
printstring("Watchdog reset");
|
||||||
/* printstring("Watchdog reset at PC $");
|
|
||||||
hexprint(ptr[3]);
|
|
||||||
hexprint(ptr[2]);*/
|
|
||||||
printstring("\nStack at $");
|
printstring("\nStack at $");
|
||||||
hexprint(((int)ptr) >> 8);
|
hexprint(((int)ptr) >> 8);
|
||||||
hexprint(((int)ptr) & 0xff);
|
hexprint(((int)ptr) & 0xff);
|
||||||
|
@ -91,7 +92,8 @@ watchdog_interrupt(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printchar('\n');
|
printchar('\n');
|
||||||
#endif
|
#endif /* PRINT_STACK_ON_REBOOT */
|
||||||
|
#endif /* CONTIKI_TARGET_SKY */
|
||||||
|
|
||||||
watchdog_reboot();
|
watchdog_reboot();
|
||||||
}
|
}
|
||||||
|
@ -101,7 +103,7 @@ watchdog_init(void)
|
||||||
{
|
{
|
||||||
/* The MSP430 watchdog is enabled at boot-up, so we stop it during
|
/* The MSP430 watchdog is enabled at boot-up, so we stop it during
|
||||||
initialization. */
|
initialization. */
|
||||||
stopped = 0;
|
counter = 0;
|
||||||
watchdog_stop();
|
watchdog_stop();
|
||||||
|
|
||||||
IFG1 &= ~WDTIFG;
|
IFG1 &= ~WDTIFG;
|
||||||
|
@ -113,8 +115,8 @@ 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. */
|
||||||
stopped--;
|
counter--;
|
||||||
if(!stopped) {
|
if(counter == 0) {
|
||||||
WDTCTL = WDTPW | WDTCNTCL | WDT_ARST_1000 | WDTTMSEL;
|
WDTCTL = WDTPW | WDTCNTCL | WDT_ARST_1000 | WDTTMSEL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,16 +126,18 @@ watchdog_periodic(void)
|
||||||
{
|
{
|
||||||
/* This function is called periodically to restart the watchdog
|
/* This function is called periodically to restart the watchdog
|
||||||
timer. */
|
timer. */
|
||||||
if(!stopped) {
|
/* if(counter < 0) {*/
|
||||||
WDTCTL = (WDTCTL & 0xff) | WDTPW | WDTCNTCL | WDTTMSEL;;
|
WDTCTL = (WDTCTL & 0xff) | WDTPW | WDTCNTCL | WDTTMSEL;
|
||||||
}
|
/* }*/
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
watchdog_stop(void)
|
watchdog_stop(void)
|
||||||
{
|
{
|
||||||
|
counter++;
|
||||||
|
if(counter == 1) {
|
||||||
WDTCTL = WDTPW | WDTHOLD;
|
WDTCTL = WDTPW | WDTHOLD;
|
||||||
stopped++;
|
}
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in a new issue