From 3c9dd526729e4296e7ac231840a445de182c8734 Mon Sep 17 00:00:00 2001 From: travisutk Date: Thu, 9 Dec 2010 22:33:19 +0000 Subject: [PATCH 1/1] Code for receiving packets. git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@783 12e2690d-a6be-4b82-a7b7-67c4a43b65c8 --- shellcode/chipcon/cc1110/Makefile | 2 +- shellcode/chipcon/cc1110/rxpacket.c | 36 +++++++++++++++++++++++------ shellcode/chipcon/cc1110/txpacket.c | 2 +- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/shellcode/chipcon/cc1110/Makefile b/shellcode/chipcon/cc1110/Makefile index a345749..0464015 100644 --- a/shellcode/chipcon/cc1110/Makefile +++ b/shellcode/chipcon/cc1110/Makefile @@ -8,7 +8,7 @@ # Use lower RAM if needed. CC=sdcc --code-loc 0xF000 -objs=crystal.ihx txpacket.ihx +objs=crystal.ihx txpacket.ihx rxpacket.ihx all: $(objs) diff --git a/shellcode/chipcon/cc1110/rxpacket.c b/shellcode/chipcon/cc1110/rxpacket.c index 9bea242..eb722d1 100644 --- a/shellcode/chipcon/cc1110/rxpacket.c +++ b/shellcode/chipcon/cc1110/rxpacket.c @@ -3,17 +3,39 @@ char __xdata at 0xfe00 packet[256] ; - //! Receives a packet out of the radio from 0xFE00. void main(){ - unsigned char len=100, i=0; - RFST=RFST_SRX; //Begin to receive. + 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. - + while(!RFTXRXIF); //Wait for byte to be ready. RFTXRXIF=0; //Clear the flag. - packet[i++]=RFD; //Grab the next byte. - len=packet[0]; //First byte of the packet is the length. + + 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. HALT; diff --git a/shellcode/chipcon/cc1110/txpacket.c b/shellcode/chipcon/cc1110/txpacket.c index 333e3d7..fa0ad98 100644 --- a/shellcode/chipcon/cc1110/txpacket.c +++ b/shellcode/chipcon/cc1110/txpacket.c @@ -8,7 +8,7 @@ void main(){ unsigned char len=packet[0], i=0; RFST=RFST_STX; //Begin transmit. while(i!=len+1){ - while(RFTXRXIF); //Wait for byte to be ready. + while(!RFTXRXIF); //Wait for byte to be ready. RFTXRXIF=0; //Clear the flag. RFD=packet[i++]; //Send the next byte. -- 2.20.1