1 /****************************************************************************** 2 * Filename: rf_data_entry.h 3 * 4 * Description: Definition of API for data exchange 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 __DATA_ENTRY_H 38 #define __DATA_ENTRY_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 data_entry 58 //! @{ 59 60 #include <stdint.h> 61 #include "rf_mailbox.h" 62 63 typedef struct __RFC_STRUCT rfc_dataEntry_s rfc_dataEntry_t; 64 typedef struct __RFC_STRUCT rfc_dataEntryGeneral_s rfc_dataEntryGeneral_t; 65 typedef struct __RFC_STRUCT rfc_dataEntryMulti_s rfc_dataEntryMulti_t; 66 typedef struct __RFC_STRUCT rfc_dataEntryPointer_s rfc_dataEntryPointer_t; 67 typedef struct __RFC_STRUCT rfc_dataEntryPartial_s rfc_dataEntryPartial_t; 68 69 //! \addtogroup dataEntry 70 //! @{ 71 struct __RFC_STRUCT rfc_dataEntry_s { 72 uint8_t* pNextEntry; //!< Pointer to next entry in the queue, NULL if this is the last entry 73 uint8_t status; //!< Indicates status of entry, including whether it is free for the system CPU to write to 74 struct { 75 uint8_t type:2; //!< \brief Type of data entry structure<br> 76 //!< 0: General data entry <br> 77 //!< 1: Multi-element Rx entry<br> 78 //!< 2: Pointer entry<br> 79 //!< 3: Partial read Rx entry 80 uint8_t lenSz:2; //!< \brief Size of length word in start of each Rx entry element<br> 81 //!< 0: No length indicator<br> 82 //!< 1: One byte length indicator<br> 83 //!< 2: Two bytes length indicator<br> 84 //!< 3: <i>Reserved</i> 85 uint8_t irqIntv:4; //!< \brief For partial read Rx entry only: The number of bytes between interrupt generated 86 //!< by the radio CPU (0: 16 bytes) 87 } config; 88 uint16_t length; //!< \brief For pointer entries: Number of bytes in the data buffer pointed to<br> 89 //!< For other entries: Number of bytes following this length field 90 } __RFC_STRUCT_ATTR; 91 92 //! @} 93 94 //! \addtogroup dataEntryGeneral 95 //! @{ 96 //! General data entry structure (type = 0) 97 98 struct __RFC_STRUCT rfc_dataEntryGeneral_s { 99 uint8_t* pNextEntry; //!< Pointer to next entry in the queue, NULL if this is the last entry 100 uint8_t status; //!< Indicates status of entry, including whether it is free for the system CPU to write to 101 struct { 102 uint8_t type:2; //!< \brief Type of data entry structure<br> 103 //!< 0: General data entry <br> 104 //!< 1: Multi-element Rx entry<br> 105 //!< 2: Pointer entry<br> 106 //!< 3: Partial read Rx entry 107 uint8_t lenSz:2; //!< \brief Size of length word in start of each Rx entry element<br> 108 //!< 0: No length indicator<br> 109 //!< 1: One byte length indicator<br> 110 //!< 2: Two bytes length indicator<br> 111 //!< 3: <i>Reserved</i> 112 uint8_t irqIntv:4; //!< \brief For partial read Rx entry only: The number of bytes between interrupt generated 113 //!< by the radio CPU (0: 16 bytes) 114 } config; 115 uint16_t length; //!< \brief For pointer entries: Number of bytes in the data buffer pointed to<br> 116 //!< For other entries: Number of bytes following this length field 117 uint8_t data; //!< First byte of the data array to be received or transmitted 118 } __RFC_STRUCT_ATTR; 119 120 //! @} 121 122 //! \addtogroup dataEntryMulti 123 //! @{ 124 //! Multi-element data entry structure (type = 1) 125 126 struct __RFC_STRUCT rfc_dataEntryMulti_s { 127 uint8_t* pNextEntry; //!< Pointer to next entry in the queue, NULL if this is the last entry 128 uint8_t status; //!< Indicates status of entry, including whether it is free for the system CPU to write to 129 struct { 130 uint8_t type:2; //!< \brief Type of data entry structure<br> 131 //!< 0: General data entry <br> 132 //!< 1: Multi-element Rx entry<br> 133 //!< 2: Pointer entry<br> 134 //!< 3: Partial read Rx entry 135 uint8_t lenSz:2; //!< \brief Size of length word in start of each Rx entry element<br> 136 //!< 0: No length indicator<br> 137 //!< 1: One byte length indicator<br> 138 //!< 2: Two bytes length indicator<br> 139 //!< 3: <i>Reserved</i> 140 uint8_t irqIntv:4; //!< \brief For partial read Rx entry only: The number of bytes between interrupt generated 141 //!< by the radio CPU (0: 16 bytes) 142 } config; 143 uint16_t length; //!< \brief For pointer entries: Number of bytes in the data buffer pointed to<br> 144 //!< For other entries: Number of bytes following this length field 145 uint16_t numElements; //!< Number of entry elements committed in the entry 146 uint16_t nextIndex; //!< Index to the byte after the last byte of the last entry element committed by the radio CPU 147 uint8_t rxData; //!< First byte of the data array of received data entry elements 148 } __RFC_STRUCT_ATTR; 149 150 //! @} 151 152 //! \addtogroup dataEntryPointer 153 //! @{ 154 //! Pointer data entry structure (type = 2) 155 156 struct __RFC_STRUCT rfc_dataEntryPointer_s { 157 uint8_t* pNextEntry; //!< Pointer to next entry in the queue, NULL if this is the last entry 158 uint8_t status; //!< Indicates status of entry, including whether it is free for the system CPU to write to 159 struct { 160 uint8_t type:2; //!< \brief Type of data entry structure<br> 161 //!< 0: General data entry <br> 162 //!< 1: Multi-element Rx entry<br> 163 //!< 2: Pointer entry<br> 164 //!< 3: Partial read Rx entry 165 uint8_t lenSz:2; //!< \brief Size of length word in start of each Rx entry element<br> 166 //!< 0: No length indicator<br> 167 //!< 1: One byte length indicator<br> 168 //!< 2: Two bytes length indicator<br> 169 //!< 3: <i>Reserved</i> 170 uint8_t irqIntv:4; //!< \brief For partial read Rx entry only: The number of bytes between interrupt generated 171 //!< by the radio CPU (0: 16 bytes) 172 } config; 173 uint16_t length; //!< \brief For pointer entries: Number of bytes in the data buffer pointed to<br> 174 //!< For other entries: Number of bytes following this length field 175 uint8_t* pData; //!< Pointer to data buffer of data to be received ro transmitted 176 } __RFC_STRUCT_ATTR; 177 178 //! @} 179 180 //! \addtogroup dataEntryPartial 181 //! @{ 182 //! Partial read data entry structure (type = 3) 183 184 struct __RFC_STRUCT rfc_dataEntryPartial_s { 185 uint8_t* pNextEntry; //!< Pointer to next entry in the queue, NULL if this is the last entry 186 uint8_t status; //!< Indicates status of entry, including whether it is free for the system CPU to write to 187 struct { 188 uint8_t type:2; //!< \brief Type of data entry structure<br> 189 //!< 0: General data entry <br> 190 //!< 1: Multi-element Rx entry<br> 191 //!< 2: Pointer entry<br> 192 //!< 3: Partial read Rx entry 193 uint8_t lenSz:2; //!< \brief Size of length word in start of each Rx entry element<br> 194 //!< 0: No length indicator<br> 195 //!< 1: One byte length indicator<br> 196 //!< 2: Two bytes length indicator<br> 197 //!< 3: <i>Reserved</i> 198 uint8_t irqIntv:4; //!< \brief For partial read Rx entry only: The number of bytes between interrupt generated 199 //!< by the radio CPU (0: 16 bytes) 200 } config; 201 uint16_t length; //!< \brief For pointer entries: Number of bytes in the data buffer pointed to<br> 202 //!< For other entries: Number of bytes following this length field 203 struct { 204 uint16_t numElements:13; //!< Number of entry elements committed in the entry 205 uint16_t bEntryOpen:1; //!< 1 if the entry contains an element that is still open for appending data 206 uint16_t bFirstCont:1; //!< 1 if the first element is a continuation of the last packet from the previous entry 207 uint16_t bLastCont:1; //!< 1 if the packet in the last element continues in the next entry 208 } pktStatus; 209 uint16_t nextIndex; //!< Index to the byte after the last byte of the last entry element committed by the radio CPU 210 uint8_t rxData; //!< First byte of the data array of received data entry elements 211 } __RFC_STRUCT_ATTR; 212 213 //! @} 214 215 //! @} 216 //! @} 217 #endif 218