CCxxxx Driver  0.0.1
cc1100_cc2500.h
Go to the documentation of this file.
1 /******************************************************************************
2 * Copyright (c) 2017, Alan Barr
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * * Redistributions of source code must retain the above copyright notice, this
9 * list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *******************************************************************************/
26 
41 #ifndef __CCX_REGISTERS_H__
42 #define __CCX_REGISTERS_H__
43 
44 
45 /******************************************************************************/
51 /******************************************************************************/
52 
53 #define CCX_REG_IOCFG2 0x00
54 #define CCX_REG_IOCFG1 0x01
55 #define CCX_REG_IOCFG0 0x02
56 #define CCX_REG_FIFOTHR 0x03
57 #define CCX_REG_SYNC1 0x04
58 #define CCX_REG_SYNC0 0x05
59 #define CCX_REG_PKTLEN 0x06
60 #define CCX_REG_PKTCTRL1 0x07
61 #define CCX_REG_PKTCTRL0 0x08
62 #define CCX_REG_ADDR 0x09
63 #define CCX_REG_CHANNR 0x0A
64 #define CCX_REG_FSCTRL1 0x0B
65 #define CCX_REG_FSCTRL0 0x0C
66 #define CCX_REG_FREQ2 0x0D
67 #define CCX_REG_FREQ1 0x0E
68 #define CCX_REG_FREQ0 0x0F
69 #define CCX_REG_MDMCFG4 0x10
70 #define CCX_REG_MDMCFG3 0x11
71 #define CCX_REG_MDMCFG2 0x12
72 #define CCX_REG_MDMCFG1 0x13
73 #define CCX_REG_MDMCFG0 0x14
74 #define CCX_REG_DEVIATN 0x15
75 #define CCX_REG_MCSM2 0x16
76 #define CCX_REG_MCSM1 0x17
77 #define CCX_REG_MCSM0 0x18
78 #define CCX_REG_FOCCFG 0x19
79 #define CCX_REG_BSCFG 0x1A
80 #define CCX_REG_AGCCTRL2 0x1B
81 #define CCX_REG_AGCCTRL1 0x1C
82 #define CCX_REG_AGCCTRL0 0x1D
83 #define CCX_REG_WOREVT1 0x1E
84 #define CCX_REG_WOREVT0 0x1F
85 #define CCX_REG_WORCTRL 0x20
86 #define CCX_REG_FREND1 0x21
87 #define CCX_REG_FREND0 0x22
88 #define CCX_REG_FSCAL3 0x23
89 #define CCX_REG_FSCAL2 0x24
90 #define CCX_REG_FSCAL1 0x25
91 #define CCX_REG_FSCAL0 0x26
92 #define CCX_REG_RCCTRL1 0x27
93 #define CCX_REG_RCCTRL0 0x28
94 #define CCX_REG_FSTEST 0x29
95 #define CCX_REG_PTEST 0x2A
96 #define CCX_REG_AGCTEST 0x2B
97 #define CCX_REG_TEST2 0x2C
98 #define CCX_REG_TEST1 0x2D
99 #define CCX_REG_TEST0 0x2E
103 /******************************************************************************/
104 
109 /******************************************************************************/
110 
111 #define CCX_REG_STROBE_SRES 0x30
112 #define CCX_REG_STROBE_SFSTXON 0x31
113 #define CCX_REG_STROBE_SXOFF 0x32
114 #define CCX_REG_STROBE_SCAL 0x33
115 #define CCX_REG_STROBE_SRX 0x34
116 #define CCX_REG_STROBE_STX 0x35
117 #define CCX_REG_STROBE_SIDLE 0x36
118 #define CCX_REG_STROBE_SWOR 0x38
119 #define CCX_REG_STROBE_SPWD 0x39
120 #define CCX_REG_STROBE_SFRX 0x3A
121 #define CCX_REG_STROBE_SFTX 0x3B
122 #define CCX_REG_STROBE_SWORRST 0x3C
123 #define CCX_REG_STROBE_SNOP 0x3D
127 /******************************************************************************/
128 
133 /******************************************************************************/
134 #define CCX_REG_STATUS_PARTNUM 0x30
135 #define CCX_REG_STATUS_VERSION 0x31
136 #define CCX_REG_STATUS_FREQEST 0x32
137 #define CCX_REG_STATUS_LQI 0x33
138 #define CCX_REG_STATUS_RSSI 0x34
139 #define CCX_REG_STATUS_MARCSTATE 0x35
140 #define CCX_REG_STATUS_WORTIME1 0x36
141 #define CCX_REG_STATUS_WORTIME0 0x37
142 #define CCX_REG_STATUS_PKTSTATUS 0x38
143 #define CCX_REG_STATUS_VCO_VC_DAC 0x39
144 #define CCX_REG_STATUS_TXBYTES 0x3A
145 #define CCX_REG_STATUS_RXBYTES 0x3B
147 /******************************************************************************/
148 /* Status Register: MARCSTATE */
149 /******************************************************************************/
150 
156 typedef enum {
180 } CcxMarcState;
181 
191 #define CCX_MARCSTATE_GET_STATE(_MS) CCX_GET_BITS_VALUE((_MS), 5, 0)
192 
193 
203 #define CCX_MARCSTATE_IS_IN_TX(_MS) \
204  (CCX_MARCSTATE_GET_STATE((_MS)) == CCX_MARCSTATE_FSTXON || \
205  CCX_MARCSTATE_GET_STATE((_MS)) == CCX_MARCSTATE_TX || \
206  CCX_MARCSTATE_GET_STATE((_MS)) == CCX_MARCSTATE_TX_END)
207 
208 /******************************************************************************/
209 /* Status Register: PKTSTATUS */
210 /******************************************************************************/
216 #define CCX_PKTSTATUS_GET_CRC_OK(_PS) CCX_GET_BITS_VALUE((_PS), 1, 7)
217 
218 /* @brief Obtain CS from contents of the Packet Status register.
219  * @param _PS Value obtained from reading @ref CCX_REG_STATUS_PKTSTATUS.
220  * @return Single bit Carrier Sense (CS) value.
221  */
222 #define CCX_PKTSTATUS_GET_PQT_REACHED(_PS) CCX_GET_BITS_VALUE((_PS), 1, 5)
223 
229 #define CCX_PKTSTATUS_GET_PQT_REACHED(_PS) CCX_GET_BITS_VALUE((_PS), 1, 5)
230 
236 #define CCX_PKTSTATUS_GET_CCA(_PS) CCX_GET_BITS_VALUE((_PS), 1, 4)
237 
243 #define CCX_PKTSTATUS_GET_SFD(_PS) CCX_GET_BITS_VALUE((_PS), 1, 3)
244 
250 #define CCX_PKTSTATUS_GET_GDO2(_PS) CCX_GET_BITS_VALUE((_PS), 1, 2)
251 
257 #define CCX_PKTSTATUS_GET_GDO0(_PS) CCX_GET_BITS_VALUE((_PS), 1, 0)
258 
259 /******************************************************************************/
260 /* Status Register: TXBYTES */
261 /******************************************************************************/
265 #define CCX_TX_FIFO_MAX 64
266 
273 #define CCX_TX_BYTES_IS_UNDERFLOW(_TX) CCX_GET_BITS_VALUE(_TX, 1, 7)
274 
281 #define CCX_TX_BYTES_IN_FIFO(_TX) CCX_GET_BITS_VALUE(_TX, 7, 0)
282 
283 /******************************************************************************/
284 /* Status Register: RXBYTES */
285 /******************************************************************************/
289 #define CCX_RX_FIFO_MAX 64
290 
297 #define CCX_RX_BYTES_IS_OVERFLOW(_RX) CCX_GET_BITS_VALUE(_RX, 1, 7)
298 
305 #define CCX_RX_BYTES_IN_FIFO(_RX) CCX_GET_BITS_VALUE(_RX, 7, 0)
306 
307 
308 
309 
312 /******************************************************************************/
322 /******************************************************************************/
323 #define CCX_REG_MULTIBYTE_PATABLE 0x3E
324 #define CCX_REG_MULTIBYTE_TXFIFO 0x3F
325 #define CCX_REG_MULTIBYTE_RXFIFO 0x3F
329 /******************************************************************************/
330 
336 /******************************************************************************/
337 
338 
344 #define CCX_MASK(_WIDTH, _OFFSET) \
345  (((2<<(_WIDTH - 1)) - 1) << (_OFFSET))
346 
357 #define CCX_GET_BITS_VALUE(_BITFIELD, _WIDTH, _OFFSET) \
358  (((_BITFIELD) & (CCX_MASK(_WIDTH, _OFFSET))) >> _OFFSET)
359 
360 
361 /******************************************************************************/
362 /* Header Byte */
363 /******************************************************************************/
364 
368 #define CCX_HEADER_READ CCX_MASK(1,7)
369 
373 #define CCX_HEADER_BURST CCX_MASK(1,6)
374 
378 #define CCX_HEADER_ADDRESS CCX_MASK(6,0)
379 
380 /******************************************************************************/
381 /* Chip Status Byte */
382 /******************************************************************************/
383 
388 typedef enum {
390  CCX_STATE_RX = 0X1,
391  CCX_STATE_TX = 0X2,
399 
400 /* CC1101 Chip Status Byte Bit Masks */
401 
406 #define CCX_SB_GET_STATE(_SB) CCX_GET_BITS_VALUE(_SB, 3, 4)
407 
413 #define CCX_SB_GET_FIFO_BYTES_AVAILABLE(_SB) CCX_GET_BITS_VALUE(_SB, 4, 0)
414 
415 /******************************************************************************/
416 /* CC1101 Appended Bytes */
417 /******************************************************************************/
418 
427 #define CCX_APD_B0_GET_RSSI(_BYTE0) (_BYTE0)
428 
438 #define CCX_APD_B1_IS_CRC_OK(_BYTE1) ((_BYTE1) & CCX_MASK(1,7))
439 
448 #define CCX_APD_B1_GET_LQI(_BYTE1) (CCX_GET_BITS_VALUE((_BYTE1),7,0))
449 
450 
453 #endif
Definition: cc1100_cc2500.h:393
Definition: cc1100_cc2500.h:392
Definition: cc1100_cc2500.h:161
Definition: cc1100_cc2500.h:390
Definition: cc1100_cc2500.h:170
Definition: cc1100_cc2500.h:177
Definition: cc1100_cc2500.h:163
Definition: cc1100_cc2500.h:175
Definition: cc1100_cc2500.h:165
Definition: cc1100_cc2500.h:172
Definition: cc1100_cc2500.h:159
Definition: cc1100_cc2500.h:391
Definition: cc1100_cc2500.h:157
Cc1101ChipStatusState
Possible states reported in the Chip Status byte. See CCX_SB_GET_STATE.
Definition: cc1100_cc2500.h:388
Definition: cc1100_cc2500.h:174
Definition: cc1100_cc2500.h:178
Definition: cc1100_cc2500.h:173
Definition: cc1100_cc2500.h:171
Definition: cc1100_cc2500.h:160
Definition: cc1100_cc2500.h:395
Definition: cc1100_cc2500.h:396
CcxMarcState
Values of the possible Main Radio Control FSM States. The field is present within CCX_REG_STATUS_MARC...
Definition: cc1100_cc2500.h:156
Definition: cc1100_cc2500.h:168
Definition: cc1100_cc2500.h:166
Definition: cc1100_cc2500.h:176
Definition: cc1100_cc2500.h:158
Definition: cc1100_cc2500.h:162
Definition: cc1100_cc2500.h:179
Definition: cc1100_cc2500.h:397
Definition: cc1100_cc2500.h:389
Definition: cc1100_cc2500.h:169
Definition: cc1100_cc2500.h:164
Definition: cc1100_cc2500.h:167