Define and use radio STATE_TRANSITION, improve debug messaging

This commit is contained in:
dak664 2010-03-02 16:29:59 +00:00
parent d3697344ec
commit 01a3912864
3 changed files with 141 additions and 109 deletions

View file

@ -1,7 +1,7 @@
/** /**
* @file * @file
* @brief This file contains the register definitions for the AT86RF230. * @brief This file contains the register definitions for the AT86RF230.
* $Id: at86rf230_registermap.h,v 1.1 2009/07/08 16:17:07 dak664 Exp $ * $Id: at86rf230_registermap.h,v 1.2 2010/03/02 16:29:59 dak664 Exp $
*/ */
/* Copyright (c) 2008, Swedish Institute of Computer Science /* Copyright (c) 2008, Swedish Institute of Computer Science
All rights reserved. All rights reserved.
@ -84,6 +84,8 @@
#define RX_AACK_ON_NOCLK (29) #define RX_AACK_ON_NOCLK (29)
/** Constant BUSY_RX_AACK_NOCLK for sub-register @ref SR_TRX_STATUS */ /** Constant BUSY_RX_AACK_NOCLK for sub-register @ref SR_TRX_STATUS */
#define BUSY_RX_AACK_NOCLK (30) #define BUSY_RX_AACK_NOCLK (30)
/** Constant STATE_TRANSITION for sub-register @ref SR_TRX_STATUS */
#define STATE_TRANSITION (31)
/** Offset for register TRX_STATE */ /** Offset for register TRX_STATE */
#define RG_TRX_STATE (0x02) #define RG_TRX_STATE (0x02)
/** Access parameters for sub-register TRAC_STATUS in register @ref RG_TRX_STATE */ /** Access parameters for sub-register TRAC_STATUS in register @ref RG_TRX_STATE */

View file

