1 #ifndef CC1020_INTERNAL_H
2 #define CC1020_INTERNAL_H
6 #define CC1020_MAIN 0x00
7 #define CC1020_INTERFACE 0x01
8 #define CC1020_RESET 0x02
9 #define CC1020_SEQUENCING 0x03
10 #define CC1020_FREQ_2A 0x04
11 #define CC1020_FREQ_1A 0x05
12 #define CC1020_FREQ_0A 0x06
13 #define CC1020_CLOCK_A 0x07
14 #define CC1020_FREQ_2B 0x08
15 #define CC1020_FREQ_1B 0x09
16 #define CC1020_FREQ_0B 0x0A
17 #define CC1020_CLOCK_B 0x0B
18 #define CC1020_VCO 0x0C
19 #define CC1020_MODEM 0x0D
20 #define CC1020_DEVIATION 0x0E
21 #define CC1020_AFC_CONTROL 0x0F
22 #define CC1020_FILTER 0x10
23 #define CC1020_VGA1 0x11
24 #define CC1020_VGA2 0x12
25 #define CC1020_VGA3 0x13
26 #define CC1020_VGA4 0x14
27 #define CC1020_LOCK 0x15
28 #define CC1020_FRONTEND 0x16
29 #define CC1020_ANALOG 0x17
30 #define CC1020_BUFF_SWING 0x18
31 #define CC1020_BUFF_CURRENT 0x19
32 #define CC1020_PLL_BW 0x1A
33 #define CC1020_CALIBRATE 0x1B
34 #define CC1020_PA_POWER 0x1C
35 #define CC1020_MATCH 0x1D
36 #define CC1020_PHASE_COMP 0x1E
37 #define CC1020_GAIN_COMP 0x1F
38 #define CC1020_POWERDOWN 0x20
39 #define CC1020_TEST1 0x21
40 #define CC1020_TEST2 0x22
41 #define CC1020_TEST3 0x23
42 #define CC1020_TEST4 0x24
43 #define CC1020_TEST5 0x25
44 #define CC1020_TEST6 0x26
45 #define CC1020_TEST7 0x27
46 #define CC1020_STATUS 0x40
47 #define CC1020_RESET_DONE 0x41
48 #define CC1020_RSS 0x42
49 #define CC1020_AFC 0x43
50 #define CC1020_GAUSS_FILTER 0x44
51 #define CC1020_STATUS1 0x45
52 #define CC1020_STATUS2 0x46
53 #define CC1020_STATUS3 0x47
54 #define CC1020_STATUS4 0x48
55 #define CC1020_STATUS5 0x49
56 #define CC1020_STATUS6 0x4A
57 #define CC1020_STATUS7 0x4B
61 #define BIAS_PD (1<<1)
62 #define XOSC_PD (1<<2)
64 #define PD_MODE_1 (1<<4)
65 #define PD_MODE_2 (1<<5)
71 #define SEQ_CAL_1 (1<<2)
72 #define SEQ_CAL_2 (1<<3)
75 #define CARRIER_SENSE 0x08
76 #define LOCK_CONTINUOUS 0x10
77 #define LOCK_INSTANT 0x20
78 #define SEQ_ERROR 0x40
79 #define CAL_COMPLETE 0x80
81 #define PA_POWER 0x0F // initial default for output power
84 #define LOCK_RECAL_OK 0x02
85 #define CAL_TIMEOUT 0x7FFE
86 #define LOCK_TIMEOUT 0x7FFE
87 #define RESET_TIMEOUT 0x7FFE
88 #define TX_CURRENT 0x87
89 #define RX_CURRENT 0x86
94 #define PDO (P2IN & 0x01)
97 #define PSEL_ON do { P3OUT &= ~0x01; } while(0)
98 #define PSEL_OFF do { P3OUT |= 0x01; } while(0)
99 #define PCLK_HIGH do { P2OUT |= 0x08; } while(0)
100 #define PCLK_LOW do { P2OUT &= ~0x08; } while(0)
103 #define PDI_HIGH do { P2OUT |= 0x02; } while(0)
105 #define PDI_LOW do { P2OUT &= ~0x02; } while(0)
108 #define LNA_POWER_ON() do { P2OUT &= ~0x10; } while(0)
110 #define LNA_POWER_OFF() do { P2OUT |= 0x10; } while(0)
112 #define CC_LOCK (P2IN & 0x04)
114 #define DISABLE_RX_IRQ() \
115 do { IE1 &= ~(URXIE0); } while(0)
117 #define ENABLE_RX_IRQ() \
118 do { IFG1 &= ~URXIFG0; IE1 |= URXIE0; } while(0)
120 #define ACK_TIMEOUT_115 4 // In RADIO_STROKE ticks
121 #define ACK_TIMEOUT_19 16
125 const uint8_t cc1020_config_19200[41] = {
171 const uint8_t cc1020_config_115200[41] = {
223 CC1020_RX_SEARCHING = 0x10,
224 CC1020_RX_RECEIVING = 0x20,
225 CC1020_RX_PROCESSING = 0x40,
227 CC1020_OP_STATE = 0x73,
229 CC1020_TURN_OFF = 0x80,
232 #define CC1020_SET_OPSTATE(opstate) cc1020_state = ((cc1020_state & ~CC1020_OP_STATE) | (opstate))
240 struct cc1020_header {
246 #define CC1020_BUFFERSIZE 128
249 #define PREAMBLE_SIZE 6
250 #define PREAMBLE 0xAA
252 #define SYNCWORD_SIZE 2
253 #define HDR_SIZE (sizeof (struct cc1020_header))