Improved handling of cc2x3x rf_flags

This commit is contained in:
George Oikonomou 2012-04-30 17:21:23 +01:00
parent 43f2790357
commit 26a87ee9cb
2 changed files with 11 additions and 8 deletions

View file

@ -76,10 +76,13 @@
#define PRINTF(...) do {} while (0) #define PRINTF(...) do {} while (0)
#endif #endif
/* rf_flags bits */
#define RX_ACTIVE 0x80 #define RX_ACTIVE 0x80
#define TX_ACK 0x40 #define TX_ACK 0x40
#define TX_ON_AIR 0x20 #define TX_ON_AIR 0x20
#define WAS_OFF 0x10 #define WAS_OFF 0x10
#define INITIALISED 0x01
#define RX_NO_DMA #define RX_NO_DMA
/* Bits of the last byte in the RX FIFO */ /* Bits of the last byte in the RX FIFO */
#define CRC_BIT_MASK 0x80 #define CRC_BIT_MASK 0x80
@ -102,7 +105,6 @@ uint8_t rf_error = 0;
PROCESS(cc2430_rf_process, "CC2430 RF driver"); PROCESS(cc2430_rf_process, "CC2430 RF driver");
#endif #endif
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static uint8_t rf_initialized = 0;
static uint8_t __data rf_flags; static uint8_t __data rf_flags;
static uint8_t rf_channel; static uint8_t rf_channel;
@ -308,7 +310,7 @@ cc2430_rf_send_ack(uint8_t pending)
static int static int
init(void) init(void)
{ {
if(rf_initialized) { if(rf_flags & INITIALISED) {
return 0; return 0;
} }
@ -358,7 +360,8 @@ init(void)
RF_TX_LED_OFF(); RF_TX_LED_OFF();
RF_RX_LED_OFF(); RF_RX_LED_OFF();
rf_initialized = 1;
rf_flags |= INITIALISED;
#if !NETSTACK_CONF_SHORTCUTS #if !NETSTACK_CONF_SHORTCUTS
process_start(&cc2430_rf_process, NULL); process_start(&cc2430_rf_process, NULL);

View file

@ -475,7 +475,7 @@ off(void)
CC2530_CSP_ISRFOFF(); CC2530_CSP_ISRFOFF();
CC2530_CSP_ISFLUSHRX(); CC2530_CSP_ISFLUSHRX();
rf_flags = 0; rf_flags &= ~RX_ACTIVE;
ENERGEST_OFF(ENERGEST_TYPE_LISTEN); ENERGEST_OFF(ENERGEST_TYPE_LISTEN);
return 1; return 1;