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_Types.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 Header file for SPIRIT types.
vpcola 0:f1d3878b8dd9 8 * @details
vpcola 0:f1d3878b8dd9 9 *
vpcola 0:f1d3878b8dd9 10 * This module provide some types definitions which will be used in
vpcola 0:f1d3878b8dd9 11 * all the modules of this library. Here is defined also the global
vpcola 0:f1d3878b8dd9 12 * variable @ref g_xStatus which contains the status of Spirit and
vpcola 0:f1d3878b8dd9 13 * is updated every time an SPI transaction occurs.
vpcola 0:f1d3878b8dd9 14 *
vpcola 0:f1d3878b8dd9 15 * @attention
vpcola 0:f1d3878b8dd9 16 *
vpcola 0:f1d3878b8dd9 17 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
vpcola 0:f1d3878b8dd9 18 *
vpcola 0:f1d3878b8dd9 19 * Redistribution and use in source and binary forms, with or without modification,
vpcola 0:f1d3878b8dd9 20 * are permitted provided that the following conditions are met:
vpcola 0:f1d3878b8dd9 21 * 1. Redistributions of source code must retain the above copyright notice,
vpcola 0:f1d3878b8dd9 22 * this list of conditions and the following disclaimer.
vpcola 0:f1d3878b8dd9 23 * 2. Redistributions in binary form must reproduce the above copyright notice,
vpcola 0:f1d3878b8dd9 24 * this list of conditions and the following disclaimer in the documentation
vpcola 0:f1d3878b8dd9 25 * and/or other materials provided with the distribution.
vpcola 0:f1d3878b8dd9 26 * 3. Neither the name of STMicroelectronics nor the names of its contributors
vpcola 0:f1d3878b8dd9 27 * may be used to endorse or promote products derived from this software
vpcola 0:f1d3878b8dd9 28 * without specific prior written permission.
vpcola 0:f1d3878b8dd9 29 *
vpcola 0:f1d3878b8dd9 30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
vpcola 0:f1d3878b8dd9 31 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
vpcola 0:f1d3878b8dd9 32 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
vpcola 0:f1d3878b8dd9 33 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
vpcola 0:f1d3878b8dd9 34 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
vpcola 0:f1d3878b8dd9 35 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
vpcola 0:f1d3878b8dd9 36 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
vpcola 0:f1d3878b8dd9 37 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
vpcola 0:f1d3878b8dd9 38 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
vpcola 0:f1d3878b8dd9 39 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
vpcola 0:f1d3878b8dd9 40 *
vpcola 0:f1d3878b8dd9 41 ******************************************************************************
vpcola 0:f1d3878b8dd9 42 */
vpcola 0:f1d3878b8dd9 43
vpcola 0:f1d3878b8dd9 44 /* Define to prevent recursive inclusion -------------------------------------*/
vpcola 0:f1d3878b8dd9 45 #ifndef __SPIRIT_GENERICTYPES_H
vpcola 0:f1d3878b8dd9 46 #define __SPIRIT_GENERICTYPES_H
vpcola 0:f1d3878b8dd9 47
vpcola 0:f1d3878b8dd9 48
vpcola 0:f1d3878b8dd9 49 /* Includes ------------------------------------------------------------------*/
vpcola 0:f1d3878b8dd9 50
vpcola 0:f1d3878b8dd9 51 /* Include all integer types definitions */
vpcola 0:f1d3878b8dd9 52 #include <stdint.h>
vpcola 0:f1d3878b8dd9 53 #include <stdio.h>
vpcola 0:f1d3878b8dd9 54 #include "SPIRIT_Regs.h"
vpcola 0:f1d3878b8dd9 55
vpcola 0:f1d3878b8dd9 56
vpcola 0:f1d3878b8dd9 57
vpcola 0:f1d3878b8dd9 58 #ifdef __cplusplus
vpcola 0:f1d3878b8dd9 59 extern "C" {
vpcola 0:f1d3878b8dd9 60 #endif
vpcola 0:f1d3878b8dd9 61
vpcola 0:f1d3878b8dd9 62
vpcola 0:f1d3878b8dd9 63 /**
vpcola 0:f1d3878b8dd9 64 * @addtogroup SPIRIT_Libraries
vpcola 0:f1d3878b8dd9 65 * @{
vpcola 0:f1d3878b8dd9 66 */
vpcola 0:f1d3878b8dd9 67
vpcola 0:f1d3878b8dd9 68
vpcola 0:f1d3878b8dd9 69 /**
vpcola 0:f1d3878b8dd9 70 * @defgroup SPIRIT_Types Types
vpcola 0:f1d3878b8dd9 71 * @brief Module for SPIRIT types definition.
vpcola 0:f1d3878b8dd9 72 * * @details See the file <i>@ref SPIRIT_Types.h</i> for more details.
vpcola 0:f1d3878b8dd9 73 * @{
vpcola 0:f1d3878b8dd9 74 */
vpcola 0:f1d3878b8dd9 75
vpcola 0:f1d3878b8dd9 76 /**
vpcola 0:f1d3878b8dd9 77 * @defgroup Types_Exported_Types Types Exported Types
vpcola 0:f1d3878b8dd9 78 * @{
vpcola 0:f1d3878b8dd9 79 */
vpcola 0:f1d3878b8dd9 80
vpcola 0:f1d3878b8dd9 81 /**
vpcola 0:f1d3878b8dd9 82 * @brief Spirit Functional state. Used to enable or disable a specific option.
vpcola 0:f1d3878b8dd9 83 */
vpcola 0:f1d3878b8dd9 84 typedef enum
vpcola 0:f1d3878b8dd9 85 {
vpcola 0:f1d3878b8dd9 86 S_DISABLE = 0,
vpcola 0:f1d3878b8dd9 87 S_ENABLE = !S_DISABLE
vpcola 0:f1d3878b8dd9 88
vpcola 0:f1d3878b8dd9 89 } SpiritFunctionalState;
vpcola 0:f1d3878b8dd9 90
vpcola 0:f1d3878b8dd9 91 #define IS_SPIRIT_FUNCTIONAL_STATE(STATE) (STATE == S_DISABLE || STATE == S_ENABLE)
vpcola 0:f1d3878b8dd9 92
vpcola 0:f1d3878b8dd9 93 /**
vpcola 0:f1d3878b8dd9 94 * @brief Spirit Flag status. Used to control the state of a flag.
vpcola 0:f1d3878b8dd9 95 */
vpcola 0:f1d3878b8dd9 96 typedef enum
vpcola 0:f1d3878b8dd9 97 {
vpcola 0:f1d3878b8dd9 98 S_RESET = 0,
vpcola 0:f1d3878b8dd9 99 S_SET = !S_RESET
vpcola 0:f1d3878b8dd9 100
vpcola 0:f1d3878b8dd9 101 } SpiritFlagStatus;
vpcola 0:f1d3878b8dd9 102
vpcola 0:f1d3878b8dd9 103 #define IS_SPIRIT_FLAG_STATUS(STATUS) (STATUS == S_RESET || STATUS == S_SET)
vpcola 0:f1d3878b8dd9 104
vpcola 0:f1d3878b8dd9 105
vpcola 0:f1d3878b8dd9 106 /**
vpcola 0:f1d3878b8dd9 107 * @brief boolean type enumeration.
vpcola 0:f1d3878b8dd9 108 */
vpcola 0:f1d3878b8dd9 109 typedef enum
vpcola 0:f1d3878b8dd9 110 {
vpcola 0:f1d3878b8dd9 111 S_FALSE = 0,
vpcola 0:f1d3878b8dd9 112 S_TRUE = !S_FALSE
vpcola 0:f1d3878b8dd9 113
vpcola 0:f1d3878b8dd9 114 } SpiritBool;
vpcola 0:f1d3878b8dd9 115
vpcola 0:f1d3878b8dd9 116
vpcola 0:f1d3878b8dd9 117 /**
vpcola 0:f1d3878b8dd9 118 * @brief SPIRIT States enumeration.
vpcola 0:f1d3878b8dd9 119 */
vpcola 0:f1d3878b8dd9 120 typedef enum
vpcola 0:f1d3878b8dd9 121 {
vpcola 0:f1d3878b8dd9 122 MC_STATE_STANDBY =0x40, /*!< STANDBY */
vpcola 0:f1d3878b8dd9 123 MC_STATE_SLEEP =0x36, /*!< SLEEP */
vpcola 0:f1d3878b8dd9 124 MC_STATE_READY =0x03, /*!< READY */
vpcola 0:f1d3878b8dd9 125 MC_STATE_PM_SETUP =0x3D, /*!< PM_SETUP */
vpcola 0:f1d3878b8dd9 126 MC_STATE_XO_SETTLING =0x23, /*!< XO_SETTLING */
vpcola 0:f1d3878b8dd9 127 MC_STATE_SYNTH_SETUP =0x53, /*!< SYNT_SETUP */
vpcola 0:f1d3878b8dd9 128 MC_STATE_PROTOCOL =0x1F, /*!< PROTOCOL */
vpcola 0:f1d3878b8dd9 129 MC_STATE_SYNTH_CALIBRATION =0x4F, /*!< SYNTH */
vpcola 0:f1d3878b8dd9 130 MC_STATE_LOCK =0x0F, /*!< LOCK */
vpcola 0:f1d3878b8dd9 131 MC_STATE_RX =0x33, /*!< RX */
vpcola 0:f1d3878b8dd9 132 MC_STATE_TX =0x5F /*!< TX */
vpcola 0:f1d3878b8dd9 133
vpcola 0:f1d3878b8dd9 134 } SpiritState;
vpcola 0:f1d3878b8dd9 135
vpcola 0:f1d3878b8dd9 136
vpcola 0:f1d3878b8dd9 137
vpcola 0:f1d3878b8dd9 138 /**
vpcola 0:f1d3878b8dd9 139 * @brief SPIRIT Status. This definition represents the single field of the SPIRIT
vpcola 0:f1d3878b8dd9 140 * status returned on each SPI transaction, equal also to the MC_STATE registers.
vpcola 0:f1d3878b8dd9 141 * This field-oriented structure allows user to address in simple way the single
vpcola 0:f1d3878b8dd9 142 * field of the SPIRIT status.
vpcola 0:f1d3878b8dd9 143 * The user shall define a variable of SpiritStatus type to access on SPIRIT status fields.
vpcola 0:f1d3878b8dd9 144 * @note The fields order in the structure depends on used endianness (little or big
vpcola 0:f1d3878b8dd9 145 * endian). The actual definition is valid ONLY for LITTLE ENDIAN mode. Be sure to
vpcola 0:f1d3878b8dd9 146 * change opportunely the fields order when use a different endianness.
vpcola 0:f1d3878b8dd9 147 */
vpcola 0:f1d3878b8dd9 148
vpcola 0:f1d3878b8dd9 149 typedef struct
vpcola 0:f1d3878b8dd9 150 {
vpcola 0:f1d3878b8dd9 151 uint8_t XO_ON:1; /*!< This one bit field notifies if XO is operating
vpcola 0:f1d3878b8dd9 152 (XO_ON is 1) or not (XO_On is 0) */
vpcola 0:f1d3878b8dd9 153 SpiritState MC_STATE: 7; /*!< This 7 bits field indicates the state of the
vpcola 0:f1d3878b8dd9 154 Main Controller of SPIRIT. The possible states
vpcola 0:f1d3878b8dd9 155 and their corresponding values are defined in
vpcola 0:f1d3878b8dd9 156 @ref SpiritState */
vpcola 0:f1d3878b8dd9 157 uint8_t ERROR_LOCK: 1; /*!< This one bit field notifies if there is an
vpcola 0:f1d3878b8dd9 158 error on RCO calibration (ERROR_LOCK is 1) or
vpcola 0:f1d3878b8dd9 159 not (ERROR_LOCK is 0) */
vpcola 0:f1d3878b8dd9 160 uint8_t RX_FIFO_EMPTY: 1; /*!< This one bit field notifies if RX FIFO is empty
vpcola 0:f1d3878b8dd9 161 (RX_FIFO_EMPTY is 1) or not (RX_FIFO_EMPTY is 0) */
vpcola 0:f1d3878b8dd9 162 uint8_t TX_FIFO_FULL: 1; /*!< This one bit field notifies if TX FIFO is full
vpcola 0:f1d3878b8dd9 163 (TX_FIFO_FULL is 1) or not (TX_FIFO_FULL is 0) */
vpcola 0:f1d3878b8dd9 164 uint8_t ANT_SELECT: 1; /*!< This one bit field notifies the currently selected
vpcola 0:f1d3878b8dd9 165 antenna */
vpcola 0:f1d3878b8dd9 166 uint8_t : 4; /*!< This 4 bits field are reserved and equal to 5 */
vpcola 0:f1d3878b8dd9 167
vpcola 0:f1d3878b8dd9 168 }SpiritStatus;
vpcola 0:f1d3878b8dd9 169
vpcola 0:f1d3878b8dd9 170
vpcola 0:f1d3878b8dd9 171
vpcola 0:f1d3878b8dd9 172 /**
vpcola 0:f1d3878b8dd9 173 * @}
vpcola 0:f1d3878b8dd9 174 */
vpcola 0:f1d3878b8dd9 175
vpcola 0:f1d3878b8dd9 176
vpcola 0:f1d3878b8dd9 177 /**
vpcola 0:f1d3878b8dd9 178 * @defgroup Types_Exported_Constants Types Exported Constants
vpcola 0:f1d3878b8dd9 179 * @{
vpcola 0:f1d3878b8dd9 180 */
vpcola 0:f1d3878b8dd9 181
vpcola 0:f1d3878b8dd9 182
vpcola 0:f1d3878b8dd9 183 /**
vpcola 0:f1d3878b8dd9 184 * @}
vpcola 0:f1d3878b8dd9 185 */
vpcola 0:f1d3878b8dd9 186
vpcola 0:f1d3878b8dd9 187 /**
vpcola 0:f1d3878b8dd9 188 * @defgroup Types_Exported_Variables Types Exported Variables
vpcola 0:f1d3878b8dd9 189 * @{
vpcola 0:f1d3878b8dd9 190 */
vpcola 0:f1d3878b8dd9 191
vpcola 0:f1d3878b8dd9 192 extern volatile SpiritStatus g_xStatus;
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 * @defgroup Types_Exported_Macros Types Exported Macros
vpcola 0:f1d3878b8dd9 200 * @{
vpcola 0:f1d3878b8dd9 201 */
vpcola 0:f1d3878b8dd9 202
vpcola 0:f1d3878b8dd9 203 #ifdef SPIRIT_USE_FULL_ASSERT
vpcola 0:f1d3878b8dd9 204 /**
vpcola 0:f1d3878b8dd9 205 * @brief The s_assert_param macro is used for function's parameters check.
vpcola 0:f1d3878b8dd9 206 * @param expr If expr is false, it calls assert_failed function which reports
vpcola 0:f1d3878b8dd9 207 * the name of the source file and the source line number of the call
vpcola 0:f1d3878b8dd9 208 * that failed. If expr is true, it returns no value.
vpcola 0:f1d3878b8dd9 209 * @retval None
vpcola 0:f1d3878b8dd9 210 */
vpcola 0:f1d3878b8dd9 211 #define s_assert_param(expr) ((expr) ? (void)0 : s_assert_failed((uint8_t *)__FILE__, __LINE__))
vpcola 0:f1d3878b8dd9 212 void s_assert_failed(uint8_t* file, uint32_t line);
vpcola 0:f1d3878b8dd9 213 #elif SPIRIT_USE_VCOM_ASSERT
vpcola 0:f1d3878b8dd9 214 /**
vpcola 0:f1d3878b8dd9 215 * @brief The s_assert_param macro is used for function's parameters check.
vpcola 0:f1d3878b8dd9 216 * @param expr If expr is false, it calls assert_failed function which reports
vpcola 0:f1d3878b8dd9 217 * the name of the source file and the source line number of the call
vpcola 0:f1d3878b8dd9 218 * that failed. If expr is true, it returns no value.
vpcola 0:f1d3878b8dd9 219 * @retval None
vpcola 0:f1d3878b8dd9 220 */
vpcola 0:f1d3878b8dd9 221 #define s_assert_param(expr) ((expr) ? (void)0 : s_assert_failed((uint8_t *)__FILE__, __LINE__,#expr))
vpcola 0:f1d3878b8dd9 222 void s_assert_failed(uint8_t* file, uint32_t line, char* expression);
vpcola 0:f1d3878b8dd9 223
vpcola 0:f1d3878b8dd9 224 #elif SPIRIT_USE_FRAME_ASSERT
vpcola 0:f1d3878b8dd9 225 /**
vpcola 0:f1d3878b8dd9 226 * @brief The s_assert_param macro is used for function's parameters check.
vpcola 0:f1d3878b8dd9 227 * @param expr If expr is false, it calls assert_failed function which reports
vpcola 0:f1d3878b8dd9 228 * the name of the source file and the source line number of the call
vpcola 0:f1d3878b8dd9 229 * that failed. If expr is true, it returns no value.
vpcola 0:f1d3878b8dd9 230 * @retval None
vpcola 0:f1d3878b8dd9 231 */
vpcola 0:f1d3878b8dd9 232 #define s_assert_param(expr) ((expr) ? (void)0 : s_assert_failed(#expr))
vpcola 0:f1d3878b8dd9 233 void s_assert_failed(char* expression);
vpcola 0:f1d3878b8dd9 234 #else
vpcola 0:f1d3878b8dd9 235 #define s_assert_param(expr) {}
vpcola 0:f1d3878b8dd9 236 #endif
vpcola 0:f1d3878b8dd9 237
vpcola 0:f1d3878b8dd9 238 /**
vpcola 0:f1d3878b8dd9 239 * @brief Returns the absolute value.
vpcola 0:f1d3878b8dd9 240 */
vpcola 0:f1d3878b8dd9 241 #define S_ABS(a) ((a)>0?(a):-(a))
vpcola 0:f1d3878b8dd9 242
vpcola 0:f1d3878b8dd9 243
vpcola 0:f1d3878b8dd9 244 /**
vpcola 0:f1d3878b8dd9 245 * @}
vpcola 0:f1d3878b8dd9 246 */
vpcola 0:f1d3878b8dd9 247
vpcola 0:f1d3878b8dd9 248
vpcola 0:f1d3878b8dd9 249 /**
vpcola 0:f1d3878b8dd9 250 * @defgroup Types_Exported_Functions Types Exported Functions
vpcola 0:f1d3878b8dd9 251 * @{
vpcola 0:f1d3878b8dd9 252 */
vpcola 0:f1d3878b8dd9 253
vpcola 0:f1d3878b8dd9 254 void SpiritRefreshStatus(void);
vpcola 0:f1d3878b8dd9 255
vpcola 0:f1d3878b8dd9 256 /**
vpcola 0:f1d3878b8dd9 257 *@}
vpcola 0:f1d3878b8dd9 258 */
vpcola 0:f1d3878b8dd9 259
vpcola 0:f1d3878b8dd9 260 /**
vpcola 0:f1d3878b8dd9 261 * @}
vpcola 0:f1d3878b8dd9 262 */
vpcola 0:f1d3878b8dd9 263
vpcola 0:f1d3878b8dd9 264
vpcola 0:f1d3878b8dd9 265 /**
vpcola 0:f1d3878b8dd9 266 * @}
vpcola 0:f1d3878b8dd9 267 */
vpcola 0:f1d3878b8dd9 268
vpcola 0:f1d3878b8dd9 269
vpcola 0:f1d3878b8dd9 270 #ifdef __cplusplus
vpcola 0:f1d3878b8dd9 271 }
vpcola 0:f1d3878b8dd9 272 #endif
vpcola 0:f1d3878b8dd9 273
vpcola 0:f1d3878b8dd9 274 #endif
vpcola 0:f1d3878b8dd9 275
vpcola 0:f1d3878b8dd9 276 /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/