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_Management.c
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 The management layer for SPIRIT1 library.
vpcola 0:f1d3878b8dd9 8 * @details
vpcola 0:f1d3878b8dd9 9 *
vpcola 0:f1d3878b8dd9 10 * @attention
vpcola 0:f1d3878b8dd9 11 *
vpcola 0:f1d3878b8dd9 12 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
vpcola 0:f1d3878b8dd9 13 *
vpcola 0:f1d3878b8dd9 14 * Redistribution and use in source and binary forms, with or without modification,
vpcola 0:f1d3878b8dd9 15 * are permitted provided that the following conditions are met:
vpcola 0:f1d3878b8dd9 16 * 1. Redistributions of source code must retain the above copyright notice,
vpcola 0:f1d3878b8dd9 17 * this list of conditions and the following disclaimer.
vpcola 0:f1d3878b8dd9 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
vpcola 0:f1d3878b8dd9 19 * this list of conditions and the following disclaimer in the documentation
vpcola 0:f1d3878b8dd9 20 * and/or other materials provided with the distribution.
vpcola 0:f1d3878b8dd9 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
vpcola 0:f1d3878b8dd9 22 * may be used to endorse or promote products derived from this software
vpcola 0:f1d3878b8dd9 23 * without specific prior written permission.
vpcola 0:f1d3878b8dd9 24 *
vpcola 0:f1d3878b8dd9 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
vpcola 0:f1d3878b8dd9 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
vpcola 0:f1d3878b8dd9 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
vpcola 0:f1d3878b8dd9 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
vpcola 0:f1d3878b8dd9 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
vpcola 0:f1d3878b8dd9 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
vpcola 0:f1d3878b8dd9 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
vpcola 0:f1d3878b8dd9 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
vpcola 0:f1d3878b8dd9 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
vpcola 0:f1d3878b8dd9 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
vpcola 0:f1d3878b8dd9 35 *
vpcola 0:f1d3878b8dd9 36 ******************************************************************************
vpcola 0:f1d3878b8dd9 37 */
vpcola 0:f1d3878b8dd9 38
vpcola 0:f1d3878b8dd9 39 /* Includes ------------------------------------------------------------------*/
vpcola 0:f1d3878b8dd9 40 #include "SPIRIT_Management.h"
vpcola 0:f1d3878b8dd9 41
vpcola 0:f1d3878b8dd9 42 /**
vpcola 0:f1d3878b8dd9 43 * @addtogroup SPIRIT_Libraries
vpcola 0:f1d3878b8dd9 44 * @{
vpcola 0:f1d3878b8dd9 45 */
vpcola 0:f1d3878b8dd9 46
vpcola 0:f1d3878b8dd9 47
vpcola 0:f1d3878b8dd9 48 /**
vpcola 0:f1d3878b8dd9 49 * @defgroup SPIRIT_MANAGEMENT SPIRIT Management
vpcola 0:f1d3878b8dd9 50 * @{
vpcola 0:f1d3878b8dd9 51 */
vpcola 0:f1d3878b8dd9 52
vpcola 0:f1d3878b8dd9 53 /**
vpcola 0:f1d3878b8dd9 54 * @brief BS value to write in the SYNT0 register according to the selected band
vpcola 0:f1d3878b8dd9 55 */
vpcola 0:f1d3878b8dd9 56 static const uint8_t s_vectcBandRegValue[4]={SYNT0_BS_6, SYNT0_BS_12, SYNT0_BS_16, SYNT0_BS_32};
vpcola 0:f1d3878b8dd9 57
vpcola 0:f1d3878b8dd9 58 #define COMMUNICATION_STATE_TX 0
vpcola 0:f1d3878b8dd9 59 #define COMMUNICATION_STATE_RX 1
vpcola 0:f1d3878b8dd9 60 #define COMMUNICATION_STATE_NONE 2
vpcola 0:f1d3878b8dd9 61
vpcola 0:f1d3878b8dd9 62 static uint32_t s_nDesiredFrequency;
vpcola 0:f1d3878b8dd9 63
vpcola 0:f1d3878b8dd9 64 static volatile uint8_t s_cCommunicationState = COMMUNICATION_STATE_NONE;
vpcola 0:f1d3878b8dd9 65
vpcola 0:f1d3878b8dd9 66
vpcola 0:f1d3878b8dd9 67 /**
vpcola 0:f1d3878b8dd9 68 * @brief Factor is: B/2 used in the formula for SYNTH word calculation
vpcola 0:f1d3878b8dd9 69 */
vpcola 0:f1d3878b8dd9 70 static const uint8_t s_vectcBHalfFactor[4]={(HIGH_BAND_FACTOR/2), (MIDDLE_BAND_FACTOR/2), (LOW_BAND_FACTOR/2), (VERY_LOW_BAND_FACTOR/2)};
vpcola 0:f1d3878b8dd9 71
vpcola 0:f1d3878b8dd9 72
vpcola 0:f1d3878b8dd9 73 /**
vpcola 0:f1d3878b8dd9 74 * @defgroup SPIRIT_MANAGEMENT_FUNCTIONS SPIRIT Management Functions
vpcola 0:f1d3878b8dd9 75 * @{
vpcola 0:f1d3878b8dd9 76 */
vpcola 0:f1d3878b8dd9 77
vpcola 0:f1d3878b8dd9 78
vpcola 0:f1d3878b8dd9 79 /**
vpcola 0:f1d3878b8dd9 80 * @defgroup WORKAROUND_FUNCTIONS SPIRIT Management Workaround Functions
vpcola 0:f1d3878b8dd9 81 * @{
vpcola 0:f1d3878b8dd9 82 */
vpcola 0:f1d3878b8dd9 83
vpcola 0:f1d3878b8dd9 84 /**
vpcola 0:f1d3878b8dd9 85 * @brief Private SpiritRadioSetFrequencyBase function only used in SpiritManagementWaVcoCalibration.
vpcola 0:f1d3878b8dd9 86 * @param lFBase the base carrier frequency expressed in Hz as unsigned word.
vpcola 0:f1d3878b8dd9 87 * @retval None.
vpcola 0:f1d3878b8dd9 88 */
vpcola 0:f1d3878b8dd9 89 void SpiritManagementSetFrequencyBase(uint32_t lFBase)
vpcola 0:f1d3878b8dd9 90 {
vpcola 0:f1d3878b8dd9 91 uint32_t synthWord, Fc;
vpcola 0:f1d3878b8dd9 92 uint8_t band = 0, anaRadioRegArray[4], wcp;
vpcola 0:f1d3878b8dd9 93
vpcola 0:f1d3878b8dd9 94 /* Check the parameter */
vpcola 0:f1d3878b8dd9 95 s_assert_param(IS_FREQUENCY_BAND(lFBase));
vpcola 0:f1d3878b8dd9 96
vpcola 0:f1d3878b8dd9 97 /* Search the operating band */
vpcola 0:f1d3878b8dd9 98 if(IS_FREQUENCY_BAND_HIGH(lFBase))
vpcola 0:f1d3878b8dd9 99 {
vpcola 0:f1d3878b8dd9 100 band = HIGH_BAND;
vpcola 0:f1d3878b8dd9 101 }
vpcola 0:f1d3878b8dd9 102 else if(IS_FREQUENCY_BAND_MIDDLE(lFBase))
vpcola 0:f1d3878b8dd9 103 {
vpcola 0:f1d3878b8dd9 104 band = MIDDLE_BAND;
vpcola 0:f1d3878b8dd9 105 }
vpcola 0:f1d3878b8dd9 106 else if(IS_FREQUENCY_BAND_LOW(lFBase))
vpcola 0:f1d3878b8dd9 107 {
vpcola 0:f1d3878b8dd9 108 band = LOW_BAND;
vpcola 0:f1d3878b8dd9 109 }
vpcola 0:f1d3878b8dd9 110 else if(IS_FREQUENCY_BAND_VERY_LOW(lFBase))
vpcola 0:f1d3878b8dd9 111 {
vpcola 0:f1d3878b8dd9 112 band = VERY_LOW_BAND;
vpcola 0:f1d3878b8dd9 113 }
vpcola 0:f1d3878b8dd9 114
vpcola 0:f1d3878b8dd9 115 int32_t FOffset = SpiritRadioGetFrequencyOffset();
vpcola 0:f1d3878b8dd9 116 uint32_t lChannelSpace = SpiritRadioGetChannelSpace();
vpcola 0:f1d3878b8dd9 117 uint8_t cChannelNum = SpiritRadioGetChannel();
vpcola 0:f1d3878b8dd9 118
vpcola 0:f1d3878b8dd9 119 /* Calculates the channel center frequency */
vpcola 0:f1d3878b8dd9 120 Fc = lFBase + FOffset + lChannelSpace*cChannelNum;
vpcola 0:f1d3878b8dd9 121
vpcola 0:f1d3878b8dd9 122 /* Reads the reference divider */
vpcola 0:f1d3878b8dd9 123 uint8_t cRefDiv = (uint8_t)SpiritRadioGetRefDiv()+1;
vpcola 0:f1d3878b8dd9 124
vpcola 0:f1d3878b8dd9 125 switch(band)
vpcola 0:f1d3878b8dd9 126 {
vpcola 0:f1d3878b8dd9 127 case VERY_LOW_BAND:
vpcola 0:f1d3878b8dd9 128 if(Fc<161281250)
vpcola 0:f1d3878b8dd9 129 {
vpcola 0:f1d3878b8dd9 130 SpiritCalibrationSelectVco(VCO_L);
vpcola 0:f1d3878b8dd9 131 }
vpcola 0:f1d3878b8dd9 132 else
vpcola 0:f1d3878b8dd9 133 {
vpcola 0:f1d3878b8dd9 134 SpiritCalibrationSelectVco(VCO_H);
vpcola 0:f1d3878b8dd9 135 }
vpcola 0:f1d3878b8dd9 136 break;
vpcola 0:f1d3878b8dd9 137
vpcola 0:f1d3878b8dd9 138 case LOW_BAND:
vpcola 0:f1d3878b8dd9 139 if(Fc<322562500)
vpcola 0:f1d3878b8dd9 140 {
vpcola 0:f1d3878b8dd9 141 SpiritCalibrationSelectVco(VCO_L);
vpcola 0:f1d3878b8dd9 142 }
vpcola 0:f1d3878b8dd9 143 else
vpcola 0:f1d3878b8dd9 144 {
vpcola 0:f1d3878b8dd9 145 SpiritCalibrationSelectVco(VCO_H);
vpcola 0:f1d3878b8dd9 146 }
vpcola 0:f1d3878b8dd9 147 break;
vpcola 0:f1d3878b8dd9 148
vpcola 0:f1d3878b8dd9 149 case MIDDLE_BAND:
vpcola 0:f1d3878b8dd9 150 if(Fc<430083334)
vpcola 0:f1d3878b8dd9 151 {
vpcola 0:f1d3878b8dd9 152 SpiritCalibrationSelectVco(VCO_L);
vpcola 0:f1d3878b8dd9 153 }
vpcola 0:f1d3878b8dd9 154 else
vpcola 0:f1d3878b8dd9 155 {
vpcola 0:f1d3878b8dd9 156 SpiritCalibrationSelectVco(VCO_H);
vpcola 0:f1d3878b8dd9 157 }
vpcola 0:f1d3878b8dd9 158 break;
vpcola 0:f1d3878b8dd9 159
vpcola 0:f1d3878b8dd9 160 case HIGH_BAND:
vpcola 0:f1d3878b8dd9 161 if(Fc<860166667)
vpcola 0:f1d3878b8dd9 162 {
vpcola 0:f1d3878b8dd9 163 SpiritCalibrationSelectVco(VCO_L);
vpcola 0:f1d3878b8dd9 164 }
vpcola 0:f1d3878b8dd9 165 else
vpcola 0:f1d3878b8dd9 166 {
vpcola 0:f1d3878b8dd9 167 SpiritCalibrationSelectVco(VCO_H);
vpcola 0:f1d3878b8dd9 168 }
vpcola 0:f1d3878b8dd9 169 }
vpcola 0:f1d3878b8dd9 170
vpcola 0:f1d3878b8dd9 171 /* Search the VCO charge pump word and set the corresponding register */
vpcola 0:f1d3878b8dd9 172 wcp = SpiritRadioSearchWCP(Fc);
vpcola 0:f1d3878b8dd9 173
vpcola 0:f1d3878b8dd9 174 synthWord = (uint32_t)(lFBase*(((double)(FBASE_DIVIDER*cRefDiv*s_vectcBHalfFactor[band]))/SpiritRadioGetXtalFrequency()));
vpcola 0:f1d3878b8dd9 175
vpcola 0:f1d3878b8dd9 176 /* Build the array of registers values for the analog part */
vpcola 0:f1d3878b8dd9 177 anaRadioRegArray[0] = (uint8_t)(((synthWord>>21)&(0x0000001F))|(wcp<<5));
vpcola 0:f1d3878b8dd9 178 anaRadioRegArray[1] = (uint8_t)((synthWord>>13)&(0x000000FF));
vpcola 0:f1d3878b8dd9 179 anaRadioRegArray[2] = (uint8_t)((synthWord>>5)&(0x000000FF));
vpcola 0:f1d3878b8dd9 180 anaRadioRegArray[3] = (uint8_t)(((synthWord&0x0000001F)<<3)| s_vectcBandRegValue[band]);
vpcola 0:f1d3878b8dd9 181
vpcola 0:f1d3878b8dd9 182 /* Configures the needed Analog Radio registers */
vpcola 0:f1d3878b8dd9 183 g_xStatus = SpiritSpiWriteRegisters(SYNT3_BASE, 4, anaRadioRegArray);
vpcola 0:f1d3878b8dd9 184 }
vpcola 0:f1d3878b8dd9 185
vpcola 0:f1d3878b8dd9 186 uint8_t SpiritManagementWaVcoCalibration(void)
vpcola 0:f1d3878b8dd9 187 {
vpcola 0:f1d3878b8dd9 188 uint8_t s_cVcoWordRx;
vpcola 0:f1d3878b8dd9 189 uint8_t s_cVcoWordTx;
vpcola 0:f1d3878b8dd9 190 uint32_t nFreq;
vpcola 0:f1d3878b8dd9 191 uint8_t cRestore = 0;
vpcola 0:f1d3878b8dd9 192 uint8_t cStandby = 0;
vpcola 0:f1d3878b8dd9 193 uint32_t xtal_frequency = SpiritRadioGetXtalFrequency();
vpcola 0:f1d3878b8dd9 194
vpcola 0:f1d3878b8dd9 195 /* Enable the reference divider if the XTAL is between 48 and 52 MHz */
vpcola 0:f1d3878b8dd9 196 if(xtal_frequency>DOUBLE_XTAL_THR)
vpcola 0:f1d3878b8dd9 197 {
vpcola 0:f1d3878b8dd9 198 if(!SpiritRadioGetRefDiv())
vpcola 0:f1d3878b8dd9 199 {
vpcola 0:f1d3878b8dd9 200 cRestore = 1;
vpcola 0:f1d3878b8dd9 201 nFreq = SpiritRadioGetFrequencyBase();
vpcola 0:f1d3878b8dd9 202 SpiritRadioSetRefDiv(S_ENABLE);
vpcola 0:f1d3878b8dd9 203 SpiritManagementSetFrequencyBase(nFreq);
vpcola 0:f1d3878b8dd9 204 }
vpcola 0:f1d3878b8dd9 205 }
vpcola 0:f1d3878b8dd9 206 nFreq = SpiritRadioGetFrequencyBase();
vpcola 0:f1d3878b8dd9 207
vpcola 0:f1d3878b8dd9 208 /* Increase the VCO current */
vpcola 0:f1d3878b8dd9 209 uint8_t tmp = 0x19; SpiritSpiWriteRegisters(0xA1,1,&tmp);
vpcola 0:f1d3878b8dd9 210
vpcola 0:f1d3878b8dd9 211 SpiritCalibrationVco(S_ENABLE);
vpcola 0:f1d3878b8dd9 212
vpcola 0:f1d3878b8dd9 213 SpiritRefreshStatus();
vpcola 0:f1d3878b8dd9 214 if(g_xStatus.MC_STATE == MC_STATE_STANDBY)
vpcola 0:f1d3878b8dd9 215 {
vpcola 0:f1d3878b8dd9 216 cStandby = 1;
vpcola 0:f1d3878b8dd9 217 SpiritCmdStrobeReady();
vpcola 0:f1d3878b8dd9 218 do{
vpcola 0:f1d3878b8dd9 219 SpiritRefreshStatus();
vpcola 0:f1d3878b8dd9 220 if(g_xStatus.MC_STATE == 0x13)
vpcola 0:f1d3878b8dd9 221 {
vpcola 0:f1d3878b8dd9 222 return 1;
vpcola 0:f1d3878b8dd9 223 }
vpcola 0:f1d3878b8dd9 224 }while(g_xStatus.MC_STATE != MC_STATE_READY);
vpcola 0:f1d3878b8dd9 225 }
vpcola 0:f1d3878b8dd9 226
vpcola 0:f1d3878b8dd9 227 SpiritCmdStrobeLockTx();
vpcola 0:f1d3878b8dd9 228
vpcola 0:f1d3878b8dd9 229 do{
vpcola 0:f1d3878b8dd9 230 SpiritRefreshStatus();
vpcola 0:f1d3878b8dd9 231 if(g_xStatus.MC_STATE == 0x13)
vpcola 0:f1d3878b8dd9 232 {
vpcola 0:f1d3878b8dd9 233 return 1;
vpcola 0:f1d3878b8dd9 234 }
vpcola 0:f1d3878b8dd9 235 }while(g_xStatus.MC_STATE != MC_STATE_LOCK);
vpcola 0:f1d3878b8dd9 236
vpcola 0:f1d3878b8dd9 237 s_cVcoWordTx = SpiritCalibrationGetVcoCalData();
vpcola 0:f1d3878b8dd9 238
vpcola 0:f1d3878b8dd9 239 SpiritCmdStrobeReady();
vpcola 0:f1d3878b8dd9 240
vpcola 0:f1d3878b8dd9 241 do{
vpcola 0:f1d3878b8dd9 242 SpiritRefreshStatus();
vpcola 0:f1d3878b8dd9 243 }while(g_xStatus.MC_STATE != MC_STATE_READY);
vpcola 0:f1d3878b8dd9 244
vpcola 0:f1d3878b8dd9 245
vpcola 0:f1d3878b8dd9 246 SpiritCmdStrobeLockRx();
vpcola 0:f1d3878b8dd9 247
vpcola 0:f1d3878b8dd9 248 do{
vpcola 0:f1d3878b8dd9 249 SpiritRefreshStatus();
vpcola 0:f1d3878b8dd9 250 if(g_xStatus.MC_STATE == 0x13)
vpcola 0:f1d3878b8dd9 251 {
vpcola 0:f1d3878b8dd9 252 return 1;
vpcola 0:f1d3878b8dd9 253 }
vpcola 0:f1d3878b8dd9 254 }while(g_xStatus.MC_STATE != MC_STATE_LOCK);
vpcola 0:f1d3878b8dd9 255
vpcola 0:f1d3878b8dd9 256 s_cVcoWordRx = SpiritCalibrationGetVcoCalData();
vpcola 0:f1d3878b8dd9 257
vpcola 0:f1d3878b8dd9 258 SpiritCmdStrobeReady();
vpcola 0:f1d3878b8dd9 259
vpcola 0:f1d3878b8dd9 260 do{
vpcola 0:f1d3878b8dd9 261 SpiritRefreshStatus();
vpcola 0:f1d3878b8dd9 262 if(g_xStatus.MC_STATE == 0x13)
vpcola 0:f1d3878b8dd9 263 {
vpcola 0:f1d3878b8dd9 264 return 1;
vpcola 0:f1d3878b8dd9 265 }
vpcola 0:f1d3878b8dd9 266 }while(g_xStatus.MC_STATE != MC_STATE_READY);
vpcola 0:f1d3878b8dd9 267
vpcola 0:f1d3878b8dd9 268 if(cStandby == 1)
vpcola 0:f1d3878b8dd9 269 {
vpcola 0:f1d3878b8dd9 270 SpiritCmdStrobeStandby();
vpcola 0:f1d3878b8dd9 271 }
vpcola 0:f1d3878b8dd9 272 SpiritCalibrationVco(S_DISABLE);
vpcola 0:f1d3878b8dd9 273
vpcola 0:f1d3878b8dd9 274 /* Disable the reference divider if the XTAL is between 48 and 52 MHz */
vpcola 0:f1d3878b8dd9 275 if(cRestore)
vpcola 0:f1d3878b8dd9 276 {
vpcola 0:f1d3878b8dd9 277 SpiritRadioSetRefDiv(S_DISABLE);
vpcola 0:f1d3878b8dd9 278 SpiritManagementSetFrequencyBase(nFreq);
vpcola 0:f1d3878b8dd9 279 }
vpcola 0:f1d3878b8dd9 280
vpcola 0:f1d3878b8dd9 281 /* Restore the VCO current */
vpcola 0:f1d3878b8dd9 282 tmp = 0x11; SpiritSpiWriteRegisters(0xA1,1,&tmp);
vpcola 0:f1d3878b8dd9 283
vpcola 0:f1d3878b8dd9 284 SpiritCalibrationSetVcoCalDataTx(s_cVcoWordTx);
vpcola 0:f1d3878b8dd9 285 SpiritCalibrationSetVcoCalDataRx(s_cVcoWordRx);
vpcola 0:f1d3878b8dd9 286
vpcola 0:f1d3878b8dd9 287 return 0;
vpcola 0:f1d3878b8dd9 288 }
vpcola 0:f1d3878b8dd9 289
vpcola 0:f1d3878b8dd9 290
vpcola 0:f1d3878b8dd9 291 void SpiritManagementWaCmdStrobeTx(void)
vpcola 0:f1d3878b8dd9 292 {
vpcola 0:f1d3878b8dd9 293 if(s_cCommunicationState != COMMUNICATION_STATE_TX)
vpcola 0:f1d3878b8dd9 294 {
vpcola 0:f1d3878b8dd9 295 //uint32_t xtal_frequency = SpiritRadioGetXtalFrequency();
vpcola 0:f1d3878b8dd9 296
vpcola 0:f1d3878b8dd9 297 /* To achive the max output power */
vpcola 0:f1d3878b8dd9 298 if(s_nDesiredFrequency>=150000000 && s_nDesiredFrequency<=470000000)
vpcola 0:f1d3878b8dd9 299 {
vpcola 0:f1d3878b8dd9 300 /* Optimal setting for Tx mode only */
vpcola 0:f1d3878b8dd9 301 SpiritRadioSetPACwc(LOAD_3_6_PF);
vpcola 0:f1d3878b8dd9 302 }
vpcola 0:f1d3878b8dd9 303 else
vpcola 0:f1d3878b8dd9 304 {
vpcola 0:f1d3878b8dd9 305 /* Optimal setting for Tx mode only */
vpcola 0:f1d3878b8dd9 306 SpiritRadioSetPACwc(LOAD_0_PF);
vpcola 0:f1d3878b8dd9 307 }
vpcola 0:f1d3878b8dd9 308
vpcola 0:f1d3878b8dd9 309 uint8_t tmp = 0x11; SpiritSpiWriteRegisters(0xa9, 1, &tmp); /* Enable VCO_L buffer */
vpcola 0:f1d3878b8dd9 310 tmp = 0x20; SpiritSpiWriteRegisters(PM_CONFIG1_BASE, 1, &tmp); /* Set SMPS switching frequency */
vpcola 0:f1d3878b8dd9 311
vpcola 0:f1d3878b8dd9 312 s_cCommunicationState = COMMUNICATION_STATE_TX;
vpcola 0:f1d3878b8dd9 313 }
vpcola 0:f1d3878b8dd9 314 }
vpcola 0:f1d3878b8dd9 315
vpcola 0:f1d3878b8dd9 316
vpcola 0:f1d3878b8dd9 317 void SpiritManagementWaCmdStrobeRx(void)
vpcola 0:f1d3878b8dd9 318 {
vpcola 0:f1d3878b8dd9 319 if(s_cCommunicationState != COMMUNICATION_STATE_RX)
vpcola 0:f1d3878b8dd9 320 {
vpcola 0:f1d3878b8dd9 321 uint8_t tmp = 0x98; SpiritSpiWriteRegisters(PM_CONFIG1_BASE, 1, &tmp); /* Set SMPS switching frequency */
vpcola 0:f1d3878b8dd9 322 SpiritRadioSetPACwc(LOAD_0_PF); /* Set the correct CWC parameter */
vpcola 0:f1d3878b8dd9 323
vpcola 0:f1d3878b8dd9 324 s_cCommunicationState = COMMUNICATION_STATE_RX;
vpcola 0:f1d3878b8dd9 325 }
vpcola 0:f1d3878b8dd9 326 }
vpcola 0:f1d3878b8dd9 327
vpcola 0:f1d3878b8dd9 328 void SpiritManagementWaTRxFcMem(uint32_t nDesiredFreq)
vpcola 0:f1d3878b8dd9 329 {
vpcola 0:f1d3878b8dd9 330 s_cCommunicationState = COMMUNICATION_STATE_NONE;
vpcola 0:f1d3878b8dd9 331 s_nDesiredFrequency = nDesiredFreq;
vpcola 0:f1d3878b8dd9 332 }
vpcola 0:f1d3878b8dd9 333
vpcola 0:f1d3878b8dd9 334
vpcola 0:f1d3878b8dd9 335 void SpiritManagementWaExtraCurrent(void)
vpcola 0:f1d3878b8dd9 336 {
vpcola 0:f1d3878b8dd9 337 uint8_t tmp= 0xCA;SpiritSpiWriteRegisters(0xB2, 1, &tmp);
vpcola 0:f1d3878b8dd9 338 tmp= 0x04;SpiritSpiWriteRegisters(0xA8, 1, &tmp);
vpcola 0:f1d3878b8dd9 339 /* just a read to loose some microsecs more */
vpcola 0:f1d3878b8dd9 340 SpiritSpiReadRegisters(0xA8, 1, &tmp);
vpcola 0:f1d3878b8dd9 341 tmp= 0x00;SpiritSpiWriteRegisters(0xA8, 1, &tmp);
vpcola 0:f1d3878b8dd9 342 }
vpcola 0:f1d3878b8dd9 343
vpcola 0:f1d3878b8dd9 344 /**
vpcola 0:f1d3878b8dd9 345 * @}
vpcola 0:f1d3878b8dd9 346 */
vpcola 0:f1d3878b8dd9 347
vpcola 0:f1d3878b8dd9 348
vpcola 0:f1d3878b8dd9 349
vpcola 0:f1d3878b8dd9 350 /**
vpcola 0:f1d3878b8dd9 351 * @}
vpcola 0:f1d3878b8dd9 352 */
vpcola 0:f1d3878b8dd9 353
vpcola 0:f1d3878b8dd9 354
vpcola 0:f1d3878b8dd9 355 /**
vpcola 0:f1d3878b8dd9 356 * @}
vpcola 0:f1d3878b8dd9 357 */
vpcola 0:f1d3878b8dd9 358
vpcola 0:f1d3878b8dd9 359 /**
vpcola 0:f1d3878b8dd9 360 * @}
vpcola 0:f1d3878b8dd9 361 */
vpcola 0:f1d3878b8dd9 362
vpcola 0:f1d3878b8dd9 363
vpcola 0:f1d3878b8dd9 364 /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/