Added 'goodfet.cc sniffdash7'.
[goodfet] / shellcode / chipcon / cc1110 / rxpacket.c
1 #include <cc1110.h>
2 #include "cc1110-ext.h"
3
4 #define MAXLEN 0xFF
5 char __xdata at 0xfe00 packet[MAXLEN] ;
6
7 //! Receives a packet out of the radio from 0xFE00.
8 void main(){
9   unsigned char len=16, i=0;
10   
11   do{
12     //1-out the buffer.
13     for(i=0;i<64;i++)
14       packet[i]=0xFF;
15     i=0;
16     
17     //Disable interrupts.
18     RFTXRXIE=0;
19     
20     //idle a bit.
21     RFST=RFST_SIDLE;
22     while(MARCSTATE!=MARC_STATE_IDLE);
23     
24     //Begin to receive.
25     RFST=RFST_SRX;
26     while(MARCSTATE!=MARC_STATE_RX);
27   
28     while(i<len+3){ //len+3 if status is appended.
29       while(!RFTXRXIF); //Wait for byte to be ready.
30       RFTXRXIF=0;      //Clear the flag.
31       
32       packet[i++]=RFD; //Grab the next byte.
33       len=packet[0];   //First byte of the packet is the length.
34     }
35     RFST = RFST_SIDLE; //End receive.
36     
37     //This while loop can be used for filtering.  Unused for now.
38   }while(0); //packet[0]==(char) 0x0f || packet[1]==(char) 0xFF || packet[9]==(char) 0x03);
39   
40   HALT;
41 }
42