Fork of my original MQTTGateway

Dependencies:   mbed-http

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SPIRIT_PktStack.h Source File

SPIRIT_PktStack.h

Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003  * @file    SPIRIT_PktStack.h
00004   * @author  VMA division - AMS
00005   * @version 3.2.2
00006   * @date    08-July-2015
00007  * @brief   Configuration and management of SPIRIT STack packets.
00008   * 
00009  * @details
00010  *
00011  * This module can be used to manage the configuration of Spirit STack
00012  * packets, and it is quite similar to the Basic packets one since the
00013  * STack packets can be considered an extension of Basic.
00014  * The user can obtain a packet configuration filling the structure
00015  * <i>@ref PktStackInit</i>, defining in it some general parameters
00016  * for the Spirit STack packet format.
00017  * Another structure the user can fill is <i>@ref PktStackAddressesInit</i>
00018  * to define the addresses which will be used during the communication.
00019  * The structure <i>@ref PktStackLlpInit</i> is provided in order to configure
00020  * the link layer protocol features like autoack, autoretransmission
00021  * or piggybacking.
00022  * Moreover, functions to set the payload length and the destination address
00023  * are provided.
00024  *
00025  * <b>Example:</b>
00026  * @code
00027  *
00028  * PktStackInit stackInit={
00029  *   PKT_PREAMBLE_LENGTH_08BYTES,       // preamble length in bytes
00030  *   PKT_SYNC_LENGTH_4BYTES,            // sync word length in bytes
00031  *   0x1A2635A8,                        // sync word
00032  *   PKT_LENGTH_VAR,                    // variable or fixed payload length
00033  *   7,                                 // length field width in bits (used only for variable length)
00034  *   PKT_NO_CRC,                        // CRC mode
00035  *   PKT_CONTROL_LENGTH_0BYTES,         // control field length
00036  *   S_DISABLE,                         // FEC
00037  *   S_ENABLE                           // whitening
00038  * };
00039  *
00040  * PktStackAddressesInit addressInit={
00041  *   S_ENABLE,                          // enable/disable filtering on my address
00042  *   0x34,                              // my address (address of the current node)
00043  *   S_DISABLE,                         // enable/disable filtering on multicast address
00044  *   0xEE,                              // multicast address
00045  *   S_DISABLE,                         // enable/disable filtering on broadcast address
00046  *   0xFF                               // broadcast address
00047  * };
00048  *
00049  * PktStackLlpInit stackLLPInit ={
00050  *   S_DISABLE,                         // enable/disable the autoack feature
00051  *   S_DISABLE,                         // enable/disable the piggybacking feature
00052  *   PKT_DISABLE_RETX                   // set the max number of retransmissions or disable them
00053  * };
00054  * ...
00055  *
00056  * SpiritPktStackInit(&stackInit);
00057  * SpiritPktStackAddressesInit(&addressInit);
00058  * SpiritPktStackLlpInit(&stackLLPInit);
00059  *
00060  * ...
00061  *
00062  * SpiritPktStackSetPayloadLength(20);
00063  * SpiritPktStackSetDestinationAddress(0x44);
00064  *
00065  * ...
00066  *
00067  * @endcode
00068  *
00069  * The module provides some other functions that can be used to modify
00070  * or read only some configuration parameters.
00071  *
00072  *
00073   * @attention
00074   *
00075   * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
00076   *
00077   * Redistribution and use in source and binary forms, with or without modification,
00078   * are permitted provided that the following conditions are met:
00079   *   1. Redistributions of source code must retain the above copyright notice,
00080   *      this list of conditions and the following disclaimer.
00081   *   2. Redistributions in binary form must reproduce the above copyright notice,
00082   *      this list of conditions and the following disclaimer in the documentation
00083   *      and/or other materials provided with the distribution.
00084   *   3. Neither the name of STMicroelectronics nor the names of its contributors
00085   *      may be used to endorse or promote products derived from this software
00086   *      without specific prior written permission.
00087   *
00088   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00089   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00090   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00091   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00092   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00093   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00094   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00095   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00096   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00097   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00098  *
00099   ******************************************************************************
00100  */
00101 
00102 /* Define to prevent recursive inclusion -------------------------------------*/
00103 #ifndef __SPIRIT_PKT_STACK_H
00104 #define __SPIRIT_PKT_STACK_H
00105 
00106 /* Includes ------------------------------------------------------------------*/
00107 
00108 #include "SPIRIT_Regs.h"
00109 #include "SPIRIT_Types.h"
00110 #include "SPIRIT_PktCommon.h"
00111 
00112 #ifdef __cplusplus
00113  extern "C" {
00114 #endif
00115 
00116 
00117 
00118 /**
00119  * @addtogroup SPIRIT_Libraries
00120  * @{
00121  */
00122 
00123 
00124 /**
00125  * @defgroup SPIRIT_PktStack    Pkt STack
00126  * @brief Configuration and management of SPIRIT STack packets.
00127  * @details See the file <i>@ref SPIRIT_PktStack.h</i> for more details.
00128  * @{
00129  */
00130 
00131 /**
00132  * @defgroup PktStack_Exported_Types    Pkt STack Exported Types
00133  * @{
00134  */
00135 
00136 /**
00137  * @brief  Preamble length in bytes enumeration.
00138  */
00139 typedef PktPreambleLength                  StackPreambleLength;
00140 
00141 #define IS_STACK_PREAMBLE_LENGTH           IS_PKT_PREAMBLE_LENGTH
00142 
00143 /**
00144  * @brief  Sync length in bytes enumeration.
00145  */
00146 typedef PktSyncLength                      StackSyncLength;
00147 
00148 #define IS_STACK_SYNC_LENGTH               IS_PKT_SYNC_LENGTH
00149 
00150 
00151 
00152 /**
00153  * @brief  CRC length in bytes enumeration.
00154  */
00155 typedef PktCrcMode                         StackCrcMode;
00156 
00157 #define IS_STACK_CRC_MODE                  IS_PKT_CRC_MODE
00158 
00159 
00160 /**
00161  * @brief  Fixed or variable payload length enumeration.
00162  */
00163 typedef PktFixVarLength                    StackFixVarLength;
00164 
00165 #define IS_STACK_FIX_VAR_LENGTH            IS_PKT_FIX_VAR_LENGTH
00166 
00167 /**
00168  * @brief  Control length in bytes enumeration for SPIRIT.
00169  */
00170 typedef PktControlLength                   StackControlLength;
00171 
00172 #define IS_STACK_CONTROL_LENGTH            IS_PKT_CONTROL_LENGTH
00173 
00174 /**
00175  * @brief  Sync words enumeration for SPIRIT.
00176  */
00177 typedef PktSyncX                           StackSyncX;
00178 
00179 #define IS_STACK_SYNCx                     IS_PKT_SYNCx
00180 
00181 /**
00182  * @brief  Max retransmission number enumeration for SPIRIT.
00183  */
00184 typedef PktNMaxReTx                        StackNMaxReTx;
00185 
00186 #define IS_STACK_NMAX_RETX                 IS_PKT_NMAX_RETX
00187 
00188 
00189 /**
00190  * @brief  SPIRIT STack Packet Init structure definition. This structure allows users to set the main options
00191  *         for the STack packet.
00192  */
00193 typedef struct
00194 {
00195 
00196   StackPreambleLength           xPreambleLength;         /*!< Specifies the preamble length of packet.
00197                                                               This parameter can be any value of @ref StackPreambleLength */
00198   StackSyncLength               xSyncLength;             /*!< Specifies the sync word length of packet.
00199                                                               This parameter can be any value of @ref StackSyncLength */
00200   uint32_t                      lSyncWords;          /*!< Specifies the sync words.
00201                                                               This parameter is a uint32_t word with format: 0x|SYNC1|SYNC2|SYNC3|SYNC4| */
00202   StackFixVarLength             xFixVarLength;           /*!< Specifies if a fixed length of packet has to be used.
00203                                                               This parameter can be any value of @ref StackFixVarLength */
00204   uint8_t                       cPktLengthWidth;         /*!< Specifies the size of the length of packet in bits. This field is useful only if
00205                                                               the field xFixVarLength is set to STACK_LENGTH_VAR. For STack packets the length width
00206                                                                is log2( max payload length + control length (0 to 4) + address length (always 2)).
00207                                                               This parameter is an uint8_t */
00208   StackCrcMode                  xCrcMode;                /*!< Specifies the CRC word length of packet.
00209                                                               This parameter can be any value of @ref StackCrcMode */
00210   StackControlLength            xControlLength;          /*!< Specifies the length of a control field to be sent.
00211                                                               This parameter can be any value of @ref StackControlLength */
00212   SpiritFunctionalState         xFec;                    /*!< Specifies if FEC has to be enabled.
00213                                                               This parameter can be any value of @ref SpiritFunctionalState */
00214   SpiritFunctionalState         xDataWhitening;          /*!< Specifies if data whitening has to be enabled.
00215                                                               This parameter can be any value of @ref SpiritFunctionalState */
00216 
00217 }PktStackInit;
00218 
00219 
00220 /**
00221  * @brief  SPIRIT STack packet address structure definition. This structure allows users to specify
00222  *         the node/multicast/broadcast addresses and the correspondent filtering options.
00223  */
00224 typedef struct
00225 {
00226 
00227   SpiritFunctionalState         xFilterOnMyAddress;             /*!< If set RX packet is accepted if its destination address matches with cMyAddress.
00228                                                                      This parameter can be S_ENABLE or S_DISABLE */
00229   uint8_t                       cMyAddress;                     /*!< Specifies the TX packet source address (address of this node).
00230                                                                      This parameter is an uint8_t */
00231   SpiritFunctionalState         xFilterOnMulticastAddress;      /*!< If set RX packet is accepted if its destination address matches with cMulticastAddress.
00232                                                                      This parameter can be S_ENABLE or S_DISABLE */
00233   uint8_t                       cMulticastAddress;              /*!< Specifies the Multicast group address for this node.
00234                                                                      This parameter is an uint8_t */
00235   SpiritFunctionalState         xFilterOnBroadcastAddress;      /*!< If set RX packet is accepted if its destination address matches with cBroadcastAddress.
00236                                                                      This parameter can be S_ENABLE or S_DISABLE */
00237   uint8_t                       cBroadcastAddress;              /*!< Specifies the Broadcast address for this node.
00238                                                                      This parameter is an uint8_t */
00239 }PktStackAddressesInit;
00240 
00241 
00242 /**
00243  * @brief  SPIRIT STack packet LLP structure definition. This structure allows users to configure
00244  *         all the LLP options for STack packets.
00245  */
00246 typedef struct
00247 {
00248 
00249   SpiritFunctionalState         xAutoAck;                /*!< Specifies if the auto ACK feature is used or not.
00250                                                               This parameter can be a value of @ref SpiritFunctionalState */
00251   SpiritFunctionalState         xPiggybacking;           /*!< Specifies if the piggybacking feature is used or not.
00252                                                               This parameter can be a value of @ref SpiritFunctionalState */
00253   StackNMaxReTx                 xNMaxRetx;               /*!< Specifies the number of MAX-Retransmissions.
00254                                                               This parameter can be a value of @ref StackNMaxReTx */
00255 }PktStackLlpInit;
00256 
00257 
00258 
00259 /**
00260  *@}
00261  */
00262 
00263 
00264 /**
00265  * @defgroup PktStack_Exported_Constants        Pkt STack Exported Constants
00266  * @{
00267  */
00268 
00269 #define IS_STACK_LENGTH_WIDTH_BITS                      IS_PKT_LENGTH_WIDTH_BITS
00270 
00271 /**
00272  *@}
00273  */
00274 
00275 
00276 /**
00277  * @defgroup PktStack_Exported_Macros   Pkt STack Exported Macros
00278  * @{
00279  */
00280 
00281 /**
00282  * @brief  Macro used to compute the lower part of the packet length
00283  *         for Spirit STack packets, to write in the PCKTLEN0 register.
00284  * @param  nLength length of the packet payload.
00285  *         This parameter is an uint16_t.
00286  * @retval None.
00287  */
00288 #define STACK_BUILD_PCKTLEN0(nLength)                                    BUILD_PCKTLEN0(nLength)
00289 
00290 
00291 /**
00292  * @brief  Macro used to compute the upper part of the packet length
00293  *         for Spirit STack packets, to write the PCKTLEN1 register.
00294  * @param  nLength length of the packet payload.
00295  *         This parameter is an uint16_t.
00296  * @retval None.
00297  */
00298 #define STACK_BUILD_PCKTLEN1(nLength)                                    BUILD_PCKTLEN1(nLength)
00299 
00300 
00301 /**
00302  * @brief  Sets the CONTROL length for SPIRIT STack packets.
00303  * @param  xControlLength length of CONTROL field in bytes.
00304  *         This parameter can be any value of @ref StackControlLength.
00305  * @retval None.
00306  */
00307 #define SpiritPktStackSetControlLength(xControlLength)                          SpiritPktCommonSetControlLength(xControlLength)
00308 
00309 
00310 /**
00311  * @brief  Returns the CONTROL length for SPIRIT STack packets.
00312  * @param  None.
00313  * @retval Control length.
00314  */
00315 #define SpiritPktStackGetControlLength()                                       SpiritPktCommonGetControlLength()
00316 
00317 
00318 /**
00319  * @brief  Sets the PREAMBLE Length mode for SPIRIT STack packets.
00320  * @param  xPreambleLength length of PREAMBLE field in bytes.
00321  *         This parameter can be any value of @ref StackPreambleLength.
00322  * @retval None.
00323  */
00324 #define SpiritPktStackSetPreambleLength(xPreambleLength)                        SpiritPktCommonSetPreambleLength((PktPreambleLength)xPreambleLength)
00325 
00326 
00327 /**
00328  * @brief  Returns the PREAMBLE Length mode for SPIRIT STack packets.
00329  * @param  None.
00330  * @retval uint8_t Preamble length in bytes.
00331  */
00332 #define SpiritPktStackGetPreambleLength()                                      SpiritPktCommonGetPreambleLength()
00333 
00334 
00335 /**
00336  * @brief  Sets the SYNC Length for SPIRIT STack packets.
00337  * @param  xSyncLength length of SYNC field in bytes.
00338  *         This parameter can be any value of @ref StackSyncLength.
00339  * @retval None.
00340  */
00341 #define SpiritPktStackSetSyncLength(xSyncLength)                                SpiritPktCommonSetSyncLength((PktSyncLength)xSyncLength)
00342 
00343 
00344 /**
00345  * @brief  Returns the SYNC Length for SPIRIT STack packets.
00346  * @param  None.
00347  * @retval uint8_t Sync length in bytes.
00348  */
00349 #define SpiritPktStackGetSyncLength()                                           SpiritPktCommonGetSyncLength()
00350 
00351 
00352 /**
00353  * @brief  Sets fixed or variable payload length mode for SPIRIT STack packets.
00354  * @param  xFixVarLength variable or fixed length.
00355  *         PKT_FIXED_LENGTH_VAR -> variable (the length is extracted from the received packet).
00356  *         PKT_FIXED_LENGTH_FIX -> fix (the length is set by PCKTLEN0 and PCKTLEN1).
00357  * @retval None.
00358  */
00359 #define SpiritPktStackSetFixVarLength(xFixVarLength)                            SpiritPktCommonSetFixVarLength((PktFixVarLength)xFixVarLength)
00360 
00361 
00362 /**
00363  * @brief  Enables or Disables the CRC filtering.
00364  * @param  xNewState new state for CRC_CHECK.
00365  *         This parameter can be S_ENABLE or S_DISABLE.
00366  * @retval None.
00367  */
00368 #define SpiritPktStackFilterOnCrc(xNewState)                                    SpiritPktCommonFilterOnCrc(xNewState)
00369 
00370 
00371 /**
00372  * @brief  Returns the CRC filtering bit.
00373  * @param  None.
00374  * @retval SpiritFunctionalState This parameter can be S_ENABLE or S_DISABLE.
00375  */
00376 #define SpiritPktStackGetFilterOnCrc()                                          SpiritPktCommonGetFilterOnCrc()
00377 
00378 
00379 /**
00380  * @brief  Sets the CRC mode for SPIRIT STack packets.
00381  * @param  xCrcMode CRC mode.
00382  *         This parameter can be any value of @ref StackCrcMode.
00383  * @retval None.
00384  */
00385 #define SpiritPktStackSetCrcMode(xCrcMode)                                      SpiritPktCommonSetCrcMode((PktCrcMode)xCrcMode)
00386 
00387 
00388 /**
00389  * @brief  Returns the CRC mode for SPIRIT packets.
00390  * @param  None.
00391  * @retval StackCrcMode Crc mode.
00392  */
00393 #define SpiritPktStackGetCrcMode()                                             (StackCrcMode)SpiritPktCommonGetCrcMode()
00394 
00395 
00396 /**
00397  * @brief  Enables or Disables WHITENING for SPIRIT STack packets.
00398  * @param  xNewState new state for WHITENING mode.
00399  *         This parameter can be S_ENABLE or S_DISABLE.
00400  * @retval None.
00401  */
00402 #define SpiritPktStackWhitening(xNewState)                                     SpiritPktCommonWhitening(xNewState)
00403 
00404 
00405 /**
00406  * @brief  Enables or Disables FEC for SPIRIT STack packets.
00407  * @param  xNewState new state for FEC mode.
00408  *         This parameter can be S_ENABLE or S_DISABLE.
00409  * @retval None.
00410  */
00411 #define SpiritPktStackFec(xNewState)                                            SpiritPktCommonFec(xNewState)
00412 
00413 
00414 /**
00415  * @brief  Sets a specific SYNC word for SPIRIT STack packets.
00416  * @param  xSyncX SYNC word number to be set.
00417  *         This parameter can be any value of @ref StackSyncX.
00418  * @param  cSyncWord SYNC word.
00419  *         This parameter is an uint8_t.
00420  * @retval None.
00421  */
00422 #define SpiritPktStackSetSyncxWord(xSyncX, cSyncWord)                          SpiritPktCommonSetSyncxWord((PktSyncX)xSyncX,cSyncWord)
00423 
00424 
00425 /**
00426  * @brief  Returns a specific SYNC word for SPIRIT STack packets.
00427  * @param  xSyncX SYNC word number to be get.
00428  *         This parameter can be any value of @ref StackSyncX.
00429  * @retval uint8_t Sync word x.
00430  */
00431 #define SpiritPktStackGetSyncxWord(xSyncX)                                     SpiritPktCommonGetSyncxWord(xSyncX)
00432 
00433 
00434 /**
00435  * @brief  Sets multiple SYNC words for SPIRIT STack packets.
00436  * @param  lSyncWords SYNC words to be set with format: 0x|SYNC1|SYNC2|SYNC3|SYNC4|.
00437  *         This parameter is a uint32_t.
00438  * @param  xSyncLength SYNC length in bytes. The 32bit word passed will be stored in the SYNCx registers from the MSb
00439  *         until the number of bytes in xSyncLength has been stored.
00440  *         This parameter is a @ref StackSyncLength.
00441  * @retval None.
00442  */
00443 #define SpiritPktStackSetSyncWords(lSyncWords, xSyncLength)                    SpiritPktCommonSetSyncWords(lSyncWords,(PktSyncLength)xSyncLength)
00444 
00445 
00446 /**
00447  * @brief  Returns multiple SYNC words for SPIRIT packets.
00448  * @param  xSyncLength SYNC length in bytes. The 32bit word passed will be stored in the SYNCx registers from the MSb
00449  *         until the number of bytes in xSyncLength has been stored.
00450  *         This parameter is a pointer to @ref StackSyncLength.
00451  * @retval uint32_t Sync words. The format of the read 32 bit word is 0x|SYNC1|SYNC2|SYNC3|SYNC4|.
00452  */
00453 #define SpiritPktStackGetSyncWords(xSyncLength)                                 SpiritPktCommonGetSyncWords((PktSyncLength)xSyncLength)
00454 
00455 
00456 /**
00457  * @brief  Returns the SPIRIT variable length width (in number of bits).
00458  * @param  None.
00459  * @retval uint8_t Variable length width in bits.
00460  */
00461 #define SpiritPktStackGetVarLengthWidth()                                       SpiritPktCommonGetVarLengthWidth()
00462 
00463 
00464 /**
00465  * @brief  Sets the destination address for the Tx packet.
00466  * @param  cAddress destination address.
00467  *         This parameter is an uint8_t.
00468  * @retval None.
00469  */
00470 #define SpiritPktStackSetDestinationAddress(cAddress)                           SpiritPktCommonSetDestinationAddress(cAddress)
00471 
00472 
00473 /**
00474  * @brief  Sets the Rx packet reference source address. The source address extracted from the received packet is masked
00475  *         with the source reference mask and then compared to the masked reference value.
00476  * @param  cAddress Reference source address.
00477  *         This parameter is an uint8_t.
00478  * @retval None.
00479  */
00480 #define SpiritPktStackSetSourceReferenceAddress(cAddress)                       SpiritPktCommonSetDestinationAddress(cAddress)
00481 
00482 
00483 /**
00484  * @brief  Returns the Rx packet reference source address. The source address extracted from the received packet is masked
00485  *         with the source reference mask and then compared to the masked reference value.
00486  * @param  cAddress Reference source address.
00487  *         This parameter is an uint8_t.
00488  * @retval None.
00489  */
00490 #define SpiritPktStackGetSourceReferenceAddress()                               SpiritPktCommonGetTransmittedDestAddress()
00491 
00492 
00493 /**
00494  * @brief  Returns the settled destination address.
00495  * @param  None.
00496  * @retval uint8_t Transmitted destination address.
00497  */
00498 #define SpiritPktStackGetTransmittedDestAddress()                               SpiritPktCommonGetTransmittedDestAddress()
00499 
00500 
00501 /**
00502  * @brief  Sets the node address. When the filtering on my address is on, if the destination address extracted from the received packet is equal to the content of the
00503  *         my address, then the packet is accepted (this is the address of the node).
00504  * @param  cAddress Address of the present node.
00505  *         This parameter is an uint8_t.
00506  * @retval None.
00507  */
00508 #define SpiritPktStackSetMyAddress(cAddress)                                    SpiritPktCommonSetMyAddress(cAddress)
00509 
00510 
00511 /**
00512  * @brief  Returns the address of the present node.
00513  * @param  None.
00514  * @retval uint8_t My address (address of this node).
00515  */
00516 #define SpiritPktStackGetMyAddress()                                            SpiritPktCommonGetMyAddress()
00517 
00518 
00519 /**
00520  * @brief  Sets the broadcast address. When the broadcast filtering is on, if the destination address extracted from the received packet is equal to the content of the
00521  *         BROADCAST_ADDR register, then the packet is accepted.
00522  * @param  cAddress Broadcast address.
00523  *         This parameter is an uint8_t.
00524  * @retval None.
00525  */
00526 #define SpiritPktStackSetBroadcastAddress(cAddress)                             SpiritPktCommonSetBroadcastAddress(cAddress)
00527 
00528 
00529 /**
00530  * @brief  Returns the broadcast address.
00531  * @param  None.
00532  * @retval uint8_t Broadcast address.
00533  */
00534 #define SpiritPktStackGetBroadcastAddress()                                     SpiritPktCommonGetBroadcastAddress()
00535 
00536 
00537 /**
00538  * @brief  Sets the multicast address. When the multicast filtering is on, if the destination address extracted from the received packet is equal to the content of the
00539  *         MULTICAST_ADDR register, then the packet is accepted.
00540  * @param  cAddress Multicast address.
00541  *         This parameter is an uint8_t.
00542  * @retval None.
00543  */
00544 #define SpiritPktStackSetMulticastAddress(cAddress)                             SpiritPktCommonSetMulticastAddress(cAddress)
00545 
00546 
00547 /**
00548  * @brief  Returns the multicast address.
00549  * @param  None.
00550  * @retval uint8_t Multicast address.
00551  */
00552 #define SpiritPktStackGetMulticastAddress()                                     SpiritPktCommonGetMulticastAddress()
00553 
00554 
00555 /**
00556  * @brief  Sets the control mask. The 1 bits of the CONTROL_MASK indicate the
00557  *         bits to be used in filtering. (All 0s no filtering)
00558  * @param  lMask Control mask.
00559  *         This parameter is an uint32_t.
00560  * @retval None.
00561  */
00562 #define SpiritPktStackSetCtrlMask(lMask)                                        SpiritPktCommonSetCtrlMask(lMask)
00563 
00564 
00565 /**
00566  * @brief  Returns the control mask. The 1 bits of the CONTROL_MASK indicate the
00567  *         bits to be used in filtering. (All 0s no filtering)
00568  * @param  None.
00569  * @retval uint32_t Control mask.
00570  */
00571 #define SpiritPktStackGetCtrlMask()                                             SpiritPktCommonGetCtrlMask()
00572 
00573 
00574 /**
00575  * @brief  Sets the control field reference. If the bits enabled by the
00576  *         CONTROL_MASK match the ones of the control fields extracted from the received packet
00577  *         then the packet is accepted.
00578  * @param  lReference Control reference.
00579  *         This parameter is an uint32_t.
00580  * @retval None.
00581  */
00582 #define SpiritPktStackSetCtrlReference(lReference)                              SpiritPktCommonSetCtrlReference(lReference)
00583 
00584 
00585 /**
00586  * @brief  Returns the control field reference.
00587  * @param  None.
00588  * @retval uint32_t Control reference.
00589  */
00590 #define SpiritPktStackGetCtrlReference()                                        SpiritPktCommonGetCtrlReference()
00591 
00592 
00593 /**
00594  * @brief  Sets the TX control field.
00595  * @param  lField TX CONTROL FIELD.
00596  *         This parameter is an uint32_t.
00597  * @retval None.
00598  */
00599 #define SpiritPktStackSetTransmittedCtrlField(lField)                           SpiritPktCommonSetTransmittedCtrlField(lField)
00600 
00601 
00602 /**
00603  * @brief  Returns the TX control field.
00604  * @param  None.
00605  * @retval uint32_t Control field of the transmitted packet.
00606  */
00607 #define SpiritPktStackGetTransmittedCtrlField()                                 SpiritPktCommonGetTransmittedCtrlField()
00608 
00609 
00610 /**
00611  * @brief  If enabled RX packet is accepted if its destination address matches with TX_SOURCE_ADDRESS.
00612  * @param  xNewState new state for DEST_VS_SOURCE_ADDRESS.
00613  *         This parameter can be S_ENABLE or S_DISABLE.
00614  * @retval None.
00615  */
00616 #define SpiritPktStackFilterOnMyAddress(xNewState)                               SpiritPktCommonFilterOnMyAddress(xNewState)
00617 
00618 
00619 /**
00620  * @brief  If enabled RX packet is accepted if its destination address matches with MULTICAST_ADDRESS.
00621  * @param  xNewState new state for DEST_VS_MULTICAST_ADDRESS.
00622  *         This parameter can be S_ENABLE or S_DISABLE.
00623  * @retval None.
00624  */
00625 #define SpiritPktStackFilterOnMulticastAddress(xNewState)                        SpiritPktCommonFilterOnMulticastAddress(xNewState)
00626 
00627 
00628 /**
00629  * @brief  If enabled RX packet is accepted if its destination address matches with BROADCAST_ADDRESS.
00630  * @param  xNewState new state for DEST_VS_BROADCAST_ADDRESS.
00631  *         This parameter can be S_ENABLE or S_DISABLE.
00632  * @retval None.
00633  */
00634 #define SpiritPktStackFilterOnBroadcastAddress(xNewState)                        SpiritPktCommonFilterOnBroadcastAddress(xNewState)
00635 
00636 
00637 /**
00638  * @brief  Returns the enable bit of the my address filtering.
00639  * @param  None.
00640  * @retval SpiritFunctionalStateThis parameter can be S_ENABLE or S_DISABLE.
00641  */
00642 #define SpiritPktStackGetFilterOnMyAddress()                                    SpiritPktCommonGetFilterOnMyAddress();
00643 
00644 
00645 /**
00646  * @brief  Returns the enable bit of the multicast address filtering.
00647  * @param  None.
00648  * @retval SpiritFunctionalState This parameter can be S_ENABLE or S_DISABLE.
00649  */
00650 #define SpiritPktStackGetFilterOnMulticastAddress()                             SpiritPktCommonGetFilterOnMulticastAddress();
00651 
00652 
00653 /**
00654  * @brief  Returns the enable bit of the broadcast address filtering.
00655  * @param  None.
00656  * @retval SpiritFunctionalState This parameter can be S_ENABLE or S_DISABLE.
00657  */
00658 #define SpiritPktStackGetFilterOnBroadcastAddress()                             SpiritPktCommonGetFilterOnBroadcastAddress();
00659 
00660 
00661 /**
00662  * @brief  Returns the control field of the received packet.
00663  * @param  None.
00664  * @retval uint32_t Received control field.
00665  */
00666 #define SpiritPktStackGetReceivedCtrlField()                                     SpiritPktCommonGetReceivedCtrlField()
00667 
00668 
00669 /**
00670  * @brief  Returns the CRC field of the received packet.
00671  * @param  cCrcFieldVect array in which the CRC field has to be stored.
00672  *         This parameter is an uint8_t array of 3 elements.
00673  * @retval None.
00674  */
00675 #define SpiritPktStackGetReceivedCrcField(cCrcFieldVect)                         SpiritPktCommonGetReceivedCrcField(cCrcFieldVect)
00676 
00677 /**
00678  * @brief  Sets the AUTO ACKNOLEDGEMENT mechanism on the receiver. When the feature is enabled and
00679  *         a data packet has been correctly received, then an acknowledgement packet is sent back to the originator of the received
00680  *         packet. If the PIGGYBACKING bit is also set, payload data will be read from the FIFO; otherwise an empty packet is sent
00681  *         only containing the source and destination addresses and the sequence number of the packet being acknowledged.
00682  * @param  xAutoAck new state for autoack.
00683  *         This parameter can be: S_ENABLE or S_DISABLE.
00684  * @param  xPiggybacking new state for autoack.
00685  *         This parameter can be: S_ENABLE or S_DISABLE.
00686  * @retval None.
00687  */
00688 #define SpiritPktStackAutoAck(xAutoAck, xPiggybacking)                          SpiritPktCommonAutoAck(xAutoAck, xPiggybacking)
00689 
00690 
00691 /**
00692  * @brief  Sets the AUTO ACKNOLEDGEMENT mechanism on the transmitter. On the transmitter side, the NACK_TX field can be used to require or not an acknowledgment for each individual packet: if
00693  *         NACK_TX is set to "1" then acknowledgment will not be required; if NACK_TX is set to "0" then acknowledgment will be
00694  *         required.
00695  * @param  xNewState new state for TX_AUTOACK.
00696  *         This parameter can be: S_ENABLE or S_DISABLE.
00697  * @retval None.
00698  */
00699 #define SpiritPktStackRequireAck(xNewState)                                     SpiritPktCommonRequireAck(xNewState)
00700 
00701 
00702 /**
00703  * @brief  Sets the TX sequence number to be used to start counting.
00704  * @param  cSeqNumberReload new value for Tx seq number reload.
00705  *         This parameter can be: S_ENABLE or S_DISABLE.
00706  * @retval None.
00707  */
00708 #define SpiritPktStackSetTransmittedSeqNumberReload(cSeqNumberReload)           SpiritPktCommonSetTransmittedSeqNumberReload(cSeqNumberReload)
00709 
00710 
00711 /**
00712  * @brief  Sets the max number of automatic retransmission.
00713  * @param  xNMaxReTx max number of retransmission.
00714  *         This parameter can be any value of @ref PktNMaxReTx.
00715  * @retval None.
00716  */
00717 #define SpiritPktStackSetNMaxReTx(xNMaxReTx)                                    SpiritPktCommonSetNMaxReTx((PktNMaxReTx)xNMaxReTx)
00718 
00719 
00720 /**
00721  * @brief  Returns the max number of automatic retransmission.
00722  * @param  None.
00723  * @retval uint8_t Max number of retransmissions.
00724  */
00725 #define SpiritPktStackGetNMaxReTx()                                             SpiritPktCommonGetNMaxReTx()
00726 
00727 
00728 /**
00729  * @brief  Returns the TX ACK request.
00730  * @param  None.
00731  * @retval SpiritFunctionalState.
00732  */
00733 #define SpiritPktStackGetGetTxAckRequest()                                       SpiritPktCommonGetTxAckRequest()
00734 
00735 /**
00736  * @brief  Returns the destination address of the received packet.
00737  * @param  None.
00738  * @retval uint8_t Destination address of the received packet.
00739  */
00740 #define SpiritPktStackGetReceivedDestAddress()                                  SpiritPktCommonGetReceivedDestAddress()
00741 
00742 
00743 /**
00744  * @brief  Returns the source address of the received packet.
00745  * @param  None.
00746  * @retval uint8_t Source address of the received packet.
00747  */
00748 #define SpiritPktStackGetReceivedSourceAddress()                                SpiritPktCommonGetReceivedSourceAddress()
00749 
00750 
00751 /**
00752  * @brief  Returns the sequence number of the received packet.
00753  * @param  None.
00754  * @retval uint8_t Received Sequence number.
00755  */
00756 #define SpiritPktStackGetReceivedSeqNumber()                                    SpiritPktCommonGetReceivedSeqNumber()
00757 
00758 
00759 /**
00760  * @brief  Returns the Nack bit of the received packet
00761  * @param  None.
00762  * @retval uint8_t Value of the NAck bit.
00763  */
00764 #define SpiritPktStackGetReceivedNackRx()                                       SpiritPktCommonGetReceivedNackRx()
00765 
00766 
00767 /**
00768  * @brief  Returns the sequence number of the transmitted packet.
00769  * @param  None.
00770  * @retval uint8_t Sequence number of the transmitted packet.
00771  */
00772 #define SpiritPktStackGetTransmittedSeqNumber()                                 SpiritPktCommonGetTransmittedSeqNumber()
00773 
00774 
00775 /**
00776  * @brief  Returns the number of retransmission done on the transmitted packet.
00777  * @param  None.
00778  * @retval uint8_t Number of retransmissions done until now.
00779  */
00780 #define SpiritPktStackGetNReTx()                                                SpiritPktCommonGetNReTx()
00781 
00782 
00783 /**
00784  * @brief  If enabled RX packet is accepted only if the masked control field matches the
00785  *         masked control field reference (CONTROL_MASK & CONTROL_FIELD_REF == CONTROL_MASK & RX_CONTROL_FIELD).
00786  * @param  xNewState new state for Control filtering enable bit.
00787  *         This parameter can be S_ENABLE or S_DISABLE.
00788  * @retval None.
00789  * @note   This filtering control is enabled by default but the control mask is by default set to 0.
00790  *         As a matter of fact the user has to enable the control filtering bit after the packet initialization
00791  *         because the PktInit routine disables it.
00792  */
00793 #define SpiritPktStackFilterOnControlField(xNewState)                           SpiritPktCommonFilterOnControlField(xNewState)
00794 
00795 
00796 /**
00797  * @brief  Returns the enable bit of the control field filtering.
00798  * @param  None.
00799  * @retval SpiritFunctionalState This parameter can be S_ENABLE or S_DISABLE.
00800  */
00801 #define SpiritPktStackGetFilterOnControlField()                                 SpiritPktCommonGetFilterOnControlField();
00802 
00803 
00804 /**
00805  *@}
00806  */
00807 
00808 
00809 /**
00810  * @defgroup PktStack_Exported_Functions        Pkt STack Exported Functions
00811  * @{
00812  */
00813 
00814 void SpiritPktStackInit(PktStackInit* pxPktStackInit);
00815 void SpiritPktStackGetInfo(PktStackInit* pxPktStackInit);
00816 void SpiritPktStackAddressesInit(PktStackAddressesInit* pxPktStackAddresses);
00817 void SpiritPktStackGetAddressesInfo(PktStackAddressesInit* pxPktStackAddresses);
00818 void SpiritPktStackLlpInit(PktStackLlpInit* pxPktStackLlpInit);
00819 void SpiritPktStackLlpGetInfo(PktStackLlpInit* pxPktStackLlpInit);
00820 void SpiritPktStackSetFormat(void);
00821 void SpiritPktStackSetPayloadLength(uint16_t nPayloadLength);
00822 uint16_t SpiritPktStackGetPayloadLength(void);
00823 void SpiritPktStackSetVarLengthWidth(uint16_t nMaxPayloadLength, StackControlLength xControlLength);
00824 void SpiritPktStackSetRxSourceMask(uint8_t cMask);
00825 uint8_t SpiritPktStackGetRxSourceMask(void);
00826 uint16_t SpiritPktStackGetReceivedPktLength(void);
00827 void SpiritPktStackFilterOnSourceAddress(SpiritFunctionalState xNewState);
00828 void SpiritPktStackSetAddressLength(void);
00829 
00830 /**
00831  *@}
00832  */
00833 
00834 /**
00835  *@}
00836  */
00837 
00838 
00839 /**
00840  *@}
00841  */
00842 
00843 #ifdef __cplusplus
00844 }
00845 #endif
00846 
00847 #endif
00848 
00849 /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/