Added support for the WNC M14A2A Cellular LTE Data Module.

Dependencies:   WNC14A2AInterface

Easy Connect

Easily add all supported connectivity methods to your mbed OS project

This project is derived from https://developer.mbed.org/teams/sandbox/code/simple-mbed-client-example/file/dd6231df71bb/easy-connect.lib. It give user the ability to switch between connectivity methods and includes support for the WNC14A2A Data Module. The `NetworkInterface` API makes this easy, but you still need a mechanism for the user to select the connection method, The selection is made by modifying the `mbed_app.json` file and using `easy_connect()` from your application.

Specifying connectivity method

To add support for the WNC14A2A, add the following to your ``mbed_app.json`` file:

mbed_app.json

{
    "config": {
        "network-interface":{
            "help": "options are ETHERNET,WIFI_ESP8266,WIFI_ODIN,MESH_LOWPAN_ND,MESH_THREAD,WNC14A2A",
            "value": "WNC14A2A"
        }
    },
}

After you choose `WNC14A2A` you'll also need to indicate if you want debug output or not by Enabling (true) or Disabling (false) WNC_DEBUG.

If WNC_DEBUG is enabled, there are 3 different levels of debug output (selected via bit settings). These debug levels are set using the following values:

ValueDescription
1Basic WNC driver debug output
2Comprehensive WNC driver debug output
4Network Layer debug output

You can have any combination of these three bit values for a total value of 0 – 7.

WNC Debug Settings

    "config": {
        "WNC_DEBUG": {
            "value": false
        },
        "WNC_DEBUG_SETTING": {
            "value": 4
        },
    }

Using Easy Connect from your application

Easy Connect has just one function which will either return a `NetworkInterface`-pointer or `NULL`:

Sample Code

#include "easy-connect.h"

int main(int, char**) {
    NetworkInterface* network = easy_connect(true); /* has 1 argument, enable_logging (pass in true to log to serial port) */
    if (!network) {
        printf("Connecting to the network failed... See serial output.\r\n");
        return 1;
    }
 
    // Rest of your program
}

Tested on

  • K64F with Ethernet.
  • AT&T Cellular IoT Starter Kit with WNC M14A2A Cellular Data Module

The WNCInterface class currently supports the following version(s):

  • MPSS: M14A2A_v11.50.164451 APSS: M14A2A_v11.53.164451

License

This library is released under the Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License and may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Committer:
group-Avnet
Date:
Wed Apr 19 01:08:11 2017 +0000
Revision:
0:478cfd88041f
Initial commit

Who changed what in which revision?

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