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_PktMbus.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 SPIRIT MBUS packets.
vpcola 0:f1d3878b8dd9 8 *
vpcola 0:f1d3878b8dd9 9 * @details
vpcola 0:f1d3878b8dd9 10 *
vpcola 0:f1d3878b8dd9 11 * This module can be used to manage the configuration of Spirit MBUS
vpcola 0:f1d3878b8dd9 12 * packets.
vpcola 0:f1d3878b8dd9 13 * The user can obtain a packet configuration filling the structure
vpcola 0:f1d3878b8dd9 14 * <i>@ref PktMbusInit</i>, defining in it some general parameters
vpcola 0:f1d3878b8dd9 15 * for the Spirit MBUS packet format.
vpcola 0:f1d3878b8dd9 16 * Since the MBUS protocol is a standard, the configuration of a MBUS
vpcola 0:f1d3878b8dd9 17 * packet is very simple to do.
vpcola 0:f1d3878b8dd9 18 *
vpcola 0:f1d3878b8dd9 19 * <b>Example:</b>
vpcola 0:f1d3878b8dd9 20 * @code
vpcola 0:f1d3878b8dd9 21 *
vpcola 0:f1d3878b8dd9 22 * PktMbusInit mbusInit={
vpcola 0:f1d3878b8dd9 23 * MBUS_SUBMODE_S1_S2_LONG_HEADER, // MBUS submode selection
vpcola 0:f1d3878b8dd9 24 * 36, // added "01" chips on preamble
vpcola 0:f1d3878b8dd9 25 * 16 // postamble length in "01" chips
vpcola 0:f1d3878b8dd9 26 * };
vpcola 0:f1d3878b8dd9 27 *
vpcola 0:f1d3878b8dd9 28 * ...
vpcola 0:f1d3878b8dd9 29 *
vpcola 0:f1d3878b8dd9 30 * SpiritPktMbusInit(&mbusInit);
vpcola 0:f1d3878b8dd9 31 *
vpcola 0:f1d3878b8dd9 32 * ...
vpcola 0:f1d3878b8dd9 33 *
vpcola 0:f1d3878b8dd9 34 * @endcode
vpcola 0:f1d3878b8dd9 35 *
vpcola 0:f1d3878b8dd9 36 * The module provides some other functions that can be used to modify
vpcola 0:f1d3878b8dd9 37 * or read only some configuration parameters.
vpcola 0:f1d3878b8dd9 38 *
vpcola 0:f1d3878b8dd9 39 *
vpcola 0:f1d3878b8dd9 40 * @attention
vpcola 0:f1d3878b8dd9 41 *
vpcola 0:f1d3878b8dd9 42 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
vpcola 0:f1d3878b8dd9 43 *
vpcola 0:f1d3878b8dd9 44 * Redistribution and use in source and binary forms, with or without modification,
vpcola 0:f1d3878b8dd9 45 * are permitted provided that the following conditions are met:
vpcola 0:f1d3878b8dd9 46 * 1. Redistributions of source code must retain the above copyright notice,
vpcola 0:f1d3878b8dd9 47 * this list of conditions and the following disclaimer.
vpcola 0:f1d3878b8dd9 48 * 2. Redistributions in binary form must reproduce the above copyright notice,
vpcola 0:f1d3878b8dd9 49 * this list of conditions and the following disclaimer in the documentation
vpcola 0:f1d3878b8dd9 50 * and/or other materials provided with the distribution.
vpcola 0:f1d3878b8dd9 51 * 3. Neither the name of STMicroelectronics nor the names of its contributors
vpcola 0:f1d3878b8dd9 52 * may be used to endorse or promote products derived from this software
vpcola 0:f1d3878b8dd9 53 * without specific prior written permission.
vpcola 0:f1d3878b8dd9 54 *
vpcola 0:f1d3878b8dd9 55 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
vpcola 0:f1d3878b8dd9 56 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
vpcola 0:f1d3878b8dd9 57 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
vpcola 0:f1d3878b8dd9 58 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
vpcola 0:f1d3878b8dd9 59 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
vpcola 0:f1d3878b8dd9 60 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
vpcola 0:f1d3878b8dd9 61 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
vpcola 0:f1d3878b8dd9 62 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
vpcola 0:f1d3878b8dd9 63 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
vpcola 0:f1d3878b8dd9 64 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
vpcola 0:f1d3878b8dd9 65 *
vpcola 0:f1d3878b8dd9 66 ******************************************************************************
vpcola 0:f1d3878b8dd9 67 */
vpcola 0:f1d3878b8dd9 68
vpcola 0:f1d3878b8dd9 69 /* Define to prevent recursive inclusion -------------------------------------*/
vpcola 0:f1d3878b8dd9 70 #ifndef __SPIRIT_PACKET_MBUS_H
vpcola 0:f1d3878b8dd9 71 #define __SPIRIT_PACKET_MBUS_H
vpcola 0:f1d3878b8dd9 72
vpcola 0:f1d3878b8dd9 73
vpcola 0:f1d3878b8dd9 74
vpcola 0:f1d3878b8dd9 75 /* Includes ------------------------------------------------------------------*/
vpcola 0:f1d3878b8dd9 76
vpcola 0:f1d3878b8dd9 77 #include "SPIRIT_Regs.h"
vpcola 0:f1d3878b8dd9 78 #include "SPIRIT_Types.h"
vpcola 0:f1d3878b8dd9 79 #include "SPIRIT_PktCommon.h"
vpcola 0:f1d3878b8dd9 80
vpcola 0:f1d3878b8dd9 81 #ifdef __cplusplus
vpcola 0:f1d3878b8dd9 82 extern "C" {
vpcola 0:f1d3878b8dd9 83 #endif
vpcola 0:f1d3878b8dd9 84
vpcola 0:f1d3878b8dd9 85
vpcola 0:f1d3878b8dd9 86
vpcola 0:f1d3878b8dd9 87 /**
vpcola 0:f1d3878b8dd9 88 * @addtogroup SPIRIT_Libraries
vpcola 0:f1d3878b8dd9 89 * @{
vpcola 0:f1d3878b8dd9 90 */
vpcola 0:f1d3878b8dd9 91
vpcola 0:f1d3878b8dd9 92
vpcola 0:f1d3878b8dd9 93 /**
vpcola 0:f1d3878b8dd9 94 * @defgroup SPIRIT_PktMbus Pkt MBUS
vpcola 0:f1d3878b8dd9 95 * @brief Configuration and management of SPIRIT MBUS packets.
vpcola 0:f1d3878b8dd9 96 * @details See the file <i>@ref SPIRIT_PktMbus.h</i> for more details.
vpcola 0:f1d3878b8dd9 97 * @{
vpcola 0:f1d3878b8dd9 98 */
vpcola 0:f1d3878b8dd9 99
vpcola 0:f1d3878b8dd9 100 /**
vpcola 0:f1d3878b8dd9 101 * @defgroup PktMbus_Exported_Types Pkt MBUS Exported Types
vpcola 0:f1d3878b8dd9 102 * @{
vpcola 0:f1d3878b8dd9 103 */
vpcola 0:f1d3878b8dd9 104
vpcola 0:f1d3878b8dd9 105
vpcola 0:f1d3878b8dd9 106
vpcola 0:f1d3878b8dd9 107 /**
vpcola 0:f1d3878b8dd9 108 * @brief MBUS submode enumeration.
vpcola 0:f1d3878b8dd9 109 */
vpcola 0:f1d3878b8dd9 110
vpcola 0:f1d3878b8dd9 111 typedef enum
vpcola 0:f1d3878b8dd9 112 {
vpcola 0:f1d3878b8dd9 113 MBUS_SUBMODE_S1_S2_LONG_HEADER = MBUS_CTRL_MBUS_SUBMODE_S1_S2L, /*!< MBUS submode S1, S2 (long header) - Header length = mbus_prmbl_ctrl + 279 (in "01" bit pairs) , Sync word = 0x7696 (length 18 bits) */
vpcola 0:f1d3878b8dd9 114 MBUS_SUBMODE_S1_M_S2_T2_OTHER_TO_METER = MBUS_CTRL_MBUS_SUBMODE_S2_S1M_T2_OTHER, /*!< MBUS submode S1-m, S2, T2 (other to meter) - Header length = mbus_prmbl_ctrl + 15 (in "01" bit pairs) , Sync word = 0x7696 (length 18 bits)*/
vpcola 0:f1d3878b8dd9 115 MBUS_SUBMODE_T1_T2_METER_TO_OTHER = MBUS_CTRL_MBUS_SUBMODE_T1_T2_METER, /*!< MBUS submode T1, T2 (meter to other) - Header length = mbus_prmbl_ctrl + 19 (in "01" bit pairs) , Sync word = 0x3D (length 10 bits)*/
vpcola 0:f1d3878b8dd9 116 MBUS_SUBMODE_R2_SHORT_HEADER = MBUS_CTRL_MBUS_SUBMODE_R2, /*!< MBUS submode R2, short header - Header length = mbus_prmbl_ctrl + 39 (in "01" bit pairs) , Sync word = 0x7696 (length 18 bits)*/
vpcola 0:f1d3878b8dd9 117
vpcola 0:f1d3878b8dd9 118 }MbusSubmode;
vpcola 0:f1d3878b8dd9 119
vpcola 0:f1d3878b8dd9 120 #define IS_MBUS_SUBMODE(MODE) (((MODE) == MBUS_SUBMODE_S1_S2_LONG_HEADER) || \
vpcola 0:f1d3878b8dd9 121 ((MODE) == MBUS_SUBMODE_S1_M_S2_T2_OTHER_TO_METER) || \
vpcola 0:f1d3878b8dd9 122 ((MODE) == MBUS_SUBMODE_T1_T2_METER_TO_OTHER) || \
vpcola 0:f1d3878b8dd9 123 ((MODE) == MBUS_SUBMODE_R2_SHORT_HEADER))
vpcola 0:f1d3878b8dd9 124
vpcola 0:f1d3878b8dd9 125
vpcola 0:f1d3878b8dd9 126 /**
vpcola 0:f1d3878b8dd9 127 * @brief SPIRIT MBUS Packet Init structure definition
vpcola 0:f1d3878b8dd9 128 */
vpcola 0:f1d3878b8dd9 129 typedef struct
vpcola 0:f1d3878b8dd9 130 {
vpcola 0:f1d3878b8dd9 131 MbusSubmode xMbusSubmode; /*!< Specifies the SUBMODE to be configured.
vpcola 0:f1d3878b8dd9 132 This parameter can be a value of @ref MbusSubmode */
vpcola 0:f1d3878b8dd9 133
vpcola 0:f1d3878b8dd9 134 uint8_t cPreambleLength; /*!< Specifies the PREAMBLE length.
vpcola 0:f1d3878b8dd9 135 This parameter can be any value between 0 and 255 chip sequence '01' */
vpcola 0:f1d3878b8dd9 136
vpcola 0:f1d3878b8dd9 137 uint8_t cPostambleLength; /*!< Specifies the POSTAMBLE length.
vpcola 0:f1d3878b8dd9 138 This parameter can be any value between 0 and 255 chip sequence '01' */
vpcola 0:f1d3878b8dd9 139
vpcola 0:f1d3878b8dd9 140 }PktMbusInit;
vpcola 0:f1d3878b8dd9 141
vpcola 0:f1d3878b8dd9 142 /**
vpcola 0:f1d3878b8dd9 143 *@}
vpcola 0:f1d3878b8dd9 144 */
vpcola 0:f1d3878b8dd9 145
vpcola 0:f1d3878b8dd9 146
vpcola 0:f1d3878b8dd9 147 /**
vpcola 0:f1d3878b8dd9 148 * @defgroup PktMbus_Exported_Constants Pkt MBUS Exported Constants
vpcola 0:f1d3878b8dd9 149 * @{
vpcola 0:f1d3878b8dd9 150 */
vpcola 0:f1d3878b8dd9 151
vpcola 0:f1d3878b8dd9 152
vpcola 0:f1d3878b8dd9 153 /**
vpcola 0:f1d3878b8dd9 154 *@}
vpcola 0:f1d3878b8dd9 155 */
vpcola 0:f1d3878b8dd9 156
vpcola 0:f1d3878b8dd9 157
vpcola 0:f1d3878b8dd9 158 /**
vpcola 0:f1d3878b8dd9 159 * @defgroup PktMbus_Exported_Macros Pkt MBUS Exported Macros
vpcola 0:f1d3878b8dd9 160 * @{
vpcola 0:f1d3878b8dd9 161 */
vpcola 0:f1d3878b8dd9 162
vpcola 0:f1d3878b8dd9 163
vpcola 0:f1d3878b8dd9 164 /**
vpcola 0:f1d3878b8dd9 165 *@}
vpcola 0:f1d3878b8dd9 166 */
vpcola 0:f1d3878b8dd9 167
vpcola 0:f1d3878b8dd9 168
vpcola 0:f1d3878b8dd9 169 /**
vpcola 0:f1d3878b8dd9 170 * @defgroup PktMbus_Exported_Functions Pkt MBUS Exported Functions
vpcola 0:f1d3878b8dd9 171 * @{
vpcola 0:f1d3878b8dd9 172 */
vpcola 0:f1d3878b8dd9 173 void SpiritPktMbusInit(PktMbusInit* pxPktMbusInit);
vpcola 0:f1d3878b8dd9 174 void SpiritPktMbusGetInfo(PktMbusInit* pxPktMbusInit);
vpcola 0:f1d3878b8dd9 175 void SpiritPktMbusSetFormat(void);
vpcola 0:f1d3878b8dd9 176 void SpiritPktMbusSetPreamble(uint8_t cPreamble);
vpcola 0:f1d3878b8dd9 177 uint8_t SpiritPktMbusGetPreamble(void);
vpcola 0:f1d3878b8dd9 178 void SpiritPktMbusSetPostamble(uint8_t cPostamble);
vpcola 0:f1d3878b8dd9 179 uint8_t SpiritPktMbusGetPostamble(void);
vpcola 0:f1d3878b8dd9 180 void SpiritPktMbusSetSubmode(MbusSubmode xMbusSubmode);
vpcola 0:f1d3878b8dd9 181 MbusSubmode SpiritPktMbusGetSubmode(void);
vpcola 0:f1d3878b8dd9 182 void SpiritPktMbusSetPayloadLength(uint16_t nPayloadLength);
vpcola 0:f1d3878b8dd9 183 uint16_t SpiritPktMbusGetPayloadLength(void);
vpcola 0:f1d3878b8dd9 184
vpcola 0:f1d3878b8dd9 185
vpcola 0:f1d3878b8dd9 186 /**
vpcola 0:f1d3878b8dd9 187 *@}
vpcola 0:f1d3878b8dd9 188 */
vpcola 0:f1d3878b8dd9 189
vpcola 0:f1d3878b8dd9 190 /**
vpcola 0:f1d3878b8dd9 191 *@}
vpcola 0:f1d3878b8dd9 192 */
vpcola 0:f1d3878b8dd9 193
vpcola 0:f1d3878b8dd9 194
vpcola 0:f1d3878b8dd9 195 /**
vpcola 0:f1d3878b8dd9 196 *@}
vpcola 0:f1d3878b8dd9 197 */
vpcola 0:f1d3878b8dd9 198
vpcola 0:f1d3878b8dd9 199
vpcola 0:f1d3878b8dd9 200 #ifdef __cplusplus
vpcola 0:f1d3878b8dd9 201 }
vpcola 0:f1d3878b8dd9 202 #endif
vpcola 0:f1d3878b8dd9 203
vpcola 0:f1d3878b8dd9 204 #endif
vpcola 0:f1d3878b8dd9 205
vpcola 0:f1d3878b8dd9 206 /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/