1 /******************************************************************************
2 *  Filename:       rf_hs_cmd.h
3 *
4 *  Description:    CC13x2/CC26x2 API for high-speed mode 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 __HS_CMD_H
38 #define __HS_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 hs_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_HS_TX_s rfc_CMD_HS_TX_t;
65 typedef struct __RFC_STRUCT rfc_CMD_HS_RX_s rfc_CMD_HS_RX_t;
66 typedef struct __RFC_STRUCT rfc_hsRxOutput_s rfc_hsRxOutput_t;
67 typedef struct __RFC_STRUCT rfc_hsRxStatus_s rfc_hsRxStatus_t;
68 
69 //! \addtogroup CMD_HS_TX
70 //! @{
71 #define CMD_HS_TX                                               0x3841
72 //! High-Speed Transmit Command
73 struct __RFC_STRUCT rfc_CMD_HS_TX_s {
74    uint16_t commandNo;                  //!<        The command ID number 0x3841
75    uint16_t status;                     //!< \brief An integer telling the status of the command. This value is
76                                         //!<        updated by the radio CPU during operation and may be read by the
77                                         //!<        system CPU at any time.
78    rfc_radioOp_t *pNextOp;              //!<        Pointer to the next operation to run after this operation is done
79    ratmr_t startTime;                   //!<        Absolute or relative start time (depending on the value of <code>startTrigger</code>)
80    struct {
81       uint8_t triggerType:4;            //!<        The type of trigger
82       uint8_t bEnaCmd:1;                //!< \brief 0: No alternative trigger command<br>
83                                         //!<        1: CMD_TRIGGER can be used as an alternative trigger
84       uint8_t triggerNo:2;              //!<        The trigger number of the CMD_TRIGGER command that triggers this action
85       uint8_t pastTrig:1;               //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error<br>
86                                         //!<        1: A trigger in the past is triggered as soon as possible
87    } startTrigger;                      //!<        Identification of the trigger that starts the operation
88    struct {
89       uint8_t rule:4;                   //!<        Condition for running next command: Rule for how to proceed
90       uint8_t nSkip:4;                  //!<        Number of skips + 1 if the rule involves skipping. 0: same, 1: next, 2: skip next, ...
91    } condition;
92    struct {
93       uint8_t bFsOff:1;                 //!< \brief 0: Keep frequency synth on after command<br>
94                                         //!<        1: Turn frequency synth off after command
95       uint8_t bUseCrc:1;                //!< \brief 0: Do not append CRC<br>
96                                         //!<        1: Append CRC
97       uint8_t bVarLen:1;                //!< \brief 0: Fixed length<br>
98                                         //!<        1: Transmit length as first half-word
99       uint8_t bCheckQAtEnd:1;           //!< \brief 0: Always end with HS_DONE_OK when packet has been transmitted<br>
100                                         //!<        1: Check if Tx queue is empty when packet has been transmitted
101    } pktConf;
102    uint8_t __dummy0;
103    dataQueue_t* pQueue;                 //!<        Pointer to Tx queue
104 } __RFC_STRUCT_ATTR;
105 
106 //! @}
107 
108 //! \addtogroup CMD_HS_RX
109 //! @{
110 #define CMD_HS_RX                                               0x3842
111 //! High-Speed Receive Command
112 struct __RFC_STRUCT rfc_CMD_HS_RX_s {
113    uint16_t commandNo;                  //!<        The command ID number 0x3842
114    uint16_t status;                     //!< \brief An integer telling the status of the command. This value is
115                                         //!<        updated by the radio CPU during operation and may be read by the
116                                         //!<        system CPU at any time.
117    rfc_radioOp_t *pNextOp;              //!<        Pointer to the next operation to run after this operation is done
118    ratmr_t startTime;                   //!<        Absolute or relative start time (depending on the value of <code>startTrigger</code>)
119    struct {
120       uint8_t triggerType:4;            //!<        The type of trigger
121       uint8_t bEnaCmd:1;                //!< \brief 0: No alternative trigger command<br>
122                                         //!<        1: CMD_TRIGGER can be used as an alternative trigger
123       uint8_t triggerNo:2;              //!<        The trigger number of the CMD_TRIGGER command that triggers this action
124       uint8_t pastTrig:1;               //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error<br>
125                                         //!<        1: A trigger in the past is triggered as soon as possible
126    } startTrigger;                      //!<        Identification of the trigger that starts the operation
127    struct {
128       uint8_t rule:4;                   //!<        Condition for running next command: Rule for how to proceed
129       uint8_t nSkip:4;                  //!<        Number of skips + 1 if the rule involves skipping. 0: same, 1: next, 2: skip next, ...
130    } condition;
131    struct {
132       uint8_t bFsOff:1;                 //!< \brief 0: Keep frequency synth on after command<br>
133                                         //!<        1: Turn frequency synth off after command
134       uint8_t bUseCrc:1;                //!< \brief 0: Do not receive or check CRC<br>
135                                         //!<        1: Receive and check CRC
136       uint8_t bVarLen:1;                //!< \brief 0: Fixed length<br>
137                                         //!<        1: Receive length as first byte
138       uint8_t bRepeatOk:1;              //!< \brief 0: End operation after receiving a packet correctly<br>
139                                         //!<        1: Go back to sync search after receiving a packet correctly
140       uint8_t bRepeatNok:1;             //!< \brief 0: End operation after receiving a packet with CRC error<br>
141                                         //!<        1: Go back to sync search after receiving a packet with CRC error
142       uint8_t addressMode:2;            //!< \brief 0: No address check<br>
143                                         //!<        1: Accept <code>address0</code> and <code>address1</code><br>
144                                         //!<        2: Accept <code>address0</code>, <code>address1</code>, and 0x0000<br>
145                                         //!<        3: Accept <code>address0</code>, <code>address1</code>, 0x0000, and 0xFFFF
146    } pktConf;
147    struct {
148       uint8_t bAutoFlushCrcErr:1;       //!<        If 1, automatically remove packets with CRC error from Rx queue
149       uint8_t bIncludeLen:1;            //!<        If 1, include the received length field in the stored packet; otherwise discard it
150       uint8_t bIncludeCrc:1;            //!<        If 1, include the received CRC field in the stored packet; otherwise 3scard it
151       uint8_t bAppendStatus:1;          //!<        If 1, append a status word to the packet in the Rx queue
152       uint8_t bAppendTimestamp:1;       //!<        If 1, append a timestamp to the packet in the Rx queue
153    } rxConf;
154    uint16_t maxPktLen;                  //!<        Packet length for fixed length; maximum packet length for variable length
155    uint16_t address0;                   //!<        Address
156    uint16_t address1;                   //!<        Address (set equal to <code>address0</code> to accept only one address)
157    uint8_t __dummy0;
158    struct {
159       uint8_t triggerType:4;            //!<        The type of trigger
160       uint8_t bEnaCmd:1;                //!< \brief 0: No alternative trigger command<br>
161                                         //!<        1: CMD_TRIGGER can be used as an alternative trigger
162       uint8_t triggerNo:2;              //!<        The trigger number of the CMD_TRIGGER command that triggers this action
163       uint8_t pastTrig:1;               //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error<br>
164                                         //!<        1: A trigger in the past is triggered as soon as possible
165    } endTrigger;                        //!<        Trigger classifier for ending the operation
166    ratmr_t endTime;                     //!<        Time used together with <code>endTrigger</code> for ending the operation
167    dataQueue_t* pQueue;                 //!<        Pointer to receive queue
168    rfc_hsRxOutput_t *pOutput;           //!<        Pointer to output structure
169 } __RFC_STRUCT_ATTR;
170 
171 //! @}
172 
173 //! \addtogroup hsRxOutput
174 //! @{
175 //! Output structure for CMD_HS_RX
176 
177 struct __RFC_STRUCT rfc_hsRxOutput_s {
178    uint16_t nRxOk;                      //!<        Number of packets that have been received with CRC OK
179    uint16_t nRxNok;                     //!<        Number of packets that have been received with CRC error
180    uint16_t nRxAborted;                 //!<        Number of packets not received due to illegal length or address mismatch
181    uint8_t nRxBufFull;                  //!<        Number of packets that have been received and discarded due to lack of buffer space
182    int8_t lastRssi;                     //!<        RSSI of last received packet
183    ratmr_t timeStamp;                   //!<        Time stamp of last received packet
184 } __RFC_STRUCT_ATTR;
185 
186 //! @}
187 
188 //! \addtogroup hsRxStatus
189 //! @{
190 //! Receive status word that may be appended to message in receive buffer
191 
192 struct __RFC_STRUCT rfc_hsRxStatus_s {
193    struct {
194       uint16_t rssi:8;                  //!<        RSSI of the received packet in dBm (signed)
195       uint16_t bCrcErr:1;               //!< \brief 0: Packet received OK<br>
196                                         //!<        1: Packet received with CRC error
197       uint16_t addressInd:2;            //!< \brief 0: Received <code>address0</code> (or no address check)<br>
198                                         //!<        1: Received <code>address1</code><br>
199                                         //!<        2: Received address 0x0000<br>
200                                         //!<        3: Received address 0xFFFF
201    } status;
202 } __RFC_STRUCT_ATTR;
203 
204 //! @}
205 
206 //! @}
207 //! @}
208 #endif
209