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