Fixed to only use leds when DEBUG is set

This commit is contained in:
nifi 2010-04-20 11:41:16 +00:00
parent a5264324b5
commit 14b1bb9f57
2 changed files with 39 additions and 17 deletions

View file

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* @(#)$Id: cc2420.c,v 1.51 2010/04/08 18:23:24 adamdunkels Exp $
* @(#)$Id: cc2420.c,v 1.52 2010/04/20 11:41:16 nifi Exp $
*/
/*
* This code is almost device independent and should be easy to port.
@ -88,6 +88,17 @@
#define PRINTF(...) do {} while (0)
#endif
#define DEBUG_LEDS DEBUG
#undef LEDS_ON
#undef LEDS_OFF
#if DEBUG_LEDS
#define LEDS_ON(x) leds_on(x)
#define LEDS_OFF(x) leds_off(x)
#else
#define LEDS_ON(x)
#define LEDS_OFF(x)
#endif
void cc2420_arch_init(void);
/* XXX hack: these will be made as Chameleon packet attributes */
@ -190,7 +201,7 @@ on(void)
strobe(CC2420_SRXON);
while(!(status() & (BV(CC2420_XOSC16M_STABLE))));
ENERGEST_ON(ENERGEST_TYPE_LISTEN);
leds_on(LEDS_GREEN);
LEDS_ON(LEDS_GREEN);
}
static void
off(void)
@ -204,7 +215,7 @@ off(void)
ENERGEST_OFF(ENERGEST_TYPE_LISTEN);
strobe(CC2420_SRFOFF);
DISABLE_FIFOP_INT();
leds_off(LEDS_GREEN);
LEDS_OFF(LEDS_GREEN);
if(!FIFOP_IS_1) {
flushrx();
@ -219,7 +230,7 @@ static void RELEASE_LOCK(void) {
lock_on = 0;
}
if(lock_off) {
leds_off(LEDS_BLUE);
LEDS_OFF(LEDS_BLUE);
off();
lock_off = 0;
}
@ -471,7 +482,7 @@ cc2420_off(void)
radio should be turned off when the lock is unlocked. */
if(locked) {
/* printf("Off when locked (%d)\n", locked);*/
leds_on(LEDS_GREEN + LEDS_BLUE);
LEDS_ON(LEDS_GREEN + LEDS_BLUE);
lock_off = 1;
return 1;
}
@ -497,7 +508,7 @@ cc2420_on(void)
return 1;
}
if(locked) {
leds_on(LEDS_GREEN + LEDS_RED);
LEDS_ON(LEDS_GREEN + LEDS_RED);
lock_on = 1;
return 1;
}

View file

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: contikimac.c,v 1.32 2010/04/08 18:23:24 adamdunkels Exp $
* $Id: contikimac.c,v 1.33 2010/04/20 11:41:16 nifi Exp $
*/
/**
@ -155,6 +155,17 @@ static volatile unsigned char radio_is_on = 0;
#define PRINTDEBUG(...)
#endif
#define DEBUG_LEDS DEBUG
#undef LEDS_ON
#undef LEDS_OFF
#if DEBUG_LEDS
#define LEDS_ON(x) leds_on(x)
#define LEDS_OFF(x) leds_off(x)
#else
#define LEDS_ON(x)
#define LEDS_OFF(x)
#endif
#if CONTIKIMAC_CONF_ANNOUNCEMENTS
/* Timers for keeping track of when to send announcements. */
static struct ctimer announcement_cycle_ctimer, announcement_ctimer;
@ -367,24 +378,24 @@ powercycle(struct rtimer *t, void *ptr)
silence_periods = 0;
}
if(silence_periods > MAX_SILENCE_PERIODS) {
leds_on(LEDS_RED);
LEDS_ON(LEDS_RED);
powercycle_turn_radio_off();
#if CONTIKIMAC_CONF_COMPOWER
compower_accumulate(&compower_idle_activity);
#endif /* CONTIKIMAC_CONF_COMPOWER */
leds_off(LEDS_RED);
LEDS_OFF(LEDS_RED);
break;
}
#if 1
if(periods > MAX_NONACTIVITY_PERIODIC && !(NETSTACK_RADIO.receiving_packet() ||
NETSTACK_RADIO.pending_packet())) {
leds_on(LEDS_GREEN);
LEDS_ON(LEDS_GREEN);
powercycle_turn_radio_off();
#if CONTIKIMAC_CONF_COMPOWER
compower_accumulate(&compower_idle_activity);
#endif /* CONTIKIMAC_CONF_COMPOWER */
leds_off(LEDS_GREEN);
LEDS_OFF(LEDS_GREEN);
break;
}
#endif /* 0 */
@ -393,18 +404,18 @@ powercycle(struct rtimer *t, void *ptr)
}
schedule_powercycle(t, CCA_CHECK_TIME + CCA_SLEEP_TIME);
leds_on(LEDS_BLUE);
LEDS_ON(LEDS_BLUE);
PT_YIELD(&pt);
leds_off(LEDS_BLUE);
LEDS_OFF(LEDS_BLUE);
}
if(radio_is_on && !(NETSTACK_RADIO.receiving_packet() ||
NETSTACK_RADIO.pending_packet())) {
leds_on(LEDS_RED + LEDS_GREEN);
LEDS_ON(LEDS_RED + LEDS_GREEN);
powercycle_turn_radio_off();
#if CONTIKIMAC_CONF_COMPOWER
compower_accumulate(&compower_idle_activity);
#endif /* CONTIKIMAC_CONF_COMPOWER */
leds_off(LEDS_RED + LEDS_GREEN);
LEDS_OFF(LEDS_RED + LEDS_GREEN);
}
} else {
#if CONTIKIMAC_CONF_COMPOWER
@ -415,7 +426,7 @@ powercycle(struct rtimer *t, void *ptr)
RTIMER_CLOCK_LT(RTIMER_NOW() - cycle_start, CYCLE_TIME - CHECK_TIME));
if(is_snooping) {
leds_on(LEDS_RED);
LEDS_ON(LEDS_RED);
}
if(RTIMER_CLOCK_LT(RTIMER_NOW() - cycle_start, CYCLE_TIME)) {
/* schedule_powercycle(t, CYCLE_TIME - (RTIMER_NOW() - cycle_start));*/
@ -424,7 +435,7 @@ powercycle(struct rtimer *t, void *ptr)
cycle_start, RTIMER_NOW(), CYCLE_TIME - (RTIMER_NOW() - cycle_start));*/
PT_YIELD(&pt);
}
leds_off(LEDS_RED);
LEDS_OFF(LEDS_RED);
}
PT_END(&pt);