@ -706,7 +706,6 @@ ISR(RADIO_VECT)
} else if (interrupt_source & HAL_TRX_END_MASK){ } else if (interrupt_source & HAL_TRX_END_MASK){
INTERRUPTDEBUG(11); INTERRUPTDEBUG(11);
// if(trx_end_callback != NULL){ // if(trx_end_callback != NULL){
// INTERRUPTDEBUG(12);
// trx_end_callback(isr_timestamp); // trx_end_callback(isr_timestamp);
// } // }
@ -715,15 +714,17 @@ ISR(RADIO_VECT)
/* Received packet interrupt */ /* Received packet interrupt */
/* Buffer the frame and call rf230_interrupt to schedule poll for rf230 receive process */ /* Buffer the frame and call rf230_interrupt to schedule poll for rf230 receive process */
// if (rxframe.length) break; //toss packet if last one not processed yet // if (rxframe.length) break; //toss packet if last one not processed yet
INTERRUPTDEBUG(42); if (rxframe.length) INTERRUPTDEBUG(42); else INTERRUPTDEBUG(12);
hal_frame_read(&rxframe, NULL); hal_frame_read(&rxframe, NULL);
rf230_interrupt(); rf230_interrupt();
// trx_end_callback(isr_timestamp); // trx_end_callback(isr_timestamp);
#if 0
/* Enable reception of next packet */ /* Enable reception of next packet */
#if RF230_CONF_NO_AUTO_ACK #if RF230_CONF_AUTOACK
hal_subregister_write(SR_TRX_CMD, RX_ON);
#else
hal_subregister_write(SR_TRX_CMD, RX_AACK_ON); hal_subregister_write(SR_TRX_CMD, RX_AACK_ON);
#else
hal_subregister_write(SR_TRX_CMD, RX_ON);
#endif
#endif #endif
} }

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* @(#)$Id: rf230bb.c,v 1.8 2010/02/28 21:19:33 dak664 Exp $ * @(#)$Id: rf230bb.c,v 1.9 2010/03/02 16:29:59 dak664 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.
@ -75,7 +75,6 @@ extern rimeaddr_t macLongAddr;
#define WITH_SEND_CCA 0 #define WITH_SEND_CCA 0
#if RF230_CONF_TIMESTAMPS #if RF230_CONF_TIMESTAMPS
bomb
#include "net/rime/timesynch.h" #include "net/rime/timesynch.h"
#define TIMESTAMP_LEN 3 #define TIMESTAMP_LEN 3
#else /* RF230_CONF_TIMESTAMPS */ #else /* RF230_CONF_TIMESTAMPS */
@ -92,6 +91,10 @@ bomb
#define RF230_CONF_AUTOACK 1 #define RF230_CONF_AUTOACK 1
#endif /* RF230_CONF_AUTOACK */ #endif /* RF230_CONF_AUTOACK */
#ifndef RF230_CONF_AUTORETRIES
#define RF230_CONF_AUTORETRIES 2
#endif /* RF230_CONF_AUTOACK */
//Automatic and manual CRC both append 2 bytes to packets //Automatic and manual CRC both append 2 bytes to packets
#if RF230_CONF_CHECKSUM #if RF230_CONF_CHECKSUM
#include "lib/crc16.h" #include "lib/crc16.h"
@ -113,6 +116,8 @@ struct timestamp {
/* Leave radio on for testing low power protocols */ /* Leave radio on for testing low power protocols */
#if JACKDAW #if JACKDAW
#define RADIOALWAYSON 1 #define RADIOALWAYSON 1
#else
#define RADIOALWAYSON 1
#endif #endif
#define DEBUG 0 #define DEBUG 0
@ -121,7 +126,7 @@ struct timestamp {
#define PRINTSHORT(...) printf(__VA_ARGS__) #define PRINTSHORT(...) printf(__VA_ARGS__)
#else #else
#define PRINTF(...) #define PRINTF(...)
#define PRINTSHORT(...) #define PRINTSHORT(...) //printf(__VA_ARGS__)
#endif #endif
/* See clock.c and httpd-cgi.c for RADIOSTATS code */ /* See clock.c and httpd-cgi.c for RADIOSTATS code */
@ -133,6 +138,14 @@ uint8_t RF230_rsigsi;
uint16_t RF230_sendpackets,RF230_receivepackets,RF230_sendfail,RF230_receivefail; uint16_t RF230_sendpackets,RF230_receivepackets,RF230_sendfail,RF230_receivefail;
#endif #endif
/* Track flow through driver, see contiki-raven-main.c for example of use */
#define DEBUGFLOWSIZE 64
#if DEBUGFLOWSIZE
uint8_t debugflowsize,debugflow[DEBUGFLOWSIZE];
#define DEBUGFLOW(c) if (debugflowsize<(DEBUGFLOWSIZE-1)) debugflow[debugflowsize++]=c
#else
#define DEBUGFLOW(c)
#endif
/* XXX hack: these will be made as Chameleon packet attributes */ /* XXX hack: these will be made as Chameleon packet attributes */
rtimer_clock_t rf230_time_of_arrival, rf230_time_of_departure; rtimer_clock_t rf230_time_of_arrival, rf230_time_of_departure;
@ -285,6 +298,32 @@ radio_reset_state_machine(void)
hal_subregister_write(SR_TRX_CMD, CMD_FORCE_TRX_OFF); hal_subregister_write(SR_TRX_CMD, CMD_FORCE_TRX_OFF);
delay_us(TIME_CMD_FORCE_TRX_OFF); delay_us(TIME_CMD_FORCE_TRX_OFF);
} }
/*---------------------------------------------------------------------------*/
static char
rf230_isidle(void)
{
uint8_t radio_state;
radio_state = hal_subregister_read(SR_TRX_STATUS);
if (radio_state != BUSY_TX_ARET &&
radio_state != BUSY_RX_AACK &&
radio_state != STATE_TRANSITION &&
radio_state != BUSY_RX &&
radio_state != BUSY_TX) {
return(1);
} else {
// printf(".%u",radio_state);
return(0);
}
}
static void
rf230_waitidle(void)
{
while (1) {
if (rf230_isidle()) break;
}
}
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/** \brief This function will change the current state of the radio /** \brief This function will change the current state of the radio
* transceiver's internal state machine. * transceiver's internal state machine.
@ -322,16 +361,17 @@ radio_set_trx_state(uint8_t new_state)
return RADIO_WRONG_STATE; return RADIO_WRONG_STATE;
} }
// Wait for radio to finish previous operation /* Wait for radio to finish previous operation */
for(;;) rf230_waitidle();
{ // for(;;)
// {
original_state = radio_get_trx_state(); original_state = radio_get_trx_state();
if (original_state != BUSY_TX_ARET && // if (original_state != BUSY_TX_ARET &&
original_state != BUSY_RX_AACK && // original_state != BUSY_RX_AACK &&
original_state != BUSY_RX && // original_state != BUSY_RX &&
original_state != BUSY_TX) // original_state != BUSY_TX)
break; // break;
} // }
if (new_state == original_state){ if (new_state == original_state){
return RADIO_SUCCESS; return RADIO_SUCCESS;
@ -379,45 +419,11 @@ radio_set_trx_state(uint8_t new_state)
if (radio_get_trx_state() == new_state){ if (radio_get_trx_state() == new_state){
set_state_status = RADIO_SUCCESS; set_state_status = RADIO_SUCCESS;
/* set rx_mode flag based on mode we're changing to */
// if (new_state == RX_ON ||
// new_state == RX_AACK_ON){
// rx_mode = true;
// } else {
// rx_mode = false;
// }
} }
return set_state_status; return set_state_status;
} }
/*---------------------------------------------------------------------------*/
static int
rf230_isidle(void)
{
uint8_t radio_state;
radio_state = hal_subregister_read(SR_TRX_STATUS);
if (radio_state != BUSY_TX_ARET &&
radio_state != BUSY_RX_AACK &&
radio_state != BUSY_RX &&
radio_state != BUSY_TX) {
return(1);
} else {
return(0);
}
}
static void
rf230_waitidle(void)
{
// PRINTF("rf230_waitidle");
while (1) {
if (rf230_isidle()) break;
// PRINTSHORT(".");
}
}
static void static void
flushrx(void) flushrx(void)
{ {
@ -449,7 +455,8 @@ on(void)
if (RF230_sleeping) { if (RF230_sleeping) {
hal_set_slptr_low(); hal_set_slptr_low();
delay_us(TIME_SLEEP_TO_TRX_OFF); delay_us(TIME_SLEEP_TO_TRX_OFF);
delay_us(TIME_SLEEP_TO_TRX_OFF);//extra delay for now, wake time depends on board capacitance // delay_us(TIME_SLEEP_TO_TRX_OFF);//extra delay for now, wake time depends on board capacitance
RF230_sleeping=0;
} }
rf230_waitidle(); rf230_waitidle();
@ -459,6 +466,7 @@ on(void)
radio_set_trx_state(RX_ON); radio_set_trx_state(RX_ON);
#endif #endif
// flushrx(); // flushrx();
// DEBUGFLOW('O');
RF230_receive_on = 1; RF230_receive_on = 1;
} }
static void static void
@ -473,6 +481,7 @@ off(void)
// PRINTSHORT("f"); // PRINTSHORT("f");
#endif #endif
// DEBUGFLOW('F');
#if !RADIOALWAYSON #if !RADIOALWAYSON
/* Wait any transmission to end */ /* Wait any transmission to end */
@ -521,6 +530,8 @@ set_txpower(uint8_t power)
int int
rf230_init(void) rf230_init(void)
{ {
DEBUGFLOW('I');
/* Wait in case VCC just applied */ /* Wait in case VCC just applied */
delay_us(TIME_TO_ENTER_P_ON); delay_us(TIME_TO_ENTER_P_ON);
@ -553,7 +564,7 @@ rf230_init(void)
hal_register_write(RG_IRQ_MASK, RF230_SUPPORTED_INTERRUPT_MASK); hal_register_write(RG_IRQ_MASK, RF230_SUPPORTED_INTERRUPT_MASK);
/* Set up number of automatic retries */ /* Set up number of automatic retries */
hal_subregister_write(SR_MAX_FRAME_RETRIES, RF230_CONF_AUTO_RETRIES ); hal_subregister_write(SR_MAX_FRAME_RETRIES, RF230_CONF_AUTORETRIES );
/* Use automatic CRC unless manual is specified */ /* Use automatic CRC unless manual is specified */
#if RF230_CONF_CHECKSUM #if RF230_CONF_CHECKSUM
@ -562,17 +573,6 @@ rf230_init(void)
hal_subregister_write(SR_TX_AUTO_CRC_ON, 1); hal_subregister_write(SR_TX_AUTO_CRC_ON, 1);
#endif #endif
#if 0
/* Set radio to receive mode (?) */
#if RF230_CONF_AUTOACK
//radio_set_trx_state(RX_AACK_ON);
hal_subregister_write(SR_TRX_CMD, CMD_RX_AACK_ON);
#else
//radio_set_trx_state(RX_ON);
hal_subregister_write(SR_TRX_CMD, CMD_RX_ON);
#endif
#endif
/* Start the packet receive process */ /* Start the packet receive process */
process_start(&rf230_process, NULL); process_start(&rf230_process, NULL);
@ -596,15 +596,28 @@ rf230_transmit(unsigned short payload_len)
#endif /* RF230_CONF_CHECKSUM */ #endif /* RF230_CONF_CHECKSUM */
GET_LOCK(); GET_LOCK();
// DEBUGFLOW('T');
/* Save receiver state */ /* Save receiver state */
radiowason=RF230_receive_on; radiowason=RF230_receive_on;
/* If radio is sleeping we have to turn it on first */ /* If radio is sleeping we have to turn it on first */
if (RF230_sleeping) { if (RF230_sleeping) {
on(); hal_set_slptr_low();
// delay_us(TIME_SLEEP_TO_TRX_OFF);
RF230_sleeping=0;
} }
/* Wait for any previous operation or state transition to finish */
rf230_waitidle();
/* Prepare to transmit */
#if RF230_CONF_AUTORETRIES
radio_set_trx_state(TX_ARET_ON);
#else
radio_set_trx_state(PLL_ON);
#endif
txpower = 0; txpower = 0;
if(packetbuf_attr(PACKETBUF_ATTR_RADIO_TXPOWER) > 0) { if(packetbuf_attr(PACKETBUF_ATTR_RADIO_TXPOWER) > 0) {
@ -620,16 +633,6 @@ rf230_transmit(unsigned short payload_len)
rtimer_clock_t txtime = timesynch_time(); rtimer_clock_t txtime = timesynch_time();
#endif /* RF230_CONF_TIMESTAMPS */ #endif /* RF230_CONF_TIMESTAMPS */
/* Wait for any previous transmission to finish (?) */
rf230_waitidle();
// hal_subregister_write(SR_TRX_CMD, CMD_FORCE_TRX_OFF);
// delay_us(TIME_P_ON_TO_TRX_OFF);
/* Enable auto retry (?) */
radio_set_trx_state(TX_ARET_ON);
// CMD_TX_START
/* Toggle the SLP_TR pin to initiate the frame transmission */ /* Toggle the SLP_TR pin to initiate the frame transmission */
hal_set_slptr_high(); hal_set_slptr_high();
hal_set_slptr_low(); hal_set_slptr_low();
@ -643,12 +646,24 @@ rf230_transmit(unsigned short payload_len)
#if RADIOSTATS #if RADIOSTATS
RF230_sendpackets++; RF230_sendpackets++;
#endif #endif
/* We wait until transmission has ended so that we get an /* We wait until transmission has ended so that we get an
accurate measurement of the transmission time.*/ accurate measurement of the transmission time.*/
rf230_waitidle(); rf230_waitidle();
#ifdef ENERGEST_CONF_LEVELDEVICE_LEVELS
ENERGEST_OFF_LEVEL(ENERGEST_TYPE_TRANSMIT,rf230_get_txpower());
#endif
/* Restore the transmission power */
if(packetbuf_attr(PACKETBUF_ATTR_RADIO_TXPOWER) > 0) {
set_txpower(txpower & 0xff);
}
/* Restore receive mode */ /* Restore receive mode */
if(radiowason) { if(radiowason) {
// DEBUGFLOW('m');
on(); on();
} }
@ -663,20 +678,17 @@ rf230_transmit(unsigned short payload_len)
#endif /* RF230_CONF_TIMESTAMPS */ #endif /* RF230_CONF_TIMESTAMPS */
#ifdef ENERGEST_CONF_LEVELDEVICE_LEVELS
ENERGEST_OFF_LEVEL(ENERGEST_TYPE_TRANSMIT,rf230_get_txpower());
#endif
ENERGEST_OFF(ENERGEST_TYPE_TRANSMIT); ENERGEST_OFF(ENERGEST_TYPE_TRANSMIT);
if(RF230_receive_on) { if(RF230_receive_on) {
ENERGEST_ON(ENERGEST_TYPE_LISTEN); ENERGEST_ON(ENERGEST_TYPE_LISTEN);
} else { } else {
/* This call not needed, radio will already be in TRX_OFF */ #if RADIOALWAYSON
// off(); /* Enable reception */
} on();
#else
if(packetbuf_attr(PACKETBUF_ATTR_RADIO_TXPOWER) > 0) { /* Go to lower power TRX_OFF state (turn off PLL) */
/* Restore the transmission power */ hal_subregister_write(SR_TRX_CMD, CMD_FORCE_TRX_OFF);
set_txpower(txpower & 0xff); #endif
} }
RELEASE_LOCK(); RELEASE_LOCK();
@ -708,6 +720,7 @@ rf230_prepare(const void *payload, unsigned short payload_len)
#endif /* RF230_CONF_CHECKSUM */ #endif /* RF230_CONF_CHECKSUM */
GET_LOCK(); GET_LOCK();
// DEBUGFLOW('P');
// PRINTF("rf230: sending %d bytes\n", payload_len); // PRINTF("rf230: sending %d bytes\n", payload_len);
// PRINTSHORT("s%d ",payload_len); // PRINTSHORT("s%d ",payload_len);
@ -840,7 +853,7 @@ rf230_on(void)
return 1; return 1;
} }
if(locked) { if(locked) {
printf("rflock"); DEBUGFLOW('L');
lock_on = 1; lock_on = 1;
return 1; return 1;
} }
@ -906,7 +919,6 @@ rf230_set_pan_addr(unsigned pan,
PRINTF("\n"); PRINTF("\n");
} }
} }
uint8_t packetreceived;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* /*
* Interrupt leaves frame intact in FIFO. * Interrupt leaves frame intact in FIFO.
@ -926,7 +938,7 @@ rf230_interrupt(void)
/* Poll the receive process, unless the stack thinks the radio is off */ /* Poll the receive process, unless the stack thinks the radio is off */
#if RADIOALWAYSON #if RADIOALWAYSON
if (RF230_receive_on) { if (RF230_receive_on) {
packetreceived=2; DEBUGFLOW('+');
#endif #endif
#if RF230_CONF_TIMESTAMPS #if RF230_CONF_TIMESTAMPS
interrupt_time = timesynch_time(); interrupt_time = timesynch_time();
@ -949,7 +961,7 @@ if (RF230_receive_on) {
#if RADIOALWAYSON #if RADIOALWAYSON
} else { } else {
packetreceived=1; DEBUGFLOW('-');
rxframe.length=0; rxframe.length=0;
} }
#endif #endif
@ -994,6 +1006,9 @@ PROCESS_THREAD(rf230_process, ev, data)
PROCESS_END(); PROCESS_END();
} }
// Get packet from Radio if any, else return zero.
// At present the last frame is buffered in the interrupt routine so it does
// not access the hardware or change its status
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static int static int
rf230_read(void *buf, unsigned short bufsize) rf230_read(void *buf, unsigned short bufsize)
@ -1012,7 +1027,7 @@ rf230_read(void *buf, unsigned short bufsize)
len=rxframe.length; len=rxframe.length;
if (len==0) { if (len==0) {
#if RADIOALWAYSON #if RADIOALWAYSON
// if (RF230_receive_on==0) printf("z"); cxmac calls with radio off? if (RF230_receive_on==0) {if (debugflow[debugflowsize-1]!='z') DEBUGFLOW('z');} //cxmac calls with radio off?
#endif #endif
return 0; return 0;
} }
@ -1036,32 +1051,34 @@ if (RF230_receive_on) {
} }
rf230_time_of_departure = 0; rf230_time_of_departure = 0;
#endif /* RF230_CONF_TIMESTAMPS */ #endif /* RF230_CONF_TIMESTAMPS */
GET_LOCK(); // GET_LOCK();
rf230_packets_read++; rf230_packets_read++;
//if(len > RF230_MAX_PACKET_LEN) { //if(len > RF230_MAX_PACKET_LEN) {
if(len > RF230_MAX_TX_FRAME_LENGTH) { if(len > RF230_MAX_TX_FRAME_LENGTH) {
/* Oops, we must be out of sync. */ /* Oops, we must be out of sync. */
PRINTSHORT("out of sync"); DEBUGFLOW('y');
flushrx(); flushrx();
RIMESTATS_ADD(badsynch); RIMESTATS_ADD(badsynch);
RELEASE_LOCK(); // RELEASE_LOCK();
return 0; return 0;
} }
if(len <= AUX_LEN) { if(len <= AUX_LEN) {
PRINTSHORT("len <= AUX_LEN\n"); DEBUGFLOW('s');
PRINTF("len <= AUX_LEN\n");
flushrx(); flushrx();
RIMESTATS_ADD(tooshort); RIMESTATS_ADD(tooshort);
RELEASE_LOCK(); // RELEASE_LOCK();
return 0; return 0;
} }
if(len - AUX_LEN > bufsize) { if(len - AUX_LEN > bufsize) {
PRINTSHORT("len - AUX_LEN > bufsize\n"); DEBUGFLOW('b');
PRINTF("len - AUX_LEN > bufsize\n");
flushrx(); flushrx();
RIMESTATS_ADD(toolong); RIMESTATS_ADD(toolong);
RELEASE_LOCK(); // RELEASE_LOCK();
return 0; return 0;
} }
/* Transfer the frame, stripping the footer */ /* Transfer the frame, stripping the footer */
@ -1084,6 +1101,7 @@ if (RF230_receive_on) {
#endif #endif
#if RF230_CONF_CHECKSUM #if RF230_CONF_CHECKSUM
if(checksum != crc16_data(buf, len - AUX_LEN, 0)) { if(checksum != crc16_data(buf, len - AUX_LEN, 0)) {
DEBUGFLOW('K');
PRINTF("checksum failed 0x%04x != 0x%04x\n", PRINTF("checksum failed 0x%04x != 0x%04x\n",
checksum, crc16_data(buf, len - AUX_LEN, 0)); checksum, crc16_data(buf, len - AUX_LEN, 0));
} }
@ -1115,6 +1133,8 @@ if (RF230_receive_on) {
#endif /* RF230_CONF_TIMESTAMPS */ #endif /* RF230_CONF_TIMESTAMPS */
} else { } else {
DEBUGFLOW('X');
PRINTF("bad crc");
RIMESTATS_ADD(badcrc); RIMESTATS_ADD(badcrc);
len = AUX_LEN; len = AUX_LEN;
} }
@ -1131,7 +1151,7 @@ if (RF230_receive_on) {
// process_poll(&rf230_process); // process_poll(&rf230_process);
// } // }
RELEASE_LOCK(); // RELEASE_LOCK();
if(len < AUX_LEN) { if(len < AUX_LEN) {
return 0; return 0;
} }
@ -1183,7 +1203,7 @@ if (RF230_receive_on) {
#if RADIOALWAYSON #if RADIOALWAYSON
} else { } else {
PRINTSHORT("R"); //Stack thought radio was off DEBUGFLOW('R'); //Stack thought radio was off
return 0; return 0;
} }
#endif #endif
@ -1208,7 +1228,7 @@ rf230_get_txpower(void)
// return hal_subregister_read(SR_TX_PWR); // return hal_subregister_read(SR_TX_PWR);
power=hal_subregister_read(SR_TX_PWR); power=hal_subregister_read(SR_TX_PWR);
if (power==0) { if (power==0) {
printf("PZ"); PRINTSHORT("PZ");
return 1; return 1;
} else { } else {
return power; return power;
@ -1230,7 +1250,8 @@ rf230_rssi(void)
rssi = (int)((signed char)hal_subregister_read(SR_RSSI)); rssi = (int)((signed char)hal_subregister_read(SR_RSSI));
if (rssi==0) { if (rssi==0) {
printf("RSZ"); DEBUGFLOW('r');
PRINTF("RSZ");
rssi=1; rssi=1;
} }
@ -1260,7 +1281,7 @@ rf230_cca(void)
} }
// cca = CCA_IS_1; // cca = CCA_IS_1;
printf("CCA"); DEBUGFLOW('c');
cca=1; cca=1;
if(radio_was_off) { if(radio_was_off) {
@ -1272,12 +1293,20 @@ rf230_cca(void)
int int
rf230_receiving_packet(void) rf230_receiving_packet(void)
{ {
return (hal_subregister_read(SR_TRX_STATUS)==BUSY_RX); uint8_t radio_state;
radio_state = hal_subregister_read(SR_TRX_STATUS);
if ((radio_state==BUSY_RX) || (radio_state==BUSY_RX_AACK)) {
DEBUGFLOW('B');
return 1;
} else {
return 0;
}
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static int static int
pending_packet(void) pending_packet(void)
{ {
if (pending) DEBUGFLOW('p');
return pending; return pending;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/