cdea825be723b1fa8e5297352843c18b45060d09
[goodfet] / shellcode / chipcon / cc1110 / rxpacketp25.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     //Fixed length
29     packet[i++]=PKTLEN;
30     while(i<PKTLEN){
31       while(!RFTXRXIF); //Wait for byte to be ready.
32       RFTXRXIF=0;      //Clear the flag.
33       
34       packet[i++]=RFD; //Grab the next byte.
35     }
36     
37     RFST = RFST_SIDLE; //End receive.
38     
39     //This while loop can be used for filtering.  Unused for now.
40   }while(packet[1]!=(char) 0xdd || packet[2]!=(char) 0x55);
41   
42   HALT;
43 }
44