Lots of new shellcodes. Need to document them later.
[goodfet] / shellcode / chipcon / cc1110 / reflexframe.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 //! Wait for a packet to come, then immediately return.
14 void rxwait(){
15   //Disable interrupts.
16   RFTXRXIE=0;
17   
18   //idle a bit.
19   RFST=RFST_SIDLE;
20   while(MARCSTATE!=MARC_STATE_IDLE);
21   
22   //Begin to receive.
23   RFST=RFST_SRX;
24   while(MARCSTATE!=MARC_STATE_RX);
25   
26   //Incoming!  Return to let the jammer handle things.
27   
28 }
29
30 //! Reflexively jam on the present channel by responding to a signal with a carrier wave.
31 void main(){
32   unsigned char threshold=packet[0], i=0, rssi=0;;
33   
34   
35   //Disable interrupts.
36   RFTXRXIE=0;
37   
38   //idle a bit.
39   //RFST=RFST_SIDLE;
40   //while(MARCSTATE!=MARC_STATE_IDLE);
41
42   while(1){
43     
44     rxwait();
45     
46     //idle a bit.
47     RFST=RFST_SIDLE;
48     while(MARCSTATE!=MARC_STATE_IDLE);
49     
50     SYNC1=0xAA;
51     SYNC0=0xAA;
52     
53     //Transmit carrier for 10ms
54     RFST=RFST_STX;
55     while(MARCSTATE!=MARC_STATE_TX);
56     sleepMillis(20);
57     
58     //Carrier will clear when the loop continue,
59     //but we can HALT to give the host a chance to take over.
60     HALT;
61   }  
62   RFST = RFST_SIDLE; //End transmit.
63   
64   HALT;
65 }