Packet reception code.
authortravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Thu, 9 Dec 2010 20:33:41 +0000 (20:33 +0000)
committertravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Thu, 9 Dec 2010 20:33:41 +0000 (20:33 +0000)
git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@782 12e2690d-a6be-4b82-a7b7-67c4a43b65c8

shellcode/chipcon/cc1110/Makefile
shellcode/chipcon/cc1110/rxpacket.c [new file with mode: 0644]
shellcode/chipcon/cc1110/txpacket.c [new file with mode: 0644]

index ccd08b8..a345749 100644 (file)
@@ -1,8 +1,14 @@
-# These targets are compiled to execute at the beginning of RAM.
-# Each should conclude with HALT (0xA5).
+# These targets are compiled to execute at the beginning of RAM.  Each
+# should conclude with HALT (0xA5).  Sometimes grabbing code from
+# foo.rst will be smaller, especially if no ljmps occur.
+
+
+# Input and output should be taken from a buffer at 0xFE00.
+# "char __xdata at 0xfe00 packet[256] ;"
+# Use lower RAM if needed.
 
 CC=sdcc --code-loc 0xF000 
 
 CC=sdcc --code-loc 0xF000 
-objs=crystal.ihx
+objs=crystal.ihx txpacket.ihx
 
 all: $(objs)
 
 
 all: $(objs)
 
diff --git a/shellcode/chipcon/cc1110/rxpacket.c b/shellcode/chipcon/cc1110/rxpacket.c
new file mode 100644 (file)
index 0000000..9bea242
--- /dev/null
@@ -0,0 +1,20 @@
+#include <cc1110.h>
+#include "cc1110-ext.h"
+
+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.
+  while(i!=len+1){
+    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.
+  }
+  RFST = RFST_SIDLE; //End transmit.
+  HALT;
+}
diff --git a/shellcode/chipcon/cc1110/txpacket.c b/shellcode/chipcon/cc1110/txpacket.c
new file mode 100644 (file)
index 0000000..333e3d7
--- /dev/null
@@ -0,0 +1,18 @@
+#include <cc1110.h>
+#include "cc1110-ext.h"
+
+char __xdata at 0xfe00 packet[256] ;
+
+//! Transmit a packet out of the radio from 0xFE00.
+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.
+    
+    RFTXRXIF=0;      //Clear the flag.
+    RFD=packet[i++]; //Send the next byte.
+  }
+  RFST = RFST_SIDLE; //End transmit.
+  HALT;
+}