Chipcon packet handling is coming along, but transmissions are still dropped. Maybe...
[goodfet] / shellcode / chipcon / cc1110 / txrxpacket.c
1 #include <cc1110.h>
2 #include "cc1110-ext.h"
3
4 char __xdata at 0xfe00 packet[256] ;
5
6 //! Transmit a packet out of the radio from 0xFE00.
7 void main(){
8   unsigned char len=packet[0], i=0;
9   
10   //idle a bit.
11   RFST=RFST_SIDLE;
12   while(MARCSTATE!=MARC_STATE_IDLE);
13   
14   RFST=RFST_STX;     //Begin transmit.
15   while(i!=len+1){
16     while(!RFTXRXIF); //Wait for byte to be ready.
17     
18     RFTXRXIF=0;      //Clear the flag.
19     RFD=packet[i++]; //Send the next byte.
20   }
21   RFST = RFST_SIDLE; //End transmit.
22   
23   
24   while(MARCSTATE!=MARC_STATE_IDLE);
25   
26   //Begin to receive.
27   RFST=RFST_SRX;
28   while(MARCSTATE!=MARC_STATE_RX);
29   i=0;len=16;
30   while(i<len+1){
31     while(!RFTXRXIF); //Wait for byte to be ready.
32     RFTXRXIF=0;      //Clear the flag.
33     
34     if (MARCSTATE == MARC_STATE_RX) {
35       packet[i]=RFD; //Grab the next byte.
36       i++;
37       len=packet[0];   //First byte of the packet is the length.
38     }else
39       HALT;
40
41   }
42   RFST = RFST_SIDLE; //End receive.
43   HALT;
44 }