Code for receiving packets.
authortravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Thu, 9 Dec 2010 22:33:19 +0000 (22:33 +0000)
committertravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Thu, 9 Dec 2010 22:33:19 +0000 (22:33 +0000)
git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@783 12e2690d-a6be-4b82-a7b7-67c4a43b65c8

shellcode/chipcon/cc1110/Makefile
shellcode/chipcon/cc1110/rxpacket.c
shellcode/chipcon/cc1110/txpacket.c

index a345749..0464015 100644 (file)
@@ -8,7 +8,7 @@
 # Use lower RAM if needed.
 
 CC=sdcc --code-loc 0xF000 
 # Use lower RAM if needed.
 
 CC=sdcc --code-loc 0xF000 
-objs=crystal.ihx txpacket.ihx
+objs=crystal.ihx txpacket.ihx rxpacket.ihx
 
 all: $(objs)
 
 
 all: $(objs)
 
index 9bea242..eb722d1 100644 (file)
@@ -3,17 +3,39 @@
 
 char __xdata at 0xfe00 packet[256] ;
 
 
 char __xdata at 0xfe00 packet[256] ;
 
-
 //! Receives a packet out of the radio from 0xFE00.
 void main(){
 //! 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(i!=len+1){
-    while(RFTXRXIF); //Wait for byte to be ready.
-    
+    while(!RFTXRXIF); //Wait for byte to be ready.
     RFTXRXIF=0;      //Clear the flag.
     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;
   }
   RFST = RFST_SIDLE; //End transmit.
   HALT;
index 333e3d7..fa0ad98 100644 (file)
@@ -8,7 +8,7 @@ void main(){
   unsigned char len=packet[0], i=0;
   RFST=RFST_STX;     //Begin transmit.
   while(i!=len+1){
   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.
     
     RFTXRXIF=0;      //Clear the flag.
     RFD=packet[i++]; //Send the next byte.