From cc7d3ae142a4348d8118976b1c22918170c87e3d Mon Sep 17 00:00:00 2001 From: adamdunkels Date: Tue, 9 Mar 2010 13:18:16 +0000 Subject: [PATCH] Reset CCA mode to default. Make sure that the radio gto switched on when reading RSSI; otherwise node will reboot because of watchdog --- core/dev/cc2420.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/dev/cc2420.c b/core/dev/cc2420.c index 66856e558..3ea9f1475 100644 --- a/core/dev/cc2420.c +++ b/core/dev/cc2420.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: cc2420.c,v 1.41 2010/02/25 16:06:44 adamdunkels Exp $ + * @(#)$Id: cc2420.c,v 1.42 2010/03/09 13:18:16 adamdunkels Exp $ */ /* * This code is almost device independent and should be easy to port. @@ -280,8 +280,6 @@ cc2420_init(void) /* Turn on/off automatic packet acknowledgment and address decoding. */ reg = getreg(CC2420_MDMCTRL0); - reg |= 0x40; /* XXX CCA mode 1 */ - #if CC2420_CONF_AUTOACK reg |= AUTOACK | ADR_DECODE; #else @@ -370,7 +368,6 @@ cc2420_transmit(unsigned short payload_len) accurate measurement of the transmission time.*/ while(status() & BV(CC2420_TX_ACTIVE)); - #ifdef ENERGEST_CONF_LEVELDEVICE_LEVELS ENERGEST_OFF_LEVEL(ENERGEST_TYPE_TRANSMIT,cc2420_get_txpower()); #endif @@ -761,9 +758,12 @@ cc2420_cca(void) if(!receive_on) { radio_was_off = 1; cc2420_on(); - } + /* Make sure that the radio really got turned on. */ + if(!receive_on) { + return 1; + } while(!(status() & BV(CC2420_RSSI_VALID))) { /* printf("cc2420_rssi: RSSI not valid.\n"); */