Fork of my MQTTGateway

Dependencies:   mbed-http

Committer:
vpcola
Date:
Sat Apr 08 14:45:51 2017 +0000
Revision:
0:f1d3878b8dd9
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vpcola 0:f1d3878b8dd9 1 /**
vpcola 0:f1d3878b8dd9 2 ******************************************************************************
vpcola 0:f1d3878b8dd9 3 * @file SPIRIT_PktBasic.c
vpcola 0:f1d3878b8dd9 4 * @author VMA division - AMS
vpcola 0:f1d3878b8dd9 5 * @version 3.2.2
vpcola 0:f1d3878b8dd9 6 * @date 08-July-2015
vpcola 0:f1d3878b8dd9 7 * @brief Configuration and management of SPIRIT Basic packets.
vpcola 0:f1d3878b8dd9 8 * @details
vpcola 0:f1d3878b8dd9 9 *
vpcola 0:f1d3878b8dd9 10 * @attention
vpcola 0:f1d3878b8dd9 11 *
vpcola 0:f1d3878b8dd9 12 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
vpcola 0:f1d3878b8dd9 13 *
vpcola 0:f1d3878b8dd9 14 * Redistribution and use in source and binary forms, with or without modification,
vpcola 0:f1d3878b8dd9 15 * are permitted provided that the following conditions are met:
vpcola 0:f1d3878b8dd9 16 * 1. Redistributions of source code must retain the above copyright notice,
vpcola 0:f1d3878b8dd9 17 * this list of conditions and the following disclaimer.
vpcola 0:f1d3878b8dd9 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
vpcola 0:f1d3878b8dd9 19 * this list of conditions and the following disclaimer in the documentation
vpcola 0:f1d3878b8dd9 20 * and/or other materials provided with the distribution.
vpcola 0:f1d3878b8dd9 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
vpcola 0:f1d3878b8dd9 22 * may be used to endorse or promote products derived from this software
vpcola 0:f1d3878b8dd9 23 * without specific prior written permission.
vpcola 0:f1d3878b8dd9 24 *
vpcola 0:f1d3878b8dd9 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
vpcola 0:f1d3878b8dd9 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
vpcola 0:f1d3878b8dd9 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
vpcola 0:f1d3878b8dd9 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
vpcola 0:f1d3878b8dd9 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
vpcola 0:f1d3878b8dd9 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
vpcola 0:f1d3878b8dd9 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
vpcola 0:f1d3878b8dd9 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
vpcola 0:f1d3878b8dd9 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
vpcola 0:f1d3878b8dd9 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
vpcola 0:f1d3878b8dd9 35 *
vpcola 0:f1d3878b8dd9 36 ******************************************************************************
vpcola 0:f1d3878b8dd9 37 */
vpcola 0:f1d3878b8dd9 38
vpcola 0:f1d3878b8dd9 39 /* Includes ------------------------------------------------------------------*/
vpcola 0:f1d3878b8dd9 40 #include "SPIRIT_PktBasic.h"
vpcola 0:f1d3878b8dd9 41 #include "MCU_Interface.h"
vpcola 0:f1d3878b8dd9 42
vpcola 0:f1d3878b8dd9 43
vpcola 0:f1d3878b8dd9 44 /**
vpcola 0:f1d3878b8dd9 45 * @addtogroup SPIRIT_Libraries
vpcola 0:f1d3878b8dd9 46 * @{
vpcola 0:f1d3878b8dd9 47 */
vpcola 0:f1d3878b8dd9 48
vpcola 0:f1d3878b8dd9 49
vpcola 0:f1d3878b8dd9 50 /**
vpcola 0:f1d3878b8dd9 51 * @addtogroup SPIRIT_PktBasic
vpcola 0:f1d3878b8dd9 52 * @{
vpcola 0:f1d3878b8dd9 53 */
vpcola 0:f1d3878b8dd9 54
vpcola 0:f1d3878b8dd9 55
vpcola 0:f1d3878b8dd9 56 /**
vpcola 0:f1d3878b8dd9 57 * @defgroup PktBasic_Private_TypesDefinitions Pkt Basic Private Types Definitions
vpcola 0:f1d3878b8dd9 58 * @{
vpcola 0:f1d3878b8dd9 59 */
vpcola 0:f1d3878b8dd9 60
vpcola 0:f1d3878b8dd9 61 /**
vpcola 0:f1d3878b8dd9 62 *@}
vpcola 0:f1d3878b8dd9 63 */
vpcola 0:f1d3878b8dd9 64
vpcola 0:f1d3878b8dd9 65
vpcola 0:f1d3878b8dd9 66 /**
vpcola 0:f1d3878b8dd9 67 * @defgroup PktBasic_Private_Defines Pkt Basic Private Defines
vpcola 0:f1d3878b8dd9 68 * @{
vpcola 0:f1d3878b8dd9 69 */
vpcola 0:f1d3878b8dd9 70
vpcola 0:f1d3878b8dd9 71 /**
vpcola 0:f1d3878b8dd9 72 *@}
vpcola 0:f1d3878b8dd9 73 */
vpcola 0:f1d3878b8dd9 74
vpcola 0:f1d3878b8dd9 75
vpcola 0:f1d3878b8dd9 76 /**
vpcola 0:f1d3878b8dd9 77 * @defgroup PktBasic_Private_Macros Pkt Basic Private Macros
vpcola 0:f1d3878b8dd9 78 * @{
vpcola 0:f1d3878b8dd9 79 */
vpcola 0:f1d3878b8dd9 80
vpcola 0:f1d3878b8dd9 81 /**
vpcola 0:f1d3878b8dd9 82 *@}
vpcola 0:f1d3878b8dd9 83 */
vpcola 0:f1d3878b8dd9 84
vpcola 0:f1d3878b8dd9 85
vpcola 0:f1d3878b8dd9 86 /**
vpcola 0:f1d3878b8dd9 87 * @defgroup PktBasic_Private_Variables Pkt Basic Private Variables
vpcola 0:f1d3878b8dd9 88 * @{
vpcola 0:f1d3878b8dd9 89 */
vpcola 0:f1d3878b8dd9 90
vpcola 0:f1d3878b8dd9 91 /**
vpcola 0:f1d3878b8dd9 92 *@}
vpcola 0:f1d3878b8dd9 93 */
vpcola 0:f1d3878b8dd9 94
vpcola 0:f1d3878b8dd9 95
vpcola 0:f1d3878b8dd9 96
vpcola 0:f1d3878b8dd9 97 /**
vpcola 0:f1d3878b8dd9 98 * @defgroup PktBasic_Private_FunctionPrototypes Pkt Basic Private Function Prototypes
vpcola 0:f1d3878b8dd9 99 * @{
vpcola 0:f1d3878b8dd9 100 */
vpcola 0:f1d3878b8dd9 101
vpcola 0:f1d3878b8dd9 102 /**
vpcola 0:f1d3878b8dd9 103 *@}
vpcola 0:f1d3878b8dd9 104 */
vpcola 0:f1d3878b8dd9 105
vpcola 0:f1d3878b8dd9 106
vpcola 0:f1d3878b8dd9 107 /**
vpcola 0:f1d3878b8dd9 108 * @defgroup PktBasic_Private_Functions Pkt Basic Private Functions
vpcola 0:f1d3878b8dd9 109 * @{
vpcola 0:f1d3878b8dd9 110 */
vpcola 0:f1d3878b8dd9 111
vpcola 0:f1d3878b8dd9 112 /**
vpcola 0:f1d3878b8dd9 113 * @brief Initializes the SPIRIT Basic packet according to the specified parameters in the PktBasicInit struct.
vpcola 0:f1d3878b8dd9 114 * Notice that this function sets the autofiltering option on CRC if it is set to any value different from BASIC_NO_CRC.
vpcola 0:f1d3878b8dd9 115 * @param pxPktBasicInit Basic packet init structure.
vpcola 0:f1d3878b8dd9 116 * This parameter is a pointer to @ref PktBasicInit.
vpcola 0:f1d3878b8dd9 117 * @retval None.
vpcola 0:f1d3878b8dd9 118 */
vpcola 0:f1d3878b8dd9 119 void SpiritPktBasicInit(PktBasicInit* pxPktBasicInit)
vpcola 0:f1d3878b8dd9 120 {
vpcola 0:f1d3878b8dd9 121 uint8_t tempRegValue[4], i;
vpcola 0:f1d3878b8dd9 122
vpcola 0:f1d3878b8dd9 123 /* Check the parameters */
vpcola 0:f1d3878b8dd9 124 s_assert_param(IS_BASIC_PREAMBLE_LENGTH(pxPktBasicInit->xPreambleLength));
vpcola 0:f1d3878b8dd9 125 s_assert_param(IS_BASIC_SYNC_LENGTH(pxPktBasicInit->xSyncLength));
vpcola 0:f1d3878b8dd9 126 s_assert_param(IS_BASIC_CRC_MODE(pxPktBasicInit->xCrcMode));
vpcola 0:f1d3878b8dd9 127 s_assert_param(IS_BASIC_LENGTH_WIDTH_BITS(pxPktBasicInit->cPktLengthWidth));
vpcola 0:f1d3878b8dd9 128 s_assert_param(IS_BASIC_FIX_VAR_LENGTH(pxPktBasicInit->xFixVarLength));
vpcola 0:f1d3878b8dd9 129 s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(pxPktBasicInit->xAddressField));
vpcola 0:f1d3878b8dd9 130 s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(pxPktBasicInit->xFec));
vpcola 0:f1d3878b8dd9 131 s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(pxPktBasicInit->xDataWhitening));
vpcola 0:f1d3878b8dd9 132 s_assert_param(IS_BASIC_CONTROL_LENGTH(pxPktBasicInit->xControlLength));
vpcola 0:f1d3878b8dd9 133
vpcola 0:f1d3878b8dd9 134 /* Reads the PROTOCOL1 register */
vpcola 0:f1d3878b8dd9 135 g_xStatus = SpiritSpiReadRegisters(PROTOCOL1_BASE, 1, &tempRegValue[0]);
vpcola 0:f1d3878b8dd9 136
vpcola 0:f1d3878b8dd9 137 /* Mask a reserved bit */
vpcola 0:f1d3878b8dd9 138 tempRegValue[0] &= ~0x20;
vpcola 0:f1d3878b8dd9 139
vpcola 0:f1d3878b8dd9 140 /* Always set the automatic packet filtering */
vpcola 0:f1d3878b8dd9 141 tempRegValue[0] |= PROTOCOL1_AUTO_PCKT_FLT_MASK;
vpcola 0:f1d3878b8dd9 142
vpcola 0:f1d3878b8dd9 143 /* Writes the value on register */
vpcola 0:f1d3878b8dd9 144 g_xStatus = SpiritSpiWriteRegisters(PROTOCOL1_BASE, 1, &tempRegValue[0]);
vpcola 0:f1d3878b8dd9 145
vpcola 0:f1d3878b8dd9 146 /* Reads the PCKT_FLT_OPTIONS register */
vpcola 0:f1d3878b8dd9 147 g_xStatus = SpiritSpiReadRegisters(PCKT_FLT_OPTIONS_BASE, 1, &tempRegValue[0]);
vpcola 0:f1d3878b8dd9 148
vpcola 0:f1d3878b8dd9 149 /* Always reset the control and source filtering (also if it is not present in basic) */
vpcola 0:f1d3878b8dd9 150 tempRegValue[0] &= ~(PCKT_FLT_OPTIONS_SOURCE_FILTERING_MASK | PCKT_FLT_OPTIONS_CONTROL_FILTERING_MASK);
vpcola 0:f1d3878b8dd9 151
vpcola 0:f1d3878b8dd9 152 /* Writes the value on register */
vpcola 0:f1d3878b8dd9 153 g_xStatus = SpiritSpiWriteRegisters(PCKT_FLT_OPTIONS_BASE, 1, &tempRegValue[0]);
vpcola 0:f1d3878b8dd9 154
vpcola 0:f1d3878b8dd9 155 if(pxPktBasicInit->xAddressField == S_ENABLE)
vpcola 0:f1d3878b8dd9 156 {
vpcola 0:f1d3878b8dd9 157 tempRegValue[0]=0x08;
vpcola 0:f1d3878b8dd9 158 }
vpcola 0:f1d3878b8dd9 159 else
vpcola 0:f1d3878b8dd9 160 {
vpcola 0:f1d3878b8dd9 161 tempRegValue[0]=0x00;
vpcola 0:f1d3878b8dd9 162 }
vpcola 0:f1d3878b8dd9 163 /* Address and control length setting */
vpcola 0:f1d3878b8dd9 164 tempRegValue[0] |= ((uint8_t) pxPktBasicInit->xControlLength);
vpcola 0:f1d3878b8dd9 165
vpcola 0:f1d3878b8dd9 166 /* Packet format and width length setting */
vpcola 0:f1d3878b8dd9 167 pxPktBasicInit->cPktLengthWidth == 0 ? pxPktBasicInit->cPktLengthWidth=1 : pxPktBasicInit->cPktLengthWidth;
vpcola 0:f1d3878b8dd9 168 tempRegValue[1] = ((uint8_t) PCKTCTRL3_PCKT_FRMT_BASIC) | ((uint8_t)(pxPktBasicInit->cPktLengthWidth-1));
vpcola 0:f1d3878b8dd9 169
vpcola 0:f1d3878b8dd9 170 /* Preamble, sync and fixed or variable length setting */
vpcola 0:f1d3878b8dd9 171 tempRegValue[2] = ((uint8_t) pxPktBasicInit->xPreambleLength) | ((uint8_t) pxPktBasicInit->xSyncLength) |
vpcola 0:f1d3878b8dd9 172 ((uint8_t) pxPktBasicInit->xFixVarLength);
vpcola 0:f1d3878b8dd9 173
vpcola 0:f1d3878b8dd9 174 /* CRC length, whitening and FEC setting */
vpcola 0:f1d3878b8dd9 175 tempRegValue[3] = (uint8_t) pxPktBasicInit->xCrcMode;
vpcola 0:f1d3878b8dd9 176
vpcola 0:f1d3878b8dd9 177 if(pxPktBasicInit->xDataWhitening == S_ENABLE)
vpcola 0:f1d3878b8dd9 178 {
vpcola 0:f1d3878b8dd9 179 tempRegValue[3] |= PCKTCTRL1_WHIT_MASK;
vpcola 0:f1d3878b8dd9 180 }
vpcola 0:f1d3878b8dd9 181
vpcola 0:f1d3878b8dd9 182 if(pxPktBasicInit->xFec == S_ENABLE)
vpcola 0:f1d3878b8dd9 183 {
vpcola 0:f1d3878b8dd9 184 tempRegValue[3] |= PCKTCTRL1_FEC_MASK;
vpcola 0:f1d3878b8dd9 185 }
vpcola 0:f1d3878b8dd9 186
vpcola 0:f1d3878b8dd9 187 /* Writes registers */
vpcola 0:f1d3878b8dd9 188 SpiritSpiWriteRegisters(PCKTCTRL4_BASE, 4, tempRegValue);
vpcola 0:f1d3878b8dd9 189
vpcola 0:f1d3878b8dd9 190 /* Sync words setting */
vpcola 0:f1d3878b8dd9 191 for(i=0;i<4;i++)
vpcola 0:f1d3878b8dd9 192 {
vpcola 0:f1d3878b8dd9 193 if(i<3-(pxPktBasicInit->xSyncLength >>1))
vpcola 0:f1d3878b8dd9 194 {
vpcola 0:f1d3878b8dd9 195 tempRegValue[i]=0;
vpcola 0:f1d3878b8dd9 196 }
vpcola 0:f1d3878b8dd9 197 else
vpcola 0:f1d3878b8dd9 198 {
vpcola 0:f1d3878b8dd9 199 tempRegValue[i] = (uint8_t)(pxPktBasicInit->lSyncWords>>(8*i));
vpcola 0:f1d3878b8dd9 200 }
vpcola 0:f1d3878b8dd9 201 }
vpcola 0:f1d3878b8dd9 202
vpcola 0:f1d3878b8dd9 203 /* Sets CRC check bit */
vpcola 0:f1d3878b8dd9 204 if(pxPktBasicInit->xCrcMode == PKT_NO_CRC)
vpcola 0:f1d3878b8dd9 205 {
vpcola 0:f1d3878b8dd9 206 SpiritPktBasicFilterOnCrc(S_DISABLE);
vpcola 0:f1d3878b8dd9 207 }
vpcola 0:f1d3878b8dd9 208 else
vpcola 0:f1d3878b8dd9 209 {
vpcola 0:f1d3878b8dd9 210 SpiritPktBasicFilterOnCrc(S_ENABLE);
vpcola 0:f1d3878b8dd9 211 }
vpcola 0:f1d3878b8dd9 212
vpcola 0:f1d3878b8dd9 213
vpcola 0:f1d3878b8dd9 214 g_xStatus = SpiritSpiWriteRegisters(SYNC4_BASE, 4, tempRegValue);
vpcola 0:f1d3878b8dd9 215
vpcola 0:f1d3878b8dd9 216 }
vpcola 0:f1d3878b8dd9 217
vpcola 0:f1d3878b8dd9 218
vpcola 0:f1d3878b8dd9 219 /**
vpcola 0:f1d3878b8dd9 220 * @brief Returns the SPIRIT Basic packet structure according to the specified parameters in the registers.
vpcola 0:f1d3878b8dd9 221 * @param pxPktBasicInit Basic packet init structure.
vpcola 0:f1d3878b8dd9 222 * This parameter is a pointer to @ref PktBasicInit.
vpcola 0:f1d3878b8dd9 223 * @retval None.
vpcola 0:f1d3878b8dd9 224 */
vpcola 0:f1d3878b8dd9 225 void SpiritPktBasicGetInfo(PktBasicInit* pxPktBasicInit)
vpcola 0:f1d3878b8dd9 226 {
vpcola 0:f1d3878b8dd9 227 uint8_t tempRegValue[10];
vpcola 0:f1d3878b8dd9 228
vpcola 0:f1d3878b8dd9 229 /* Reads registers */
vpcola 0:f1d3878b8dd9 230 g_xStatus = SpiritSpiReadRegisters(PCKTCTRL4_BASE, 10, tempRegValue);
vpcola 0:f1d3878b8dd9 231
vpcola 0:f1d3878b8dd9 232 /* Length width */
vpcola 0:f1d3878b8dd9 233 pxPktBasicInit->cPktLengthWidth=(tempRegValue[1] & 0x0F)+1;
vpcola 0:f1d3878b8dd9 234
vpcola 0:f1d3878b8dd9 235 /* Address field */
vpcola 0:f1d3878b8dd9 236 pxPktBasicInit->xAddressField=(SpiritFunctionalState)((tempRegValue[0]>>3) & 0x01);
vpcola 0:f1d3878b8dd9 237
vpcola 0:f1d3878b8dd9 238 /* Control length */
vpcola 0:f1d3878b8dd9 239 pxPktBasicInit->xControlLength=(BasicControlLength)(tempRegValue[0] & 0x07);
vpcola 0:f1d3878b8dd9 240
vpcola 0:f1d3878b8dd9 241 /* CRC mode */
vpcola 0:f1d3878b8dd9 242 pxPktBasicInit->xCrcMode=(BasicCrcMode)(tempRegValue[3] & 0xE0);
vpcola 0:f1d3878b8dd9 243
vpcola 0:f1d3878b8dd9 244 /* Whitening */
vpcola 0:f1d3878b8dd9 245 pxPktBasicInit->xDataWhitening=(SpiritFunctionalState)((tempRegValue[3] >> 4) & 0x01);
vpcola 0:f1d3878b8dd9 246
vpcola 0:f1d3878b8dd9 247 /* FEC */
vpcola 0:f1d3878b8dd9 248 pxPktBasicInit->xFec=(SpiritFunctionalState)(tempRegValue[3] & 0x01);
vpcola 0:f1d3878b8dd9 249
vpcola 0:f1d3878b8dd9 250 /* FIX or VAR bit */
vpcola 0:f1d3878b8dd9 251 pxPktBasicInit->xFixVarLength=(BasicFixVarLength)(tempRegValue[2] & 0x01);
vpcola 0:f1d3878b8dd9 252
vpcola 0:f1d3878b8dd9 253 /* Preamble length */
vpcola 0:f1d3878b8dd9 254 pxPktBasicInit->xPreambleLength=(BasicPreambleLength)(tempRegValue[2] & 0xF8);
vpcola 0:f1d3878b8dd9 255
vpcola 0:f1d3878b8dd9 256 /* Sync length */
vpcola 0:f1d3878b8dd9 257 pxPktBasicInit->xSyncLength=(BasicSyncLength)(tempRegValue[2] & 0x06);
vpcola 0:f1d3878b8dd9 258
vpcola 0:f1d3878b8dd9 259 /* sync Words */
vpcola 0:f1d3878b8dd9 260 pxPktBasicInit->lSyncWords=0;
vpcola 0:f1d3878b8dd9 261 for(uint8_t i=0 ; i<4 ; i++)
vpcola 0:f1d3878b8dd9 262 {
vpcola 0:f1d3878b8dd9 263 if(i>2-(((uint8_t)pxPktBasicInit->xSyncLength) >>1))
vpcola 0:f1d3878b8dd9 264 {
vpcola 0:f1d3878b8dd9 265 pxPktBasicInit->lSyncWords |= (uint32_t)(tempRegValue[i+6])<<(8*i);
vpcola 0:f1d3878b8dd9 266 }
vpcola 0:f1d3878b8dd9 267 }
vpcola 0:f1d3878b8dd9 268
vpcola 0:f1d3878b8dd9 269 }
vpcola 0:f1d3878b8dd9 270
vpcola 0:f1d3878b8dd9 271
vpcola 0:f1d3878b8dd9 272 /**
vpcola 0:f1d3878b8dd9 273 * @brief Initializes the SPIRIT Basic packet addresses according to the specified
vpcola 0:f1d3878b8dd9 274 * parameters in the PktBasicAddressesInit struct.
vpcola 0:f1d3878b8dd9 275 * @param pxPktBasicAddresses Basic packet addresses init structure.
vpcola 0:f1d3878b8dd9 276 * This parameter is a pointer to @ref PktBasicAddresses.
vpcola 0:f1d3878b8dd9 277 * @retval None.
vpcola 0:f1d3878b8dd9 278 */
vpcola 0:f1d3878b8dd9 279 void SpiritPktBasicAddressesInit(PktBasicAddressesInit* pxPktBasicAddresses)
vpcola 0:f1d3878b8dd9 280 {
vpcola 0:f1d3878b8dd9 281 uint8_t tempRegValue[3];
vpcola 0:f1d3878b8dd9 282
vpcola 0:f1d3878b8dd9 283 /* Check the parameters */
vpcola 0:f1d3878b8dd9 284 s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(pxPktBasicAddresses->xFilterOnMyAddress));
vpcola 0:f1d3878b8dd9 285 s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(pxPktBasicAddresses->xFilterOnMulticastAddress));
vpcola 0:f1d3878b8dd9 286 s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(pxPktBasicAddresses->xFilterOnBroadcastAddress));
vpcola 0:f1d3878b8dd9 287
vpcola 0:f1d3878b8dd9 288
vpcola 0:f1d3878b8dd9 289 /* Reads the PCKT_FLT_OPTIONS ragister */
vpcola 0:f1d3878b8dd9 290 g_xStatus = SpiritSpiReadRegisters(PCKT_FLT_OPTIONS_BASE, 1, &tempRegValue[0]);
vpcola 0:f1d3878b8dd9 291
vpcola 0:f1d3878b8dd9 292 /* Enables or disables filtering on my address */
vpcola 0:f1d3878b8dd9 293 if(pxPktBasicAddresses->xFilterOnMyAddress == S_ENABLE)
vpcola 0:f1d3878b8dd9 294 {
vpcola 0:f1d3878b8dd9 295 tempRegValue[0] |= PCKT_FLT_OPTIONS_DEST_VS_TX_ADDR_MASK;
vpcola 0:f1d3878b8dd9 296 }
vpcola 0:f1d3878b8dd9 297 else
vpcola 0:f1d3878b8dd9 298 {
vpcola 0:f1d3878b8dd9 299 tempRegValue[0] &= ~PCKT_FLT_OPTIONS_DEST_VS_TX_ADDR_MASK;
vpcola 0:f1d3878b8dd9 300 }
vpcola 0:f1d3878b8dd9 301
vpcola 0:f1d3878b8dd9 302 /* Enables or disables filtering on multicast address */
vpcola 0:f1d3878b8dd9 303 if(pxPktBasicAddresses->xFilterOnMulticastAddress == S_ENABLE)
vpcola 0:f1d3878b8dd9 304 {
vpcola 0:f1d3878b8dd9 305 tempRegValue[0] |= PCKT_FLT_OPTIONS_DEST_VS_MULTICAST_ADDR_MASK;
vpcola 0:f1d3878b8dd9 306 }
vpcola 0:f1d3878b8dd9 307 else
vpcola 0:f1d3878b8dd9 308 {
vpcola 0:f1d3878b8dd9 309 tempRegValue[0] &= ~PCKT_FLT_OPTIONS_DEST_VS_MULTICAST_ADDR_MASK;
vpcola 0:f1d3878b8dd9 310 }
vpcola 0:f1d3878b8dd9 311
vpcola 0:f1d3878b8dd9 312 /* Enables or disables filtering on broadcast address */
vpcola 0:f1d3878b8dd9 313 if(pxPktBasicAddresses->xFilterOnBroadcastAddress == S_ENABLE)
vpcola 0:f1d3878b8dd9 314 {
vpcola 0:f1d3878b8dd9 315 tempRegValue[0] |= PCKT_FLT_OPTIONS_DEST_VS_BROADCAST_ADDR_MASK;
vpcola 0:f1d3878b8dd9 316 }
vpcola 0:f1d3878b8dd9 317 else
vpcola 0:f1d3878b8dd9 318 {
vpcola 0:f1d3878b8dd9 319 tempRegValue[0] &= ~PCKT_FLT_OPTIONS_DEST_VS_BROADCAST_ADDR_MASK;
vpcola 0:f1d3878b8dd9 320 }
vpcola 0:f1d3878b8dd9 321
vpcola 0:f1d3878b8dd9 322 /* Writes the new value on the PCKT_FLT_OPTIONS register */
vpcola 0:f1d3878b8dd9 323 g_xStatus = SpiritSpiWriteRegisters(PCKT_FLT_OPTIONS_BASE, 1, &tempRegValue[0]);
vpcola 0:f1d3878b8dd9 324
vpcola 0:f1d3878b8dd9 325 /* Fills the array with the addresses passed in the structure */
vpcola 0:f1d3878b8dd9 326 tempRegValue[0] = pxPktBasicAddresses->cBroadcastAddress;
vpcola 0:f1d3878b8dd9 327 tempRegValue[1] = pxPktBasicAddresses->cMulticastAddress;
vpcola 0:f1d3878b8dd9 328 tempRegValue[2] = pxPktBasicAddresses->cMyAddress;
vpcola 0:f1d3878b8dd9 329
vpcola 0:f1d3878b8dd9 330 /* Writes values on the PCKT_FLT_GOALS registers */
vpcola 0:f1d3878b8dd9 331 g_xStatus = SpiritSpiWriteRegisters(PCKT_FLT_GOALS_BROADCAST_BASE, 3, tempRegValue);
vpcola 0:f1d3878b8dd9 332
vpcola 0:f1d3878b8dd9 333
vpcola 0:f1d3878b8dd9 334 }
vpcola 0:f1d3878b8dd9 335
vpcola 0:f1d3878b8dd9 336
vpcola 0:f1d3878b8dd9 337 /**
vpcola 0:f1d3878b8dd9 338 * @brief Returns the SPIRIT Basic packet addresses structure according to the specified
vpcola 0:f1d3878b8dd9 339 * parameters in the registers.
vpcola 0:f1d3878b8dd9 340 * @param pxPktBasicAddresses Basic packet addresses init structure.
vpcola 0:f1d3878b8dd9 341 * This parameter is a pointer to @ref PktBasicAddresses.
vpcola 0:f1d3878b8dd9 342 * @retval None.
vpcola 0:f1d3878b8dd9 343 */
vpcola 0:f1d3878b8dd9 344 void SpiritPktBasicGetAddressesInfo(PktBasicAddressesInit* pxPktBasicAddresses)
vpcola 0:f1d3878b8dd9 345 {
vpcola 0:f1d3878b8dd9 346 uint8_t tempRegValue[3];
vpcola 0:f1d3878b8dd9 347
vpcola 0:f1d3878b8dd9 348 /* Reads values on the PCKT_FLT_GOALS registers */
vpcola 0:f1d3878b8dd9 349 g_xStatus = SpiritSpiReadRegisters(PCKT_FLT_GOALS_BROADCAST_BASE, 3, tempRegValue);
vpcola 0:f1d3878b8dd9 350
vpcola 0:f1d3878b8dd9 351 /* Fit the structure with the read addresses */
vpcola 0:f1d3878b8dd9 352 pxPktBasicAddresses->cBroadcastAddress = tempRegValue[0];
vpcola 0:f1d3878b8dd9 353 pxPktBasicAddresses->cMulticastAddress = tempRegValue[1];
vpcola 0:f1d3878b8dd9 354 pxPktBasicAddresses->cMyAddress = tempRegValue[2];
vpcola 0:f1d3878b8dd9 355
vpcola 0:f1d3878b8dd9 356 g_xStatus = SpiritSpiReadRegisters(PCKT_FLT_OPTIONS_BASE, 1, &tempRegValue[0]);
vpcola 0:f1d3878b8dd9 357
vpcola 0:f1d3878b8dd9 358 /* Fit the structure with the read filtering bits */
vpcola 0:f1d3878b8dd9 359 pxPktBasicAddresses->xFilterOnBroadcastAddress = (SpiritFunctionalState)((tempRegValue[0] >> 1) & 0x01);
vpcola 0:f1d3878b8dd9 360 pxPktBasicAddresses->xFilterOnMulticastAddress = (SpiritFunctionalState)((tempRegValue[0] >> 2) & 0x01);
vpcola 0:f1d3878b8dd9 361 pxPktBasicAddresses->xFilterOnMyAddress = (SpiritFunctionalState)((tempRegValue[0] >> 3) & 0x01);
vpcola 0:f1d3878b8dd9 362
vpcola 0:f1d3878b8dd9 363 }
vpcola 0:f1d3878b8dd9 364
vpcola 0:f1d3878b8dd9 365
vpcola 0:f1d3878b8dd9 366 /**
vpcola 0:f1d3878b8dd9 367 * @brief Configures the Basic packet format as packet used by SPIRIT.
vpcola 0:f1d3878b8dd9 368 * @param None.
vpcola 0:f1d3878b8dd9 369 * @retval None.
vpcola 0:f1d3878b8dd9 370 */
vpcola 0:f1d3878b8dd9 371 void SpiritPktBasicSetFormat(void)
vpcola 0:f1d3878b8dd9 372 {
vpcola 0:f1d3878b8dd9 373 uint8_t tempRegValue;
vpcola 0:f1d3878b8dd9 374
vpcola 0:f1d3878b8dd9 375 /* Reads the register value */
vpcola 0:f1d3878b8dd9 376 g_xStatus = SpiritSpiReadRegisters(PCKTCTRL3_BASE, 1, &tempRegValue);
vpcola 0:f1d3878b8dd9 377
vpcola 0:f1d3878b8dd9 378 /* Build the new value. Also set to 0 the direct RX mode bits */
vpcola 0:f1d3878b8dd9 379 tempRegValue &= 0x0F;
vpcola 0:f1d3878b8dd9 380 tempRegValue |= (uint8_t)PCKTCTRL3_PCKT_FRMT_BASIC;
vpcola 0:f1d3878b8dd9 381
vpcola 0:f1d3878b8dd9 382 /* Writes the value on the PCKTCTRL3 register */
vpcola 0:f1d3878b8dd9 383 g_xStatus = SpiritSpiWriteRegisters(PCKTCTRL3_BASE, 1, &tempRegValue);
vpcola 0:f1d3878b8dd9 384
vpcola 0:f1d3878b8dd9 385 /* Reads the PCKTCTRL1_BASE register */
vpcola 0:f1d3878b8dd9 386 g_xStatus = SpiritSpiReadRegisters(PCKTCTRL1_BASE, 1, &tempRegValue);
vpcola 0:f1d3878b8dd9 387
vpcola 0:f1d3878b8dd9 388 /* Build the new value. Set to 0 the direct TX mode bits */
vpcola 0:f1d3878b8dd9 389 tempRegValue &= 0xF3;
vpcola 0:f1d3878b8dd9 390
vpcola 0:f1d3878b8dd9 391 /* Writes the value on the PCKTCTRL1 register */
vpcola 0:f1d3878b8dd9 392 g_xStatus = SpiritSpiWriteRegisters(PCKTCTRL1_BASE, 1, &tempRegValue);
vpcola 0:f1d3878b8dd9 393
vpcola 0:f1d3878b8dd9 394 /* Reads the PROTOCOL1 register */
vpcola 0:f1d3878b8dd9 395 g_xStatus = SpiritSpiReadRegisters(PROTOCOL1_BASE, 1, &tempRegValue);
vpcola 0:f1d3878b8dd9 396
vpcola 0:f1d3878b8dd9 397 /* Mask a reserved bit */
vpcola 0:f1d3878b8dd9 398 tempRegValue &= ~0x20;
vpcola 0:f1d3878b8dd9 399
vpcola 0:f1d3878b8dd9 400 /* Writes the value on register */
vpcola 0:f1d3878b8dd9 401 g_xStatus = SpiritSpiWriteRegisters(PROTOCOL1_BASE, 1, &tempRegValue);
vpcola 0:f1d3878b8dd9 402 }
vpcola 0:f1d3878b8dd9 403
vpcola 0:f1d3878b8dd9 404
vpcola 0:f1d3878b8dd9 405 /**
vpcola 0:f1d3878b8dd9 406 * @brief Sets the address length for SPIRIT Basic packets.
vpcola 0:f1d3878b8dd9 407 * @param xAddressField length of ADDRESS in bytes.
vpcola 0:f1d3878b8dd9 408 * This parameter can be: S_ENABLE or S_DISABLE.
vpcola 0:f1d3878b8dd9 409 * @retval None.
vpcola 0:f1d3878b8dd9 410 */
vpcola 0:f1d3878b8dd9 411 void SpiritPktBasicAddressField(SpiritFunctionalState xAddressField)
vpcola 0:f1d3878b8dd9 412 {
vpcola 0:f1d3878b8dd9 413 uint8_t tempRegValue;
vpcola 0:f1d3878b8dd9 414
vpcola 0:f1d3878b8dd9 415 /* Check the parameters */
vpcola 0:f1d3878b8dd9 416 s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(xAddressField));
vpcola 0:f1d3878b8dd9 417
vpcola 0:f1d3878b8dd9 418 /* Reads the PCKTCTRL4 register value */
vpcola 0:f1d3878b8dd9 419 g_xStatus = SpiritSpiReadRegisters(PCKTCTRL4_BASE, 1, &tempRegValue);
vpcola 0:f1d3878b8dd9 420
vpcola 0:f1d3878b8dd9 421 /* Build the address length for the register */
vpcola 0:f1d3878b8dd9 422 if(xAddressField==S_ENABLE)
vpcola 0:f1d3878b8dd9 423 {
vpcola 0:f1d3878b8dd9 424 tempRegValue |= 0x08;
vpcola 0:f1d3878b8dd9 425 }
vpcola 0:f1d3878b8dd9 426 else
vpcola 0:f1d3878b8dd9 427 {
vpcola 0:f1d3878b8dd9 428 tempRegValue &= 0x07;
vpcola 0:f1d3878b8dd9 429 }
vpcola 0:f1d3878b8dd9 430
vpcola 0:f1d3878b8dd9 431 /* Writes the new value on the PCKTCTRL4 register */
vpcola 0:f1d3878b8dd9 432 g_xStatus = SpiritSpiWriteRegisters(PCKTCTRL4_BASE, 1, &tempRegValue);
vpcola 0:f1d3878b8dd9 433
vpcola 0:f1d3878b8dd9 434 }
vpcola 0:f1d3878b8dd9 435
vpcola 0:f1d3878b8dd9 436
vpcola 0:f1d3878b8dd9 437 /**
vpcola 0:f1d3878b8dd9 438 * @brief Specifies if the Address field for SPIRIT Basic packets is enabled or disabled.
vpcola 0:f1d3878b8dd9 439 * @param None.
vpcola 0:f1d3878b8dd9 440 * @retval SpiritFunctionalState Notifies if the address field is enabled or disabled.
vpcola 0:f1d3878b8dd9 441 */
vpcola 0:f1d3878b8dd9 442 SpiritFunctionalState SpiritPktBasicGetAddressField(void)
vpcola 0:f1d3878b8dd9 443 {
vpcola 0:f1d3878b8dd9 444 uint8_t tempRegValue;
vpcola 0:f1d3878b8dd9 445
vpcola 0:f1d3878b8dd9 446 /* Reads the PCKTCTRL4 register value */
vpcola 0:f1d3878b8dd9 447 g_xStatus = SpiritSpiReadRegisters(PCKTCTRL4_BASE, 1, &tempRegValue);
vpcola 0:f1d3878b8dd9 448
vpcola 0:f1d3878b8dd9 449 /* Returns the address field value */
vpcola 0:f1d3878b8dd9 450 if(tempRegValue & PCKTCTRL4_ADDRESS_LEN_MASK)
vpcola 0:f1d3878b8dd9 451 {
vpcola 0:f1d3878b8dd9 452 return S_ENABLE;
vpcola 0:f1d3878b8dd9 453 }
vpcola 0:f1d3878b8dd9 454 else
vpcola 0:f1d3878b8dd9 455 {
vpcola 0:f1d3878b8dd9 456 return S_DISABLE;
vpcola 0:f1d3878b8dd9 457 }
vpcola 0:f1d3878b8dd9 458
vpcola 0:f1d3878b8dd9 459 }
vpcola 0:f1d3878b8dd9 460
vpcola 0:f1d3878b8dd9 461
vpcola 0:f1d3878b8dd9 462 /**
vpcola 0:f1d3878b8dd9 463 * @brief Sets the payload length for SPIRIT Basic packets. Since the packet length
vpcola 0:f1d3878b8dd9 464 * depends from the address and the control field size, this
vpcola 0:f1d3878b8dd9 465 * function reads the correspondent registers in order to determine
vpcola 0:f1d3878b8dd9 466 * the correct packet length to be written.
vpcola 0:f1d3878b8dd9 467 * @param nPayloadLength payload length in bytes.
vpcola 0:f1d3878b8dd9 468 * This parameter is an uint16_t.
vpcola 0:f1d3878b8dd9 469 * @retval None.
vpcola 0:f1d3878b8dd9 470 */
vpcola 0:f1d3878b8dd9 471 void SpiritPktBasicSetPayloadLength(uint16_t nPayloadLength)
vpcola 0:f1d3878b8dd9 472 {
vpcola 0:f1d3878b8dd9 473 uint8_t tempRegValue[2];
vpcola 0:f1d3878b8dd9 474 uint16_t overSize=0;
vpcola 0:f1d3878b8dd9 475
vpcola 0:f1d3878b8dd9 476 /* Computes the oversize (address + control) size */
vpcola 0:f1d3878b8dd9 477 if(SpiritPktBasicGetAddressField())
vpcola 0:f1d3878b8dd9 478 {
vpcola 0:f1d3878b8dd9 479 overSize=1;
vpcola 0:f1d3878b8dd9 480 }
vpcola 0:f1d3878b8dd9 481 overSize += (uint16_t) SpiritPktBasicGetControlLength();
vpcola 0:f1d3878b8dd9 482
vpcola 0:f1d3878b8dd9 483 /* Computes PCKTLEN0 value from nPayloadLength */
vpcola 0:f1d3878b8dd9 484 tempRegValue[1]=BASIC_BUILD_PCKTLEN0(nPayloadLength+overSize);
vpcola 0:f1d3878b8dd9 485 /* Computes PCKTLEN1 value from nPayloadLength */
vpcola 0:f1d3878b8dd9 486 tempRegValue[0]=BASIC_BUILD_PCKTLEN1(nPayloadLength+overSize);
vpcola 0:f1d3878b8dd9 487
vpcola 0:f1d3878b8dd9 488 /* Writes data on the PCKTLEN1/0 register */
vpcola 0:f1d3878b8dd9 489 g_xStatus = SpiritSpiWriteRegisters(PCKTLEN1_BASE, 2, tempRegValue);
vpcola 0:f1d3878b8dd9 490
vpcola 0:f1d3878b8dd9 491 }
vpcola 0:f1d3878b8dd9 492
vpcola 0:f1d3878b8dd9 493
vpcola 0:f1d3878b8dd9 494 /**
vpcola 0:f1d3878b8dd9 495 * @brief Returns the payload length for SPIRIT Basic packets. Since the
vpcola 0:f1d3878b8dd9 496 * packet length depends from the address and the control
vpcola 0:f1d3878b8dd9 497 * field size, this function reads the correspondent
vpcola 0:f1d3878b8dd9 498 * registers in order to determine the correct payload length
vpcola 0:f1d3878b8dd9 499 * to be returned.
vpcola 0:f1d3878b8dd9 500 * @param None.
vpcola 0:f1d3878b8dd9 501 * @retval uint16_t Payload length in bytes.
vpcola 0:f1d3878b8dd9 502 */
vpcola 0:f1d3878b8dd9 503 uint16_t SpiritPktBasicGetPayloadLength(void)
vpcola 0:f1d3878b8dd9 504 {
vpcola 0:f1d3878b8dd9 505 uint8_t tempRegValue[2];
vpcola 0:f1d3878b8dd9 506 uint16_t overSize=0;
vpcola 0:f1d3878b8dd9 507
vpcola 0:f1d3878b8dd9 508 /* Computes the oversize (address + control) size */
vpcola 0:f1d3878b8dd9 509 if(SpiritPktBasicGetAddressField())
vpcola 0:f1d3878b8dd9 510 {
vpcola 0:f1d3878b8dd9 511 overSize=1;
vpcola 0:f1d3878b8dd9 512 }
vpcola 0:f1d3878b8dd9 513 overSize += (uint16_t) SpiritPktBasicGetControlLength();
vpcola 0:f1d3878b8dd9 514
vpcola 0:f1d3878b8dd9 515 /* Reads the packet length registers */
vpcola 0:f1d3878b8dd9 516 g_xStatus = SpiritSpiReadRegisters(PCKTLEN1_BASE, 2, tempRegValue);
vpcola 0:f1d3878b8dd9 517
vpcola 0:f1d3878b8dd9 518 /* Returns the packet length */
vpcola 0:f1d3878b8dd9 519 return ((((uint16_t)tempRegValue[0])<<8) + (uint16_t) tempRegValue[1]) - overSize;
vpcola 0:f1d3878b8dd9 520 }
vpcola 0:f1d3878b8dd9 521
vpcola 0:f1d3878b8dd9 522 /**
vpcola 0:f1d3878b8dd9 523 * @brief Returns the packet length field of the received packet.
vpcola 0:f1d3878b8dd9 524 * @param None.
vpcola 0:f1d3878b8dd9 525 * @retval uint16_t Packet length.
vpcola 0:f1d3878b8dd9 526 */
vpcola 0:f1d3878b8dd9 527 uint16_t SpiritPktBasicGetReceivedPktLength(void)
vpcola 0:f1d3878b8dd9 528 {
vpcola 0:f1d3878b8dd9 529 uint8_t tempRegValue[2];
vpcola 0:f1d3878b8dd9 530 uint16_t overSize=0;
vpcola 0:f1d3878b8dd9 531
vpcola 0:f1d3878b8dd9 532 /* Computes the oversize (address + control) size */
vpcola 0:f1d3878b8dd9 533 if(SpiritPktBasicGetAddressField())
vpcola 0:f1d3878b8dd9 534 {
vpcola 0:f1d3878b8dd9 535 overSize=1;
vpcola 0:f1d3878b8dd9 536 }
vpcola 0:f1d3878b8dd9 537 overSize += (uint16_t) SpiritPktBasicGetControlLength();
vpcola 0:f1d3878b8dd9 538
vpcola 0:f1d3878b8dd9 539 /* Reads the RX_PCKT_LENx registers value */
vpcola 0:f1d3878b8dd9 540 g_xStatus = SpiritSpiReadRegisters(RX_PCKT_LEN1_BASE, 2, tempRegValue);
vpcola 0:f1d3878b8dd9 541
vpcola 0:f1d3878b8dd9 542 /* Rebuild and return the length field */
vpcola 0:f1d3878b8dd9 543 return (((((uint16_t) tempRegValue[0]) << 8) + (uint16_t) tempRegValue[1]) - overSize);
vpcola 0:f1d3878b8dd9 544 }
vpcola 0:f1d3878b8dd9 545
vpcola 0:f1d3878b8dd9 546 /**
vpcola 0:f1d3878b8dd9 547 * @brief Computes and sets the variable payload length for SPIRIT Basic packets.
vpcola 0:f1d3878b8dd9 548 * @param nMaxPayloadLength payload length in bytes.
vpcola 0:f1d3878b8dd9 549 * This parameter is an uint16_t.
vpcola 0:f1d3878b8dd9 550 * @param xAddressField Enable or Disable Address Field.
vpcola 0:f1d3878b8dd9 551 * This parameter can be S_ENABLE or S_DISABLE.
vpcola 0:f1d3878b8dd9 552 * @param xControlLength Control length in bytes.
vpcola 0:f1d3878b8dd9 553 * This parameter can be any value of @ref BasicControlLength.
vpcola 0:f1d3878b8dd9 554 * @retval None.
vpcola 0:f1d3878b8dd9 555 */
vpcola 0:f1d3878b8dd9 556 void SpiritPktBasicSetVarLengthWidth(uint16_t nMaxPayloadLength, SpiritFunctionalState xAddressField, BasicControlLength xControlLength)
vpcola 0:f1d3878b8dd9 557 {
vpcola 0:f1d3878b8dd9 558 uint8_t tempRegValue,
vpcola 0:f1d3878b8dd9 559 addressLength,
vpcola 0:f1d3878b8dd9 560 i;
vpcola 0:f1d3878b8dd9 561 uint32_t packetLength;
vpcola 0:f1d3878b8dd9 562
vpcola 0:f1d3878b8dd9 563 /* Sets the address length according to xAddressField */
vpcola 0:f1d3878b8dd9 564 if(xAddressField == S_ENABLE)
vpcola 0:f1d3878b8dd9 565 {
vpcola 0:f1d3878b8dd9 566 addressLength=1;
vpcola 0:f1d3878b8dd9 567 }
vpcola 0:f1d3878b8dd9 568 else
vpcola 0:f1d3878b8dd9 569 {
vpcola 0:f1d3878b8dd9 570 addressLength=0;
vpcola 0:f1d3878b8dd9 571 }
vpcola 0:f1d3878b8dd9 572
vpcola 0:f1d3878b8dd9 573 /* packet length = payload length + address length + control length */
vpcola 0:f1d3878b8dd9 574 packetLength=nMaxPayloadLength+addressLength+xControlLength;
vpcola 0:f1d3878b8dd9 575
vpcola 0:f1d3878b8dd9 576 /* Computes the number of bits */
vpcola 0:f1d3878b8dd9 577 for(i=0;i<16;i++)
vpcola 0:f1d3878b8dd9 578 {
vpcola 0:f1d3878b8dd9 579 if(packetLength == 0) break;
vpcola 0:f1d3878b8dd9 580 {
vpcola 0:f1d3878b8dd9 581 packetLength >>= 1;
vpcola 0:f1d3878b8dd9 582 }
vpcola 0:f1d3878b8dd9 583 }
vpcola 0:f1d3878b8dd9 584 i==0 ? i=1 : i;
vpcola 0:f1d3878b8dd9 585
vpcola 0:f1d3878b8dd9 586 /* Reads the PCKTCTRL3 register value */
vpcola 0:f1d3878b8dd9 587 g_xStatus = SpiritSpiReadRegisters(PCKTCTRL3_BASE, 1, &tempRegValue);
vpcola 0:f1d3878b8dd9 588
vpcola 0:f1d3878b8dd9 589 /* Build value for the length width */
vpcola 0:f1d3878b8dd9 590 tempRegValue &= ~PCKTCTRL3_LEN_WID_MASK;
vpcola 0:f1d3878b8dd9 591 tempRegValue |= (uint8_t)(i-1);
vpcola 0:f1d3878b8dd9 592
vpcola 0:f1d3878b8dd9 593 /* Writes the PCKTCTRL3 register value */
vpcola 0:f1d3878b8dd9 594 g_xStatus = SpiritSpiWriteRegisters(PCKTCTRL3_BASE, 1, &tempRegValue);
vpcola 0:f1d3878b8dd9 595
vpcola 0:f1d3878b8dd9 596 }
vpcola 0:f1d3878b8dd9 597
vpcola 0:f1d3878b8dd9 598
vpcola 0:f1d3878b8dd9 599
vpcola 0:f1d3878b8dd9 600 /**
vpcola 0:f1d3878b8dd9 601 *@}
vpcola 0:f1d3878b8dd9 602 */
vpcola 0:f1d3878b8dd9 603
vpcola 0:f1d3878b8dd9 604 /**
vpcola 0:f1d3878b8dd9 605 *@}
vpcola 0:f1d3878b8dd9 606 */
vpcola 0:f1d3878b8dd9 607
vpcola 0:f1d3878b8dd9 608
vpcola 0:f1d3878b8dd9 609 /**
vpcola 0:f1d3878b8dd9 610 *@}
vpcola 0:f1d3878b8dd9 611 */
vpcola 0:f1d3878b8dd9 612
vpcola 0:f1d3878b8dd9 613
vpcola 0:f1d3878b8dd9 614
vpcola 0:f1d3878b8dd9 615 /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/