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_Calibration.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 VCO-RCO calibration.
vpcola 0:f1d3878b8dd9 8 *
vpcola 0:f1d3878b8dd9 9 * @details
vpcola 0:f1d3878b8dd9 10 *
vpcola 0:f1d3878b8dd9 11 * This module allows the user to set some parameters which deal
vpcola 0:f1d3878b8dd9 12 * with the oscillators calibration.
vpcola 0:f1d3878b8dd9 13 * The state machine of Spirit contemplates some optional calibrating operations
vpcola 0:f1d3878b8dd9 14 * in the transition between the READY and the LOCK state.
vpcola 0:f1d3878b8dd9 15 * The user is allowed to enable or disable the automatic RCO/VCO calibration
vpcola 0:f1d3878b8dd9 16 * by calling the functions <i>@ref SpiritCalibrationVco()</i> and <i>@ref SpiritCalibrationRco()</i>.
vpcola 0:f1d3878b8dd9 17 * The following example shows how to do an initial calibration of VCO.
vpcola 0:f1d3878b8dd9 18 *
vpcola 0:f1d3878b8dd9 19 * <b>Example:</b>
vpcola 0:f1d3878b8dd9 20 * @code
vpcola 0:f1d3878b8dd9 21 * uint8_t calData;
vpcola 0:f1d3878b8dd9 22 *
vpcola 0:f1d3878b8dd9 23 * SpiritCalibrationVco(S_ENABLE);
vpcola 0:f1d3878b8dd9 24 * SpiritCmdStrobeLockTx();
vpcola 0:f1d3878b8dd9 25 *
vpcola 0:f1d3878b8dd9 26 * while(g_xStatus.MC_STATE != MC_STATE_LOCK){
vpcola 0:f1d3878b8dd9 27 * SpiritRefreshStatus();
vpcola 0:f1d3878b8dd9 28 * }
vpcola 0:f1d3878b8dd9 29 *
vpcola 0:f1d3878b8dd9 30 * calData = SpiritCalibrationGetVcoCalDataTx();
vpcola 0:f1d3878b8dd9 31 * SpiritCalibrationSetVcoCalDataTx(calData);
vpcola 0:f1d3878b8dd9 32 *
vpcola 0:f1d3878b8dd9 33 * SpiritCmdStrobeReady();
vpcola 0:f1d3878b8dd9 34 * SpiritCalibrationVco(S_DISABLE);
vpcola 0:f1d3878b8dd9 35 *
vpcola 0:f1d3878b8dd9 36 * @endcode
vpcola 0:f1d3878b8dd9 37 *
vpcola 0:f1d3878b8dd9 38 * Similar operations can be done for the RCO calibrator.
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_CALIBRATION_H
vpcola 0:f1d3878b8dd9 71 #define __SPIRIT_CALIBRATION_H
vpcola 0:f1d3878b8dd9 72
vpcola 0:f1d3878b8dd9 73
vpcola 0:f1d3878b8dd9 74 /* Includes ------------------------------------------------------------------*/
vpcola 0:f1d3878b8dd9 75
vpcola 0:f1d3878b8dd9 76 #include "SPIRIT_Regs.h"
vpcola 0:f1d3878b8dd9 77 #include "SPIRIT_Types.h"
vpcola 0:f1d3878b8dd9 78
vpcola 0:f1d3878b8dd9 79
vpcola 0:f1d3878b8dd9 80 #ifdef __cplusplus
vpcola 0:f1d3878b8dd9 81 extern "C" {
vpcola 0:f1d3878b8dd9 82 #endif
vpcola 0:f1d3878b8dd9 83
vpcola 0:f1d3878b8dd9 84
vpcola 0:f1d3878b8dd9 85 /**
vpcola 0:f1d3878b8dd9 86 * @addtogroup SPIRIT_Libraries
vpcola 0:f1d3878b8dd9 87 * @{
vpcola 0:f1d3878b8dd9 88 */
vpcola 0:f1d3878b8dd9 89
vpcola 0:f1d3878b8dd9 90
vpcola 0:f1d3878b8dd9 91 /**
vpcola 0:f1d3878b8dd9 92 * @defgroup SPIRIT_Calibration Calibration
vpcola 0:f1d3878b8dd9 93 * @brief Configuration and management of SPIRIT VCO-RCO calibration.
vpcola 0:f1d3878b8dd9 94 * @details See the file <i>@ref SPIRIT_Calibration.h</i> for more details.
vpcola 0:f1d3878b8dd9 95 * @{
vpcola 0:f1d3878b8dd9 96 */
vpcola 0:f1d3878b8dd9 97
vpcola 0:f1d3878b8dd9 98 /**
vpcola 0:f1d3878b8dd9 99 * @defgroup Calibration_Exported_Types Calibration Exported Types
vpcola 0:f1d3878b8dd9 100 * @{
vpcola 0:f1d3878b8dd9 101 */
vpcola 0:f1d3878b8dd9 102
vpcola 0:f1d3878b8dd9 103
vpcola 0:f1d3878b8dd9 104 /**
vpcola 0:f1d3878b8dd9 105 * @brief VCO / RCO calibration window.
vpcola 0:f1d3878b8dd9 106 */
vpcola 0:f1d3878b8dd9 107 typedef enum
vpcola 0:f1d3878b8dd9 108 {
vpcola 0:f1d3878b8dd9 109
vpcola 0:f1d3878b8dd9 110 CALIB_TIME_7_33_US_24MHZ = 0x00, /*!< calibration window of 7.33 us with XTAL=24MHz */
vpcola 0:f1d3878b8dd9 111 CALIB_TIME_14_67_US_24MHZ, /*!< calibration window of 14.67 us with XTAL=24MHz */
vpcola 0:f1d3878b8dd9 112 CALIB_TIME_29_33_US_24MHZ, /*!< calibration window of 29.33 us with XTAL=24MHz */
vpcola 0:f1d3878b8dd9 113 CALIB_TIME_58_67_US_24MHZ, /*!< calibration window of 58.67 us with XTAL=24MHz */
vpcola 0:f1d3878b8dd9 114
vpcola 0:f1d3878b8dd9 115 CALIB_TIME_6_77_US_26MHZ = 0x00, /*!< calibration window of 6.77 us with XTAL=26MHz */
vpcola 0:f1d3878b8dd9 116 CALIB_TIME_13_54_US_26MHZ, /*!< calibration window of 13.54 us with XTAL=26MHz */
vpcola 0:f1d3878b8dd9 117 CALIB_TIME_27_08_US_26MHZ, /*!< calibration window of 27.08 us with XTAL=26MHz */
vpcola 0:f1d3878b8dd9 118 CALIB_TIME_54_15_US_26MHZ /*!< calibration window of 54.15 us with XTAL=26MHz */
vpcola 0:f1d3878b8dd9 119
vpcola 0:f1d3878b8dd9 120 } VcoWin;
vpcola 0:f1d3878b8dd9 121
vpcola 0:f1d3878b8dd9 122
vpcola 0:f1d3878b8dd9 123 #define IS_VCO_WIN(REF) (REF == CALIB_TIME_7_33_US_24MHZ ||\
vpcola 0:f1d3878b8dd9 124 REF == CALIB_TIME_14_67_US_24MHZ ||\
vpcola 0:f1d3878b8dd9 125 REF == CALIB_TIME_29_33_US_24MHZ ||\
vpcola 0:f1d3878b8dd9 126 REF == CALIB_TIME_58_67_US_24MHZ ||\
vpcola 0:f1d3878b8dd9 127 REF == CALIB_TIME_6_77_US_26MHZ ||\
vpcola 0:f1d3878b8dd9 128 REF == CALIB_TIME_13_54_US_26MHZ ||\
vpcola 0:f1d3878b8dd9 129 REF == CALIB_TIME_27_08_US_26MHZ ||\
vpcola 0:f1d3878b8dd9 130 REF == CALIB_TIME_54_15_US_26MHZ \
vpcola 0:f1d3878b8dd9 131 )
vpcola 0:f1d3878b8dd9 132
vpcola 0:f1d3878b8dd9 133 /**
vpcola 0:f1d3878b8dd9 134 * @brief VCO_H / VCO_L selection.
vpcola 0:f1d3878b8dd9 135 */
vpcola 0:f1d3878b8dd9 136 typedef enum
vpcola 0:f1d3878b8dd9 137 {
vpcola 0:f1d3878b8dd9 138
vpcola 0:f1d3878b8dd9 139 VCO_L = 0x00, /*!< VCO lower */
vpcola 0:f1d3878b8dd9 140 VCO_H, /*!< VCO higher */
vpcola 0:f1d3878b8dd9 141 } VcoSel;
vpcola 0:f1d3878b8dd9 142
vpcola 0:f1d3878b8dd9 143
vpcola 0:f1d3878b8dd9 144 #define IS_VCO_SEL(REF) (REF == VCO_L ||\
vpcola 0:f1d3878b8dd9 145 REF == VCO_H \
vpcola 0:f1d3878b8dd9 146 )
vpcola 0:f1d3878b8dd9 147
vpcola 0:f1d3878b8dd9 148
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 * @defgroup Calibration_Exported_Constants Calibration Exported Constants
vpcola 0:f1d3878b8dd9 156 * @{
vpcola 0:f1d3878b8dd9 157 */
vpcola 0:f1d3878b8dd9 158
vpcola 0:f1d3878b8dd9 159 /**
vpcola 0:f1d3878b8dd9 160 * @}
vpcola 0:f1d3878b8dd9 161 */
vpcola 0:f1d3878b8dd9 162
vpcola 0:f1d3878b8dd9 163
vpcola 0:f1d3878b8dd9 164
vpcola 0:f1d3878b8dd9 165 /** @defgroup VCO_Calibration VCO Calibration
vpcola 0:f1d3878b8dd9 166 * @{
vpcola 0:f1d3878b8dd9 167 */
vpcola 0:f1d3878b8dd9 168
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 * @defgroup Calibration_Exported_Macros Calibration Exported Macros
vpcola 0:f1d3878b8dd9 178 * @{
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 Calibration_Exported_Functions Calibration Exported Functions
vpcola 0:f1d3878b8dd9 189 * @{
vpcola 0:f1d3878b8dd9 190 */
vpcola 0:f1d3878b8dd9 191
vpcola 0:f1d3878b8dd9 192 void SpiritCalibrationRco(SpiritFunctionalState xNewState);
vpcola 0:f1d3878b8dd9 193 void SpiritCalibrationVco(SpiritFunctionalState xNewState);
vpcola 0:f1d3878b8dd9 194 void SpiritCalibrationSetRcoCalWords(uint8_t cRwt, uint8_t cRfb);
vpcola 0:f1d3878b8dd9 195 void SpiritCalibrationGetRcoCalWords(uint8_t* pcRwt, uint8_t* pcRfb);
vpcola 0:f1d3878b8dd9 196 uint8_t SpiritCalibrationGetVcoCalData(void);
vpcola 0:f1d3878b8dd9 197 void SpiritCalibrationSetVcoCalDataTx(uint8_t cVcoCalData);
vpcola 0:f1d3878b8dd9 198 uint8_t SpiritCalibrationGetVcoCalDataTx(void);
vpcola 0:f1d3878b8dd9 199 void SpiritCalibrationSetVcoCalDataRx(uint8_t cVcoCalData);
vpcola 0:f1d3878b8dd9 200 uint8_t SpiritCalibrationGetVcoCalDataRx(void);
vpcola 0:f1d3878b8dd9 201 void SpiritCalibrationSetVcoWindow(VcoWin xRefWord);
vpcola 0:f1d3878b8dd9 202 VcoWin SpiritCalibrationGetVcoWindow(void);
vpcola 0:f1d3878b8dd9 203 VcoSel SpiritCalibrationGetVcoSelecttion(void);
vpcola 0:f1d3878b8dd9 204 void SpiritCalibrationSelectVco(VcoSel xVco);
vpcola 0:f1d3878b8dd9 205
vpcola 0:f1d3878b8dd9 206 /**
vpcola 0:f1d3878b8dd9 207 * @}
vpcola 0:f1d3878b8dd9 208 */
vpcola 0:f1d3878b8dd9 209
vpcola 0:f1d3878b8dd9 210
vpcola 0:f1d3878b8dd9 211 /**
vpcola 0:f1d3878b8dd9 212 * @}
vpcola 0:f1d3878b8dd9 213 */
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 #ifdef __cplusplus
vpcola 0:f1d3878b8dd9 221 }
vpcola 0:f1d3878b8dd9 222 #endif
vpcola 0:f1d3878b8dd9 223
vpcola 0:f1d3878b8dd9 224 #endif
vpcola 0:f1d3878b8dd9 225
vpcola 0:f1d3878b8dd9 226 /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/