additions for cxmac
This commit is contained in:
parent
470b93c79f
commit
fee5efb141
|
@ -720,7 +720,11 @@ ISR(RADIO_VECT)
|
||||||
rf230_interrupt();
|
rf230_interrupt();
|
||||||
// trx_end_callback(isr_timestamp);
|
// trx_end_callback(isr_timestamp);
|
||||||
/* Enable reception of next packet */
|
/* Enable reception of next packet */
|
||||||
|
#if RF230_CONF_NO_AUTO_ACK
|
||||||
|
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);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (interrupt_source & HAL_TRX_UR_MASK){
|
} else if (interrupt_source & HAL_TRX_UR_MASK){
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* $Id: rf230bb.c,v 1.3 2010/02/16 21:41:24 dak664 Exp $
|
* $Id: rf230bb.c,v 1.4 2010/02/18 17:20:50 dak664 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -122,6 +122,9 @@ struct timestamp {
|
||||||
#define FOOTER1_CRC_OK 0x80
|
#define FOOTER1_CRC_OK 0x80
|
||||||
#define FOOTER1_CORRELATION 0x7f
|
#define FOOTER1_CORRELATION 0x7f
|
||||||
|
|
||||||
|
/* Terse printing for faster processing */
|
||||||
|
#define PRINTSHORT(FORMAT,args...) printf_P(PSTR(FORMAT),##args)
|
||||||
|
//#define PRINTSHORT(...)
|
||||||
#define DEBUG 0
|
#define DEBUG 0
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args)
|
#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args)
|
||||||
|
@ -184,7 +187,7 @@ uint8_t rx_mode;
|
||||||
/* Radio stuff in network byte order. */
|
/* Radio stuff in network byte order. */
|
||||||
//static uint16_t pan_id;
|
//static uint16_t pan_id;
|
||||||
|
|
||||||
//static int channel;
|
static int channel;
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
@ -400,7 +403,20 @@ static void
|
||||||
on(void)
|
on(void)
|
||||||
{
|
{
|
||||||
ENERGEST_ON(ENERGEST_TYPE_LISTEN);
|
ENERGEST_ON(ENERGEST_TYPE_LISTEN);
|
||||||
// printf("on");
|
// PRINTSHORT("o");
|
||||||
|
#if JACKDAW
|
||||||
|
//blue=0 red=1 green=2 yellow=3
|
||||||
|
#define Led0_on() (PORTD |= 0x80)
|
||||||
|
#define Led1_on() (PORTD &= ~0x20)
|
||||||
|
#define Led2_on() (PORTE &= ~0x80)
|
||||||
|
#define Led3_on() (PORTE &= ~0x40)
|
||||||
|
#define Led0_off() (PORTD &= ~0x80)
|
||||||
|
#define Led1_off() (PORTD |= 0x20)
|
||||||
|
#define Led2_off() (PORTE |= 0x80)
|
||||||
|
#define Led3_off() (PORTE |= 0x40)
|
||||||
|
Led2_on();
|
||||||
|
#endif
|
||||||
|
|
||||||
PRINTF("rf230 on");
|
PRINTF("rf230 on");
|
||||||
RF230_radio_on = 1;
|
RF230_radio_on = 1;
|
||||||
|
|
||||||
|
@ -409,14 +425,23 @@ on(void)
|
||||||
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
|
delay_us(TIME_SLEEP_TO_TRX_OFF);//extra delay for now
|
||||||
|
|
||||||
radio_set_trx_state(RX_AACK_ON);
|
|
||||||
|
#if RF230_CONF_NO_AUTO_ACK
|
||||||
|
radio_set_trx_state(RX_ON);
|
||||||
|
#else
|
||||||
|
radio_set_trx_state(RX_AACK_ON);
|
||||||
|
#endif
|
||||||
// flushrx();
|
// flushrx();
|
||||||
}
|
}
|
||||||
static void
|
static void
|
||||||
off(void)
|
off(void)
|
||||||
{
|
{
|
||||||
// printf("of");
|
// PRINTSHORT("f");
|
||||||
PRINTF("rf230 off");
|
PRINTF("rf230 off");
|
||||||
|
#if JACKDAW
|
||||||
|
Led2_off();
|
||||||
|
#endif
|
||||||
|
//#if !JACKDAW && 0 //Leave stick radio on for now
|
||||||
RF230_radio_on = 0;
|
RF230_radio_on = 0;
|
||||||
|
|
||||||
/* Wait for transmission to end before turning radio off. */
|
/* Wait for transmission to end before turning radio off. */
|
||||||
|
@ -427,6 +452,7 @@ off(void)
|
||||||
|
|
||||||
/* Sleep Radio */
|
/* Sleep Radio */
|
||||||
hal_set_slptr_high();
|
hal_set_slptr_high();
|
||||||
|
//#endif
|
||||||
|
|
||||||
ENERGEST_OFF(ENERGEST_TYPE_LISTEN);
|
ENERGEST_OFF(ENERGEST_TYPE_LISTEN);
|
||||||
}
|
}
|
||||||
|
@ -434,10 +460,12 @@ off(void)
|
||||||
#define GET_LOCK() locked = 1
|
#define GET_LOCK() locked = 1
|
||||||
static void RELEASE_LOCK(void) {
|
static void RELEASE_LOCK(void) {
|
||||||
if(lock_on) {
|
if(lock_on) {
|
||||||
|
PRINTSHORT("Q");
|
||||||
on();
|
on();
|
||||||
lock_on = 0;
|
lock_on = 0;
|
||||||
}
|
}
|
||||||
if(lock_off) {
|
if(lock_off) {
|
||||||
|
PRINTSHORT("S");
|
||||||
off();
|
off();
|
||||||
lock_off = 0;
|
lock_off = 0;
|
||||||
}
|
}
|
||||||
|
@ -458,12 +486,14 @@ rf230_off(void)
|
||||||
PRINTF("off");
|
PRINTF("off");
|
||||||
/* Don't do anything if we are already turned off. */
|
/* Don't do anything if we are already turned off. */
|
||||||
if(RF230_radio_on == 0) {
|
if(RF230_radio_on == 0) {
|
||||||
|
PRINTSHORT("Z");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we are called when the driver is locked, we indicate that the
|
/* If we are called when the driver is locked, we indicate that the
|
||||||
radio should be turned off when the lock is unlocked. */
|
radio should be turned off when the lock is unlocked. */
|
||||||
if(locked) {
|
if(locked) {
|
||||||
|
PRINTSHORT("L");
|
||||||
lock_off = 1;
|
lock_off = 1;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -476,9 +506,11 @@ int
|
||||||
rf230_on(void)
|
rf230_on(void)
|
||||||
{
|
{
|
||||||
if(RF230_radio_on) {
|
if(RF230_radio_on) {
|
||||||
|
PRINTSHORT("M");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if(locked) {
|
if(locked) {
|
||||||
|
PRINTSHORT("N");
|
||||||
lock_on = 1;
|
lock_on = 1;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -490,8 +522,9 @@ rf230_on(void)
|
||||||
int
|
int
|
||||||
rf230_get_channel(void)
|
rf230_get_channel(void)
|
||||||
{
|
{
|
||||||
return hal_subregister_read(SR_CHANNEL);
|
//jackdaw reads zero channel, raven reads correct channel?
|
||||||
// return channel;
|
//return hal_subregister_read(SR_CHANNEL);
|
||||||
|
return channel;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
|
@ -500,7 +533,7 @@ rf230_set_channel(int c)
|
||||||
/* Wait for any transmission to end. */
|
/* Wait for any transmission to end. */
|
||||||
rf230_waitidle();
|
rf230_waitidle();
|
||||||
|
|
||||||
//channel=c;
|
channel=c;
|
||||||
hal_subregister_write(SR_CHANNEL, c);
|
hal_subregister_write(SR_CHANNEL, c);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -542,7 +575,7 @@ rf230_set_pan_addr(uint16_t pan,uint16_t addr,uint8_t *ieee_addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//uint8_t rf230processflag; //for debugging process call problems
|
uint8_t rf230processflag; //for debugging process call problems
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* Process to handle input packets
|
/* Process to handle input packets
|
||||||
* Receive interrupts cause this process to be polled
|
* Receive interrupts cause this process to be polled
|
||||||
|
@ -558,9 +591,9 @@ PROCESS_THREAD(rf230_process, ev, data)
|
||||||
#if RF230_TIMETABLE_PROFILING
|
#if RF230_TIMETABLE_PROFILING
|
||||||
TIMETABLE_TIMESTAMP(rf230_timetable, "poll");
|
TIMETABLE_TIMESTAMP(rf230_timetable, "poll");
|
||||||
#endif /* RF230_TIMETABLE_PROFILING */
|
#endif /* RF230_TIMETABLE_PROFILING */
|
||||||
// rf230processflag=1;
|
// rf230processflag=1;
|
||||||
if(receiver_callback != NULL) {
|
if(receiver_callback != NULL) {
|
||||||
// rf230processflag=2;
|
// rf230processflag=2;
|
||||||
receiver_callback(&rf230_driver);
|
receiver_callback(&rf230_driver);
|
||||||
#if RF230_TIMETABLE_PROFILING
|
#if RF230_TIMETABLE_PROFILING
|
||||||
TIMETABLE_TIMESTAMP(rf230_timetable, "end");
|
TIMETABLE_TIMESTAMP(rf230_timetable, "end");
|
||||||
|
@ -569,7 +602,7 @@ PROCESS_THREAD(rf230_process, ev, data)
|
||||||
timetable_clear(&rf230_timetable);
|
timetable_clear(&rf230_timetable);
|
||||||
#endif /* RF230_TIMETABLE_PROFILING */
|
#endif /* RF230_TIMETABLE_PROFILING */
|
||||||
} else {
|
} else {
|
||||||
// rf230processflag=99;
|
rf230processflag=99;
|
||||||
PRINTF("rf230_process not receiving function\n");
|
PRINTF("rf230_process not receiving function\n");
|
||||||
// flushrx();
|
// flushrx();
|
||||||
}
|
}
|
||||||
|
@ -629,11 +662,11 @@ rf230_read(void *buf, unsigned short bufsize)
|
||||||
for (len=0;len<rxframe.length;len++) PRINTF(" %x",rxframe.data[len]);PRINTF("\n");
|
for (len=0;len<rxframe.length;len++) PRINTF(" %x",rxframe.data[len]);PRINTF("\n");
|
||||||
#endif
|
#endif
|
||||||
if (rxframe.length==0) {
|
if (rxframe.length==0) {
|
||||||
|
// PRINTSHORT("Z");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
// PRINTSHORT("R%d ",rxframe.length);
|
||||||
#if RF230_CONF_TIMESTAMPS
|
#if RF230_CONF_TIMESTAMPS
|
||||||
bomb
|
|
||||||
if(interrupt_time_set) {
|
if(interrupt_time_set) {
|
||||||
rf230_time_of_arrival = interrupt_time;
|
rf230_time_of_arrival = interrupt_time;
|
||||||
interrupt_time_set = 0;
|
interrupt_time_set = 0;
|
||||||
|
@ -780,7 +813,7 @@ int
|
||||||
rf230_get_txpower(void)
|
rf230_get_txpower(void)
|
||||||
{
|
{
|
||||||
if (radio_is_sleeping() ==true) {
|
if (radio_is_sleeping() ==true) {
|
||||||
printf("rf230_get_txpower:Sleeping");
|
PRINTF("rf230_get_txpower:Sleeping");
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
return hal_subregister_read(SR_TX_PWR);
|
return hal_subregister_read(SR_TX_PWR);
|
||||||
|
@ -988,7 +1021,14 @@ rf230_send(const void *payload, unsigned short payload_len)
|
||||||
/* 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();
|
||||||
radio_set_trx_state(RX_AACK_ON);//Re-enable receive mode
|
|
||||||
|
/* Re-enable receive mode */
|
||||||
|
#if RF230_CONF_NO_AUTO_ACK
|
||||||
|
radio_set_trx_state(RX_ON);
|
||||||
|
#else
|
||||||
|
radio_set_trx_state(RX_AACK_ON);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if RF230_CONF_TIMESTAMPS
|
#if RF230_CONF_TIMESTAMPS
|
||||||
setup_time_for_transmission = txtime - timestamp.time;
|
setup_time_for_transmission = txtime - timestamp.time;
|
||||||
|
|
||||||
|
@ -1081,8 +1121,13 @@ rf230_init(void)
|
||||||
/* Set up the radio for auto mode operation. */
|
/* Set up the radio for auto mode operation. */
|
||||||
hal_subregister_write(SR_MAX_FRAME_RETRIES, 2 );
|
hal_subregister_write(SR_MAX_FRAME_RETRIES, 2 );
|
||||||
hal_subregister_write(SR_TX_AUTO_CRC_ON, 1);
|
hal_subregister_write(SR_TX_AUTO_CRC_ON, 1);
|
||||||
|
#if RF230_CONF_NO_AUTO_ACK
|
||||||
|
hal_subregister_write(SR_TRX_CMD, CMD_RX_ON);
|
||||||
|
#else
|
||||||
hal_subregister_write(SR_TRX_CMD, CMD_RX_AACK_ON);
|
hal_subregister_write(SR_TRX_CMD, CMD_RX_AACK_ON);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Start the packet receive process */
|
/* Start the packet receive process */
|
||||||
|
// rf230processflag=42;
|
||||||
process_start(&rf230_process, NULL);
|
process_start(&rf230_process, NULL);
|
||||||
}
|
}
|
Loading…
Reference in a new issue