X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=shellcode%2Fchipcon%2Fcc1110%2Frxpacket.c;h=13ec690865339b06931584e6b1ba3c02666b5e5a;hp=eb722d16c27fcb12f20401bc32937e94a5d7431e;hb=f9fa242f4cd7c7ad6ff7f2a603d77e721595a7ac;hpb=3c9dd526729e4296e7ac231840a445de182c8734 diff --git a/shellcode/chipcon/cc1110/rxpacket.c b/shellcode/chipcon/cc1110/rxpacket.c index eb722d1..13ec690 100644 --- a/shellcode/chipcon/cc1110/rxpacket.c +++ b/shellcode/chipcon/cc1110/rxpacket.c @@ -1,42 +1,54 @@ #include #include "cc1110-ext.h" -char __xdata at 0xfe00 packet[256] ; +#define MAXLEN 0xFF +char __xdata at 0xfe00 packet[MAXLEN] ; //! Receives a packet out of the radio from 0xFE00. void main(){ unsigned char len=16, i=0; - //1-out the buffer. - for(i=0;i<64;i++) - packet[i]=0xFF; - i=0; - - //Disable interrupts. - RFTXRXIE=0; - - //idle a bit. - RFST=RFST_SIDLE; - while(MARCSTATE!=MARC_STATE_IDLE); - - //Begin to receive. - RFST=RFST_SRX; - while(MARCSTATE!=MARC_STATE_RX); - - while(i!=len+1){ - while(!RFTXRXIF); //Wait for byte to be ready. - RFTXRXIF=0; //Clear the flag. + do{ + //1-out the buffer. + for(i=0;i<64;i++) + packet[i]=0xFF; + i=0; - if (MARCSTATE == MARC_STATE_RX) { - packet[i]=RFD; //Grab the next byte. - //packet[i]=MARCSTATE; - //if(packet[i]!=0) - i++; - //len=packet[0]; //First byte of the packet is the length. - }else - HALT; - - } - RFST = RFST_SIDLE; //End transmit. + //Disable interrupts. + RFTXRXIE=0; + + //idle a bit. + RFST=RFST_SIDLE; + while(MARCSTATE!=MARC_STATE_IDLE); + + //Begin to receive. + RFST=RFST_SRX; + while(MARCSTATE!=MARC_STATE_RX); + + if(PKTCTRL0&1){ + //auto length + while(i