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_Qi.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 QI.
vpcola 0:f1d3878b8dd9 8 * @details
vpcola 0:f1d3878b8dd9 9 *
vpcola 0:f1d3878b8dd9 10 * This module can be used to configure and read some quality indicators
vpcola 0:f1d3878b8dd9 11 * used by Spirit.
vpcola 0:f1d3878b8dd9 12 * API to set thresholds and to read values in raw mode or in dBm are
vpcola 0:f1d3878b8dd9 13 * provided.
vpcola 0:f1d3878b8dd9 14 *
vpcola 0:f1d3878b8dd9 15 * <b>Example:</b>
vpcola 0:f1d3878b8dd9 16 * @code
vpcola 0:f1d3878b8dd9 17 *
vpcola 0:f1d3878b8dd9 18 * float rssiValuedBm;
vpcola 0:f1d3878b8dd9 19 * uint8_t pqiValue, sqiValue;
vpcola 0:f1d3878b8dd9 20 *
vpcola 0:f1d3878b8dd9 21 * SpiritQiPqiCheck(S_ENABLE);
vpcola 0:f1d3878b8dd9 22 * SpiritQiSqiCheck(S_ENABLE);
vpcola 0:f1d3878b8dd9 23 *
vpcola 0:f1d3878b8dd9 24 * ...
vpcola 0:f1d3878b8dd9 25 *
vpcola 0:f1d3878b8dd9 26 * rssiValueDbm = SpiritQiGetRssidBm();
vpcola 0:f1d3878b8dd9 27 * pqiValue = SpiritQiGetPqi();
vpcola 0:f1d3878b8dd9 28 * sqiValue = SpiritQiGetSqi();
vpcola 0:f1d3878b8dd9 29 *
vpcola 0:f1d3878b8dd9 30 * ...
vpcola 0:f1d3878b8dd9 31 *
vpcola 0:f1d3878b8dd9 32 * @endcode
vpcola 0:f1d3878b8dd9 33 *
vpcola 0:f1d3878b8dd9 34 * @attention
vpcola 0:f1d3878b8dd9 35 *
vpcola 0:f1d3878b8dd9 36 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
vpcola 0:f1d3878b8dd9 37 *
vpcola 0:f1d3878b8dd9 38 * Redistribution and use in source and binary forms, with or without modification,
vpcola 0:f1d3878b8dd9 39 * are permitted provided that the following conditions are met:
vpcola 0:f1d3878b8dd9 40 * 1. Redistributions of source code must retain the above copyright notice,
vpcola 0:f1d3878b8dd9 41 * this list of conditions and the following disclaimer.
vpcola 0:f1d3878b8dd9 42 * 2. Redistributions in binary form must reproduce the above copyright notice,
vpcola 0:f1d3878b8dd9 43 * this list of conditions and the following disclaimer in the documentation
vpcola 0:f1d3878b8dd9 44 * and/or other materials provided with the distribution.
vpcola 0:f1d3878b8dd9 45 * 3. Neither the name of STMicroelectronics nor the names of its contributors
vpcola 0:f1d3878b8dd9 46 * may be used to endorse or promote products derived from this software
vpcola 0:f1d3878b8dd9 47 * without specific prior written permission.
vpcola 0:f1d3878b8dd9 48 *
vpcola 0:f1d3878b8dd9 49 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
vpcola 0:f1d3878b8dd9 50 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
vpcola 0:f1d3878b8dd9 51 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
vpcola 0:f1d3878b8dd9 52 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
vpcola 0:f1d3878b8dd9 53 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
vpcola 0:f1d3878b8dd9 54 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
vpcola 0:f1d3878b8dd9 55 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
vpcola 0:f1d3878b8dd9 56 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
vpcola 0:f1d3878b8dd9 57 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
vpcola 0:f1d3878b8dd9 58 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
vpcola 0:f1d3878b8dd9 59 *
vpcola 0:f1d3878b8dd9 60 ******************************************************************************
vpcola 0:f1d3878b8dd9 61 */
vpcola 0:f1d3878b8dd9 62
vpcola 0:f1d3878b8dd9 63 /* Define to prevent recursive inclusion -------------------------------------*/
vpcola 0:f1d3878b8dd9 64 #ifndef __SPIRIT_QI_H
vpcola 0:f1d3878b8dd9 65 #define __SPIRIT_QI_H
vpcola 0:f1d3878b8dd9 66
vpcola 0:f1d3878b8dd9 67
vpcola 0:f1d3878b8dd9 68 /* Includes ------------------------------------------------------------------*/
vpcola 0:f1d3878b8dd9 69
vpcola 0:f1d3878b8dd9 70 #include "SPIRIT_Regs.h"
vpcola 0:f1d3878b8dd9 71 #include "SPIRIT_Types.h"
vpcola 0:f1d3878b8dd9 72
vpcola 0:f1d3878b8dd9 73
vpcola 0:f1d3878b8dd9 74 #ifdef __cplusplus
vpcola 0:f1d3878b8dd9 75 extern "C" {
vpcola 0:f1d3878b8dd9 76 #endif
vpcola 0:f1d3878b8dd9 77
vpcola 0:f1d3878b8dd9 78
vpcola 0:f1d3878b8dd9 79 /**
vpcola 0:f1d3878b8dd9 80 * @addtogroup SPIRIT_Libraries
vpcola 0:f1d3878b8dd9 81 * @{
vpcola 0:f1d3878b8dd9 82 */
vpcola 0:f1d3878b8dd9 83
vpcola 0:f1d3878b8dd9 84
vpcola 0:f1d3878b8dd9 85 /**
vpcola 0:f1d3878b8dd9 86 * @defgroup SPIRIT_Qi QI
vpcola 0:f1d3878b8dd9 87 * @brief Configuration and management of SPIRIT QI.
vpcola 0:f1d3878b8dd9 88 * @details See the file <i>@ref SPIRIT_Qi.h</i> for more details.
vpcola 0:f1d3878b8dd9 89 * @{
vpcola 0:f1d3878b8dd9 90 */
vpcola 0:f1d3878b8dd9 91
vpcola 0:f1d3878b8dd9 92 /**
vpcola 0:f1d3878b8dd9 93 * @defgroup Qi_Exported_Types QI Exported Types
vpcola 0:f1d3878b8dd9 94 * @{
vpcola 0:f1d3878b8dd9 95 */
vpcola 0:f1d3878b8dd9 96
vpcola 0:f1d3878b8dd9 97
vpcola 0:f1d3878b8dd9 98 /**
vpcola 0:f1d3878b8dd9 99 * @brief PQI threshold value enumeration.
vpcola 0:f1d3878b8dd9 100 */
vpcola 0:f1d3878b8dd9 101 typedef enum
vpcola 0:f1d3878b8dd9 102 {
vpcola 0:f1d3878b8dd9 103 PQI_TH_0=0x00,
vpcola 0:f1d3878b8dd9 104 PQI_TH_1=0x04,
vpcola 0:f1d3878b8dd9 105 PQI_TH_2=0x08,
vpcola 0:f1d3878b8dd9 106 PQI_TH_3=0x0C,
vpcola 0:f1d3878b8dd9 107 PQI_TH_4=0x10,
vpcola 0:f1d3878b8dd9 108 PQI_TH_5=0x14,
vpcola 0:f1d3878b8dd9 109 PQI_TH_6=0x18,
vpcola 0:f1d3878b8dd9 110 PQI_TH_7=0x1C,
vpcola 0:f1d3878b8dd9 111 PQI_TH_8=0x20,
vpcola 0:f1d3878b8dd9 112 PQI_TH_9=0x24,
vpcola 0:f1d3878b8dd9 113 PQI_TH_10=0x28,
vpcola 0:f1d3878b8dd9 114 PQI_TH_11=0x2C,
vpcola 0:f1d3878b8dd9 115 PQI_TH_12=0x30,
vpcola 0:f1d3878b8dd9 116 PQI_TH_13=0x34,
vpcola 0:f1d3878b8dd9 117 PQI_TH_14=0x38,
vpcola 0:f1d3878b8dd9 118 PQI_TH_15=0x3C
vpcola 0:f1d3878b8dd9 119
vpcola 0:f1d3878b8dd9 120 } PqiThreshold;
vpcola 0:f1d3878b8dd9 121
vpcola 0:f1d3878b8dd9 122 #define IS_PQI_THR(VALUE) (VALUE==PQI_TH_0 ||\
vpcola 0:f1d3878b8dd9 123 VALUE==PQI_TH_1 ||\
vpcola 0:f1d3878b8dd9 124 VALUE==PQI_TH_2 ||\
vpcola 0:f1d3878b8dd9 125 VALUE==PQI_TH_3 ||\
vpcola 0:f1d3878b8dd9 126 VALUE==PQI_TH_4 ||\
vpcola 0:f1d3878b8dd9 127 VALUE==PQI_TH_5 ||\
vpcola 0:f1d3878b8dd9 128 VALUE==PQI_TH_6 ||\
vpcola 0:f1d3878b8dd9 129 VALUE==PQI_TH_7 ||\
vpcola 0:f1d3878b8dd9 130 VALUE==PQI_TH_8 ||\
vpcola 0:f1d3878b8dd9 131 VALUE==PQI_TH_9 ||\
vpcola 0:f1d3878b8dd9 132 VALUE==PQI_TH_10 ||\
vpcola 0:f1d3878b8dd9 133 VALUE==PQI_TH_11 ||\
vpcola 0:f1d3878b8dd9 134 VALUE==PQI_TH_12 ||\
vpcola 0:f1d3878b8dd9 135 VALUE==PQI_TH_13 ||\
vpcola 0:f1d3878b8dd9 136 VALUE==PQI_TH_14 ||\
vpcola 0:f1d3878b8dd9 137 VALUE==PQI_TH_15)
vpcola 0:f1d3878b8dd9 138
vpcola 0:f1d3878b8dd9 139 /**
vpcola 0:f1d3878b8dd9 140 * @brief SQI threshold value enumeration.
vpcola 0:f1d3878b8dd9 141 */
vpcola 0:f1d3878b8dd9 142 typedef enum
vpcola 0:f1d3878b8dd9 143 {
vpcola 0:f1d3878b8dd9 144 SQI_TH_0=0x00,
vpcola 0:f1d3878b8dd9 145 SQI_TH_1=0x40,
vpcola 0:f1d3878b8dd9 146 SQI_TH_2=0x80,
vpcola 0:f1d3878b8dd9 147 SQI_TH_3=0xC0
vpcola 0:f1d3878b8dd9 148
vpcola 0:f1d3878b8dd9 149 } SqiThreshold;
vpcola 0:f1d3878b8dd9 150
vpcola 0:f1d3878b8dd9 151 #define IS_SQI_THR(VALUE) (VALUE==SQI_TH_0 ||\
vpcola 0:f1d3878b8dd9 152 VALUE==SQI_TH_1 ||\
vpcola 0:f1d3878b8dd9 153 VALUE==SQI_TH_2 ||\
vpcola 0:f1d3878b8dd9 154 VALUE==SQI_TH_3)
vpcola 0:f1d3878b8dd9 155
vpcola 0:f1d3878b8dd9 156
vpcola 0:f1d3878b8dd9 157 /**
vpcola 0:f1d3878b8dd9 158 * @brief RSSI filter gain value enumeration.
vpcola 0:f1d3878b8dd9 159 */
vpcola 0:f1d3878b8dd9 160 typedef enum
vpcola 0:f1d3878b8dd9 161 {
vpcola 0:f1d3878b8dd9 162 RSSI_FG_0=0x00,
vpcola 0:f1d3878b8dd9 163 RSSI_FG_1=0x10,
vpcola 0:f1d3878b8dd9 164 RSSI_FG_2=0x20,
vpcola 0:f1d3878b8dd9 165 RSSI_FG_3=0x30,
vpcola 0:f1d3878b8dd9 166 RSSI_FG_4=0x40,
vpcola 0:f1d3878b8dd9 167 RSSI_FG_5=0x50,
vpcola 0:f1d3878b8dd9 168 RSSI_FG_6=0x60,
vpcola 0:f1d3878b8dd9 169 RSSI_FG_7=0x70,
vpcola 0:f1d3878b8dd9 170 RSSI_FG_8=0x80,
vpcola 0:f1d3878b8dd9 171 RSSI_FG_9=0x90,
vpcola 0:f1d3878b8dd9 172 RSSI_FG_10=0xA0,
vpcola 0:f1d3878b8dd9 173 RSSI_FG_11=0xB0,
vpcola 0:f1d3878b8dd9 174 RSSI_FG_12=0xC0,
vpcola 0:f1d3878b8dd9 175 RSSI_FG_13=0xD0,
vpcola 0:f1d3878b8dd9 176 RSSI_FG_14=0xE0, /*<! recommended value */
vpcola 0:f1d3878b8dd9 177 RSSI_FG_15=0xF0
vpcola 0:f1d3878b8dd9 178
vpcola 0:f1d3878b8dd9 179 } RssiFilterGain;
vpcola 0:f1d3878b8dd9 180
vpcola 0:f1d3878b8dd9 181 #define IS_RSSI_FILTER_GAIN(VALUE) (VALUE==RSSI_FG_0 ||\
vpcola 0:f1d3878b8dd9 182 VALUE==RSSI_FG_1 ||\
vpcola 0:f1d3878b8dd9 183 VALUE==RSSI_FG_2 ||\
vpcola 0:f1d3878b8dd9 184 VALUE==RSSI_FG_3 ||\
vpcola 0:f1d3878b8dd9 185 VALUE==RSSI_FG_4 ||\
vpcola 0:f1d3878b8dd9 186 VALUE==RSSI_FG_5 ||\
vpcola 0:f1d3878b8dd9 187 VALUE==RSSI_FG_6 ||\
vpcola 0:f1d3878b8dd9 188 VALUE==RSSI_FG_7 ||\
vpcola 0:f1d3878b8dd9 189 VALUE==RSSI_FG_8 ||\
vpcola 0:f1d3878b8dd9 190 VALUE==RSSI_FG_9 ||\
vpcola 0:f1d3878b8dd9 191 VALUE==RSSI_FG_10 ||\
vpcola 0:f1d3878b8dd9 192 VALUE==RSSI_FG_11 ||\
vpcola 0:f1d3878b8dd9 193 VALUE==RSSI_FG_12 ||\
vpcola 0:f1d3878b8dd9 194 VALUE==RSSI_FG_13 ||\
vpcola 0:f1d3878b8dd9 195 VALUE==RSSI_FG_14 ||\
vpcola 0:f1d3878b8dd9 196 VALUE==RSSI_FG_15)
vpcola 0:f1d3878b8dd9 197
vpcola 0:f1d3878b8dd9 198 /**
vpcola 0:f1d3878b8dd9 199 * @brief CS mode enumeration.
vpcola 0:f1d3878b8dd9 200 */
vpcola 0:f1d3878b8dd9 201 typedef enum
vpcola 0:f1d3878b8dd9 202 {
vpcola 0:f1d3878b8dd9 203 CS_MODE_STATIC_3DB=0x00,
vpcola 0:f1d3878b8dd9 204 CS_MODE_DYNAMIC_6DB=0x04,
vpcola 0:f1d3878b8dd9 205 CS_MODE_DYNAMIC_12DB=0x08,
vpcola 0:f1d3878b8dd9 206 CS_MODE_DYNAMIC_18DB=0x0C
vpcola 0:f1d3878b8dd9 207
vpcola 0:f1d3878b8dd9 208 } CSMode;
vpcola 0:f1d3878b8dd9 209
vpcola 0:f1d3878b8dd9 210 #define IS_CS_MODE(MODE) (MODE==CS_MODE_STATIC_3DB ||\
vpcola 0:f1d3878b8dd9 211 MODE==CS_MODE_DYNAMIC_6DB ||\
vpcola 0:f1d3878b8dd9 212 MODE==CS_MODE_DYNAMIC_12DB ||\
vpcola 0:f1d3878b8dd9 213 MODE==CS_MODE_DYNAMIC_18DB)
vpcola 0:f1d3878b8dd9 214
vpcola 0:f1d3878b8dd9 215 /**
vpcola 0:f1d3878b8dd9 216 *@}
vpcola 0:f1d3878b8dd9 217 */
vpcola 0:f1d3878b8dd9 218
vpcola 0:f1d3878b8dd9 219
vpcola 0:f1d3878b8dd9 220 /**
vpcola 0:f1d3878b8dd9 221 * @defgroup Qi_Exported_Constants QI Exported Constants
vpcola 0:f1d3878b8dd9 222 * @{
vpcola 0:f1d3878b8dd9 223 */
vpcola 0:f1d3878b8dd9 224
vpcola 0:f1d3878b8dd9 225 /* range for the RSSI Threshold in dBm */
vpcola 0:f1d3878b8dd9 226 #define IS_RSSI_THR_DBM(VALUE) (VALUE>=-130 && VALUE<=-2)
vpcola 0:f1d3878b8dd9 227
vpcola 0:f1d3878b8dd9 228 /**
vpcola 0:f1d3878b8dd9 229 *@}
vpcola 0:f1d3878b8dd9 230 */
vpcola 0:f1d3878b8dd9 231
vpcola 0:f1d3878b8dd9 232
vpcola 0:f1d3878b8dd9 233 /**
vpcola 0:f1d3878b8dd9 234 * @defgroup Qi_Exported_Macros QI Exported Macros
vpcola 0:f1d3878b8dd9 235 * @{
vpcola 0:f1d3878b8dd9 236 */
vpcola 0:f1d3878b8dd9 237
vpcola 0:f1d3878b8dd9 238 /**
vpcola 0:f1d3878b8dd9 239 * @brief Macro to obtain the RSSI value in dBm
vpcola 0:f1d3878b8dd9 240 * @param None.
vpcola 0:f1d3878b8dd9 241 * @retval RSSI in dBm.
vpcola 0:f1d3878b8dd9 242 * This parameter is a float.
vpcola 0:f1d3878b8dd9 243 */
vpcola 0:f1d3878b8dd9 244 #define SpiritQiGetRssidBm() (-120.0+((float)(SpiritQiGetRssi()-20))/2)
vpcola 0:f1d3878b8dd9 245
vpcola 0:f1d3878b8dd9 246 /**
vpcola 0:f1d3878b8dd9 247 *@}
vpcola 0:f1d3878b8dd9 248 */
vpcola 0:f1d3878b8dd9 249
vpcola 0:f1d3878b8dd9 250
vpcola 0:f1d3878b8dd9 251 /**
vpcola 0:f1d3878b8dd9 252 * @defgroup Qi_Exported_Functions QI Exported Functions
vpcola 0:f1d3878b8dd9 253 * @{
vpcola 0:f1d3878b8dd9 254 */
vpcola 0:f1d3878b8dd9 255
vpcola 0:f1d3878b8dd9 256 void SpiritQiPqiCheck(SpiritFunctionalState xNewState);
vpcola 0:f1d3878b8dd9 257 void SpiritQiSqiCheck(SpiritFunctionalState xNewState);
vpcola 0:f1d3878b8dd9 258 void SpiritQiSetPqiThreshold(PqiThreshold xPqiThr);
vpcola 0:f1d3878b8dd9 259 PqiThreshold SpiritQiGetPqiThreshold(void);
vpcola 0:f1d3878b8dd9 260 void SpiritQiSetSqiThreshold(SqiThreshold xSqiThr);
vpcola 0:f1d3878b8dd9 261 SqiThreshold SpiritQiGetSqiThreshold(void);
vpcola 0:f1d3878b8dd9 262 void SpiritQiSetRssiThreshold(uint8_t cRssiThr);
vpcola 0:f1d3878b8dd9 263 uint8_t SpiritQiGetRssiThreshold(void);
vpcola 0:f1d3878b8dd9 264 uint8_t SpiritQiComputeRssiThreshold(int cDbmValue);
vpcola 0:f1d3878b8dd9 265 void SpiritQiSetRssiThresholddBm(int nDbmValue);
vpcola 0:f1d3878b8dd9 266 uint8_t SpiritQiGetPqi(void);
vpcola 0:f1d3878b8dd9 267 uint8_t SpiritQiGetSqi(void);
vpcola 0:f1d3878b8dd9 268 uint8_t SpiritQiGetLqi(void);
vpcola 0:f1d3878b8dd9 269 SpiritFlagStatus SpiritQiGetCs(void);
vpcola 0:f1d3878b8dd9 270 uint8_t SpiritQiGetRssi(void);
vpcola 0:f1d3878b8dd9 271 void SpiritQiSetRssiFilterGain(RssiFilterGain xRssiFg);
vpcola 0:f1d3878b8dd9 272 RssiFilterGain SpiritQiGetRssiFilterGain(void);
vpcola 0:f1d3878b8dd9 273 void SpiritQiSetCsMode(CSMode xCsMode);
vpcola 0:f1d3878b8dd9 274 CSMode SpiritQiGetCsMode(void);
vpcola 0:f1d3878b8dd9 275 void SpiritQiCsTimeoutMask(SpiritFunctionalState xNewState);
vpcola 0:f1d3878b8dd9 276 void SpiritQiPqiTimeoutMask(SpiritFunctionalState xNewState);
vpcola 0:f1d3878b8dd9 277 void SpiritQiSqiTimeoutMask(SpiritFunctionalState xNewState);
vpcola 0:f1d3878b8dd9 278
vpcola 0:f1d3878b8dd9 279
vpcola 0:f1d3878b8dd9 280 /**
vpcola 0:f1d3878b8dd9 281 *@}
vpcola 0:f1d3878b8dd9 282 */
vpcola 0:f1d3878b8dd9 283
vpcola 0:f1d3878b8dd9 284 /**
vpcola 0:f1d3878b8dd9 285 *@}
vpcola 0:f1d3878b8dd9 286 */
vpcola 0:f1d3878b8dd9 287
vpcola 0:f1d3878b8dd9 288
vpcola 0:f1d3878b8dd9 289 /**
vpcola 0:f1d3878b8dd9 290 *@}
vpcola 0:f1d3878b8dd9 291 */
vpcola 0:f1d3878b8dd9 292
vpcola 0:f1d3878b8dd9 293
vpcola 0:f1d3878b8dd9 294 #ifdef __cplusplus
vpcola 0:f1d3878b8dd9 295 }
vpcola 0:f1d3878b8dd9 296 #endif
vpcola 0:f1d3878b8dd9 297
vpcola 0:f1d3878b8dd9 298 #endif
vpcola 0:f1d3878b8dd9 299
vpcola 0:f1d3878b8dd9 300 /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/