2 #include "cc1110-ext.h"
4 char __xdata at 0xfe00 packet[256] ;
6 char __xdata at 0xfdf0 cfg[5] ;
7 char __xdata at 0xfdf8 freq[3] ;
22 void restore_settings(){
36 // Set the system clock source to HS XOSC and max CPU speed,
37 // ref. [clk]=>[clk_xosc.c]
39 SLEEP &= ~SLEEP_OSC_PD;
40 while( !(SLEEP & SLEEP_XOSC_S) );
41 CLKCON = (CLKCON & ~(CLKCON_CLKSPD | CLKCON_OSC)) | CLKSPD_DIV_1;
42 while (CLKCON & CLKCON_OSC);
43 SLEEP |= SLEEP_OSC_PD;
48 /* Setup radio with settings from SmartRF® Studio. The default settings are
49 * used, except that "unmodulated" is chosen in the "Simple RX tab". This
50 * results in an umodulated carrier with a frequency of approx. 2.433 GHz.
52 //FSCTRL1 = 0x0A; // Frequency synthesizer control.
53 //FSCTRL0 = 0x00; // Frequency synthesizer control.
56 //Bandwidth, Symbol Rate
60 //Sensitivity, shift-keying mode
62 //FEC, Premable, Spacing
67 /* Settings not from SmartRF® Studio. Setting both sync word registers to
68 * 0xAA = 0b10101010, i.e., the same as the preamble pattern. Not necessary,
69 * but gives control of what the radio attempts to transmit.
72 //These sync values are better for jamming, but they break reception.
76 #define RFON RFST = RFST_SIDLE; RFST = RFST_STX; while ((MARCSTATE & MARCSTATE_MARC_STATE) != MARC_STATE_TX);
77 #define RFOFF RFST = RFST_SIDLE; //while ((MARCSTATE & MARCSTATE_MARC_STATE) != MARC_STATE_IDLE);
83 void sleepMillis(int ms) {
86 for (j=0; j<1200;j++); // about 1 millisecond
91 //! Reflexively jam on the present channel by responding to a signal with a carrier wave.
93 unsigned char threshold=packet[0], i=0, rssi=0;;
106 while(MARCSTATE!=MARC_STATE_IDLE);
109 //idle a bit, unecessary
111 //while(MARCSTATE!=MARC_STATE_FSTXON);
118 //while(MARCSTATE!=MARC_STATE_FSTXON);
121 //Transmit carrier for 10ms
136 //! Receives a packet out of the radio from 0xFE00.
138 unsigned char len=16, i=0;
140 //Test to always carry.
149 //Disable interrupts.
154 while(MARCSTATE!=MARC_STATE_IDLE);
158 while(MARCSTATE!=MARC_STATE_RX);
160 //RFST = RFST_SIDLE; //End receive.
166 while(i<3){ //PKTLEN){
167 while(!RFTXRXIF); //Wait for byte to be ready.
168 RFTXRXIF=0; //Clear the flag.
170 packet[i++]=RFD; //Grab the next byte.
173 RFST = RFST_SIDLE; //End receive.
175 //This while loop can be used for filtering. Unused for now.
176 }while(0); //packet[0]==(char) 0x0f || packet[1]==(char) 0xFF || packet[9]==(char) 0x03);