wifi test

Dependencies:   X_NUCLEO_IKS01A2 mbed-http

Committer:
JMF
Date:
Wed Sep 05 14:28:24 2018 +0000
Revision:
0:24d3eb812fd4
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
JMF 0:24d3eb812fd4 1 /**
JMF 0:24d3eb812fd4 2 ******************************************************************************
JMF 0:24d3eb812fd4 3 * @file SPIRIT_Timer.h
JMF 0:24d3eb812fd4 4 * @author VMA division - AMS
JMF 0:24d3eb812fd4 5 * @version 3.2.2
JMF 0:24d3eb812fd4 6 * @date 08-July-2015
JMF 0:24d3eb812fd4 7 * @brief Configuration and management of SPIRIT timers.
JMF 0:24d3eb812fd4 8 * @details
JMF 0:24d3eb812fd4 9 *
JMF 0:24d3eb812fd4 10 * This module provides API to configure the Spirit timing mechanisms.
JMF 0:24d3eb812fd4 11 * They allow the user to set the timer registers using raw values or
JMF 0:24d3eb812fd4 12 * compute them since the desired timer value is expressed in ms.
JMF 0:24d3eb812fd4 13 * Moreover the management of the Spirit LDCR mode can be done using
JMF 0:24d3eb812fd4 14 * these API.
JMF 0:24d3eb812fd4 15 *
JMF 0:24d3eb812fd4 16 * <b>Example:</b>
JMF 0:24d3eb812fd4 17 * @code
JMF 0:24d3eb812fd4 18 * ...
JMF 0:24d3eb812fd4 19 *
JMF 0:24d3eb812fd4 20 * SpiritTimerSetRxTimeoutMs(50.0);
JMF 0:24d3eb812fd4 21 * SpiritTimerSetWakeUpTimerMs(150.0);
JMF 0:24d3eb812fd4 22 *
JMF 0:24d3eb812fd4 23 * // IRQ configuration for RX_TIMEOUT and WAKEUP_TIMEOUT
JMF 0:24d3eb812fd4 24 * ...
JMF 0:24d3eb812fd4 25 *
JMF 0:24d3eb812fd4 26 * SpiritTimerLdcrMode(S_ENABLE);
JMF 0:24d3eb812fd4 27 *
JMF 0:24d3eb812fd4 28 * ...
JMF 0:24d3eb812fd4 29 *
JMF 0:24d3eb812fd4 30 * @endcode
JMF 0:24d3eb812fd4 31 *
JMF 0:24d3eb812fd4 32 *
JMF 0:24d3eb812fd4 33 * @attention
JMF 0:24d3eb812fd4 34 *
JMF 0:24d3eb812fd4 35 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
JMF 0:24d3eb812fd4 36 *
JMF 0:24d3eb812fd4 37 * Redistribution and use in source and binary forms, with or without modification,
JMF 0:24d3eb812fd4 38 * are permitted provided that the following conditions are met:
JMF 0:24d3eb812fd4 39 * 1. Redistributions of source code must retain the above copyright notice,
JMF 0:24d3eb812fd4 40 * this list of conditions and the following disclaimer.
JMF 0:24d3eb812fd4 41 * 2. Redistributions in binary form must reproduce the above copyright notice,
JMF 0:24d3eb812fd4 42 * this list of conditions and the following disclaimer in the documentation
JMF 0:24d3eb812fd4 43 * and/or other materials provided with the distribution.
JMF 0:24d3eb812fd4 44 * 3. Neither the name of STMicroelectronics nor the names of its contributors
JMF 0:24d3eb812fd4 45 * may be used to endorse or promote products derived from this software
JMF 0:24d3eb812fd4 46 * without specific prior written permission.
JMF 0:24d3eb812fd4 47 *
JMF 0:24d3eb812fd4 48 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
JMF 0:24d3eb812fd4 49 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
JMF 0:24d3eb812fd4 50 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
JMF 0:24d3eb812fd4 51 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
JMF 0:24d3eb812fd4 52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
JMF 0:24d3eb812fd4 53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
JMF 0:24d3eb812fd4 54 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
JMF 0:24d3eb812fd4 55 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
JMF 0:24d3eb812fd4 56 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
JMF 0:24d3eb812fd4 57 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
JMF 0:24d3eb812fd4 58 *
JMF 0:24d3eb812fd4 59 ******************************************************************************
JMF 0:24d3eb812fd4 60 */
JMF 0:24d3eb812fd4 61
JMF 0:24d3eb812fd4 62 /* Define to prevent recursive inclusion -------------------------------------*/
JMF 0:24d3eb812fd4 63 #ifndef __SPIRIT1_TIMER_H
JMF 0:24d3eb812fd4 64 #define __SPIRIT1_TIMER_H
JMF 0:24d3eb812fd4 65
JMF 0:24d3eb812fd4 66
JMF 0:24d3eb812fd4 67 /* Includes ------------------------------------------------------------------*/
JMF 0:24d3eb812fd4 68
JMF 0:24d3eb812fd4 69 #include "SPIRIT_Regs.h"
JMF 0:24d3eb812fd4 70 #include "SPIRIT_Types.h"
JMF 0:24d3eb812fd4 71
JMF 0:24d3eb812fd4 72
JMF 0:24d3eb812fd4 73 #ifdef __cplusplus
JMF 0:24d3eb812fd4 74 extern "C" {
JMF 0:24d3eb812fd4 75 #endif
JMF 0:24d3eb812fd4 76
JMF 0:24d3eb812fd4 77
JMF 0:24d3eb812fd4 78 /**
JMF 0:24d3eb812fd4 79 * @addtogroup SPIRIT_Libraries
JMF 0:24d3eb812fd4 80 * @{
JMF 0:24d3eb812fd4 81 */
JMF 0:24d3eb812fd4 82
JMF 0:24d3eb812fd4 83
JMF 0:24d3eb812fd4 84 /**
JMF 0:24d3eb812fd4 85 * @defgroup SPIRIT_Timer Timer
JMF 0:24d3eb812fd4 86 * @brief Configuration and management of SPIRIT Timers.
JMF 0:24d3eb812fd4 87 * @details See the file <i>@ref SPIRIT_Timer.h</i> for more details.
JMF 0:24d3eb812fd4 88 * @{
JMF 0:24d3eb812fd4 89 */
JMF 0:24d3eb812fd4 90
JMF 0:24d3eb812fd4 91
JMF 0:24d3eb812fd4 92 /**
JMF 0:24d3eb812fd4 93 * @defgroup Timer_Exported_Types Timer Exported Types
JMF 0:24d3eb812fd4 94 * @{
JMF 0:24d3eb812fd4 95 */
JMF 0:24d3eb812fd4 96
JMF 0:24d3eb812fd4 97 /**
JMF 0:24d3eb812fd4 98 * @brief All the possible RX timeout stop conditions enumeration.
JMF 0:24d3eb812fd4 99 */
JMF 0:24d3eb812fd4 100 typedef enum{
JMF 0:24d3eb812fd4 101
JMF 0:24d3eb812fd4 102 NO_TIMEOUT_STOP = 0x00, /*!< Timeout never stopped */
JMF 0:24d3eb812fd4 103 TIMEOUT_ALWAYS_STOPPED = 0x08, /*!< Timeout always stopped (default) */
JMF 0:24d3eb812fd4 104 RSSI_ABOVE_THRESHOLD = 0x04, /*!< Timeout stopped on RSSI above threshold */
JMF 0:24d3eb812fd4 105 SQI_ABOVE_THRESHOLD = 0x02, /*!< Timeout stopped on SQI above threshold */
JMF 0:24d3eb812fd4 106 PQI_ABOVE_THRESHOLD = 0x01, /*!< Timeout stopped on PQI above threshold */
JMF 0:24d3eb812fd4 107 RSSI_AND_SQI_ABOVE_THRESHOLD = 0x06, /*!< Timeout stopped on both RSSI and SQI above threshold */
JMF 0:24d3eb812fd4 108 RSSI_AND_PQI_ABOVE_THRESHOLD = 0x05, /*!< Timeout stopped on both RSSI and PQI above threshold */
JMF 0:24d3eb812fd4 109 SQI_AND_PQI_ABOVE_THRESHOLD = 0x03, /*!< Timeout stopped on both SQI and PQI above threshold */
JMF 0:24d3eb812fd4 110 ALL_ABOVE_THRESHOLD = 0x07, /*!< Timeout stopped only if RSSI, SQI and PQI are above threshold */
JMF 0:24d3eb812fd4 111 RSSI_OR_SQI_ABOVE_THRESHOLD = 0x0E, /*!< Timeout stopped if one between RSSI or SQI are above threshold */
JMF 0:24d3eb812fd4 112 RSSI_OR_PQI_ABOVE_THRESHOLD = 0x0D, /*!< Timeout stopped if one between RSSI or PQI are above threshold */
JMF 0:24d3eb812fd4 113 SQI_OR_PQI_ABOVE_THRESHOLD = 0x0B, /*!< Timeout stopped if one between SQI or PQI are above threshold */
JMF 0:24d3eb812fd4 114 ANY_ABOVE_THRESHOLD = 0x0F /*!< Timeout stopped if one among RSSI, SQI or SQI are above threshold */
JMF 0:24d3eb812fd4 115
JMF 0:24d3eb812fd4 116 } RxTimeoutStopCondition;
JMF 0:24d3eb812fd4 117
JMF 0:24d3eb812fd4 118
JMF 0:24d3eb812fd4 119 #define IS_RX_TIMEOUT_STOP_CONDITION(COND) ( COND == NO_TIMEOUT_STOP || \
JMF 0:24d3eb812fd4 120 COND == TIMEOUT_ALWAYS_STOPPED || \
JMF 0:24d3eb812fd4 121 COND == RSSI_ABOVE_THRESHOLD || \
JMF 0:24d3eb812fd4 122 COND == SQI_ABOVE_THRESHOLD || \
JMF 0:24d3eb812fd4 123 COND == PQI_ABOVE_THRESHOLD || \
JMF 0:24d3eb812fd4 124 COND == RSSI_AND_SQI_ABOVE_THRESHOLD || \
JMF 0:24d3eb812fd4 125 COND == RSSI_AND_PQI_ABOVE_THRESHOLD || \
JMF 0:24d3eb812fd4 126 COND == SQI_AND_PQI_ABOVE_THRESHOLD || \
JMF 0:24d3eb812fd4 127 COND == ALL_ABOVE_THRESHOLD || \
JMF 0:24d3eb812fd4 128 COND == RSSI_OR_SQI_ABOVE_THRESHOLD || \
JMF 0:24d3eb812fd4 129 COND == RSSI_OR_PQI_ABOVE_THRESHOLD || \
JMF 0:24d3eb812fd4 130 COND == SQI_OR_PQI_ABOVE_THRESHOLD || \
JMF 0:24d3eb812fd4 131 COND == ANY_ABOVE_THRESHOLD )
JMF 0:24d3eb812fd4 132
JMF 0:24d3eb812fd4 133
JMF 0:24d3eb812fd4 134
JMF 0:24d3eb812fd4 135 /**
JMF 0:24d3eb812fd4 136 * @}
JMF 0:24d3eb812fd4 137 */
JMF 0:24d3eb812fd4 138
JMF 0:24d3eb812fd4 139
JMF 0:24d3eb812fd4 140 /**
JMF 0:24d3eb812fd4 141 * @defgroup Timer_Exported_Constants Timer Exported Constants
JMF 0:24d3eb812fd4 142 * @{
JMF 0:24d3eb812fd4 143 */
JMF 0:24d3eb812fd4 144
JMF 0:24d3eb812fd4 145 /**
JMF 0:24d3eb812fd4 146 * @brief It represents the Time Step for RX_Timeout timer in case of 24 MHz Crystal, expressed in us.
JMF 0:24d3eb812fd4 147 * It is equal to 1210/(24*10^6). With this time step it is possible to fix the RX_Timeout to
JMF 0:24d3eb812fd4 148 * a minimum value of 50.417us to a maximum value of about 3.278 s.
JMF 0:24d3eb812fd4 149 * Remember that it is possible to have infinite RX_Timeout writing 0 in the RX_Timeout_Counter and/or RX_Timeout_Prescaler registers.
JMF 0:24d3eb812fd4 150 */
JMF 0:24d3eb812fd4 151 #define RX_TCLK_24MHz 50.417f
JMF 0:24d3eb812fd4 152 #define IS_RX_TIMEOUT_24MHz(TIMEOUT) (TIMEOUT*1000)>=RX_TCLK_24MHz
JMF 0:24d3eb812fd4 153
JMF 0:24d3eb812fd4 154 /**
JMF 0:24d3eb812fd4 155 * @brief It represents the Time Step for RX_Timeout timer in case of 26 MHz Crystal, expressed in us.
JMF 0:24d3eb812fd4 156 * It is equal to 1210/(26*10^6). With this time step it is possible to fix the RX_Timeout to
JMF 0:24d3eb812fd4 157 * a minimum value of 46.538us to a maximum value of about 3.026 s.
JMF 0:24d3eb812fd4 158 * Remember that it is possible to have infinite RX_Timeout writing 0 in the RX_Timeout_Counter register.
JMF 0:24d3eb812fd4 159 */
JMF 0:24d3eb812fd4 160 #define RX_TCLK_26MHz 46.538f
JMF 0:24d3eb812fd4 161 #define IS_RX_TIMEOUT_26MHz(TIMEOUT) (TIMEOUT*1000)>=RX_TCLK_26MHz
JMF 0:24d3eb812fd4 162
JMF 0:24d3eb812fd4 163 /**
JMF 0:24d3eb812fd4 164 * @brief It represents the Time Step for RX_Wakeup timer expressed in us. This timer is based on RCO (about 34.7 kHZ).
JMF 0:24d3eb812fd4 165 * With this time step it is possible to fix the Wakeup_Timeout to a minimum value of 28.818us to a maximum
JMF 0:24d3eb812fd4 166 * value of about 1.888 s.
JMF 0:24d3eb812fd4 167 */
JMF 0:24d3eb812fd4 168 #define WAKEUP_TCLK 28.818f
JMF 0:24d3eb812fd4 169 #define IS_WKUP_TIMEOUT(TIMEOUT) (TIMEOUT*1000)>=WAKEUP_TCLK
JMF 0:24d3eb812fd4 170
JMF 0:24d3eb812fd4 171
JMF 0:24d3eb812fd4 172
JMF 0:24d3eb812fd4 173 /**
JMF 0:24d3eb812fd4 174 * @}
JMF 0:24d3eb812fd4 175 */
JMF 0:24d3eb812fd4 176
JMF 0:24d3eb812fd4 177
JMF 0:24d3eb812fd4 178 /**
JMF 0:24d3eb812fd4 179 * @defgroup Timer_Exported_Macros Timer Exported Macros
JMF 0:24d3eb812fd4 180 * @{
JMF 0:24d3eb812fd4 181 */
JMF 0:24d3eb812fd4 182
JMF 0:24d3eb812fd4 183 #define SET_INFINITE_RX_TIMEOUT() SpiritTimerSetRxTimeoutCounter(0)
JMF 0:24d3eb812fd4 184
JMF 0:24d3eb812fd4 185 /**
JMF 0:24d3eb812fd4 186 * @}
JMF 0:24d3eb812fd4 187 */
JMF 0:24d3eb812fd4 188
JMF 0:24d3eb812fd4 189
JMF 0:24d3eb812fd4 190 /**
JMF 0:24d3eb812fd4 191 * @defgroup Timer_Exported_Functions Timer Exported Functions
JMF 0:24d3eb812fd4 192 * @{
JMF 0:24d3eb812fd4 193 */
JMF 0:24d3eb812fd4 194
JMF 0:24d3eb812fd4 195 void SpiritTimerLdcrMode(SpiritFunctionalState xNewState);
JMF 0:24d3eb812fd4 196 void SpiritTimerLdcrAutoReload(SpiritFunctionalState xNewState);
JMF 0:24d3eb812fd4 197 SpiritFunctionalState SpiritTimerLdcrGetAutoReload(void);
JMF 0:24d3eb812fd4 198 void SpiritTimerSetRxTimeout(uint8_t cCounter , uint8_t cPrescaler);
JMF 0:24d3eb812fd4 199 void SpiritTimerSetRxTimeoutMs(float fDesiredMsec);
JMF 0:24d3eb812fd4 200 void SpiritTimerSetRxTimeoutCounter(uint8_t cCounter);
JMF 0:24d3eb812fd4 201 void SpiritTimerSetRxTimeoutPrescaler(uint8_t cPrescaler);
JMF 0:24d3eb812fd4 202 void SpiritTimerGetRxTimeout(float* pfTimeoutMsec, uint8_t* pcCounter , uint8_t* pcPrescaler);
JMF 0:24d3eb812fd4 203 void SpiritTimerSetWakeUpTimer(uint8_t cCounter , uint8_t cPrescaler);
JMF 0:24d3eb812fd4 204 void SpiritTimerSetWakeUpTimerMs(float fDesiredMsec);
JMF 0:24d3eb812fd4 205 void SpiritTimerSetWakeUpTimerCounter(uint8_t cCounter);
JMF 0:24d3eb812fd4 206 void SpiritTimerSetWakeUpTimerPrescaler(uint8_t cPrescaler);
JMF 0:24d3eb812fd4 207 void SpiritTimerSetWakeUpTimerReloadMs(float fDesiredMsec);
JMF 0:24d3eb812fd4 208 void SpiritTimerGetWakeUpTimer(float* pfWakeUpMsec, uint8_t* pcCounter , uint8_t* pcPrescaler);
JMF 0:24d3eb812fd4 209 void SpiritTimerSetWakeUpTimerReload(uint8_t cCounter , uint8_t cPrescaler);
JMF 0:24d3eb812fd4 210 void SpiritTimerSetWakeUpTimerReloadCounter(uint8_t cCounter);
JMF 0:24d3eb812fd4 211 void SpiritTimerSetWakeUpTimerReloadPrescaler(uint8_t cPrescaler);
JMF 0:24d3eb812fd4 212 void SpiritTimerGetWakeUpTimerReload(float* pfWakeUpReloadMsec, uint8_t* pcCounter , uint8_t* pcPrescaler);
JMF 0:24d3eb812fd4 213 void SpiritTimerComputeWakeUpValues(float fDesiredMsec , uint8_t* pcCounter , uint8_t* pcPrescaler);
JMF 0:24d3eb812fd4 214 void SpiritTimerComputeRxTimeoutValues(float fDesiredMsec , uint8_t* pcCounter , uint8_t* pcPrescaler);
JMF 0:24d3eb812fd4 215 void SpiritTimerSetRxTimeoutStopCondition(RxTimeoutStopCondition xStopCondition);
JMF 0:24d3eb812fd4 216 void SpiritTimerReloadStrobe(void);
JMF 0:24d3eb812fd4 217 uint16_t SpiritTimerGetRcoFrequency(void);
JMF 0:24d3eb812fd4 218
JMF 0:24d3eb812fd4 219 /**
JMF 0:24d3eb812fd4 220 * @}
JMF 0:24d3eb812fd4 221 */
JMF 0:24d3eb812fd4 222
JMF 0:24d3eb812fd4 223 /**
JMF 0:24d3eb812fd4 224 * @}
JMF 0:24d3eb812fd4 225 */
JMF 0:24d3eb812fd4 226
JMF 0:24d3eb812fd4 227
JMF 0:24d3eb812fd4 228 /**
JMF 0:24d3eb812fd4 229 * @}
JMF 0:24d3eb812fd4 230 */
JMF 0:24d3eb812fd4 231
JMF 0:24d3eb812fd4 232 #ifdef __cplusplus
JMF 0:24d3eb812fd4 233 }
JMF 0:24d3eb812fd4 234 #endif
JMF 0:24d3eb812fd4 235
JMF 0:24d3eb812fd4 236 #endif
JMF 0:24d3eb812fd4 237
JMF 0:24d3eb812fd4 238 /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/
JMF 0:24d3eb812fd4 239