Fork of my original MQTTGateway

Dependencies:   mbed-http

Committer:
vpcola
Date:
Sat Apr 08 14:43:14 2017 +0000
Revision:
0:a1734fe1ec4b
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vpcola 0:a1734fe1ec4b 1 /**
vpcola 0:a1734fe1ec4b 2 ******************************************************************************
vpcola 0:a1734fe1ec4b 3 * @file SPIRIT_PktCommon.h
vpcola 0:a1734fe1ec4b 4 * @author VMA division - AMS
vpcola 0:a1734fe1ec4b 5 * @version 3.2.2
vpcola 0:a1734fe1ec4b 6 * @date 08-July-2015
vpcola 0:a1734fe1ec4b 7 * @brief Configuration and management of the common features of SPIRIT packets.
vpcola 0:a1734fe1ec4b 8 *
vpcola 0:a1734fe1ec4b 9 * @details
vpcola 0:a1734fe1ec4b 10 *
vpcola 0:a1734fe1ec4b 11 * This module provides all the common functions and definitions used by the
vpcola 0:a1734fe1ec4b 12 * packets modules.
vpcola 0:a1734fe1ec4b 13 * Here are also defined all the generic enumeration types that are redefined
vpcola 0:a1734fe1ec4b 14 * in the specific packets modules, but every enumeration value is referred
vpcola 0:a1734fe1ec4b 15 * to this module. So the user who wants to configure the preamble of a Basic,
vpcola 0:a1734fe1ec4b 16 * or a STack packet has to use the enumeration values defined here.
vpcola 0:a1734fe1ec4b 17 *
vpcola 0:a1734fe1ec4b 18 * <b>Example:</b>
vpcola 0:a1734fe1ec4b 19 * @code
vpcola 0:a1734fe1ec4b 20 *
vpcola 0:a1734fe1ec4b 21 * ...
vpcola 0:a1734fe1ec4b 22 *
vpcola 0:a1734fe1ec4b 23 * SpiritPktBasicSetPreambleLength(PKT_PREAMBLE_LENGTH_18BYTES);
vpcola 0:a1734fe1ec4b 24 *
vpcola 0:a1734fe1ec4b 25 * ...
vpcola 0:a1734fe1ec4b 26 *
vpcola 0:a1734fe1ec4b 27 * @endcode
vpcola 0:a1734fe1ec4b 28 *
vpcola 0:a1734fe1ec4b 29 * @note Is recommended for the user to not use these API directly
vpcola 0:a1734fe1ec4b 30 * importing this module in his application.
vpcola 0:a1734fe1ec4b 31 *
vpcola 0:a1734fe1ec4b 32 *
vpcola 0:a1734fe1ec4b 33 * @attention
vpcola 0:a1734fe1ec4b 34 *
vpcola 0:a1734fe1ec4b 35 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
vpcola 0:a1734fe1ec4b 36 *
vpcola 0:a1734fe1ec4b 37 * Redistribution and use in source and binary forms, with or without modification,
vpcola 0:a1734fe1ec4b 38 * are permitted provided that the following conditions are met:
vpcola 0:a1734fe1ec4b 39 * 1. Redistributions of source code must retain the above copyright notice,
vpcola 0:a1734fe1ec4b 40 * this list of conditions and the following disclaimer.
vpcola 0:a1734fe1ec4b 41 * 2. Redistributions in binary form must reproduce the above copyright notice,
vpcola 0:a1734fe1ec4b 42 * this list of conditions and the following disclaimer in the documentation
vpcola 0:a1734fe1ec4b 43 * and/or other materials provided with the distribution.
vpcola 0:a1734fe1ec4b 44 * 3. Neither the name of STMicroelectronics nor the names of its contributors
vpcola 0:a1734fe1ec4b 45 * may be used to endorse or promote products derived from this software
vpcola 0:a1734fe1ec4b 46 * without specific prior written permission.
vpcola 0:a1734fe1ec4b 47 *
vpcola 0:a1734fe1ec4b 48 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
vpcola 0:a1734fe1ec4b 49 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
vpcola 0:a1734fe1ec4b 50 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
vpcola 0:a1734fe1ec4b 51 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
vpcola 0:a1734fe1ec4b 52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
vpcola 0:a1734fe1ec4b 53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
vpcola 0:a1734fe1ec4b 54 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
vpcola 0:a1734fe1ec4b 55 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
vpcola 0:a1734fe1ec4b 56 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
vpcola 0:a1734fe1ec4b 57 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
vpcola 0:a1734fe1ec4b 58 *
vpcola 0:a1734fe1ec4b 59 ******************************************************************************
vpcola 0:a1734fe1ec4b 60 */
vpcola 0:a1734fe1ec4b 61
vpcola 0:a1734fe1ec4b 62 /* Define to prevent recursive inclusion -------------------------------------*/
vpcola 0:a1734fe1ec4b 63 #ifndef __SPIRIT_PKT_COMMON_H
vpcola 0:a1734fe1ec4b 64 #define __SPIRIT_PKT_COMMON_H
vpcola 0:a1734fe1ec4b 65
vpcola 0:a1734fe1ec4b 66 /* Includes ------------------------------------------------------------------*/
vpcola 0:a1734fe1ec4b 67
vpcola 0:a1734fe1ec4b 68 #include "SPIRIT_Regs.h"
vpcola 0:a1734fe1ec4b 69 #include "SPIRIT_Types.h"
vpcola 0:a1734fe1ec4b 70
vpcola 0:a1734fe1ec4b 71
vpcola 0:a1734fe1ec4b 72 #ifdef __cplusplus
vpcola 0:a1734fe1ec4b 73 extern "C" {
vpcola 0:a1734fe1ec4b 74 #endif
vpcola 0:a1734fe1ec4b 75
vpcola 0:a1734fe1ec4b 76
vpcola 0:a1734fe1ec4b 77
vpcola 0:a1734fe1ec4b 78 /**
vpcola 0:a1734fe1ec4b 79 * @addtogroup SPIRIT_Libraries
vpcola 0:a1734fe1ec4b 80 * @{
vpcola 0:a1734fe1ec4b 81 */
vpcola 0:a1734fe1ec4b 82
vpcola 0:a1734fe1ec4b 83
vpcola 0:a1734fe1ec4b 84 /**
vpcola 0:a1734fe1ec4b 85 * @defgroup SPIRIT_PktCommon Pkt Common
vpcola 0:a1734fe1ec4b 86 * @brief Configuration and management of the common features of SPIRIT packets.
vpcola 0:a1734fe1ec4b 87 * @details See the file <i>@ref SPIRIT_PktCommon.h</i> for more details.
vpcola 0:a1734fe1ec4b 88 * @{
vpcola 0:a1734fe1ec4b 89 */
vpcola 0:a1734fe1ec4b 90
vpcola 0:a1734fe1ec4b 91 /**
vpcola 0:a1734fe1ec4b 92 * @defgroup PktCommon_Exported_Types Pkt Common Exported Types
vpcola 0:a1734fe1ec4b 93 * @{
vpcola 0:a1734fe1ec4b 94 */
vpcola 0:a1734fe1ec4b 95
vpcola 0:a1734fe1ec4b 96
vpcola 0:a1734fe1ec4b 97 /**
vpcola 0:a1734fe1ec4b 98 * @brief Preamble length in bytes enumeration.
vpcola 0:a1734fe1ec4b 99 */
vpcola 0:a1734fe1ec4b 100 typedef enum
vpcola 0:a1734fe1ec4b 101 {
vpcola 0:a1734fe1ec4b 102 PKT_PREAMBLE_LENGTH_01BYTE = 0x00, /*!< Preamble length 1 byte*/
vpcola 0:a1734fe1ec4b 103 PKT_PREAMBLE_LENGTH_02BYTES = 0x08, /*!< Preamble length 2 bytes */
vpcola 0:a1734fe1ec4b 104 PKT_PREAMBLE_LENGTH_03BYTES = 0x10, /*!< Preamble length 3 bytes */
vpcola 0:a1734fe1ec4b 105 PKT_PREAMBLE_LENGTH_04BYTES = 0x18, /*!< Preamble length 4 bytes */
vpcola 0:a1734fe1ec4b 106 PKT_PREAMBLE_LENGTH_05BYTES = 0x20, /*!< Preamble length 5 bytes */
vpcola 0:a1734fe1ec4b 107 PKT_PREAMBLE_LENGTH_06BYTES = 0x28, /*!< Preamble length 6 bytes */
vpcola 0:a1734fe1ec4b 108 PKT_PREAMBLE_LENGTH_07BYTES = 0x30, /*!< Preamble length 7 bytes */
vpcola 0:a1734fe1ec4b 109 PKT_PREAMBLE_LENGTH_08BYTES = 0x38, /*!< Preamble length 8 bytes */
vpcola 0:a1734fe1ec4b 110 PKT_PREAMBLE_LENGTH_09BYTES = 0x40, /*!< Preamble length 9 bytes */
vpcola 0:a1734fe1ec4b 111 PKT_PREAMBLE_LENGTH_10BYTES = 0x48, /*!< Preamble length 10 bytes */
vpcola 0:a1734fe1ec4b 112 PKT_PREAMBLE_LENGTH_11BYTES = 0x50, /*!< Preamble length 11 bytes */
vpcola 0:a1734fe1ec4b 113 PKT_PREAMBLE_LENGTH_12BYTES = 0x58, /*!< Preamble length 12 bytes */
vpcola 0:a1734fe1ec4b 114 PKT_PREAMBLE_LENGTH_13BYTES = 0x60, /*!< Preamble length 13 bytes */
vpcola 0:a1734fe1ec4b 115 PKT_PREAMBLE_LENGTH_14BYTES = 0x68, /*!< Preamble length 14 bytes */
vpcola 0:a1734fe1ec4b 116 PKT_PREAMBLE_LENGTH_15BYTES = 0x70, /*!< Preamble length 15 bytes */
vpcola 0:a1734fe1ec4b 117 PKT_PREAMBLE_LENGTH_16BYTES = 0x78, /*!< Preamble length 16 bytes */
vpcola 0:a1734fe1ec4b 118 PKT_PREAMBLE_LENGTH_17BYTES = 0x80, /*!< Preamble length 17 bytes */
vpcola 0:a1734fe1ec4b 119 PKT_PREAMBLE_LENGTH_18BYTES = 0x88, /*!< Preamble length 18 bytes */
vpcola 0:a1734fe1ec4b 120 PKT_PREAMBLE_LENGTH_19BYTES = 0x90, /*!< Preamble length 19 bytes */
vpcola 0:a1734fe1ec4b 121 PKT_PREAMBLE_LENGTH_20BYTES = 0x98, /*!< Preamble length 20 bytes */
vpcola 0:a1734fe1ec4b 122 PKT_PREAMBLE_LENGTH_21BYTES = 0xA0, /*!< Preamble length 21 bytes */
vpcola 0:a1734fe1ec4b 123 PKT_PREAMBLE_LENGTH_22BYTES = 0xA8, /*!< Preamble length 22 bytes */
vpcola 0:a1734fe1ec4b 124 PKT_PREAMBLE_LENGTH_23BYTES = 0xB0, /*!< Preamble length 23 bytes */
vpcola 0:a1734fe1ec4b 125 PKT_PREAMBLE_LENGTH_24BYTES = 0xB8, /*!< Preamble length 24 bytes */
vpcola 0:a1734fe1ec4b 126 PKT_PREAMBLE_LENGTH_25BYTES = 0xC0, /*!< Preamble length 25 bytes */
vpcola 0:a1734fe1ec4b 127 PKT_PREAMBLE_LENGTH_26BYTES = 0xC8, /*!< Preamble length 26 bytes */
vpcola 0:a1734fe1ec4b 128 PKT_PREAMBLE_LENGTH_27BYTES = 0xD0, /*!< Preamble length 27 bytes */
vpcola 0:a1734fe1ec4b 129 PKT_PREAMBLE_LENGTH_28BYTES = 0xD8, /*!< Preamble length 28 bytes */
vpcola 0:a1734fe1ec4b 130 PKT_PREAMBLE_LENGTH_29BYTES = 0xE0, /*!< Preamble length 29 bytes */
vpcola 0:a1734fe1ec4b 131 PKT_PREAMBLE_LENGTH_30BYTES = 0xE8, /*!< Preamble length 30 bytes */
vpcola 0:a1734fe1ec4b 132 PKT_PREAMBLE_LENGTH_31BYTES = 0xF0, /*!< Preamble length 31 bytes */
vpcola 0:a1734fe1ec4b 133 PKT_PREAMBLE_LENGTH_32BYTES = 0xF8 /*!< Preamble length 32 bytes */
vpcola 0:a1734fe1ec4b 134
vpcola 0:a1734fe1ec4b 135 }PktPreambleLength;
vpcola 0:a1734fe1ec4b 136
vpcola 0:a1734fe1ec4b 137 #define IS_PKT_PREAMBLE_LENGTH(LENGTH) ((LENGTH == PKT_PREAMBLE_LENGTH_01BYTE) || \
vpcola 0:a1734fe1ec4b 138 (LENGTH == PKT_PREAMBLE_LENGTH_02BYTES) || \
vpcola 0:a1734fe1ec4b 139 (LENGTH == PKT_PREAMBLE_LENGTH_03BYTES) || \
vpcola 0:a1734fe1ec4b 140 (LENGTH == PKT_PREAMBLE_LENGTH_04BYTES) || \
vpcola 0:a1734fe1ec4b 141 (LENGTH == PKT_PREAMBLE_LENGTH_05BYTES) || \
vpcola 0:a1734fe1ec4b 142 (LENGTH == PKT_PREAMBLE_LENGTH_06BYTES) || \
vpcola 0:a1734fe1ec4b 143 (LENGTH == PKT_PREAMBLE_LENGTH_07BYTES) || \
vpcola 0:a1734fe1ec4b 144 (LENGTH == PKT_PREAMBLE_LENGTH_08BYTES) || \
vpcola 0:a1734fe1ec4b 145 (LENGTH == PKT_PREAMBLE_LENGTH_09BYTES) || \
vpcola 0:a1734fe1ec4b 146 (LENGTH == PKT_PREAMBLE_LENGTH_10BYTES) || \
vpcola 0:a1734fe1ec4b 147 (LENGTH == PKT_PREAMBLE_LENGTH_11BYTES) || \
vpcola 0:a1734fe1ec4b 148 (LENGTH == PKT_PREAMBLE_LENGTH_12BYTES) || \
vpcola 0:a1734fe1ec4b 149 (LENGTH == PKT_PREAMBLE_LENGTH_13BYTES) || \
vpcola 0:a1734fe1ec4b 150 (LENGTH == PKT_PREAMBLE_LENGTH_14BYTES) || \
vpcola 0:a1734fe1ec4b 151 (LENGTH == PKT_PREAMBLE_LENGTH_15BYTES) || \
vpcola 0:a1734fe1ec4b 152 (LENGTH == PKT_PREAMBLE_LENGTH_16BYTES) || \
vpcola 0:a1734fe1ec4b 153 (LENGTH == PKT_PREAMBLE_LENGTH_17BYTES) || \
vpcola 0:a1734fe1ec4b 154 (LENGTH == PKT_PREAMBLE_LENGTH_18BYTES) || \
vpcola 0:a1734fe1ec4b 155 (LENGTH == PKT_PREAMBLE_LENGTH_19BYTES) || \
vpcola 0:a1734fe1ec4b 156 (LENGTH == PKT_PREAMBLE_LENGTH_20BYTES) || \
vpcola 0:a1734fe1ec4b 157 (LENGTH == PKT_PREAMBLE_LENGTH_21BYTES) || \
vpcola 0:a1734fe1ec4b 158 (LENGTH == PKT_PREAMBLE_LENGTH_22BYTES) || \
vpcola 0:a1734fe1ec4b 159 (LENGTH == PKT_PREAMBLE_LENGTH_23BYTES) || \
vpcola 0:a1734fe1ec4b 160 (LENGTH == PKT_PREAMBLE_LENGTH_24BYTES) || \
vpcola 0:a1734fe1ec4b 161 (LENGTH == PKT_PREAMBLE_LENGTH_25BYTES) || \
vpcola 0:a1734fe1ec4b 162 (LENGTH == PKT_PREAMBLE_LENGTH_26BYTES) || \
vpcola 0:a1734fe1ec4b 163 (LENGTH == PKT_PREAMBLE_LENGTH_27BYTES) || \
vpcola 0:a1734fe1ec4b 164 (LENGTH == PKT_PREAMBLE_LENGTH_28BYTES) || \
vpcola 0:a1734fe1ec4b 165 (LENGTH == PKT_PREAMBLE_LENGTH_29BYTES) || \
vpcola 0:a1734fe1ec4b 166 (LENGTH == PKT_PREAMBLE_LENGTH_30BYTES) || \
vpcola 0:a1734fe1ec4b 167 (LENGTH == PKT_PREAMBLE_LENGTH_31BYTES) || \
vpcola 0:a1734fe1ec4b 168 (LENGTH == PKT_PREAMBLE_LENGTH_32BYTES))
vpcola 0:a1734fe1ec4b 169
vpcola 0:a1734fe1ec4b 170
vpcola 0:a1734fe1ec4b 171
vpcola 0:a1734fe1ec4b 172 /**
vpcola 0:a1734fe1ec4b 173 * @brief Sync length in bytes enumeration.
vpcola 0:a1734fe1ec4b 174 */
vpcola 0:a1734fe1ec4b 175 typedef enum
vpcola 0:a1734fe1ec4b 176 {
vpcola 0:a1734fe1ec4b 177 PKT_SYNC_LENGTH_1BYTE = 0x00, /*!< Sync length 1 byte*/
vpcola 0:a1734fe1ec4b 178 PKT_SYNC_LENGTH_2BYTES = 0x02, /*!< Sync length 2 bytes*/
vpcola 0:a1734fe1ec4b 179 PKT_SYNC_LENGTH_3BYTES = 0x04, /*!< Sync length 3 bytes */
vpcola 0:a1734fe1ec4b 180 PKT_SYNC_LENGTH_4BYTES = 0x06 , /*!< Sync length 4 bytes */
vpcola 0:a1734fe1ec4b 181
vpcola 0:a1734fe1ec4b 182 }PktSyncLength;
vpcola 0:a1734fe1ec4b 183
vpcola 0:a1734fe1ec4b 184 #define IS_PKT_SYNC_LENGTH(LENGTH) ((LENGTH == PKT_SYNC_LENGTH_1BYTE) || \
vpcola 0:a1734fe1ec4b 185 (LENGTH == PKT_SYNC_LENGTH_2BYTES)|| \
vpcola 0:a1734fe1ec4b 186 (LENGTH == PKT_SYNC_LENGTH_3BYTES)|| \
vpcola 0:a1734fe1ec4b 187 (LENGTH == PKT_SYNC_LENGTH_4BYTES))
vpcola 0:a1734fe1ec4b 188
vpcola 0:a1734fe1ec4b 189
vpcola 0:a1734fe1ec4b 190
vpcola 0:a1734fe1ec4b 191 /**
vpcola 0:a1734fe1ec4b 192 * @brief CRC length in bytes enumeration.
vpcola 0:a1734fe1ec4b 193 */
vpcola 0:a1734fe1ec4b 194 typedef enum
vpcola 0:a1734fe1ec4b 195 {
vpcola 0:a1734fe1ec4b 196 PKT_NO_CRC = 0x00, /*!< No CRC */
vpcola 0:a1734fe1ec4b 197 PKT_CRC_MODE_8BITS = 0x20, /*!< CRC length 8 bits - poly: 0x07 */
vpcola 0:a1734fe1ec4b 198 PKT_CRC_MODE_16BITS_1 = 0x40, /*!< CRC length 16 bits - poly: 0x8005 */
vpcola 0:a1734fe1ec4b 199 PKT_CRC_MODE_16BITS_2 = 0x60, /*!< CRC length 16 bits - poly: 0x1021 */
vpcola 0:a1734fe1ec4b 200 PKT_CRC_MODE_24BITS = 0x80, /*!< CRC length 24 bits - poly: 0x864CFB */
vpcola 0:a1734fe1ec4b 201
vpcola 0:a1734fe1ec4b 202 }PktCrcMode;
vpcola 0:a1734fe1ec4b 203
vpcola 0:a1734fe1ec4b 204 #define IS_PKT_CRC_MODE(MODE) ((MODE == PKT_NO_CRC) || \
vpcola 0:a1734fe1ec4b 205 (MODE == PKT_CRC_MODE_8BITS) || \
vpcola 0:a1734fe1ec4b 206 (MODE == PKT_CRC_MODE_16BITS_1) || \
vpcola 0:a1734fe1ec4b 207 (MODE == PKT_CRC_MODE_16BITS_2) || \
vpcola 0:a1734fe1ec4b 208 (MODE == PKT_CRC_MODE_24BITS))
vpcola 0:a1734fe1ec4b 209
vpcola 0:a1734fe1ec4b 210
vpcola 0:a1734fe1ec4b 211
vpcola 0:a1734fe1ec4b 212 /**
vpcola 0:a1734fe1ec4b 213 * @brief Fixed or variable payload length enumeration.
vpcola 0:a1734fe1ec4b 214 */
vpcola 0:a1734fe1ec4b 215 typedef enum
vpcola 0:a1734fe1ec4b 216 {
vpcola 0:a1734fe1ec4b 217 PKT_LENGTH_FIX = 0x00, /*!< Fixed payload length */
vpcola 0:a1734fe1ec4b 218 PKT_LENGTH_VAR = 0x01 /*!< Variable payload length */
vpcola 0:a1734fe1ec4b 219
vpcola 0:a1734fe1ec4b 220 }PktFixVarLength;
vpcola 0:a1734fe1ec4b 221
vpcola 0:a1734fe1ec4b 222 #define IS_PKT_FIX_VAR_LENGTH(LENGTH) ((LENGTH == PKT_LENGTH_FIX) || \
vpcola 0:a1734fe1ec4b 223 (LENGTH == PKT_LENGTH_VAR))
vpcola 0:a1734fe1ec4b 224
vpcola 0:a1734fe1ec4b 225
vpcola 0:a1734fe1ec4b 226 /**
vpcola 0:a1734fe1ec4b 227 * @brief Control length in bytes enumeration for SPIRIT packets.
vpcola 0:a1734fe1ec4b 228 */
vpcola 0:a1734fe1ec4b 229 typedef enum
vpcola 0:a1734fe1ec4b 230 {
vpcola 0:a1734fe1ec4b 231 PKT_CONTROL_LENGTH_0BYTES = 0x00, /*!< Control length 0 byte*/
vpcola 0:a1734fe1ec4b 232 PKT_CONTROL_LENGTH_1BYTE, /*!< Control length 1 byte*/
vpcola 0:a1734fe1ec4b 233 PKT_CONTROL_LENGTH_2BYTES, /*!< Control length 2 bytes*/
vpcola 0:a1734fe1ec4b 234 PKT_CONTROL_LENGTH_3BYTES, /*!< Control length 3 bytes*/
vpcola 0:a1734fe1ec4b 235 PKT_CONTROL_LENGTH_4BYTES /*!< Control length 4 bytes*/
vpcola 0:a1734fe1ec4b 236
vpcola 0:a1734fe1ec4b 237 }PktControlLength;
vpcola 0:a1734fe1ec4b 238
vpcola 0:a1734fe1ec4b 239 #define IS_PKT_CONTROL_LENGTH(LENGTH) ((LENGTH == PKT_CONTROL_LENGTH_0BYTES) || \
vpcola 0:a1734fe1ec4b 240 (LENGTH == PKT_CONTROL_LENGTH_1BYTE) || \
vpcola 0:a1734fe1ec4b 241 (LENGTH == PKT_CONTROL_LENGTH_2BYTES) || \
vpcola 0:a1734fe1ec4b 242 (LENGTH == PKT_CONTROL_LENGTH_3BYTES) || \
vpcola 0:a1734fe1ec4b 243 (LENGTH == PKT_CONTROL_LENGTH_4BYTES))
vpcola 0:a1734fe1ec4b 244
vpcola 0:a1734fe1ec4b 245 /**
vpcola 0:a1734fe1ec4b 246 * @brief Sync words enumeration for SPIRIT packets.
vpcola 0:a1734fe1ec4b 247 */
vpcola 0:a1734fe1ec4b 248 typedef enum
vpcola 0:a1734fe1ec4b 249 {
vpcola 0:a1734fe1ec4b 250 PKT_SYNC_WORD_1=0x01, /*!< Index of the 1st sync word*/
vpcola 0:a1734fe1ec4b 251 PKT_SYNC_WORD_2, /*!< Index of the 2nd sync word*/
vpcola 0:a1734fe1ec4b 252 PKT_SYNC_WORD_3, /*!< Index of the 3rd sync word*/
vpcola 0:a1734fe1ec4b 253 PKT_SYNC_WORD_4 /*!< Index of the 4th sync word*/
vpcola 0:a1734fe1ec4b 254
vpcola 0:a1734fe1ec4b 255 }PktSyncX;
vpcola 0:a1734fe1ec4b 256
vpcola 0:a1734fe1ec4b 257 #define IS_PKT_SYNCx(WORD) ((WORD == PKT_SYNC_WORD_1) || \
vpcola 0:a1734fe1ec4b 258 (WORD == PKT_SYNC_WORD_2) || \
vpcola 0:a1734fe1ec4b 259 (WORD == PKT_SYNC_WORD_3) || \
vpcola 0:a1734fe1ec4b 260 (WORD == PKT_SYNC_WORD_4))
vpcola 0:a1734fe1ec4b 261
vpcola 0:a1734fe1ec4b 262
vpcola 0:a1734fe1ec4b 263
vpcola 0:a1734fe1ec4b 264 /**
vpcola 0:a1734fe1ec4b 265 * @brief Max retransmissions number enumeration for SPIRIT packets.
vpcola 0:a1734fe1ec4b 266 */
vpcola 0:a1734fe1ec4b 267 typedef enum
vpcola 0:a1734fe1ec4b 268 {
vpcola 0:a1734fe1ec4b 269 PKT_DISABLE_RETX = 0x00, /*!< No retrasmissions*/
vpcola 0:a1734fe1ec4b 270 PKT_N_RETX_1 = 0x10, /*!< Max retrasmissions 1*/
vpcola 0:a1734fe1ec4b 271 PKT_N_RETX_2 = 0x20, /*!< Max retrasmissions 2*/
vpcola 0:a1734fe1ec4b 272 PKT_N_RETX_3 = 0x30, /*!< Max retrasmissions 3*/
vpcola 0:a1734fe1ec4b 273 PKT_N_RETX_4 = 0x40, /*!< Max retrasmissions 4*/
vpcola 0:a1734fe1ec4b 274 PKT_N_RETX_5 = 0x50, /*!< Max retrasmissions 5*/
vpcola 0:a1734fe1ec4b 275 PKT_N_RETX_6 = 0x60, /*!< Max retrasmissions 6*/
vpcola 0:a1734fe1ec4b 276 PKT_N_RETX_7 = 0x70, /*!< Max retrasmissions 7*/
vpcola 0:a1734fe1ec4b 277 PKT_N_RETX_8 = 0x80, /*!< Max retrasmissions 8*/
vpcola 0:a1734fe1ec4b 278 PKT_N_RETX_9 = 0x90, /*!< Max retrasmissions 9*/
vpcola 0:a1734fe1ec4b 279 PKT_N_RETX_10 = 0xA0, /*!< Max retrasmissions 10*/
vpcola 0:a1734fe1ec4b 280 PKT_N_RETX_11 = 0xB0, /*!< Max retrasmissions 11*/
vpcola 0:a1734fe1ec4b 281 PKT_N_RETX_12 = 0xC0, /*!< Max retrasmissions 12*/
vpcola 0:a1734fe1ec4b 282 PKT_N_RETX_13 = 0xD0, /*!< Max retrasmissions 13*/
vpcola 0:a1734fe1ec4b 283 PKT_N_RETX_14 = 0xE0, /*!< Max retrasmissions 14*/
vpcola 0:a1734fe1ec4b 284 PKT_N_RETX_15 = 0xF0 /*!< Max retrasmissions 15*/
vpcola 0:a1734fe1ec4b 285
vpcola 0:a1734fe1ec4b 286 }PktNMaxReTx;
vpcola 0:a1734fe1ec4b 287
vpcola 0:a1734fe1ec4b 288 #define IS_PKT_NMAX_RETX(N_RETX) ((N_RETX == PKT_DISABLE_RETX) || \
vpcola 0:a1734fe1ec4b 289 (N_RETX == PKT_N_RETX_1) || \
vpcola 0:a1734fe1ec4b 290 (N_RETX == PKT_N_RETX_2) || \
vpcola 0:a1734fe1ec4b 291 (N_RETX == PKT_N_RETX_3) || \
vpcola 0:a1734fe1ec4b 292 (N_RETX == PKT_N_RETX_4) || \
vpcola 0:a1734fe1ec4b 293 (N_RETX == PKT_N_RETX_5) || \
vpcola 0:a1734fe1ec4b 294 (N_RETX == PKT_N_RETX_6) || \
vpcola 0:a1734fe1ec4b 295 (N_RETX == PKT_N_RETX_7) || \
vpcola 0:a1734fe1ec4b 296 (N_RETX == PKT_N_RETX_8) || \
vpcola 0:a1734fe1ec4b 297 (N_RETX == PKT_N_RETX_9) || \
vpcola 0:a1734fe1ec4b 298 (N_RETX == PKT_N_RETX_10) || \
vpcola 0:a1734fe1ec4b 299 (N_RETX == PKT_N_RETX_11) || \
vpcola 0:a1734fe1ec4b 300 (N_RETX == PKT_N_RETX_12) || \
vpcola 0:a1734fe1ec4b 301 (N_RETX == PKT_N_RETX_13) || \
vpcola 0:a1734fe1ec4b 302 (N_RETX == PKT_N_RETX_14) || \
vpcola 0:a1734fe1ec4b 303 (N_RETX == PKT_N_RETX_15))
vpcola 0:a1734fe1ec4b 304
vpcola 0:a1734fe1ec4b 305
vpcola 0:a1734fe1ec4b 306 /**
vpcola 0:a1734fe1ec4b 307 *@}
vpcola 0:a1734fe1ec4b 308 */
vpcola 0:a1734fe1ec4b 309
vpcola 0:a1734fe1ec4b 310
vpcola 0:a1734fe1ec4b 311 /**
vpcola 0:a1734fe1ec4b 312 * @defgroup PktCommon_Exported_Constants Pkt Common Exported Constants
vpcola 0:a1734fe1ec4b 313 * @{
vpcola 0:a1734fe1ec4b 314 */
vpcola 0:a1734fe1ec4b 315
vpcola 0:a1734fe1ec4b 316 #define IS_PKT_LENGTH_WIDTH_BITS(BITS) (BITS<=16)
vpcola 0:a1734fe1ec4b 317 #define IS_PKT_SEQ_NUMBER_RELOAD(SEQN) (SEQN<=3)
vpcola 0:a1734fe1ec4b 318
vpcola 0:a1734fe1ec4b 319 /**
vpcola 0:a1734fe1ec4b 320 *@}
vpcola 0:a1734fe1ec4b 321 */
vpcola 0:a1734fe1ec4b 322
vpcola 0:a1734fe1ec4b 323
vpcola 0:a1734fe1ec4b 324 /**
vpcola 0:a1734fe1ec4b 325 * @defgroup PktCommon_Exported_Macros Pkt Common Exported Macros
vpcola 0:a1734fe1ec4b 326 * @{
vpcola 0:a1734fe1ec4b 327 */
vpcola 0:a1734fe1ec4b 328
vpcola 0:a1734fe1ec4b 329
vpcola 0:a1734fe1ec4b 330 /**
vpcola 0:a1734fe1ec4b 331 * @brief Macro used to compute the lower part of the packet length, to write in the PCKTLEN0 register
vpcola 0:a1734fe1ec4b 332 * @param nLength Length of the packet payload.
vpcola 0:a1734fe1ec4b 333 * This parameter is an uint16_t.
vpcola 0:a1734fe1ec4b 334 * @retval None.
vpcola 0:a1734fe1ec4b 335 */
vpcola 0:a1734fe1ec4b 336 #define BUILD_PCKTLEN0(nLength) ((nLength) & 0xFF)
vpcola 0:a1734fe1ec4b 337
vpcola 0:a1734fe1ec4b 338
vpcola 0:a1734fe1ec4b 339 /**
vpcola 0:a1734fe1ec4b 340 * @brief Macro used to compute the upper part of the packet length, to write the PCKTLEN1 register
vpcola 0:a1734fe1ec4b 341 * @param nLength Length of the packet payload.
vpcola 0:a1734fe1ec4b 342 * This parameter is an uint16_t.
vpcola 0:a1734fe1ec4b 343 * @retval None.
vpcola 0:a1734fe1ec4b 344 */
vpcola 0:a1734fe1ec4b 345 #define BUILD_PCKTLEN1(nLength) ((nLength) >> 8)
vpcola 0:a1734fe1ec4b 346
vpcola 0:a1734fe1ec4b 347 /**
vpcola 0:a1734fe1ec4b 348 *@}
vpcola 0:a1734fe1ec4b 349 */
vpcola 0:a1734fe1ec4b 350
vpcola 0:a1734fe1ec4b 351
vpcola 0:a1734fe1ec4b 352 /**
vpcola 0:a1734fe1ec4b 353 * @defgroup PktCommon_Exported_Functions Pkt Common Exported Functions
vpcola 0:a1734fe1ec4b 354 * @{
vpcola 0:a1734fe1ec4b 355 */
vpcola 0:a1734fe1ec4b 356
vpcola 0:a1734fe1ec4b 357 void SpiritPktCommonSetControlLength(PktControlLength xControlLength);
vpcola 0:a1734fe1ec4b 358 uint8_t SpiritPktCommonGetControlLength(void);
vpcola 0:a1734fe1ec4b 359 void SpiritPktCommonSetPreambleLength(PktPreambleLength xPreambleLength);
vpcola 0:a1734fe1ec4b 360 uint8_t SpiritPktCommonGetPreambleLength(void);
vpcola 0:a1734fe1ec4b 361 void SpiritPktCommonSetSyncLength(PktSyncLength xSyncLength);
vpcola 0:a1734fe1ec4b 362 uint8_t SpiritPktCommonGetSyncLength(void);
vpcola 0:a1734fe1ec4b 363 void SpiritPktCommonSetFixVarLength(PktFixVarLength xFixVarLength);
vpcola 0:a1734fe1ec4b 364 void SpiritPktCommonFilterOnCrc(SpiritFunctionalState xNewState);
vpcola 0:a1734fe1ec4b 365 SpiritFunctionalState SpiritPktCommonGetFilterOnCrc(void);
vpcola 0:a1734fe1ec4b 366 void SpiritPktCommonSetCrcMode(PktCrcMode xCrcLength);
vpcola 0:a1734fe1ec4b 367 PktCrcMode SpiritPktCommonGetCrcMode(void);
vpcola 0:a1734fe1ec4b 368 void SpiritPktCommonWhitening(SpiritFunctionalState xNewState);
vpcola 0:a1734fe1ec4b 369 void SpiritPktCommonFec(SpiritFunctionalState xNewState);
vpcola 0:a1734fe1ec4b 370 void SpiritPktCommonSetSyncxWord(PktSyncX xSyncX, uint8_t cSyncWord);
vpcola 0:a1734fe1ec4b 371 uint8_t SpiritPktCommonGetSyncxWord(PktSyncX xSyncX);
vpcola 0:a1734fe1ec4b 372 void SpiritPktCommonSetSyncWords(uint32_t lSyncWords, PktSyncLength xSyncLength);
vpcola 0:a1734fe1ec4b 373 uint32_t SpiritPktCommonGetSyncWords(PktSyncLength xSyncLength);
vpcola 0:a1734fe1ec4b 374 uint8_t SpiritPktCommonGetVarLengthWidth(void);
vpcola 0:a1734fe1ec4b 375 void SpiritPktCommonSetDestinationAddress(uint8_t cAddress);
vpcola 0:a1734fe1ec4b 376 uint8_t SpiritPktCommonGetTransmittedDestAddress(void);
vpcola 0:a1734fe1ec4b 377 void SpiritPktCommonSetMyAddress(uint8_t cAddress);
vpcola 0:a1734fe1ec4b 378 uint8_t SpiritPktCommonGetMyAddress(void);
vpcola 0:a1734fe1ec4b 379 void SpiritPktCommonSetBroadcastAddress(uint8_t cAddress);
vpcola 0:a1734fe1ec4b 380 uint8_t SpiritPktCommonGetBroadcastAddress(void);
vpcola 0:a1734fe1ec4b 381 SpiritFunctionalState SpiritPktCommonGetTxAckRequest(void);
vpcola 0:a1734fe1ec4b 382 void SpiritPktCommonSetMulticastAddress(uint8_t cAddress);
vpcola 0:a1734fe1ec4b 383 uint8_t SpiritPktCommonGetMulticastAddress(void);
vpcola 0:a1734fe1ec4b 384 void SpiritPktCommonSetCtrlMask(uint32_t lMask);
vpcola 0:a1734fe1ec4b 385 uint32_t SpiritPktCommonGetCtrlMask(void);
vpcola 0:a1734fe1ec4b 386 void SpiritPktCommonSetCtrlReference(uint32_t lReference);
vpcola 0:a1734fe1ec4b 387 uint32_t SpiritPktCommonGetCtrlReference(void);
vpcola 0:a1734fe1ec4b 388 void SpiritPktCommonSetTransmittedCtrlField(uint32_t lField);
vpcola 0:a1734fe1ec4b 389 uint32_t SpiritPktCommonGetTransmittedCtrlField(void);
vpcola 0:a1734fe1ec4b 390 void SpiritPktCommonFilterOnMyAddress(SpiritFunctionalState xNewState);
vpcola 0:a1734fe1ec4b 391 void SpiritPktCommonFilterOnMulticastAddress(SpiritFunctionalState xNewState);
vpcola 0:a1734fe1ec4b 392 void SpiritPktCommonFilterOnBroadcastAddress(SpiritFunctionalState xNewState);
vpcola 0:a1734fe1ec4b 393 SpiritFunctionalState SpiritPktCommonGetFilterOnMyAddress(void);
vpcola 0:a1734fe1ec4b 394 SpiritFunctionalState SpiritPktCommonGetFilterOnMulticastAddress(void);
vpcola 0:a1734fe1ec4b 395 SpiritFunctionalState SpiritPktCommonGetFilterOnBroadcastAddress(void);
vpcola 0:a1734fe1ec4b 396 uint8_t SpiritPktCommonGetReceivedDestAddress(void);
vpcola 0:a1734fe1ec4b 397 uint32_t SpiritPktCommonGetReceivedCtrlField(void);
vpcola 0:a1734fe1ec4b 398 void SpiritPktCommonGetReceivedCrcField(uint8_t* cCrcFieldVect);
vpcola 0:a1734fe1ec4b 399 void SpiritPktCommonAutoAck(SpiritFunctionalState xAutoAck,SpiritFunctionalState xPiggybacking);
vpcola 0:a1734fe1ec4b 400 void SpiritPktCommonRequireAck(SpiritFunctionalState xRequireAck);
vpcola 0:a1734fe1ec4b 401 void SpiritPktCommonSetTransmittedSeqNumberReload(uint8_t cSeqNumberReload);
vpcola 0:a1734fe1ec4b 402 void SpiritPktCommonSetNMaxReTx(PktNMaxReTx xNMaxReTx);
vpcola 0:a1734fe1ec4b 403 uint8_t SpiritPktCommonGetNMaxReTx(void);
vpcola 0:a1734fe1ec4b 404 uint8_t SpiritPktCommonGetReceivedDestAddress(void);
vpcola 0:a1734fe1ec4b 405 uint8_t SpiritPktCommonGetReceivedSourceAddress(void);
vpcola 0:a1734fe1ec4b 406 uint8_t SpiritPktCommonGetReceivedSeqNumber(void);
vpcola 0:a1734fe1ec4b 407 uint8_t SpiritPktCommonGetReceivedNackRx(void);
vpcola 0:a1734fe1ec4b 408 uint8_t SpiritPktCommonGetTransmittedSeqNumber(void);
vpcola 0:a1734fe1ec4b 409 uint8_t SpiritPktCommonGetNReTx(void);
vpcola 0:a1734fe1ec4b 410 void SpiritPktCommonFilterOnControlField(SpiritFunctionalState xNewState);
vpcola 0:a1734fe1ec4b 411 SpiritFunctionalState SpiritPktCommonGetFilterOnControlField(void);
vpcola 0:a1734fe1ec4b 412
vpcola 0:a1734fe1ec4b 413 /**
vpcola 0:a1734fe1ec4b 414 *@}
vpcola 0:a1734fe1ec4b 415 */
vpcola 0:a1734fe1ec4b 416
vpcola 0:a1734fe1ec4b 417 /**
vpcola 0:a1734fe1ec4b 418 *@}
vpcola 0:a1734fe1ec4b 419 */
vpcola 0:a1734fe1ec4b 420
vpcola 0:a1734fe1ec4b 421
vpcola 0:a1734fe1ec4b 422 /**
vpcola 0:a1734fe1ec4b 423 *@}
vpcola 0:a1734fe1ec4b 424 */
vpcola 0:a1734fe1ec4b 425
vpcola 0:a1734fe1ec4b 426 #ifdef __cplusplus
vpcola 0:a1734fe1ec4b 427 }
vpcola 0:a1734fe1ec4b 428 #endif
vpcola 0:a1734fe1ec4b 429
vpcola 0:a1734fe1ec4b 430 #endif
vpcola 0:a1734fe1ec4b 431
vpcola 0:a1734fe1ec4b 432 /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/