Fork of my original MQTTGateway

Dependencies:   mbed-http

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

Who changed what in which revision?

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