Added watchdog support

This commit is contained in:
adamdunkels 2007-11-17 10:29:33 +00:00
parent 75a1cb72f8
commit ff45f9d2c4

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* @(#)$Id: contiki-sky-main.c,v 1.14 2007/11/10 20:44:30 adamdunkels Exp $ * @(#)$Id: contiki-sky-main.c,v 1.15 2007/11/17 10:29:33 adamdunkels Exp $
*/ */
#include <signal.h> #include <signal.h>
@ -44,7 +44,7 @@
#include "dev/light.h" #include "dev/light.h"
#include "dev/xmem.h" #include "dev/xmem.h"
#include "dev/simple-cc2420.h" #include "dev/simple-cc2420.h"
#include "dev/watchdog.h"
#include "dev/slip.h" #include "dev/slip.h"
#include "dev/uart1.h" #include "dev/uart1.h"
@ -127,7 +127,7 @@ main(int argc, char **argv)
#endif /* WITH_UIP */ #endif /* WITH_UIP */
printf("Starting %s " printf("Starting %s "
"($Id: contiki-sky-main.c,v 1.14 2007/11/10 20:44:30 adamdunkels Exp $)\n", __FILE__); "($Id: contiki-sky-main.c,v 1.15 2007/11/17 10:29:33 adamdunkels Exp $)\n", __FILE__);
leds_on(LEDS_GREEN); leds_on(LEDS_GREEN);
ds2411_init(); ds2411_init();
sensors_light_init(); sensors_light_init();
@ -197,6 +197,7 @@ main(int argc, char **argv)
*/ */
printf("process_run()...\n"); printf("process_run()...\n");
ENERGEST_ON(ENERGEST_TYPE_CPU); ENERGEST_ON(ENERGEST_TYPE_CPU);
watchdog_start();
while (1) { while (1) {
int r; int r;
#if PROFILE_CONF_ON #if PROFILE_CONF_ON
@ -204,6 +205,7 @@ main(int argc, char **argv)
#endif /* PROFILE_CONF_ON */ #endif /* PROFILE_CONF_ON */
do { do {
/* Reset watchdog. */ /* Reset watchdog. */
watchdog_periodic();
r = process_run(); r = process_run();
} while(r > 0); } while(r > 0);
#if PROFILE_CONF_ON #if PROFILE_CONF_ON
@ -225,7 +227,7 @@ main(int argc, char **argv)
are asleep, so we discard the processing time done when we are asleep, so we discard the processing time done when we
were awake. */ were awake. */
energest_type_set(ENERGEST_TYPE_IRQ, irq_energest); energest_type_set(ENERGEST_TYPE_IRQ, irq_energest);
watchdog_stop();
_BIS_SR(GIE | SCG0 | /*SCG1 |*/ CPUOFF); /* LPM3 sleep. This _BIS_SR(GIE | SCG0 | /*SCG1 |*/ CPUOFF); /* LPM3 sleep. This
statement will block statement will block
until the CPU is until the CPU is
@ -239,6 +241,7 @@ main(int argc, char **argv)
dint(); dint();
irq_energest = energest_type_time(ENERGEST_TYPE_IRQ); irq_energest = energest_type_time(ENERGEST_TYPE_IRQ);
eint(); eint();
watchdog_start();
ENERGEST_OFF(ENERGEST_TYPE_LPM); ENERGEST_OFF(ENERGEST_TYPE_LPM);
ENERGEST_ON(ENERGEST_TYPE_CPU); ENERGEST_ON(ENERGEST_TYPE_CPU);
#if PROFILE_CONF_ON #if PROFILE_CONF_ON