From: travisutk Date: Thu, 9 Dec 2010 20:33:41 +0000 (+0000) Subject: Packet reception code. X-Git-Url: http://git.rot13.org/?p=goodfet;a=commitdiff_plain;h=a06f45d24b010987c9128261ff33dd2c93db0970;hp=b9e8a6ef91caf381fbc81606a3c442b77974ed62 Packet reception code. git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@782 12e2690d-a6be-4b82-a7b7-67c4a43b65c8 --- diff --git a/shellcode/chipcon/cc1110/Makefile b/shellcode/chipcon/cc1110/Makefile index ccd08b8..a345749 100644 --- a/shellcode/chipcon/cc1110/Makefile +++ b/shellcode/chipcon/cc1110/Makefile @@ -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 -objs=crystal.ihx +objs=crystal.ihx txpacket.ihx all: $(objs) diff --git a/shellcode/chipcon/cc1110/rxpacket.c b/shellcode/chipcon/cc1110/rxpacket.c new file mode 100644 index 0000000..9bea242 --- /dev/null +++ b/shellcode/chipcon/cc1110/rxpacket.c @@ -0,0 +1,20 @@ +#include +#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 index 0000000..333e3d7 --- /dev/null +++ b/shellcode/chipcon/cc1110/txpacket.c @@ -0,0 +1,18 @@ +#include +#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; +}