1 /******************************************************************************
2 *  Filename:       rf_ieee_cmd.h
3 *
4 *  Description:    CC13x2/CC26x2 API for IEEE 802.15.4 commands
5 *
6 *  Copyright (c) 2015 - 2020, Texas Instruments Incorporated
7 *  All rights reserved.
8 *
9 *  Redistribution and use in source and binary forms, with or without
10 *  modification, are permitted provided that the following conditions are met:
11 *
12 *  1) Redistributions of source code must retain the above copyright notice,
13 *     this list of conditions and the following disclaimer.
14 *
15 *  2) Redistributions in binary form must reproduce the above copyright notice,
16 *     this list of conditions and the following disclaimer in the documentation
17 *     and/or other materials provided with the distribution.
18 *
19 *  3) Neither the name of the ORGANIZATION nor the names of its contributors may
20 *     be used to endorse or promote products derived from this software without
21 *     specific prior written permission.
22 *
23 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27 *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 *  POSSIBILITY OF SUCH DAMAGE.
34 *
35 ******************************************************************************/
36 
37 #ifndef __IEEE_CMD_H
38 #define __IEEE_CMD_H
39 
40 #ifndef __RFC_STRUCT
41 #define __RFC_STRUCT
42 #endif
43 
44 #ifndef __RFC_STRUCT_ATTR
45 #if defined(__GNUC__)
46 #define __RFC_STRUCT_ATTR __attribute__ ((aligned (4)))
47 #elif defined(__TI_ARM__)
48 #define __RFC_STRUCT_ATTR __attribute__ ((__packed__,aligned (4)))
49 #else
50 #define __RFC_STRUCT_ATTR
51 #endif
52 #endif
53 
54 //! \addtogroup rfc
55 //! @{
56 
57 //! \addtogroup ieee_cmd
58 //! @{
59 
60 #include <stdint.h>
61 #include "rf_mailbox.h"
62 #include "rf_common_cmd.h"
63 
64 typedef struct __RFC_STRUCT rfc_CMD_IEEE_RX_s rfc_CMD_IEEE_RX_t;
65 typedef struct __RFC_STRUCT rfc_CMD_IEEE_ED_SCAN_s rfc_CMD_IEEE_ED_SCAN_t;
66 typedef struct __RFC_STRUCT rfc_CMD_IEEE_TX_s rfc_CMD_IEEE_TX_t;
67 typedef struct __RFC_STRUCT rfc_CMD_IEEE_CSMA_s rfc_CMD_IEEE_CSMA_t;
68 typedef struct __RFC_STRUCT rfc_CMD_IEEE_RX_ACK_s rfc_CMD_IEEE_RX_ACK_t;
69 typedef struct __RFC_STRUCT rfc_CMD_IEEE_ABORT_BG_s rfc_CMD_IEEE_ABORT_BG_t;
70 typedef struct __RFC_STRUCT rfc_CMD_IEEE_MOD_CCA_s rfc_CMD_IEEE_MOD_CCA_t;
71 typedef struct __RFC_STRUCT rfc_CMD_IEEE_MOD_FILT_s rfc_CMD_IEEE_MOD_FILT_t;
72 typedef struct __RFC_STRUCT rfc_CMD_IEEE_MOD_SRC_MATCH_s rfc_CMD_IEEE_MOD_SRC_MATCH_t;
73 typedef struct __RFC_STRUCT rfc_CMD_IEEE_ABORT_FG_s rfc_CMD_IEEE_ABORT_FG_t;
74 typedef struct __RFC_STRUCT rfc_CMD_IEEE_STOP_FG_s rfc_CMD_IEEE_STOP_FG_t;
75 typedef struct __RFC_STRUCT rfc_CMD_IEEE_CCA_REQ_s rfc_CMD_IEEE_CCA_REQ_t;
76 typedef struct __RFC_STRUCT rfc_ieeeRxOutput_s rfc_ieeeRxOutput_t;
77 typedef struct __RFC_STRUCT rfc_shortAddrEntry_s rfc_shortAddrEntry_t;
78 typedef struct __RFC_STRUCT rfc_ieeeRxCorrCrc_s rfc_ieeeRxCorrCrc_t;
79 
80 //! \addtogroup CMD_IEEE_RX
81 //! @{
82 #define CMD_IEEE_RX                                             0x2801
83 //! IEEE 802.15.4 Receive Command
84 struct __RFC_STRUCT rfc_CMD_IEEE_RX_s {
85    uint16_t commandNo;                  //!<        The command ID number 0x2801
86    uint16_t status;                     //!< \brief An integer telling the status of the command. This value is
87                                         //!<        updated by the radio CPU during operation and may be read by the
88                                         //!<        system CPU at any time.
89    rfc_radioOp_t *pNextOp;              //!<        Pointer to the next operation to run after this operation is done
90    ratmr_t startTime;                   //!<        Absolute or relative start time (depending on the value of <code>startTrigger</code>)
91    struct {
92       uint8_t triggerType:4;            //!<        The type of trigger
93       uint8_t bEnaCmd:1;                //!< \brief 0: No alternative trigger command<br>
94                                         //!<        1: CMD_TRIGGER can be used as an alternative trigger
95       uint8_t triggerNo:2;              //!<        The trigger number of the CMD_TRIGGER command that triggers this action
96       uint8_t pastTrig:1;               //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error<br>
97                                         //!<        1: A trigger in the past is triggered as soon as possible
98    } startTrigger;                      //!<        Identification of the trigger that starts the operation
99    struct {
100       uint8_t rule:4;                   //!<        Condition for running next command: Rule for how to proceed
101       uint8_t nSkip:4;                  //!<        Number of skips + 1 if the rule involves skipping. 0: same, 1: next, 2: skip next, ...
102    } condition;
103    uint8_t channel;                     //!< \brief Channel to tune to in the start of the operation<br>
104                                         //!<        0: Use existing channel<br>
105                                         //!<        11--26: Use as IEEE 802.15.4 channel, i.e. frequency is (2405 + 5 &times; (channel - 11)) MHz<br>
106                                         //!<        60--207: Frequency is  (2300 + channel) MHz<br>
107                                         //!<        Others: <i>Reserved</i>
108    struct {
109       uint8_t bAutoFlushCrc:1;          //!<        If 1, automatically remove packets with CRC error from Rx queue
110       uint8_t bAutoFlushIgn:1;          //!<        If 1, automatically remove packets that can be ignored according to frame filtering from Rx queue
111       uint8_t bIncludePhyHdr:1;         //!<        If 1, include the received PHY header field in the stored packet; otherwise discard it
112       uint8_t bIncludeCrc:1;            //!<        If 1, include the received CRC field in the stored packet; otherwise discard it
113       uint8_t bAppendRssi:1;            //!<        If 1, append an RSSI byte to the packet in the Rx queue
114       uint8_t bAppendCorrCrc:1;         //!<        If 1, append a correlation value and CRC result byte to the packet in the Rx queue
115       uint8_t bAppendSrcInd:1;          //!<        If 1, append an index from the source matching algorithm
116       uint8_t bAppendTimestamp:1;       //!<        If 1, append a timestamp to the packet in the Rx queue
117    } rxConfig;
118    dataQueue_t* pRxQ;                   //!<        Pointer to receive queue
119    rfc_ieeeRxOutput_t *pOutput;         //!<        Pointer to output structure (NULL: Do not store results)
120    struct {
121       uint16_t frameFiltEn:1;           //!< \brief 0: Disable frame filtering<br>
122                                         //!<        1: Enable frame filtering
123       uint16_t frameFiltStop:1;         //!< \brief 0: Receive all packets to the end<br>
124                                         //!<        1: Stop receiving frame once frame filtering has caused the frame to be rejected.
125       uint16_t autoAckEn:1;             //!< \brief 0: Disable auto ACK<br>
126                                         //!<        1: Enable auto ACK.
127       uint16_t slottedAckEn:1;          //!< \brief 0: Non-slotted ACK<br>
128                                         //!<        1: Slotted ACK.
129       uint16_t autoPendEn:1;            //!< \brief 0: Auto-pend disabled<br>
130                                         //!<        1: Auto-pend enabled
131       uint16_t defaultPend:1;           //!<        The value of the pending data bit in auto ACK packets that are not subject to auto-pend
132       uint16_t bPendDataReqOnly:1;      //!< \brief 0: Use auto-pend for any packet<br>
133                                         //!<        1: Use auto-pend for data request packets only
134       uint16_t bPanCoord:1;             //!< \brief 0: Device is not PAN coordinator<br>
135                                         //!<        1: Device is PAN coordinator
136       uint16_t maxFrameVersion:2;       //!<        Reject frames where the frame version field in the FCF is greater than this value
137       uint16_t fcfReservedMask:3;       //!<        Value to be AND-ed with the reserved part of the FCF; frame rejected if result is non-zero
138       uint16_t modifyFtFilter:2;        //!< \brief Treatment of MSB of frame type field before frame-type filtering:<br>
139                                         //!<        0: No modification<br>
140                                         //!<        1: Invert MSB<br>
141                                         //!<        2: Set MSB to 0<br>
142                                         //!<        3: Set MSB to 1
143       uint16_t bStrictLenFilter:1;      //!< \brief 0: Accept acknowledgement frames of any length >= 5<br>
144                                         //!<        1: Accept only acknowledgement frames of length 5
145    } frameFiltOpt;                      //!<        Frame filtering options
146    struct {
147       uint8_t bAcceptFt0Beacon:1;       //!< \brief Treatment of frames with frame type 000 (beacon):<br>
148                                         //!<        0: Reject<br>
149                                         //!<        1: Accept
150       uint8_t bAcceptFt1Data:1;         //!< \brief Treatment of frames with frame type 001 (data):<br>
151                                         //!<        0: Reject<br>
152                                         //!<        1: Accept
153       uint8_t bAcceptFt2Ack:1;          //!< \brief Treatment of frames with frame type 010 (ACK):<br>
154                                         //!<        0: Reject, unless running ACK receive command<br>
155                                         //!<        1: Always accept
156       uint8_t bAcceptFt3MacCmd:1;       //!< \brief Treatment of frames with frame type 011 (MAC command):<br>
157                                         //!<        0: Reject<br>
158                                         //!<        1: Accept
159       uint8_t bAcceptFt4Reserved:1;     //!< \brief Treatment of frames with frame type 100 (reserved):<br>
160                                         //!<        0: Reject<br>
161                                         //!<        1: Accept
162       uint8_t bAcceptFt5Reserved:1;     //!< \brief Treatment of frames with frame type 101 (reserved):<br>
163                                         //!<        0: Reject<br>
164                                         //!<        1: Accept
165       uint8_t bAcceptFt6Reserved:1;     //!< \brief Treatment of frames with frame type 110 (reserved):<br>
166                                         //!<        0: Reject<br>
167                                         //!<        1: Accept
168       uint8_t bAcceptFt7Reserved:1;     //!< \brief Treatment of frames with frame type 111 (reserved):<br>
169                                         //!<        0: Reject<br>
170                                         //!<        1: Accept
171    } frameTypes;                        //!<        Frame types to receive in frame filtering
172    struct {
173       uint8_t ccaEnEnergy:1;            //!<        Enable energy scan as CCA source
174       uint8_t ccaEnCorr:1;              //!<        Enable correlator based carrier sense as CCA source
175       uint8_t ccaEnSync:1;              //!<        Enable sync found based carrier sense as CCA source
176       uint8_t ccaCorrOp:1;              //!< \brief Operator to use between energy based and correlator based CCA<br>
177                                         //!<        0: Report busy channel if either ccaEnergy or ccaCorr are busy<br>
178                                         //!<        1: Report busy channel if both ccaEnergy and ccaCorr are busy
179       uint8_t ccaSyncOp:1;              //!< \brief Operator to use between sync found based CCA and the others<br>
180                                         //!<        0: Always report busy channel if ccaSync is busy<br>
181                                         //!<        1: Always report idle channel if ccaSync is idle
182       uint8_t ccaCorrThr:2;             //!<        Threshold for number of correlation peaks in correlator based carrier sense
183    } ccaOpt;                            //!<        CCA options
184    int8_t ccaRssiThr;                   //!<        RSSI threshold for CCA
185    uint8_t __dummy0;
186    uint8_t numExtEntries;               //!<        Number of extended address entries
187    uint8_t numShortEntries;             //!<        Number of short address entries
188    uint32_t* pExtEntryList;             //!<        Pointer to list of extended address entries
189    uint32_t* pShortEntryList;           //!<        Pointer to list of short address entries
190    uint64_t localExtAddr;               //!<        The extended address of the local device
191    uint16_t localShortAddr;             //!<        The short address of the local device
192    uint16_t localPanID;                 //!<        The PAN ID of the local device
193    uint16_t __dummy1;
194    uint8_t __dummy2;
195    struct {
196       uint8_t triggerType:4;            //!<        The type of trigger
197       uint8_t bEnaCmd:1;                //!< \brief 0: No alternative trigger command<br>
198                                         //!<        1: CMD_TRIGGER can be used as an alternative trigger
199       uint8_t triggerNo:2;              //!<        The trigger number of the CMD_TRIGGER command that triggers this action
200       uint8_t pastTrig:1;               //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error<br>
201                                         //!<        1: A trigger in the past is triggered as soon as possible
202    } endTrigger;                        //!<        Trigger that causes the device to end the Rx operation
203    ratmr_t endTime;                     //!< \brief Time used together with <code>endTrigger</code> that causes the device to end the Rx
204                                         //!<        operation
205 } __RFC_STRUCT_ATTR;
206 
207 //! @}
208 
209 //! \addtogroup CMD_IEEE_ED_SCAN
210 //! @{
211 #define CMD_IEEE_ED_SCAN                                        0x2802
212 //! IEEE 802.15.4 Energy Detect Scan Command
213 struct __RFC_STRUCT rfc_CMD_IEEE_ED_SCAN_s {
214    uint16_t commandNo;                  //!<        The command ID number 0x2802
215    uint16_t status;                     //!< \brief An integer telling the status of the command. This value is
216                                         //!<        updated by the radio CPU during operation and may be read by the
217                                         //!<        system CPU at any time.
218    rfc_radioOp_t *pNextOp;              //!<        Pointer to the next operation to run after this operation is done
219    ratmr_t startTime;                   //!<        Absolute or relative start time (depending on the value of <code>startTrigger</code>)
220    struct {
221       uint8_t triggerType:4;            //!<        The type of trigger
222       uint8_t bEnaCmd:1;                //!< \brief 0: No alternative trigger command<br>
223                                         //!<        1: CMD_TRIGGER can be used as an alternative trigger
224       uint8_t triggerNo:2;              //!<        The trigger number of the CMD_TRIGGER command that triggers this action
225       uint8_t pastTrig:1;               //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error<br>
226                                         //!<        1: A trigger in the past is triggered as soon as possible
227    } startTrigger;                      //!<        Identification of the trigger that starts the operation
228    struct {
229       uint8_t rule:4;                   //!<        Condition for running next command: Rule for how to proceed
230       uint8_t nSkip:4;                  //!<        Number of skips + 1 if the rule involves skipping. 0: same, 1: next, 2: skip next, ...
231    } condition;
232    uint8_t channel;                     //!< \brief Channel to tune to in the start of the operation<br>
233                                         //!<        0: Use existing channel<br>
234                                         //!<        11--26: Use as IEEE 802.15.4 channel, i.e. frequency is (2405 + 5 &times; (channel - 11)) MHz<br>
235                                         //!<        60--207: Frequency is  (2300 + channel) MHz<br>
236                                         //!<        Others: <i>Reserved</i>
237    struct {
238       uint8_t ccaEnEnergy:1;            //!<        Enable energy scan as CCA source
239       uint8_t ccaEnCorr:1;              //!<        Enable correlator based carrier sense as CCA source
240       uint8_t ccaEnSync:1;              //!<        Enable sync found based carrier sense as CCA source
241       uint8_t ccaCorrOp:1;              //!< \brief Operator to use between energy based and correlator based CCA<br>
242                                         //!<        0: Report busy channel if either ccaEnergy or ccaCorr are busy<br>
243                                         //!<        1: Report busy channel if both ccaEnergy and ccaCorr are busy
244       uint8_t ccaSyncOp:1;              //!< \brief Operator to use between sync found based CCA and the others<br>
245                                         //!<        0: Always report busy channel if ccaSync is busy<br>
246                                         //!<        1: Always report idle channel if ccaSync is idle
247       uint8_t ccaCorrThr:2;             //!<        Threshold for number of correlation peaks in correlator based carrier sense
248    } ccaOpt;                            //!<        CCA options
249    int8_t ccaRssiThr;                   //!<        RSSI threshold for CCA
250    uint8_t __dummy0;
251    int8_t maxRssi;                      //!<        The maximum RSSI recorded during the ED scan
252    struct {
253       uint8_t triggerType:4;            //!<        The type of trigger
254       uint8_t bEnaCmd:1;                //!< \brief 0: No alternative trigger command<br>
255                                         //!<        1: CMD_TRIGGER can be used as an alternative trigger
256       uint8_t triggerNo:2;              //!<        The trigger number of the CMD_TRIGGER command that triggers this action
257       uint8_t pastTrig:1;               //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error<br>
258                                         //!<        1: A trigger in the past is triggered as soon as possible
259    } endTrigger;                        //!<        Trigger that causes the device to end the Rx operation
260    ratmr_t endTime;                     //!< \brief Time used together with <code>endTrigger</code> that causes the device to end the Rx
261                                         //!<        operation
262 } __RFC_STRUCT_ATTR;
263 
264 //! @}
265 
266 //! \addtogroup CMD_IEEE_TX
267 //! @{
268 #define CMD_IEEE_TX                                             0x2C01
269 //! IEEE 802.15.4 Transmit Command
270 struct __RFC_STRUCT rfc_CMD_IEEE_TX_s {
271    uint16_t commandNo;                  //!<        The command ID number 0x2C01
272    uint16_t status;                     //!< \brief An integer telling the status of the command. This value is
273                                         //!<        updated by the radio CPU during operation and may be read by the
274                                         //!<        system CPU at any time.
275    rfc_radioOp_t *pNextOp;              //!<        Pointer to the next operation to run after this operation is done
276    ratmr_t startTime;                   //!<        Absolute or relative start time (depending on the value of <code>startTrigger</code>)
277    struct {
278       uint8_t triggerType:4;            //!<        The type of trigger
279       uint8_t bEnaCmd:1;                //!< \brief 0: No alternative trigger command<br>
280                                         //!<        1: CMD_TRIGGER can be used as an alternative trigger
281       uint8_t triggerNo:2;              //!<        The trigger number of the CMD_TRIGGER command that triggers this action
282       uint8_t pastTrig:1;               //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error<br>
283                                         //!<        1: A trigger in the past is triggered as soon as possible
284    } startTrigger;                      //!<        Identification of the trigger that starts the operation
285    struct {
286       uint8_t rule:4;                   //!<        Condition for running next command: Rule for how to proceed
287       uint8_t nSkip:4;                  //!<        Number of skips + 1 if the rule involves skipping. 0: same, 1: next, 2: skip next, ...
288    } condition;
289    struct {
290       uint8_t bIncludePhyHdr:1;         //!< \brief 0: Find PHY header automatically<br>
291                                         //!<        1: Insert PHY header from the buffer
292       uint8_t bIncludeCrc:1;            //!< \brief 0: Append automatically calculated CRC<br>
293                                         //!<        1: Insert FCS (CRC) from the buffer
294       uint8_t :1;
295       uint8_t payloadLenMsb:5;          //!< \brief Most significant bits of payload length. Should only be non-zero to create long
296                                         //!<        non-standard packets for test purposes
297    } txOpt;
298    uint8_t payloadLen;                  //!<        Number of bytes in the payload
299    uint8_t* pPayload;                   //!<        Pointer to payload buffer of size <code>payloadLen</code>
300    ratmr_t timeStamp;                   //!<        Time stamp of transmitted frame
301 } __RFC_STRUCT_ATTR;
302 
303 //! @}
304 
305 //! \addtogroup CMD_IEEE_CSMA
306 //! @{
307 #define CMD_IEEE_CSMA                                           0x2C02
308 //! IEEE 802.15.4 CSMA-CA Command
309 struct __RFC_STRUCT rfc_CMD_IEEE_CSMA_s {
310    uint16_t commandNo;                  //!<        The command ID number 0x2C02
311    uint16_t status;                     //!< \brief An integer telling the status of the command. This value is
312                                         //!<        updated by the radio CPU during operation and may be read by the
313                                         //!<        system CPU at any time.
314    rfc_radioOp_t *pNextOp;              //!<        Pointer to the next operation to run after this operation is done
315    ratmr_t startTime;                   //!<        Absolute or relative start time (depending on the value of <code>startTrigger</code>)
316    struct {
317       uint8_t triggerType:4;            //!<        The type of trigger
318       uint8_t bEnaCmd:1;                //!< \brief 0: No alternative trigger command<br>
319                                         //!<        1: CMD_TRIGGER can be used as an alternative trigger
320       uint8_t triggerNo:2;              //!<        The trigger number of the CMD_TRIGGER command that triggers this action
321       uint8_t pastTrig:1;               //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error<br>
322                                         //!<        1: A trigger in the past is triggered as soon as possible
323    } startTrigger;                      //!<        Identification of the trigger that starts the operation
324    struct {
325       uint8_t rule:4;                   //!<        Condition for running next command: Rule for how to proceed
326       uint8_t nSkip:4;                  //!<        Number of skips + 1 if the rule involves skipping. 0: same, 1: next, 2: skip next, ...
327    } condition;
328    uint16_t randomState;                //!<        The state of the pseudo-random generator
329    uint8_t macMaxBE;                    //!<        The IEEE 802.15.4 MAC parameter <i>macMaxBE</i>
330    uint8_t macMaxCSMABackoffs;          //!<        The IEEE 802.15.4 MAC parameter <i>macMaxCSMABackoffs</i>
331    struct {
332       uint8_t initCW:5;                 //!<        The initialization value for the CW parameter
333       uint8_t bSlotted:1;               //!< \brief 0:  non-slotted CSMA<br>
334                                         //!<        1: slotted CSMA
335       uint8_t rxOffMode:2;              //!< \brief 0: RX stays on during CSMA backoffs<br>
336                                         //!<        1: The CSMA-CA algorithm will suspend the receiver if no frame is being received<br>
337                                         //!<        2: The CSMA-CA algorithm will suspend the receiver if no frame is being received,
338                                         //!<        or after finishing it (including auto ACK) otherwise<br>
339                                         //!<        3: The CSMA-CA algorithm will suspend the receiver immediately during back-offs
340    } csmaConfig;
341    uint8_t NB;                          //!<        The NB parameter from the IEEE 802.15.4 CSMA-CA algorithm
342    uint8_t BE;                          //!<        The BE parameter from the IEEE 802.15.4 CSMA-CA algorithm
343    uint8_t remainingPeriods;            //!<        The number of remaining periods from a paused backoff countdown
344    int8_t lastRssi;                     //!<        RSSI measured at the last CCA operation
345    struct {
346       uint8_t triggerType:4;            //!<        The type of trigger
347       uint8_t bEnaCmd:1;                //!< \brief 0: No alternative trigger command<br>
348                                         //!<        1: CMD_TRIGGER can be used as an alternative trigger
349       uint8_t triggerNo:2;              //!<        The trigger number of the CMD_TRIGGER command that triggers this action
350       uint8_t pastTrig:1;               //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error<br>
351                                         //!<        1: A trigger in the past is triggered as soon as possible
352    } endTrigger;                        //!<        Trigger that causes the device to end the CSMA-CA operation
353    ratmr_t lastTimeStamp;               //!<        Time of the last CCA operation
354    ratmr_t endTime;                     //!< \brief Time used together with <code>endTrigger</code> that causes the device to end the
355                                         //!<        CSMA-CA operation
356 } __RFC_STRUCT_ATTR;
357 
358 //! @}
359 
360 //! \addtogroup CMD_IEEE_RX_ACK
361 //! @{
362 #define CMD_IEEE_RX_ACK                                         0x2C03
363 //! IEEE 802.15.4 Receive Acknowledgement Command
364 struct __RFC_STRUCT rfc_CMD_IEEE_RX_ACK_s {
365    uint16_t commandNo;                  //!<        The command ID number 0x2C03
366    uint16_t status;                     //!< \brief An integer telling the status of the command. This value is
367                                         //!<        updated by the radio CPU during operation and may be read by the
368                                         //!<        system CPU at any time.
369    rfc_radioOp_t *pNextOp;              //!<        Pointer to the next operation to run after this operation is done
370    ratmr_t startTime;                   //!<        Absolute or relative start time (depending on the value of <code>startTrigger</code>)
371    struct {
372       uint8_t triggerType:4;            //!<        The type of trigger
373       uint8_t bEnaCmd:1;                //!< \brief 0: No alternative trigger command<br>
374                                         //!<        1: CMD_TRIGGER can be used as an alternative trigger
375       uint8_t triggerNo:2;              //!<        The trigger number of the CMD_TRIGGER command that triggers this action
376       uint8_t pastTrig:1;               //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error<br>
377                                         //!<        1: A trigger in the past is triggered as soon as possible
378    } startTrigger;                      //!<        Identification of the trigger that starts the operation
379    struct {
380       uint8_t rule:4;                   //!<        Condition for running next command: Rule for how to proceed
381       uint8_t nSkip:4;                  //!<        Number of skips + 1 if the rule involves skipping. 0: same, 1: next, 2: skip next, ...
382    } condition;
383    uint8_t seqNo;                       //!<        Sequence number to expect
384    struct {
385       uint8_t triggerType:4;            //!<        The type of trigger
386       uint8_t bEnaCmd:1;                //!< \brief 0: No alternative trigger command<br>
387                                         //!<        1: CMD_TRIGGER can be used as an alternative trigger
388       uint8_t triggerNo:2;              //!<        The trigger number of the CMD_TRIGGER command that triggers this action
389       uint8_t pastTrig:1;               //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error<br>
390                                         //!<        1: A trigger in the past is triggered as soon as possible
391    } endTrigger;                        //!<        Trigger that causes the device to give up acknowledgement reception
392    ratmr_t endTime;                     //!< \brief Time used together with <code>endTrigger</code> that causes the device to give up
393                                         //!<        acknowledgement reception
394 } __RFC_STRUCT_ATTR;
395 
396 //! @}
397 
398 //! \addtogroup CMD_IEEE_ABORT_BG
399 //! @{
400 #define CMD_IEEE_ABORT_BG                                       0x2C04
401 //! IEEE 802.15.4 Abort Background Level Command
402 struct __RFC_STRUCT rfc_CMD_IEEE_ABORT_BG_s {
403    uint16_t commandNo;                  //!<        The command ID number 0x2C04
404    uint16_t status;                     //!< \brief An integer telling the status of the command. This value is
405                                         //!<        updated by the radio CPU during operation and may be read by the
406                                         //!<        system CPU at any time.
407    rfc_radioOp_t *pNextOp;              //!<        Pointer to the next operation to run after this operation is done
408    ratmr_t startTime;                   //!<        Absolute or relative start time (depending on the value of <code>startTrigger</code>)
409    struct {
410       uint8_t triggerType:4;            //!<        The type of trigger
411       uint8_t bEnaCmd:1;                //!< \brief 0: No alternative trigger command<br>
412                                         //!<        1: CMD_TRIGGER can be used as an alternative trigger
413       uint8_t triggerNo:2;              //!<        The trigger number of the CMD_TRIGGER command that triggers this action
414       uint8_t pastTrig:1;               //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error<br>
415                                         //!<        1: A trigger in the past is triggered as soon as possible
416    } startTrigger;                      //!<        Identification of the trigger that starts the operation
417    struct {
418       uint8_t rule:4;                   //!<        Condition for running next command: Rule for how to proceed
419       uint8_t nSkip:4;                  //!<        Number of skips + 1 if the rule involves skipping. 0: same, 1: next, 2: skip next, ...
420    } condition;
421 } __RFC_STRUCT_ATTR;
422 
423 //! @}
424 
425 //! \addtogroup CMD_IEEE_MOD_CCA
426 //! @{
427 #define CMD_IEEE_MOD_CCA                                        0x2001
428 //! IEEE 802.15.4 Modify CCA Parameter Command
429 struct __RFC_STRUCT rfc_CMD_IEEE_MOD_CCA_s {
430    uint16_t commandNo;                  //!<        The command ID number 0x2001
431    struct {
432       uint8_t ccaEnEnergy:1;            //!<        Enable energy scan as CCA source
433       uint8_t ccaEnCorr:1;              //!<        Enable correlator based carrier sense as CCA source
434       uint8_t ccaEnSync:1;              //!<        Enable sync found based carrier sense as CCA source
435       uint8_t ccaCorrOp:1;              //!< \brief Operator to use between energy based and correlator based CCA<br>
436                                         //!<        0: Report busy channel if either ccaEnergy or ccaCorr are busy<br>
437                                         //!<        1: Report busy channel if both ccaEnergy and ccaCorr are busy
438       uint8_t ccaSyncOp:1;              //!< \brief Operator to use between sync found based CCA and the others<br>
439                                         //!<        0: Always report busy channel if ccaSync is busy<br>
440                                         //!<        1: Always report idle channel if ccaSync is idle
441       uint8_t ccaCorrThr:2;             //!<        Threshold for number of correlation peaks in correlator based carrier sense
442    } newCcaOpt;                         //!<        New value of <code>ccaOpt</code> for the running background level operation
443    int8_t newCcaRssiThr;                //!<        New value of <code>ccaRssiThr</code> for the running background level operation
444 } __RFC_STRUCT_ATTR;
445 
446 //! @}
447 
448 //! \addtogroup CMD_IEEE_MOD_FILT
449 //! @{
450 #define CMD_IEEE_MOD_FILT                                       0x2002
451 //! IEEE 802.15.4 Modify Frame Filtering Parameter Command
452 struct __RFC_STRUCT rfc_CMD_IEEE_MOD_FILT_s {
453    uint16_t commandNo;                  //!<        The command ID number 0x2002
454    struct {
455       uint16_t frameFiltEn:1;           //!< \brief 0: Disable frame filtering<br>
456                                         //!<        1: Enable frame filtering
457       uint16_t frameFiltStop:1;         //!< \brief 0: Receive all packets to the end<br>
458                                         //!<        1: Stop receiving frame once frame filtering has caused the frame to be rejected.
459       uint16_t autoAckEn:1;             //!< \brief 0: Disable auto ACK<br>
460                                         //!<        1: Enable auto ACK.
461       uint16_t slottedAckEn:1;          //!< \brief 0: Non-slotted ACK<br>
462                                         //!<        1: Slotted ACK.
463       uint16_t autoPendEn:1;            //!< \brief 0: Auto-pend disabled<br>
464                                         //!<        1: Auto-pend enabled
465       uint16_t defaultPend:1;           //!<        The value of the pending data bit in auto ACK packets that are not subject to auto-pend
466       uint16_t bPendDataReqOnly:1;      //!< \brief 0: Use auto-pend for any packet<br>
467                                         //!<        1: Use auto-pend for data request packets only
468       uint16_t bPanCoord:1;             //!< \brief 0: Device is not PAN coordinator<br>
469                                         //!<        1: Device is PAN coordinator
470       uint16_t maxFrameVersion:2;       //!<        Reject frames where the frame version field in the FCF is greater than this value
471       uint16_t fcfReservedMask:3;       //!<        Value to be AND-ed with the reserved part of the FCF; frame rejected if result is non-zero
472       uint16_t modifyFtFilter:2;        //!< \brief Treatment of MSB of frame type field before frame-type filtering:<br>
473                                         //!<        0: No modification<br>
474                                         //!<        1: Invert MSB<br>
475                                         //!<        2: Set MSB to 0<br>
476                                         //!<        3: Set MSB to 1
477       uint16_t bStrictLenFilter:1;      //!< \brief 0: Accept acknowledgement frames of any length >= 5<br>
478                                         //!<        1: Accept only acknowledgement frames of length 5
479    } newFrameFiltOpt;                   //!<        New value of <code>frameFiltOpt</code> for the running background level operation
480    struct {
481       uint8_t bAcceptFt0Beacon:1;       //!< \brief Treatment of frames with frame type 000 (beacon):<br>
482                                         //!<        0: Reject<br>
483                                         //!<        1: Accept
484       uint8_t bAcceptFt1Data:1;         //!< \brief Treatment of frames with frame type 001 (data):<br>
485                                         //!<        0: Reject<br>
486                                         //!<        1: Accept
487       uint8_t bAcceptFt2Ack:1;          //!< \brief Treatment of frames with frame type 010 (ACK):<br>
488                                         //!<        0: Reject, unless running ACK receive command<br>
489                                         //!<        1: Always accept
490       uint8_t bAcceptFt3MacCmd:1;       //!< \brief Treatment of frames with frame type 011 (MAC command):<br>
491                                         //!<        0: Reject<br>
492                                         //!<        1: Accept
493       uint8_t bAcceptFt4Reserved:1;     //!< \brief Treatment of frames with frame type 100 (reserved):<br>
494                                         //!<        0: Reject<br>
495                                         //!<        1: Accept
496       uint8_t bAcceptFt5Reserved:1;     //!< \brief Treatment of frames with frame type 101 (reserved):<br>
497                                         //!<        0: Reject<br>
498                                         //!<        1: Accept
499       uint8_t bAcceptFt6Reserved:1;     //!< \brief Treatment of frames with frame type 110 (reserved):<br>
500                                         //!<        0: Reject<br>
501                                         //!<        1: Accept
502       uint8_t bAcceptFt7Reserved:1;     //!< \brief Treatment of frames with frame type 111 (reserved):<br>
503                                         //!<        0: Reject<br>
504                                         //!<        1: Accept
505    } newFrameTypes;                     //!<        New value of <code>frameTypes</code> for the running background level operation
506 } __RFC_STRUCT_ATTR;
507 
508 //! @}
509 
510 //! \addtogroup CMD_IEEE_MOD_SRC_MATCH
511 //! @{
512 #define CMD_IEEE_MOD_SRC_MATCH                                  0x2003
513 //! IEEE 802.15.4 Enable/Disable Source Matching Entry Command
514 struct __RFC_STRUCT rfc_CMD_IEEE_MOD_SRC_MATCH_s {
515    uint16_t commandNo;                  //!<        The command ID number 0x2003
516    struct {
517       uint8_t bEnable:1;                //!< \brief 0: Disable entry<br>
518                                         //!<        1: Enable entry
519       uint8_t srcPend:1;                //!<        New value of the pending bit for the entry
520       uint8_t entryType:1;              //!< \brief 0: Short address<br>
521                                         //!<        1: Extended address
522    } options;
523    uint8_t entryNo;                     //!<        Index of entry to enable or disable
524 } __RFC_STRUCT_ATTR;
525 
526 //! @}
527 
528 //! \addtogroup CMD_IEEE_ABORT_FG
529 //! @{
530 #define CMD_IEEE_ABORT_FG                                       0x2401
531 //! IEEE 802.15.4 Abort Foreground Level Command
532 struct __RFC_STRUCT rfc_CMD_IEEE_ABORT_FG_s {
533    uint16_t commandNo;                  //!<        The command ID number 0x2401
534 } __RFC_STRUCT_ATTR;
535 
536 //! @}
537 
538 //! \addtogroup CMD_IEEE_STOP_FG
539 //! @{
540 #define CMD_IEEE_STOP_FG                                        0x2402
541 //! IEEE 802.15.4 Gracefully Stop Foreground Level Command
542 struct __RFC_STRUCT rfc_CMD_IEEE_STOP_FG_s {
543    uint16_t commandNo;                  //!<        The command ID number 0x2402
544 } __RFC_STRUCT_ATTR;
545 
546 //! @}
547 
548 //! \addtogroup CMD_IEEE_CCA_REQ
549 //! @{
550 #define CMD_IEEE_CCA_REQ                                        0x2403
551 //! IEEE 802.15.4 CCA and RSSI Information Request Command
552 struct __RFC_STRUCT rfc_CMD_IEEE_CCA_REQ_s {
553    uint16_t commandNo;                  //!<        The command ID number 0x2403
554    int8_t currentRssi;                  //!<        The RSSI currently observed on the channel
555    int8_t maxRssi;                      //!<        The maximum RSSI observed on the channel since Rx was started
556    struct {
557       uint8_t ccaState:2;               //!< \brief Value of the current CCA state<br>
558                                         //!<        0: Idle<br>
559                                         //!<        1: Busy<br>
560                                         //!<        2: Invalid
561       uint8_t ccaEnergy:2;              //!< \brief Value of the current energy detect CCA state<br>
562                                         //!<        0: Idle<br>
563                                         //!<        1: Busy<br>
564                                         //!<        2: Invalid
565       uint8_t ccaCorr:2;                //!< \brief Value of the current correlator based carrier sense CCA state<br>
566                                         //!<        0: Idle<br>
567                                         //!<        1: Busy<br>
568                                         //!<        2: Invalid
569       uint8_t ccaSync:1;                //!< \brief Value of the current sync found based carrier sense CCA state<br>
570                                         //!<        0: Idle<br>
571                                         //!<        1: Busy
572    } ccaInfo;
573 } __RFC_STRUCT_ATTR;
574 
575 //! @}
576 
577 //! \addtogroup ieeeRxOutput
578 //! @{
579 //! Output structure for CMD_IEEE_RX
580 
581 struct __RFC_STRUCT rfc_ieeeRxOutput_s {
582    uint8_t nTxAck;                      //!<        Total number of transmitted ACK frames
583    uint8_t nRxBeacon;                   //!<        Number of received beacon frames
584    uint8_t nRxData;                     //!<        Number of received data frames
585    uint8_t nRxAck;                      //!<        Number of received acknowledgement frames
586    uint8_t nRxMacCmd;                   //!<        Number of received MAC command frames
587    uint8_t nRxReserved;                 //!<        Number of received frames with reserved frame type
588    uint8_t nRxNok;                      //!<        Number of received frames with CRC error
589    uint8_t nRxIgnored;                  //!<        Number of frames received that are to be ignored
590    uint8_t nRxBufFull;                  //!<        Number of received frames discarded because the Rx buffer was full
591    int8_t lastRssi;                     //!<        RSSI of last received frame
592    int8_t maxRssi;                      //!<        Highest RSSI observed in the operation
593    uint8_t __dummy0;
594    ratmr_t beaconTimeStamp;             //!<        Time stamp of last received beacon frame
595 } __RFC_STRUCT_ATTR;
596 
597 //! @}
598 
599 //! \addtogroup shortAddrEntry
600 //! @{
601 //! Structure for short address entries
602 
603 struct __RFC_STRUCT rfc_shortAddrEntry_s {
604    uint16_t shortAddr;                  //!<        Short address
605    uint16_t panId;                      //!<        PAN ID
606 } __RFC_STRUCT_ATTR;
607 
608 //! @}
609 
610 //! \addtogroup ieeeRxCorrCrc
611 //! @{
612 //! Receive status byte that may be appended to message in receive buffer
613 
614 struct __RFC_STRUCT rfc_ieeeRxCorrCrc_s {
615    struct {
616       uint8_t corr:6;                   //!<        The correlation value
617       uint8_t bIgnore:1;                //!<        1 if the packet should be rejected by frame filtering, 0 otherwise
618       uint8_t bCrcErr:1;                //!<        1 if the packet was received with CRC error, 0 otherwise
619    } status;
620 } __RFC_STRUCT_ATTR;
621 
622 //! @}
623 
624 //! @}
625 //! @}
626 #endif
627