From 26a87ee9cbe4da3ddbec781270fbce09a37ccfa0 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Mon, 30 Apr 2012 17:21:23 +0100 Subject: [PATCH] Improved handling of cc2x3x rf_flags --- cpu/cc2430/dev/cc2430_rf.c | 17 ++++++++++------- cpu/cc253x/dev/cc2530-rf.c | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/cpu/cc2430/dev/cc2430_rf.c b/cpu/cc2430/dev/cc2430_rf.c index fa66006f8..5339c84cc 100644 --- a/cpu/cc2430/dev/cc2430_rf.c +++ b/cpu/cc2430/dev/cc2430_rf.c @@ -76,10 +76,13 @@ #define PRINTF(...) do {} while (0) #endif -#define RX_ACTIVE 0x80 -#define TX_ACK 0x40 -#define TX_ON_AIR 0x20 -#define WAS_OFF 0x10 +/* rf_flags bits */ +#define RX_ACTIVE 0x80 +#define TX_ACK 0x40 +#define TX_ON_AIR 0x20 +#define WAS_OFF 0x10 +#define INITIALISED 0x01 + #define RX_NO_DMA /* Bits of the last byte in the RX FIFO */ #define CRC_BIT_MASK 0x80 @@ -102,7 +105,6 @@ uint8_t rf_error = 0; PROCESS(cc2430_rf_process, "CC2430 RF driver"); #endif /*---------------------------------------------------------------------------*/ -static uint8_t rf_initialized = 0; static uint8_t __data rf_flags; static uint8_t rf_channel; @@ -308,7 +310,7 @@ cc2430_rf_send_ack(uint8_t pending) static int init(void) { - if(rf_initialized) { + if(rf_flags & INITIALISED) { return 0; } @@ -358,7 +360,8 @@ init(void) RF_TX_LED_OFF(); RF_RX_LED_OFF(); - rf_initialized = 1; + + rf_flags |= INITIALISED; #if !NETSTACK_CONF_SHORTCUTS process_start(&cc2430_rf_process, NULL); diff --git a/cpu/cc253x/dev/cc2530-rf.c b/cpu/cc253x/dev/cc2530-rf.c index a8c12b800..b590b7f2d 100644 --- a/cpu/cc253x/dev/cc2530-rf.c +++ b/cpu/cc253x/dev/cc2530-rf.c @@ -475,7 +475,7 @@ off(void) CC2530_CSP_ISRFOFF(); CC2530_CSP_ISFLUSHRX(); - rf_flags = 0; + rf_flags &= ~RX_ACTIVE; ENERGEST_OFF(ENERGEST_TYPE_LISTEN); return 1;