Fixed to only use leds when DEBUG is set
This commit is contained in:
parent
a5264324b5
commit
14b1bb9f57
2 changed files with 39 additions and 17 deletions
|
@ -28,7 +28,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* 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.
|
* This code is almost device independent and should be easy to port.
|
||||||
|
@ -88,6 +88,17 @@
|
||||||
#define PRINTF(...) do {} while (0)
|
#define PRINTF(...) do {} while (0)
|
||||||
#endif
|
#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);
|
void cc2420_arch_init(void);
|
||||||
|
|
||||||
/* XXX hack: these will be made as Chameleon packet attributes */
|
/* XXX hack: these will be made as Chameleon packet attributes */
|
||||||
|
@ -190,7 +201,7 @@ on(void)
|
||||||
strobe(CC2420_SRXON);
|
strobe(CC2420_SRXON);
|
||||||
while(!(status() & (BV(CC2420_XOSC16M_STABLE))));
|
while(!(status() & (BV(CC2420_XOSC16M_STABLE))));
|
||||||
ENERGEST_ON(ENERGEST_TYPE_LISTEN);
|
ENERGEST_ON(ENERGEST_TYPE_LISTEN);
|
||||||
leds_on(LEDS_GREEN);
|
LEDS_ON(LEDS_GREEN);
|
||||||
}
|
}
|
||||||
static void
|
static void
|
||||||
off(void)
|
off(void)
|
||||||
|
@ -204,7 +215,7 @@ off(void)
|
||||||
ENERGEST_OFF(ENERGEST_TYPE_LISTEN);
|
ENERGEST_OFF(ENERGEST_TYPE_LISTEN);
|
||||||
strobe(CC2420_SRFOFF);
|
strobe(CC2420_SRFOFF);
|
||||||
DISABLE_FIFOP_INT();
|
DISABLE_FIFOP_INT();
|
||||||
leds_off(LEDS_GREEN);
|
LEDS_OFF(LEDS_GREEN);
|
||||||
|
|
||||||
if(!FIFOP_IS_1) {
|
if(!FIFOP_IS_1) {
|
||||||
flushrx();
|
flushrx();
|
||||||
|
@ -219,7 +230,7 @@ static void RELEASE_LOCK(void) {
|
||||||
lock_on = 0;
|
lock_on = 0;
|
||||||
}
|
}
|
||||||
if(lock_off) {
|
if(lock_off) {
|
||||||
leds_off(LEDS_BLUE);
|
LEDS_OFF(LEDS_BLUE);
|
||||||
off();
|
off();
|
||||||
lock_off = 0;
|
lock_off = 0;
|
||||||
}
|
}
|
||||||
|
@ -471,7 +482,7 @@ cc2420_off(void)
|
||||||
radio should be turned off when the lock is unlocked. */
|
radio should be turned off when the lock is unlocked. */
|
||||||
if(locked) {
|
if(locked) {
|
||||||
/* printf("Off when locked (%d)\n", locked);*/
|
/* printf("Off when locked (%d)\n", locked);*/
|
||||||
leds_on(LEDS_GREEN + LEDS_BLUE);
|
LEDS_ON(LEDS_GREEN + LEDS_BLUE);
|
||||||
lock_off = 1;
|
lock_off = 1;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -497,7 +508,7 @@ cc2420_on(void)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if(locked) {
|
if(locked) {
|
||||||
leds_on(LEDS_GREEN + LEDS_RED);
|
LEDS_ON(LEDS_GREEN + LEDS_RED);
|
||||||
lock_on = 1;
|
lock_on = 1;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* 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(...)
|
#define PRINTDEBUG(...)
|
||||||
#endif
|
#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
|
#if CONTIKIMAC_CONF_ANNOUNCEMENTS
|
||||||
/* Timers for keeping track of when to send announcements. */
|
/* Timers for keeping track of when to send announcements. */
|
||||||
static struct ctimer announcement_cycle_ctimer, announcement_ctimer;
|
static struct ctimer announcement_cycle_ctimer, announcement_ctimer;
|
||||||
|
@ -367,24 +378,24 @@ powercycle(struct rtimer *t, void *ptr)
|
||||||
silence_periods = 0;
|
silence_periods = 0;
|
||||||
}
|
}
|
||||||
if(silence_periods > MAX_SILENCE_PERIODS) {
|
if(silence_periods > MAX_SILENCE_PERIODS) {
|
||||||
leds_on(LEDS_RED);
|
LEDS_ON(LEDS_RED);
|
||||||
powercycle_turn_radio_off();
|
powercycle_turn_radio_off();
|
||||||
#if CONTIKIMAC_CONF_COMPOWER
|
#if CONTIKIMAC_CONF_COMPOWER
|
||||||
compower_accumulate(&compower_idle_activity);
|
compower_accumulate(&compower_idle_activity);
|
||||||
#endif /* CONTIKIMAC_CONF_COMPOWER */
|
#endif /* CONTIKIMAC_CONF_COMPOWER */
|
||||||
leds_off(LEDS_RED);
|
LEDS_OFF(LEDS_RED);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#if 1
|
#if 1
|
||||||
if(periods > MAX_NONACTIVITY_PERIODIC && !(NETSTACK_RADIO.receiving_packet() ||
|
if(periods > MAX_NONACTIVITY_PERIODIC && !(NETSTACK_RADIO.receiving_packet() ||
|
||||||
NETSTACK_RADIO.pending_packet())) {
|
NETSTACK_RADIO.pending_packet())) {
|
||||||
leds_on(LEDS_GREEN);
|
LEDS_ON(LEDS_GREEN);
|
||||||
powercycle_turn_radio_off();
|
powercycle_turn_radio_off();
|
||||||
#if CONTIKIMAC_CONF_COMPOWER
|
#if CONTIKIMAC_CONF_COMPOWER
|
||||||
compower_accumulate(&compower_idle_activity);
|
compower_accumulate(&compower_idle_activity);
|
||||||
#endif /* CONTIKIMAC_CONF_COMPOWER */
|
#endif /* CONTIKIMAC_CONF_COMPOWER */
|
||||||
|
|
||||||
leds_off(LEDS_GREEN);
|
LEDS_OFF(LEDS_GREEN);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif /* 0 */
|
#endif /* 0 */
|
||||||
|
@ -393,18 +404,18 @@ powercycle(struct rtimer *t, void *ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
schedule_powercycle(t, CCA_CHECK_TIME + CCA_SLEEP_TIME);
|
schedule_powercycle(t, CCA_CHECK_TIME + CCA_SLEEP_TIME);
|
||||||
leds_on(LEDS_BLUE);
|
LEDS_ON(LEDS_BLUE);
|
||||||
PT_YIELD(&pt);
|
PT_YIELD(&pt);
|
||||||
leds_off(LEDS_BLUE);
|
LEDS_OFF(LEDS_BLUE);
|
||||||
}
|
}
|
||||||
if(radio_is_on && !(NETSTACK_RADIO.receiving_packet() ||
|
if(radio_is_on && !(NETSTACK_RADIO.receiving_packet() ||
|
||||||
NETSTACK_RADIO.pending_packet())) {
|
NETSTACK_RADIO.pending_packet())) {
|
||||||
leds_on(LEDS_RED + LEDS_GREEN);
|
LEDS_ON(LEDS_RED + LEDS_GREEN);
|
||||||
powercycle_turn_radio_off();
|
powercycle_turn_radio_off();
|
||||||
#if CONTIKIMAC_CONF_COMPOWER
|
#if CONTIKIMAC_CONF_COMPOWER
|
||||||
compower_accumulate(&compower_idle_activity);
|
compower_accumulate(&compower_idle_activity);
|
||||||
#endif /* CONTIKIMAC_CONF_COMPOWER */
|
#endif /* CONTIKIMAC_CONF_COMPOWER */
|
||||||
leds_off(LEDS_RED + LEDS_GREEN);
|
LEDS_OFF(LEDS_RED + LEDS_GREEN);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#if CONTIKIMAC_CONF_COMPOWER
|
#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));
|
RTIMER_CLOCK_LT(RTIMER_NOW() - cycle_start, CYCLE_TIME - CHECK_TIME));
|
||||||
|
|
||||||
if(is_snooping) {
|
if(is_snooping) {
|
||||||
leds_on(LEDS_RED);
|
LEDS_ON(LEDS_RED);
|
||||||
}
|
}
|
||||||
if(RTIMER_CLOCK_LT(RTIMER_NOW() - cycle_start, CYCLE_TIME)) {
|
if(RTIMER_CLOCK_LT(RTIMER_NOW() - cycle_start, CYCLE_TIME)) {
|
||||||
/* schedule_powercycle(t, CYCLE_TIME - (RTIMER_NOW() - cycle_start));*/
|
/* 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));*/
|
cycle_start, RTIMER_NOW(), CYCLE_TIME - (RTIMER_NOW() - cycle_start));*/
|
||||||
PT_YIELD(&pt);
|
PT_YIELD(&pt);
|
||||||
}
|
}
|
||||||
leds_off(LEDS_RED);
|
LEDS_OFF(LEDS_RED);
|
||||||
}
|
}
|
||||||
|
|
||||||
PT_END(&pt);
|
PT_END(&pt);
|
||||||
|
|
Loading…
Reference in a new issue