- Fixed a compilation problem caused by 2.3 root Makefile-include changes with regard to sdcc.

- Fixed a small typo in cc2430_rf.c
- examples/sensinode now compiles
This commit is contained in:
zdshelby 2009-09-09 07:32:02 +00:00
parent c9954072c9
commit 4a14db6d3a
2 changed files with 65 additions and 63 deletions

View File

@ -1,7 +1,3 @@
CONTIKI_CPU_DIRS = . net
CONTIKI_SOURCEFILES += #mtarch.c rtimer-arch.c elfloader-stub.c watchdog.c
### Compiler definitions ### Compiler definitions
CC = sdcc CC = sdcc
LD = sdcc LD = sdcc
@ -36,9 +32,15 @@ CONTIKI_PLATFORM_DIRS = $(PLATFORM_APPDIRS) \
### Compilation rules ### Compilation rules
#CUSTOM_RULE_C_TO_OBJECTDIR_O=1 CUSTOM_RULE_C_TO_OBJECTDIR_O=1
CUSTOM_RULE_ALLOBJS_TO_TARGETLIB=1 CUSTOM_RULE_ALLOBJS_TO_TARGETLIB=1
ifdef CUSTOM_RULE_C_TO_OBJECTDIR_O
$(OBJECTDIR)/%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
@$(FINALIZE_DEPENDENCY)
endif
ifdef CUSTOM_RULE_CS_TO_OBJECTDIR_O ifdef CUSTOM_RULE_CS_TO_OBJECTDIR_O
$(OBJECTDIR)/%.o: %.cS $(OBJECTDIR)/%.o: %.cS
cp $< $(OBJECTDIR)/$*.c cp $< $(OBJECTDIR)/$*.c

View File

