CC13xx Driver Library
rf_mailbox.h
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: rf_mailbox.h
3 * Revised: $ $
4 * Revision: $ $
5 *
6 * Description: Definitions for interface between system and radio CPU
7 *
8 * Copyright (c) 2015 - 2016, Texas Instruments Incorporated
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 *
14 * 1) Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 *
17 * 2) Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 *
21 * 3) Neither the name of the ORGANIZATION nor the names of its contributors may
22 * be used to endorse or promote products derived from this software without
23 * specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 *
37 ******************************************************************************/
38 
39 #ifndef _MAILBOX_H
40 #define _MAILBOX_H
41 
42 #include <stdint.h>
43 #include <string.h>
44 
45 
49 #define RF_MODE_PROPRIETARY_SUB_1 0x00
50 #define RF_MODE_BLE 0x01
51 #define RF_MODE_IEEE_15_4 0x02
52 #define RF_MODE_PROPRIETARY_2_4 0x03
53 #define RF_MODE_PROPRIETARY RF_MODE_PROPRIETARY_2_4
54 #define RF_MODE_MULTIPLE 0x05
55 
57 
59 typedef uint32_t ratmr_t;
60 
61 
62 
64 typedef struct {
65  uint8_t *pCurrEntry;
66  uint8_t *pLastEntry;
67 } dataQueue_t;
68 
69 
70 
74 #define IRQN_COMMAND_DONE 0
75 #define IRQN_LAST_COMMAND_DONE 1
76 #define IRQN_FG_COMMAND_DONE 2
77 #define IRQN_LAST_FG_COMMAND_DONE 3
78 #define IRQN_TX_DONE 4
79 #define IRQN_TX_ACK 5
80 #define IRQN_TX_CTRL 6
81 #define IRQN_TX_CTRL_ACK 7
82 #define IRQN_TX_CTRL_ACK_ACK 8
83 #define IRQN_TX_RETRANS 9
84 #define IRQN_TX_ENTRY_DONE 10
85 #define IRQN_TX_BUFFER_CHANGED 11
86 #define IRQN_RX_OK 16
87 #define IRQN_RX_NOK 17
88 #define IRQN_RX_IGNORED 18
89 #define IRQN_RX_EMPTY 19
90 #define IRQN_RX_CTRL 20
91 #define IRQN_RX_CTRL_ACK 21
92 #define IRQN_RX_BUF_FULL 22
93 #define IRQN_RX_ENTRY_DONE 23
94 #define IRQN_RX_DATA_WRITTEN 24
95 #define IRQN_RX_N_DATA_WRITTEN 25
96 #define IRQN_RX_ABORTED 26
97 #define IRQN_RX_COLLISION_DETECTED 27
98 #define IRQN_SYNTH_NO_LOCK 28
99 #define IRQN_MODULES_UNLOCKED 29
100 #define IRQN_BOOT_DONE 30
101 
102 #define IRQN_INTERNAL_ERROR 31
103 
104 #define IRQ_COMMAND_DONE (1U << IRQN_COMMAND_DONE)
105 #define IRQ_LAST_COMMAND_DONE (1U << IRQN_LAST_COMMAND_DONE)
106 #define IRQ_FG_COMMAND_DONE (1U << IRQN_FG_COMMAND_DONE)
107 #define IRQ_LAST_FG_COMMAND_DONE (1U << IRQN_LAST_FG_COMMAND_DONE)
108 
109 #define IRQ_TX_DONE (1U << IRQN_TX_DONE)
110 #define IRQ_TX_ACK (1U << IRQN_TX_ACK)
111 #define IRQ_TX_CTRL (1U << IRQN_TX_CTRL)
112 #define IRQ_TX_CTRL_ACK (1U << IRQN_TX_CTRL_ACK)
113 #define IRQ_TX_CTRL_ACK_ACK (1U << IRQN_TX_CTRL_ACK_ACK)
114 #define IRQ_TX_RETRANS (1U << IRQN_TX_RETRANS)
115 
116 #define IRQ_TX_ENTRY_DONE (1U << IRQN_TX_ENTRY_DONE)
117 #define IRQ_TX_BUFFER_CHANGED (1U << IRQN_TX_BUFFER_CHANGED)
118 
119 #define IRQ_RX_OK (1U << IRQN_RX_OK)
120 #define IRQ_RX_NOK (1U << IRQN_RX_NOK)
121 #define IRQ_RX_IGNORED (1U << IRQN_RX_IGNORED)
122 #define IRQ_RX_EMPTY (1U << IRQN_RX_EMPTY)
123 #define IRQ_RX_CTRL (1U << IRQN_RX_CTRL)
124 #define IRQ_RX_CTRL_ACK (1U << IRQN_RX_CTRL_ACK)
125 #define IRQ_RX_BUF_FULL (1U << IRQN_RX_BUF_FULL)
126 #define IRQ_RX_ENTRY_DONE (1U << IRQN_RX_ENTRY_DONE)
127 #define IRQ_RX_DATA_WRITTEN (1U << IRQN_RX_DATA_WRITTEN)
128 #define IRQ_RX_N_DATA_WRITTEN (1U << IRQN_RX_N_DATA_WRITTEN)
129 #define IRQ_RX_ABORTED (1U << IRQN_RX_ABORTED)
130 #define IRQ_RX_COLLISION_DETECTED (1U << IRQN_RX_COLLISION_DETECTED)
131 #define IRQ_SYNTH_NO_LOCK (1U << IRQN_SYNTH_NO_LOCK)
132 #define IRQ_MODULES_UNLOCKED (1U << IRQN_MODULES_UNLOCKED)
133 #define IRQ_BOOT_DONE (1U << IRQN_BOOT_DONE)
134 #define IRQ_INTERNAL_ERROR (1U << IRQN_INTERNAL_ERROR)
135 
137 
138 
142 #define CMDSTA_Pending 0x00
143 #define CMDSTA_Done 0x01
144 
145 #define CMDSTA_IllegalPointer 0x81
146 #define CMDSTA_UnknownCommand 0x82
147 #define CMDSTA_UnknownDirCommand 0x83
148 #define CMDSTA_ContextError 0x85
150 #define CMDSTA_SchedulingError 0x86
152 #define CMDSTA_ParError 0x87
154 #define CMDSTA_QueueError 0x88
156 #define CMDSTA_QueueBusy 0x89
158 
161 
162 
166 #define CMDR_DIR_CMD(cmdId) (((cmdId) << 16) | 1)
167 
169 #define CMDR_DIR_CMD_1BYTE(cmdId, par) (((cmdId) << 16) | ((par) << 8) | 1)
170 
172 #define CMDR_DIR_CMD_2BYTE(cmdId, par) (((cmdId) << 16) | ((par) & 0xFFFC) | 1)
173 
175 
176 
177 
180 #define TRIG_NOW 0
181 #define TRIG_NEVER 1
182 #define TRIG_ABSTIME 2
183 #define TRIG_REL_SUBMIT 3
184 #define TRIG_REL_START 4
185 #define TRIG_REL_PREVSTART 5
186 #define TRIG_REL_FIRSTSTART 6
187 #define TRIG_REL_PREVEND 7
188 #define TRIG_REL_EVT1 8
189 #define TRIG_REL_EVT2 9
190 #define TRIG_EXTERNAL 10
191 #define TRIG_PAST_BM 0x80
192 
195 
198 #define COND_ALWAYS 0
199 #define COND_NEVER 1
200 #define COND_STOP_ON_FALSE 2
201 #define COND_STOP_ON_TRUE 3
203 #define COND_SKIP_ON_FALSE 4
205 #define COND_SKIP_ON_TRUE 5
207 
210 
211 
216 #define IDLE 0x0000
217 #define PENDING 0x0001
218 #define ACTIVE 0x0002
219 #define SKIPPED 0x0003
220 #define DONE_OK 0x0400
224 #define DONE_COUNTDOWN 0x0401
225 #define DONE_RXERR 0x0402
226 #define DONE_TIMEOUT 0x0403
227 #define DONE_STOPPED 0x0404
228 #define DONE_ABORT 0x0405
229 #define DONE_FAILED 0x0406
230 #define ERROR_PAST_START 0x0800
234 #define ERROR_START_TRIG 0x0801
235 #define ERROR_CONDITION 0x0802
236 #define ERROR_PAR 0x0803
237 #define ERROR_POINTER 0x0804
238 #define ERROR_CMDID 0x0805
239 #define ERROR_WRONG_BG 0x0806
241 #define ERROR_NO_SETUP 0x0807
242 #define ERROR_NO_FS 0x0808
243 #define ERROR_SYNTH_PROG 0x0809
244 #define ERROR_TXUNF 0x080A
245 #define ERROR_RXOVF 0x080B
246 #define ERROR_NO_RX 0x080C
247 #define ERROR_PENDING 0x080D
248 
251 
254 #define DATA_ENTRY_TYPE_GEN 0
255 #define DATA_ENTRY_TYPE_MULTI 1
256 #define DATA_ENTRY_TYPE_PTR 2
257 #define DATA_ENTRY_TYPE_PARTIAL 3
258 
260 
263 #define DATA_ENTRY_PENDING 0
264 #define DATA_ENTRY_ACTIVE 1
265 #define DATA_ENTRY_BUSY 2
266 #define DATA_ENTRY_FINISHED 3
267 #define DATA_ENTRY_UNFINISHED 4
268 
270 
271 
275 #define ADI_VAL_MASK(addr, mask, value) \
276 (((addr) & 1) ? (((mask) & 0x0F) | (((value) & 0x0F) << 4)) : \
277  ((((mask) & 0x0F) << 4) | ((value) & 0x0F)))
278 #define HW_REG_OVERRIDE(addr, val) ((((uintptr_t) (addr)) & 0xFFFC) | ((uint32_t)(val) << 16))
280 #define ADI_REG_OVERRIDE(adiNo, addr, val) (2 | ((uint32_t)(val) << 16) | \
282 (((addr) & 0x3F) << 24) | (((adiNo) ? 1U : 0) << 31))
283 #define ADI_2REG_OVERRIDE(adiNo, addr, val, addr2, val2) \
285 (2 | ((uint32_t)(val2) << 2) | (((addr2) & 0x3F) << 10) | ((uint32_t)(val) << 16) | \
286 (((addr) & 0x3F) << 24) | (((adiNo) ? 1U : 0) << 31))
287 #define ADI_HALFREG_OVERRIDE(adiNo, addr, mask, val) (2 | (ADI_VAL_MASK(addr, mask, val) << 16) | \
289 (((addr) & 0x3F) << 24) | (1U << 30) | (((adiNo) ? 1U : 0) << 31))
290 #define ADI_2HALFREG_OVERRIDE(adiNo, addr, mask, val, addr2, mask2, val2) \
292 (2 | (ADI_VAL_MASK(addr2, mask2, val2) << 2) | (((addr2) & 0x3F) << 10) | \
293 (ADI_VAL_MASK(addr, mask, val) << 16) | (((addr) & 0x3F) << 24) | (1U << 30) | (((adiNo) ? 1U : 0) << 31))
294 
296 #define SW_REG_OVERRIDE(cmd, field, val) (3 | ((_POSITION_##cmd##_##field) << 4) | ((uint32_t)(val) << 16))
297 #define SW_REG_IND_OVERRIDE(cmd, field, offset, val) (3 | \
299 (((_POSITION_##cmd##_##field) + ((offset) << 1)) << 4) | ((uint32_t)(val) << 16))
300 #define SW_REG_BYTE_OVERRIDE(cmd, field, val) (0x8003 | ((_POSITION_##cmd##_##field) << 4) | \
302 ((uint32_t)(val) << 16))
303 #define SW_REG_2BYTE_OVERRIDE(cmd, field, val0, val1) (3 | (((_POSITION_##cmd##_##field) & 0xFFFE) << 4) | \
305  (((uint32_t)(val0) << 16) & 0x00FF0000) | ((uint32_t)(val1) << 24))
306 #define HW16_ARRAY_OVERRIDE(addr, length) (1 | (((uintptr_t) (addr)) & 0xFFFC) | ((uint32_t)(length) << 16))
307 #define HW32_ARRAY_OVERRIDE(addr, length) (1 | (((uintptr_t) (addr)) & 0xFFFC) | \
308 ((uint32_t)(length) << 16) | (1U << 30))
309 #define ADI_ARRAY_OVERRIDE(adiNo, addr, bHalfSize, length) (1 | ((((addr) & 0x3F) << 2)) | \
310 ((!!(bHalfSize)) << 8) | ((!!(adiNo)) << 9) | ((uint32_t)(length) << 16) | (2U << 30))
311 #define SW_ARRAY_OVERRIDE(cmd, firstfield, length) (1 | (((_POSITION_##cmd##_##firstfield)) << 2) | \
312 ((uint32_t)(length) << 16) | (3U << 30))
313 #define MCE_RFE_OVERRIDE(bMceRam, mceRomBank, mceMode, bRfeRam, rfeRomBank, rfeMode) \
314  (7 | ((!!(bMceRam)) << 8) | (((mceRomBank) & 0x07) << 9) | ((!!(bRfeRam)) << 12) | (((rfeRomBank) & 0x07) << 13) | \
315  (((mceMode) & 0x00FF) << 16) | (((rfeMode) & 0x00FF) << 24))
316 #define NEW_OVERRIDE_SEGMENT(address) (((((uintptr_t)(address)) & 0x03FFFFFC) << 6) | 0x000F | \
317  (((((uintptr_t)(address) >> 24) == 0x20) ? 0x01 : \
318  (((uintptr_t)(address) >> 24) == 0x21) ? 0x02 : \
319  (((uintptr_t)(address) >> 24) == 0xA0) ? 0x03 : \
320  (((uintptr_t)(address) >> 24) == 0x00) ? 0x04 : \
321  (((uintptr_t)(address) >> 24) == 0x10) ? 0x05 : \
322  (((uintptr_t)(address) >> 24) == 0x11) ? 0x06 : \
323  (((uintptr_t)(address) >> 24) == 0x40) ? 0x07 : \
324  (((uintptr_t)(address) >> 24) == 0x50) ? 0x08 : \
325  0x09) << 4)) // Use illegal value for illegal address range
326 #define END_OVERRIDE 0xFFFFFFFF
328 
329 
331 #define ADI_ADDR_VAL(addr, value) ((((addr) & 0x7F) << 8) | ((value) & 0xFF))
332 #define ADI_ADDR_VAL_MASK(addr, mask, value) ((((addr) & 0x7F) << 8) | ADI_VAL_MASK(addr, mask, value))
333 
335 #define LOWORD(value) ((value) & 0xFFFF)
336 #define HIWORD(value) ((value) >> 16)
338 
340 
341 #endif
uint8_t * pCurrEntry
Pointer to the data queue entry to be used, NULL for an empty queue.
Definition: rf_mailbox.h:65
uint8_t * pLastEntry
Pointer to the last entry in the queue, NULL for a circular queue.
Definition: rf_mailbox.h:66
uint32_t ratmr_t
Type definition for RAT.
Definition: rf_mailbox.h:59
Type definition for a data queue.
Definition: rf_mailbox.h:64