turn ftdi driver into echo server
[goodfet] / shellcode / chipcon / cc1110 / carrier.c
1 #include <cc1110.h>
2 #include "cc1110-ext.h"
3
4
5
6 //! Generates a carrier wave.
7 void main(){
8   // Set the system clock source to HS XOSC and max CPU speed,
9   // ref. [clk]=>[clk_xosc.c]
10   SLEEP &= ~SLEEP_OSC_PD;
11   while( !(SLEEP & SLEEP_XOSC_S) );
12   CLKCON = (CLKCON & ~(CLKCON_CLKSPD | CLKCON_OSC)) | CLKSPD_DIV_1;
13   while (CLKCON & CLKCON_OSC);
14   SLEEP |= SLEEP_OSC_PD;
15
16
17   /* Setup radio with settings from SmartRF® Studio. The default settings are
18    * used, except that "unmodulated" is chosen in the "Simple RX tab". This
19    * results in an umodulated carrier with a frequency of approx. 2.433 GHz.
20    */
21   FSCTRL1   = 0x0A;   // Frequency synthesizer control.
22   FSCTRL0   = 0x00;   // Frequency synthesizer control.
23   
24   
25     
26   MDMCFG4   = 0x86;   // Modem configuration.
27   MDMCFG3   = 0x83;   // Modem configuration.
28   MDMCFG2   = 0x30;   // Modem configuration.
29   MDMCFG1   = 0x22;   // Modem configuration.
30   MDMCFG0   = 0xF8;   // Modem configuration.
31   CHANNR    = 0x00;   // Channel number.
32   DEVIATN   = 0x00;   // Modem deviation setting (when FSK modulation is enabled).
33   FREND1    = 0x56;   // Front end RX configuration.
34   FREND0    = 0x10;   // Front end RX configuration.
35   MCSM0     = 0x14;   // Main Radio Control State Machine configuration.
36   FOCCFG    = 0x16;   // Frequency Offset Compensation Configuration.
37   BSCFG     = 0x6C;   // Bit synchronization Configuration.
38   AGCCTRL2  = 0x03;   // AGC control.
39   AGCCTRL1  = 0x40;   // AGC control.
40   AGCCTRL0  = 0x91;   // AGC control.
41   FSCAL3    = 0xE9;   // Frequency synthesizer calibration.
42   FSCAL2    = 0x2a;   // Frequency synthesizer calibration.
43   FSCAL1    = 0x00;   // Frequency synthesizer calibration.
44   FSCAL0    = 0x1f;   // Frequency synthesizer calibration
45   
46   TEST2     = 0x88;   // Various test settings.
47   TEST1     = 0x31;   // Various test settings.
48   TEST0     = 0x09;   // Various test settings.
49   
50   //FE is too high
51   PA_TABLE0 = 0x50;   // PA output power setting.
52   PKTCTRL1  = 0x04;   // Packet automation control.
53   PKTCTRL0  = 0x22;   // Packet automation control.
54   ADDR      = 0x00;   // Device address.
55   PKTLEN    = 0xFF;   // Packet length.
56
57   /* Settings not from SmartRF® Studio. Setting both sync word registers to
58    * 0xAA = 0b10101010, i.e., the same as the preamble pattern. Not necessary,
59    * but gives control of what the radio attempts to transmit.
60    */
61   SYNC1     = 0xAA;
62   SYNC0     = 0xAA;
63
64   /* Put radio in TX. 
65   RFST      = RFST_STX;
66   while ((MARCSTATE & MARCSTATE_MARC_STATE) != MARC_STATE_TX);
67   */
68
69   
70 #define RFON RFST = RFST_STX; while ((MARCSTATE & MARCSTATE_MARC_STATE) != MARC_STATE_TX);
71 #define RFOFF RFST=RFST_SIDLE;
72   RFON;
73   while(1);
74   
75   RFST      = RFST_SIDLE;
76   
77   
78   
79 }