@ -114,49 +114,49 @@ cc2430_rf_init(void)
if(rf_initialized) { if(rf_initialized) {
return; return;
} }
printf("cc2430_rf_init called\n"); printf("cc2430_rf_init called\n");
RFPWR &= ~RREG_RADIO_PD; /*make sure it's powered*/ RFPWR &= ~RREG_RADIO_PD; /*make sure it's powered*/
while((RFPWR & ADI_RADIO_PD) == 1); while((RFPWR & ADI_RADIO_PD) == 1);
while((RFIF & IRQ_RREG_ON) == 0); /*wait for power up*/ while((RFIF & IRQ_RREG_ON) == 0); /*wait for power up*/
SLEEP &= ~OSC_PD; /*Osc on*/ SLEEP &= ~OSC_PD; /*Osc on*/
while((SLEEP & XOSC_STB) == 0); /*wait for power up*/ while((SLEEP & XOSC_STB) == 0); /*wait for power up*/
rf_flags = 0; rf_flags = 0;
rf_softack = 0; rf_softack = 0;
rf_addr_mode = RF_DECODER_NONE; rf_addr_mode = RF_DECODER_NONE;
FSMTC1 = 1; /*don't abort reception, if enable called, accept ack, auto rx after tx*/ FSMTC1 = 1; /*don't abort reception, if enable called, accept ack, auto rx after tx*/
MDMCTRL0H = 0x02; /* Generic client, standard hysteresis, decoder on 0x0a */ MDMCTRL0H = 0x02; /* Generic client, standard hysteresis, decoder on 0x0a */
MDMCTRL0L = 0xE2; /* automatic ACK and CRC, standard CCA and preamble 0xf2 */ MDMCTRL0L = 0xE2; /* automatic ACK and CRC, standard CCA and preamble 0xf2 */
MDMCTRL1H = 0x30; /* Defaults */ MDMCTRL1H = 0x30; /* Defaults */
MDMCTRL1L = 0x0; MDMCTRL1L = 0x0;
RXCTRL0H = 0x32; /* RX tuning optimized */ RXCTRL0H = 0x32; /* RX tuning optimized */
RXCTRL0L = 0xf5; RXCTRL0L = 0xf5;
/* get ID for MAC */ /* get ID for MAC */
rf_manfid = CHVER; rf_manfid = CHVER;
rf_manfid <<= 8; rf_manfid <<= 8;
rf_manfid += CHIPID; rf_manfid += CHIPID;
cc2430_rf_channel_set(RF_DEFAULT_CHANNEL); cc2430_rf_channel_set(RF_DEFAULT_CHANNEL);
cc2430_rf_command(ISFLUSHTX); cc2430_rf_command(ISFLUSHTX);
cc2430_rf_command(ISFLUSHRX); cc2430_rf_command(ISFLUSHRX);
RFIM = IRQ_FIFOP; RFIM = IRQ_FIFOP;
RFIF &= ~(IRQ_FIFOP); RFIF &= ~(IRQ_FIFOP);
S1CON &= ~(RFIF_0 | RFIF_1); S1CON &= ~(RFIF_0 | RFIF_1);
IEN2 |= RFIE; IEN2 |= RFIE;
RF_TX_LED_OFF(); RF_TX_LED_OFF();
RF_RX_LED_OFF(); RF_RX_LED_OFF();
rf_initialized = 1; rf_initialized = 1;
process_start(&cc2430_rf_process, NULL); process_start(&cc2430_rf_process, NULL);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
@ -170,9 +170,9 @@ int
cc2430_rf_send(const void *payload, unsigned short payload_len) cc2430_rf_send(const void *payload, unsigned short payload_len)
{ {
uint8_t i, counter; uint8_t i, counter;
/*PRINTF("cc2430_rf_send\n");*/ /*PRINTF("cc2430_rf_send\n");*/
if(rf_flags & TX_ACK) { if(rf_flags & TX_ACK) {
return -1; return -1;
} }
@ -183,13 +183,13 @@ cc2430_rf_send(const void *payload, unsigned short payload_len)
/* Check packet attributes */ /* Check packet attributes */
/*printf("packetbuf_attr: txpower = %d\n", packetbuf_attr(PACKETBUF_ATTR_RADIO_TXPOWER));*/ /*printf("packetbuf_attr: txpower = %d\n", packetbuf_attr(PACKETBUF_ATTR_RADIO_TXPOWER));*/
/* Should set TX power according to this if > 0 */ /* Should set TX power according to this if > 0 */
PRINTF("cc2430_rf: sending %d byte payload\n", payload_len); PRINTF("cc2430_rf: sending %d byte payload\n", payload_len);
RIMESTATS_ADD(lltx); RIMESTATS_ADD(lltx);
/* Add checksum to end of packet as in cc2420 driver? */ /* Add checksum to end of packet as in cc2420 driver? */
/* Send */ /* Send */
cc2430_rf_command(ISFLUSHTX); cc2430_rf_command(ISFLUSHTX);
@ -199,20 +199,20 @@ cc2430_rf_send(const void *payload, unsigned short payload_len)
} }
RFD = (0); RFD = (0);
RFD = (0); RFD = (0);
if(cc2430_rf_cca_check(0,0) == -1) { if(cc2430_rf_cca_check(0,0) == -1) {
return -1; return -1;
} }
/* Start the transmission */ /* Start the transmission */
RFIF &= ~IRQ_TXDONE; RFIF &= ~IRQ_TXDONE;
cc2430_rf_command(ISTXON); cc2430_rf_command(ISTXON);
counter = 0; counter = 0;
while(!(RFSTATUS & TX_ACTIVE) && (counter++ < 3)) { while(!(RFSTATUS & TX_ACTIVE) && (counter++ < 3)) {
clock_delay(10); clock_delay(10);
} }
if(!(RFSTATUS & TX_ACTIVE)) { if(!(RFSTATUS & TX_ACTIVE)) {
printf("cc2430_rf: TX never active.\n"); printf("cc2430_rf: TX never active.\n");
cc2430_rf_command(ISFLUSHTX); cc2430_rf_command(ISFLUSHTX);
@ -232,14 +232,14 @@ cc2430_rf_read(void *buf, unsigned short bufsize)
#if CC2420_CONF_CHECKSUM #if CC2420_CONF_CHECKSUM
uint16_t checksum; uint16_t checksum;
#endif /* CC2420_CONF_CHECKSUM */ #endif /* CC2420_CONF_CHECKSUM */
/* RX interrupt polled the cc2430_rf_process, now read the RX FIFO */ /* RX interrupt polled the cc2430_rf_process, now read the RX FIFO */
/* Check the length */ /* Check the length */
len = RFD; len = RFD;
len &= 0x7f; len &= 0x7f;
printf("cc2430_rf: received %d bytes\n", len); printf("cc2430_rf: received %d bytes\n", len);
/* Check for validity */ /* Check for validity */
if(len > CC2430_MAX_PACKET_LEN) { if(len > CC2430_MAX_PACKET_LEN) {
/* Oops, we must be out of sync. */ /* Oops, we must be out of sync. */
@ -248,25 +248,25 @@ cc2430_rf_read(void *buf, unsigned short bufsize)
RIMESTATS_ADD(badsynch); RIMESTATS_ADD(badsynch);
return 0; return 0;
} }
if(len <= CC2430_MIN_PACKET_LEN) { if(len <= CC2430_MIN_PACKET_LEN) {
printf("error: too short\n"); printf("error: too short\n");
cc2430_rf_command(ISFLUSHRX); cc2430_rf_command(ISFLUSHRX);
RIMESTATS_ADD(tooshort); RIMESTATS_ADD(tooshort);
return 0; return 0;
} }
if(len - CHECKSUM_LEN > bufsize) { if(len - CHECKSUM_LEN > bufsize) {
printf("error: too long\n"); printf("error: too long\n");
cc2430_rf_command(ISFLUSHRX); cc2430_rf_command(ISFLUSHRX);
RIMESTATS_ADD(toolong); RIMESTATS_ADD(toolong);
return 0; return 0;
} }
/* Check the type */ /* Check the type */
type = RFD; type = RFD;
type &= 0x07; type &= 0x07;
if(typ e== 0x02) { if(type == 0x02) {
printf("cc2430_rf: ack\n"); printf("cc2430_rf: ack\n");
} else { } else {
/* Read the buffer */ /* Read the buffer */
@ -283,13 +283,13 @@ cc2430_rf_read(void *buf, unsigned short bufsize)
packetbuf_set_attr(PACKETBUF_ATTR_RSSI, ((int8_t) RFD) - 45); packetbuf_set_attr(PACKETBUF_ATTR_RSSI, ((int8_t) RFD) - 45);
packetbuf_set_attr(PACKETBUF_ATTR_LINK_QUALITY, RFD); packetbuf_set_attr(PACKETBUF_ATTR_LINK_QUALITY, RFD);
cc2430_rf_command(ISFLUSHRX); cc2430_rf_command(ISFLUSHRX);
RIMESTATS_ADD(llrx); RIMESTATS_ADD(llrx);
RF_RX_LED_OFF(); RF_RX_LED_OFF();
return (len - 2 - CHECKSUM_LEN); return (len - 2 - CHECKSUM_LEN);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
@ -328,7 +328,7 @@ void cc2430_rf_command(uint8_t command)
RFST = ISFLUSHRX; RFST = ISFLUSHRX;
} }
break; break;
default: default:
RFST = command; RFST = command;
} }
@ -357,11 +357,11 @@ int8_t
cc2430_rf_channel_set(uint8_t channel) cc2430_rf_channel_set(uint8_t channel)
{ {
uint16_t freq; uint16_t freq;
if((channel < 11) || (channel > 26)) { if((channel < 11) || (channel > 26)) {
return -1; return -1;
} }
cc2430_rf_command(ISSTOP); /*make sure CSP is not running*/ cc2430_rf_command(ISSTOP); /*make sure CSP is not running*/
cc2430_rf_command(ISRFOFF); cc2430_rf_command(ISRFOFF);
/* Channel values: 11-26 */ /* Channel values: 11-26 */
@ -371,11 +371,11 @@ cc2430_rf_channel_set(uint8_t channel)
freq |= 0x4000; /*LOCK_THR = 1*/ freq |= 0x4000; /*LOCK_THR = 1*/
FSCTRLH = (freq >> 8); FSCTRLH = (freq >> 8);
FSCTRLL = (uint8_t)freq; FSCTRLL = (uint8_t)freq;
cc2430_rf_command(ISRXON); cc2430_rf_command(ISRXON);
rf_channel = channel; rf_channel = channel;
return (int8_t) channel; return (int8_t) channel;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
@ -401,7 +401,7 @@ int8_t
cc2430_rf_power_set(uint8_t new_power) cc2430_rf_power_set(uint8_t new_power)
{ {
uint16_t power; uint16_t power;
if(new_power > 100) { if(new_power > 100) {
return -1; return -1;
} }
@ -409,11 +409,11 @@ cc2430_rf_power_set(uint8_t new_power)
power = 31 * new_power; power = 31 * new_power;
power /= 100; power /= 100;
power += 0xA160; power += 0xA160;
/* Set transmitter power */ /* Set transmitter power */
TXCTRLH = (power >> 8); TXCTRLH = (power >> 8);
TXCTRLL = (uint8_t)power; TXCTRLL = (uint8_t)power;
rf_tx_power = (int8_t) new_power; rf_tx_power = (int8_t) new_power;
return rf_tx_power; return rf_tx_power;
} }
@ -433,12 +433,12 @@ cc2430_rf_rx_enable(void)
IOCFG0 = 0x7f; // Set the FIFOP threshold 127 IOCFG0 = 0x7f; // Set the FIFOP threshold 127
RSSIH = 0xd2; /* -84dbm = 0xd2 default, 0xe0 -70 dbm */ RSSIH = 0xd2; /* -84dbm = 0xd2 default, 0xe0 -70 dbm */
rf_flags |= RX_ACTIVE; rf_flags |= RX_ACTIVE;
RFPWR &= ~RREG_RADIO_PD; /*make sure it's powered*/ RFPWR &= ~RREG_RADIO_PD; /*make sure it's powered*/
while((RFIF & IRQ_RREG_ON) == 0); /*wait for power up*/ while((RFIF & IRQ_RREG_ON) == 0); /*wait for power up*/
SLEEP &= ~OSC_PD; /*Osc on*/ SLEEP &= ~OSC_PD; /*Osc on*/
while((SLEEP & XOSC_STB) == 0); /*wait for power up*/ while((SLEEP & XOSC_STB) == 0); /*wait for power up*/
cc2430_rf_command(ISRXON); cc2430_rf_command(ISRXON);
cc2430_rf_command(ISFLUSHRX); cc2430_rf_command(ISFLUSHRX);
} }
@ -456,9 +456,9 @@ int8_t cc2430_rf_rx_disable(void)
{ {
cc2430_rf_command(ISSTOP); /*make sure CSP is not running*/ cc2430_rf_command(ISSTOP); /*make sure CSP is not running*/
cc2430_rf_command(ISRFOFF); cc2430_rf_command(ISRFOFF);
RFPWR |= RREG_RADIO_PD; /*RF powerdown*/ RFPWR |= RREG_RADIO_PD; /*RF powerdown*/
rf_flags = 0; rf_flags = 0;
return 1; return 1;
} }
@ -474,7 +474,7 @@ int8_t
cc2430_rf_tx_enable(void) cc2430_rf_tx_enable(void)
{ {
DMAARM = 0x80 + (1 << 0); /*ABORT + channel bit*/ DMAARM = 0x80 + (1 << 0); /*ABORT + channel bit*/
return 1; return 1;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
@ -488,7 +488,7 @@ int8_t
cc2430_rf_address_decoder_mode(rf_address_mode_t mode) cc2430_rf_address_decoder_mode(rf_address_mode_t mode)
{ {
int8_t retval = -1; int8_t retval = -1;
rf_softack = 0; rf_softack = 0;
/* set oscillator on*/ /* set oscillator on*/
switch(mode) { switch(mode) {
@ -498,24 +498,24 @@ cc2430_rf_address_decoder_mode(rf_address_mode_t mode)
MDMCTRL0H |= 0x10; /*Address-decode off , coordinator*/ MDMCTRL0H |= 0x10; /*Address-decode off , coordinator*/
MDMCTRL0L &= ~0x10; /*no automatic ACK */ MDMCTRL0L &= ~0x10; /*no automatic ACK */
break; break;
case RF_DECODER_COORDINATOR: case RF_DECODER_COORDINATOR:
MDMCTRL0H |= 0x18; /*Address-decode on , coordinator*/ MDMCTRL0H |= 0x18; /*Address-decode on , coordinator*/
MDMCTRL0L |= 0x10; /*automatic ACK */ MDMCTRL0L |= 0x10; /*automatic ACK */
break; break;
case RF_DECODER_ON: case RF_DECODER_ON:
MDMCTRL0H |= 0x08; /*Address-decode on */ MDMCTRL0H |= 0x08; /*Address-decode on */
MDMCTRL0L &= ~0x10; /* no automatic ACK */ MDMCTRL0L &= ~0x10; /* no automatic ACK */
break; break;
default: default:
MDMCTRL0H &= ~0x18; /* Generic client */ MDMCTRL0H &= ~0x18; /* Generic client */
MDMCTRL0L &= ~0x10; /* no automatic ACK */ MDMCTRL0L &= ~0x10; /* no automatic ACK */
break; break;
} }
rf_addr_mode = mode; rf_addr_mode = mode;
retval = 1; retval = 1;
return retval; return retval;
} }
@ -533,7 +533,7 @@ cc2430_rf_analyze_rssi(void)
{ {
int8_t retval = -128; int8_t retval = -128;
/*pause_us(128);*/ /*pause_us(128);*/
retval = (int8_t)RSSIL; retval = (int8_t)RSSIL;
retval -= 45; retval -= 45;
return retval; return retval;
@ -552,11 +552,11 @@ cc2430_rf_cca_check(uint8_t backoff_count, uint8_t slotted)
int8_t retval = 1; int8_t retval = 1;
backoff_count; backoff_count;
cc2430_rf_command(ISRXON); cc2430_rf_command(ISRXON);
clock_delay(64); clock_delay(64);
switch(slotted) { switch(slotted) {
case 1: case 1:
if(RFSTATUS & CCA) { if(RFSTATUS & CCA) {
counter = 0; counter = 0;
cca = 1; cca = 1;
@ -575,12 +575,12 @@ cc2430_rf_cca_check(uint8_t backoff_count, uint8_t slotted)
retval = -1; retval = -1;
} }
break; break;
case 0: case 0:
if(!(RFSTATUS & CCA)) { if(!(RFSTATUS & CCA)) {
retval = -1; retval = -1;
} else { } else {
} }
break; break;
} }
@ -629,7 +629,7 @@ cc2430_rf_ISR( void ) __interrupt (RF_VECTOR)
} }
RFIF &= ~IRQ_FIFOP; RFIF &= ~IRQ_FIFOP;
} }
S1CON &= ~(RFIF_0 | RFIF_1); S1CON &= ~(RFIF_0 | RFIF_1);
RFIM |= IRQ_FIFOP; RFIM |= IRQ_FIFOP;
EA = 1; EA = 1;