2 #include "cc1110-ext.h"
4 char __xdata at 0xfe00 packet[256] ;
6 char __xdata at 0xfdf0 cfg[5] ;
17 void restore_settings(){
26 // Set the system clock source to HS XOSC and max CPU speed,
27 // ref. [clk]=>[clk_xosc.c]
28 SLEEP &= ~SLEEP_OSC_PD;
29 while( !(SLEEP & SLEEP_XOSC_S) );
30 CLKCON = (CLKCON & ~(CLKCON_CLKSPD | CLKCON_OSC)) | CLKSPD_DIV_1;
31 while (CLKCON & CLKCON_OSC);
32 SLEEP |= SLEEP_OSC_PD;
35 /* Setup radio with settings from SmartRF® Studio. The default settings are
36 * used, except that "unmodulated" is chosen in the "Simple RX tab". This
37 * results in an umodulated carrier with a frequency of approx. 2.433 GHz.
39 //FSCTRL1 = 0x0A; // Frequency synthesizer control.
40 //FSCTRL0 = 0x00; // Frequency synthesizer control.
43 MDMCFG4 = 0x86; // Modem configuration.
44 MDMCFG3 = 0x83; // Modem configuration.
45 MDMCFG2 = 0x30; // Modem configuration.
46 MDMCFG1 = 0x22; // Modem configuration.
47 MDMCFG0 = 0xF8; // Modem configuration.
49 /* Settings not from SmartRF® Studio. Setting both sync word registers to
50 * 0xAA = 0b10101010, i.e., the same as the preamble pattern. Not necessary,
51 * but gives control of what the radio attempts to transmit.
54 //These sync values are better for jamming, but they break reception.
58 #define RFON RFST = RFST_SIDLE; RFST = RFST_STX; while ((MARCSTATE & MARCSTATE_MARC_STATE) != MARC_STATE_TX);
59 #define RFOFF RFST = RFST_SIDLE; //while ((MARCSTATE & MARCSTATE_MARC_STATE) != MARC_STATE_IDLE);
67 void sleepMillis(int ms) {
70 for (j=0; j<1200;j++); // about 1 millisecond
75 //! Reflexively jam on the present channel by responding to a signal with a carrier wave.
77 unsigned char threshold=packet[0], i=0, rssi=0;;
90 while(MARCSTATE!=MARC_STATE_IDLE);
94 //idle a bit, unecessary
96 //while(MARCSTATE!=MARC_STATE_FSTXON);
103 //while(MARCSTATE!=MARC_STATE_FSTXON);
114 //Transmit carrier for 10ms
125 //! Receives a packet out of the radio from 0xFE00.
127 unsigned char len=16, i=0;
135 //Disable interrupts.
140 while(MARCSTATE!=MARC_STATE_IDLE);
144 while(MARCSTATE!=MARC_STATE_RX);
148 while(i<len+3){ //len+3 if status is appended.
149 while(!RFTXRXIF); //Wait for byte to be ready.
150 RFTXRXIF=0; //Clear the flag.
152 packet[i++]=RFD; //Grab the next byte.
153 len=packet[0]; //First byte of the packet is the length.
159 while(!RFTXRXIF); //Wait for byte to be ready.
160 RFTXRXIF=0; //Clear the flag.
162 packet[i++]=RFD; //Grab the next byte.
165 RFST = RFST_SIDLE; //End receive.
167 //This while loop can be used for filtering. Unused for now.
168 }while(0); //packet[0]==(char) 0x0f || packet[1]==(char) 0xFF || packet[9]==(char) 0x03);