From fee5efb141b701670a0104182b46b2bf67588b2a Mon Sep 17 00:00:00 2001 From: dak664 Date: Thu, 18 Feb 2010 17:20:50 +0000 Subject: [PATCH] additions for cxmac --- cpu/avr/radio/rf230bb/halbb.c | 4 ++ cpu/avr/radio/rf230bb/rf230bb.c | 77 ++++++++++++++++++++++++++------- 2 files changed, 65 insertions(+), 16 deletions(-) diff --git a/cpu/avr/radio/rf230bb/halbb.c b/cpu/avr/radio/rf230bb/halbb.c index 315b6e0ff..6870748a7 100644 --- a/cpu/avr/radio/rf230bb/halbb.c +++ b/cpu/avr/radio/rf230bb/halbb.c @@ -720,7 +720,11 @@ ISR(RADIO_VECT) rf230_interrupt(); // trx_end_callback(isr_timestamp); /* 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); +#endif } } else if (interrupt_source & HAL_TRX_UR_MASK){ diff --git a/cpu/avr/radio/rf230bb/rf230bb.c b/cpu/avr/radio/rf230bb/rf230bb.c index d81f58c90..55ffd2736 100644 --- a/cpu/avr/radio/rf230bb/rf230bb.c +++ b/cpu/avr/radio/rf230bb/rf230bb.c @@ -27,7 +27,7 @@ * 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_CORRELATION 0x7f +/* Terse printing for faster processing */ +#define PRINTSHORT(FORMAT,args...) printf_P(PSTR(FORMAT),##args) +//#define PRINTSHORT(...) #define DEBUG 0 #if DEBUG #define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args) @@ -184,7 +187,7 @@ uint8_t rx_mode; /* Radio stuff in network byte order. */ //static uint16_t pan_id; -//static int channel; +static int channel; /*----------------------------------------------------------------------------*/ @@ -400,7 +403,20 @@ static void on(void) { 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"); RF230_radio_on = 1; @@ -409,14 +425,23 @@ on(void) delay_us(TIME_SLEEP_TO_TRX_OFF); 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(); } static void off(void) { - // printf("of"); +// PRINTSHORT("f"); PRINTF("rf230 off"); +#if JACKDAW + Led2_off(); +#endif +//#if !JACKDAW && 0 //Leave stick radio on for now RF230_radio_on = 0; /* Wait for transmission to end before turning radio off. */ @@ -427,6 +452,7 @@ off(void) /* Sleep Radio */ hal_set_slptr_high(); +//#endif ENERGEST_OFF(ENERGEST_TYPE_LISTEN); } @@ -434,10 +460,12 @@ off(void) #define GET_LOCK() locked = 1 static void RELEASE_LOCK(void) { if(lock_on) { + PRINTSHORT("Q"); on(); lock_on = 0; } if(lock_off) { + PRINTSHORT("S"); off(); lock_off = 0; } @@ -458,12 +486,14 @@ rf230_off(void) PRINTF("off"); /* Don't do anything if we are already turned off. */ if(RF230_radio_on == 0) { + PRINTSHORT("Z"); return 1; } /* If we are called when the driver is locked, we indicate that the radio should be turned off when the lock is unlocked. */ if(locked) { + PRINTSHORT("L"); lock_off = 1; return 1; } @@ -476,9 +506,11 @@ int rf230_on(void) { if(RF230_radio_on) { + PRINTSHORT("M"); return 1; } if(locked) { + PRINTSHORT("N"); lock_on = 1; return 1; } @@ -490,8 +522,9 @@ rf230_on(void) int rf230_get_channel(void) { - return hal_subregister_read(SR_CHANNEL); -// return channel; +//jackdaw reads zero channel, raven reads correct channel? +//return hal_subregister_read(SR_CHANNEL); + return channel; } /*---------------------------------------------------------------------------*/ void @@ -500,7 +533,7 @@ rf230_set_channel(int c) /* Wait for any transmission to end. */ rf230_waitidle(); -//channel=c; + 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 * Receive interrupts cause this process to be polled @@ -558,9 +591,9 @@ PROCESS_THREAD(rf230_process, ev, data) #if RF230_TIMETABLE_PROFILING TIMETABLE_TIMESTAMP(rf230_timetable, "poll"); #endif /* RF230_TIMETABLE_PROFILING */ -// rf230processflag=1; +// rf230processflag=1; if(receiver_callback != NULL) { -// rf230processflag=2; + // rf230processflag=2; receiver_callback(&rf230_driver); #if RF230_TIMETABLE_PROFILING TIMETABLE_TIMESTAMP(rf230_timetable, "end"); @@ -569,7 +602,7 @@ PROCESS_THREAD(rf230_process, ev, data) timetable_clear(&rf230_timetable); #endif /* RF230_TIMETABLE_PROFILING */ } else { -// rf230processflag=99; + rf230processflag=99; PRINTF("rf230_process not receiving function\n"); // flushrx(); } @@ -629,11 +662,11 @@ rf230_read(void *buf, unsigned short bufsize) for (len=0;len