Prototype RF driver for STM Sub-1 GHz RF expansion board based on the SPSGRF-868 module for STM32 Nucleo.

Prototype RF Driver for STM Sub-1 GHz RF Expansion Boards based on the SPSGRF-868 and SPSGRF-915 Modules for STM32 Nucleo

Currently supported boards:

Note, in order to use expansion board X-NUCLEO-IDS01A4 in mbed you need to perform the following HW modifications on the board:

  • Unmount resistor R4
  • Mount resistor R7

Furthermore, on some Nucleo development boards (e.g. the NUCLEO_F429ZI), in order to be able to use Ethernet together with these Sub-1 GHz RF expansion boards, you need to compile this driver with macro SPIRIT1_SPI_MOSI=PB_5 defined, while the development board typically requires some HW modification as e.g. described here!

This driver can be used together with the 6LoWPAN stack (a.k.a. Nanostack).

Committer:
Wolfgang Betz
Date:
Thu Oct 13 15:41:39 2016 +0200
Revision:
0:4fb29d9ee571
First compiling version (without warnings)

Who changed what in which revision?

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