turn ftdi driver into echo server
[goodfet] / shellcode / chipcon / cc1110 / txpacket.c
1 #include <cc1110.h>
2 #include "cc1110-ext.h"
3
4 char __xdata at 0xfe00 packet[256] ;
5
6 void sleepMillis(int ms) {
7         int j;
8         while (--ms > 0) { 
9                 for (j=0; j<1200;j++); // about 1 millisecond
10         };
11 }
12
13 //! Transmit a packet out of the radio from 0xFE00.
14 void main(){
15   unsigned char len=packet[0], i=0;
16   long j;
17   
18   //Disable interrupts.
19   RFTXRXIE=0;
20   
21   //idle a bit.
22   RFST=RFST_SIDLE;
23   while(MARCSTATE!=MARC_STATE_IDLE);
24   
25   
26   RFST=RFST_STX;     //Begin transmit.
27   while(MARCSTATE!=MARC_STATE_TX);
28   
29   while(i<len+1){
30     while(!RFTXRXIF); //Wait for byte to be ready.
31     while(MARCSTATE!=MARC_STATE_TX); //Lockup if needed.
32     RFTXRXIF=0;      //Clear the flag.
33     RFD=packet[i++]; //Send the next byte.
34   }
35   
36   //Wait for transmission to complete.
37   while(MARCSTATE==MARC_STATE_TX);
38
39   //RFST = RFST_SIDLE; //End transmit.
40   HALT;
41 }