Easily add all supported connectivity methods to your mbed OS project

Dependencies:   type-yd-driver

Committer:
MACRUM
Date:
Wed Jul 12 10:52:58 2017 +0000
Revision:
0:615f90842ce8
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MACRUM 0:615f90842ce8 1 /**
MACRUM 0:615f90842ce8 2 ******************************************************************************
MACRUM 0:615f90842ce8 3 * @file SPIRIT_Radio.c
MACRUM 0:615f90842ce8 4 * @author VMA division - AMS
MACRUM 0:615f90842ce8 5 * @version 3.2.2
MACRUM 0:615f90842ce8 6 * @date 08-July-2015
MACRUM 0:615f90842ce8 7 * @brief This file provides all the low level API to manage Analog and Digital
MACRUM 0:615f90842ce8 8 * radio part of SPIRIT.
MACRUM 0:615f90842ce8 9 * @details
MACRUM 0:615f90842ce8 10 *
MACRUM 0:615f90842ce8 11 * @attention
MACRUM 0:615f90842ce8 12 *
MACRUM 0:615f90842ce8 13 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
MACRUM 0:615f90842ce8 14 *
MACRUM 0:615f90842ce8 15 * Redistribution and use in source and binary forms, with or without modification,
MACRUM 0:615f90842ce8 16 * are permitted provided that the following conditions are met:
MACRUM 0:615f90842ce8 17 * 1. Redistributions of source code must retain the above copyright notice,
MACRUM 0:615f90842ce8 18 * this list of conditions and the following disclaimer.
MACRUM 0:615f90842ce8 19 * 2. Redistributions in binary form must reproduce the above copyright notice,
MACRUM 0:615f90842ce8 20 * this list of conditions and the following disclaimer in the documentation
MACRUM 0:615f90842ce8 21 * and/or other materials provided with the distribution.
MACRUM 0:615f90842ce8 22 * 3. Neither the name of STMicroelectronics nor the names of its contributors
MACRUM 0:615f90842ce8 23 * may be used to endorse or promote products derived from this software
MACRUM 0:615f90842ce8 24 * without specific prior written permission.
MACRUM 0:615f90842ce8 25 *
MACRUM 0:615f90842ce8 26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
MACRUM 0:615f90842ce8 27 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
MACRUM 0:615f90842ce8 28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
MACRUM 0:615f90842ce8 29 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
MACRUM 0:615f90842ce8 30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
MACRUM 0:615f90842ce8 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
MACRUM 0:615f90842ce8 32 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
MACRUM 0:615f90842ce8 33 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
MACRUM 0:615f90842ce8 34 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
MACRUM 0:615f90842ce8 35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
MACRUM 0:615f90842ce8 36 *
MACRUM 0:615f90842ce8 37 ******************************************************************************
MACRUM 0:615f90842ce8 38 */
MACRUM 0:615f90842ce8 39
MACRUM 0:615f90842ce8 40 /* Includes ------------------------------------------------------------------*/
MACRUM 0:615f90842ce8 41 #include "SPIRIT_Radio.h"
MACRUM 0:615f90842ce8 42 #include "MCU_Interface.h"
MACRUM 0:615f90842ce8 43 #include <math.h>
MACRUM 0:615f90842ce8 44
MACRUM 0:615f90842ce8 45 /** @addtogroup SPIRIT_Libraries
MACRUM 0:615f90842ce8 46 * @{
MACRUM 0:615f90842ce8 47 */
MACRUM 0:615f90842ce8 48
MACRUM 0:615f90842ce8 49
MACRUM 0:615f90842ce8 50 /** @addtogroup SPIRIT_Radio
MACRUM 0:615f90842ce8 51 * @{
MACRUM 0:615f90842ce8 52 */
MACRUM 0:615f90842ce8 53
MACRUM 0:615f90842ce8 54
MACRUM 0:615f90842ce8 55 /** @defgroup Radio_Private_TypesDefinitions Radio Private Types Definitions
MACRUM 0:615f90842ce8 56 * @{
MACRUM 0:615f90842ce8 57 */
MACRUM 0:615f90842ce8 58
MACRUM 0:615f90842ce8 59
MACRUM 0:615f90842ce8 60 /**
MACRUM 0:615f90842ce8 61 * @}
MACRUM 0:615f90842ce8 62 */
MACRUM 0:615f90842ce8 63
MACRUM 0:615f90842ce8 64
MACRUM 0:615f90842ce8 65 /** @defgroup Radio_Private_Defines Radio Private Defines
MACRUM 0:615f90842ce8 66 * @{
MACRUM 0:615f90842ce8 67 */
MACRUM 0:615f90842ce8 68
MACRUM 0:615f90842ce8 69
MACRUM 0:615f90842ce8 70
MACRUM 0:615f90842ce8 71
MACRUM 0:615f90842ce8 72 /**
MACRUM 0:615f90842ce8 73 * @}
MACRUM 0:615f90842ce8 74 */
MACRUM 0:615f90842ce8 75
MACRUM 0:615f90842ce8 76
MACRUM 0:615f90842ce8 77 /** @defgroup Radio_Private_Macros Radio Private Macros
MACRUM 0:615f90842ce8 78 * @{
MACRUM 0:615f90842ce8 79 */
MACRUM 0:615f90842ce8 80 #define XTAL_FLAG(xtalFrequency) (xtalFrequency>=25e6) ? XTAL_FLAG_26_MHz:XTAL_FLAG_24_MHz
MACRUM 0:615f90842ce8 81
MACRUM 0:615f90842ce8 82 #define ROUND(A) (((A-(uint32_t)A)> 0.5)? (uint32_t)A+1:(uint32_t)A)
MACRUM 0:615f90842ce8 83 /**
MACRUM 0:615f90842ce8 84 * @}
MACRUM 0:615f90842ce8 85 */
MACRUM 0:615f90842ce8 86
MACRUM 0:615f90842ce8 87
MACRUM 0:615f90842ce8 88 /** @defgroup Radio_Private_Variables Radio Private Variables
MACRUM 0:615f90842ce8 89 * @{
MACRUM 0:615f90842ce8 90 */
MACRUM 0:615f90842ce8 91 /**
MACRUM 0:615f90842ce8 92 * @brief The Xtal frequency. To be set by the user (see SetXtalFreq() function)
MACRUM 0:615f90842ce8 93 */
MACRUM 0:615f90842ce8 94 static uint32_t s_lXtalFrequency;
MACRUM 0:615f90842ce8 95
MACRUM 0:615f90842ce8 96 /**
MACRUM 0:615f90842ce8 97 * @brief Factor is: B/2 used in the formula for SYNTH word calculation
MACRUM 0:615f90842ce8 98 */
MACRUM 0:615f90842ce8 99 static const uint8_t s_vectcBHalfFactor[4]={(HIGH_BAND_FACTOR/2), (MIDDLE_BAND_FACTOR/2), (LOW_BAND_FACTOR/2), (VERY_LOW_BAND_FACTOR/2)};
MACRUM 0:615f90842ce8 100
MACRUM 0:615f90842ce8 101 /**
MACRUM 0:615f90842ce8 102 * @brief BS value to write in the SYNT0 register according to the selected band
MACRUM 0:615f90842ce8 103 */
MACRUM 0:615f90842ce8 104 static const uint8_t s_vectcBandRegValue[4]={SYNT0_BS_6, SYNT0_BS_12, SYNT0_BS_16, SYNT0_BS_32};
MACRUM 0:615f90842ce8 105
MACRUM 0:615f90842ce8 106
MACRUM 0:615f90842ce8 107 /**
MACRUM 0:615f90842ce8 108 * @brief It represents the available channel bandwidth times 10 for 26 Mhz xtal.
MACRUM 0:615f90842ce8 109 * @note The channel bandwidth for others xtal frequencies can be computed since this table
MACRUM 0:615f90842ce8 110 * multiplying the current table by a factor xtal_frequency/26e6.
MACRUM 0:615f90842ce8 111 */
MACRUM 0:615f90842ce8 112 static const uint16_t s_vectnBandwidth26M[90]=
MACRUM 0:615f90842ce8 113 {
MACRUM 0:615f90842ce8 114 8001, 7951, 7684, 7368, 7051, 6709, 6423, 5867, 5414, \
MACRUM 0:615f90842ce8 115 4509, 4259, 4032, 3808, 3621, 3417, 3254, 2945, 2703, \
MACRUM 0:615f90842ce8 116 2247, 2124, 2015, 1900, 1807, 1706, 1624, 1471, 1350, \
MACRUM 0:615f90842ce8 117 1123, 1062, 1005, 950, 903, 853, 812, 735, 675, \
MACRUM 0:615f90842ce8 118 561, 530, 502, 474, 451, 426, 406, 367, 337, \
MACRUM 0:615f90842ce8 119 280, 265, 251, 237, 226, 213, 203, 184, 169, \
MACRUM 0:615f90842ce8 120 140, 133, 126, 119, 113, 106, 101, 92, 84, \
MACRUM 0:615f90842ce8 121 70, 66, 63, 59, 56, 53, 51, 46, 42, \
MACRUM 0:615f90842ce8 122 35, 33, 31, 30, 28, 27, 25, 23, 21, \
MACRUM 0:615f90842ce8 123 18, 17, 16, 15, 14, 13, 13, 12, 11
MACRUM 0:615f90842ce8 124 };
MACRUM 0:615f90842ce8 125
MACRUM 0:615f90842ce8 126 /**
MACRUM 0:615f90842ce8 127 * @brief It represents the available VCO frequencies
MACRUM 0:615f90842ce8 128 */
MACRUM 0:615f90842ce8 129 static const uint16_t s_vectnVCOFreq[16]=
MACRUM 0:615f90842ce8 130 {
MACRUM 0:615f90842ce8 131 4644, 4708, 4772, 4836, 4902, 4966, 5030, 5095, \
MACRUM 0:615f90842ce8 132 5161, 5232, 5303, 5375, 5448, 5519, 5592, 5663
MACRUM 0:615f90842ce8 133 };
MACRUM 0:615f90842ce8 134
MACRUM 0:615f90842ce8 135 /**
MACRUM 0:615f90842ce8 136 * @brief This variable is used to enable or disable
MACRUM 0:615f90842ce8 137 * the VCO calibration WA called at the end of the SpiritRadioSetFrequencyBase fcn.
MACRUM 0:615f90842ce8 138 * Default is enabled.
MACRUM 0:615f90842ce8 139 */
MACRUM 0:615f90842ce8 140 static SpiritFunctionalState xDoVcoCalibrationWA=S_ENABLE;
MACRUM 0:615f90842ce8 141
MACRUM 0:615f90842ce8 142
MACRUM 0:615f90842ce8 143 /**
MACRUM 0:615f90842ce8 144 * @brief These values are used to interpolate the power curves.
MACRUM 0:615f90842ce8 145 * Interpolation curves are linear in the following 3 regions:
MACRUM 0:615f90842ce8 146 * - reg value: 1 to 13 (up region)
MACRUM 0:615f90842ce8 147 * - reg value: 13 to 40 (mid region)
MACRUM 0:615f90842ce8 148 * - reg value: 41 to 90 (low region)
MACRUM 0:615f90842ce8 149 * power_reg = m*power_dBm + q
MACRUM 0:615f90842ce8 150 * For each band the order is: {m-up, q-up, m-mid, q-mid, m-low, q-low}.
MACRUM 0:615f90842ce8 151 * @note The power interpolation curves have been extracted
MACRUM 0:615f90842ce8 152 * by measurements done on the divisional evaluation boards.
MACRUM 0:615f90842ce8 153 */
MACRUM 0:615f90842ce8 154 static const float fPowerFactors[5][6]={
MACRUM 0:615f90842ce8 155 {-2.11,25.66,-2.11,25.66,-2.00,31.28}, /* 915 */
MACRUM 0:615f90842ce8 156 {-2.04,23.45,-2.04,23.45,-1.95,27.66}, /* 868 */
MACRUM 0:615f90842ce8 157 {-3.48,38.45,-1.89,27.66,-1.92,30.23}, /* 433 */
MACRUM 0:615f90842ce8 158 {-3.27,35.43,-1.80,26.31,-1.89,29.61}, /* 315 */
MACRUM 0:615f90842ce8 159 {-4.18,50.66,-1.80,30.04,-1.86,32.22}, /* 169 */
MACRUM 0:615f90842ce8 160 };
MACRUM 0:615f90842ce8 161
MACRUM 0:615f90842ce8 162 /**
MACRUM 0:615f90842ce8 163 * @}
MACRUM 0:615f90842ce8 164 */
MACRUM 0:615f90842ce8 165
MACRUM 0:615f90842ce8 166
MACRUM 0:615f90842ce8 167 /** @defgroup Radio_Private_FunctionPrototypes Radio Private Function Prototypes
MACRUM 0:615f90842ce8 168 * @{
MACRUM 0:615f90842ce8 169 */
MACRUM 0:615f90842ce8 170
MACRUM 0:615f90842ce8 171
MACRUM 0:615f90842ce8 172 /**
MACRUM 0:615f90842ce8 173 * @}
MACRUM 0:615f90842ce8 174 */
MACRUM 0:615f90842ce8 175
MACRUM 0:615f90842ce8 176
MACRUM 0:615f90842ce8 177 /** @defgroup Radio_Private_Functions Radio Private Functions
MACRUM 0:615f90842ce8 178 * @{
MACRUM 0:615f90842ce8 179 */
MACRUM 0:615f90842ce8 180
MACRUM 0:615f90842ce8 181 /**
MACRUM 0:615f90842ce8 182 * @brief Initializes the SPIRIT analog and digital radio part according to the specified
MACRUM 0:615f90842ce8 183 * parameters in the pxSRadioInitStruct.
MACRUM 0:615f90842ce8 184 * @param pxSRadioInitStruct pointer to a SRadioInit structure that
MACRUM 0:615f90842ce8 185 * contains the configuration information for the analog radio part of SPIRIT.
MACRUM 0:615f90842ce8 186 * @retval Error code: 0=no error, 1=error during calibration of VCO.
MACRUM 0:615f90842ce8 187 */
MACRUM 0:615f90842ce8 188 uint8_t SpiritRadioInit(SRadioInit* pxSRadioInitStruct)
MACRUM 0:615f90842ce8 189 {
MACRUM 0:615f90842ce8 190 int32_t FOffsetTmp;
MACRUM 0:615f90842ce8 191 uint8_t anaRadioRegArray[8], digRadioRegArray[4];
MACRUM 0:615f90842ce8 192 int16_t xtalOffsetFactor;
MACRUM 0:615f90842ce8 193 uint8_t drM, drE, FdevM, FdevE, bwM, bwE;
MACRUM 0:615f90842ce8 194
MACRUM 0:615f90842ce8 195 /* Workaround for Vtune */
MACRUM 0:615f90842ce8 196 uint8_t value = 0xA0; SpiritSpiWriteRegisters(0x9F, 1, &value);
MACRUM 0:615f90842ce8 197
MACRUM 0:615f90842ce8 198 /* Calculates the offset respect to RF frequency and according to xtal_ppm parameter: (xtal_ppm*FBase)/10^6 */
MACRUM 0:615f90842ce8 199 FOffsetTmp = (int32_t)(((float)pxSRadioInitStruct->nXtalOffsetPpm*pxSRadioInitStruct->lFrequencyBase)/PPM_FACTOR);
MACRUM 0:615f90842ce8 200
MACRUM 0:615f90842ce8 201 /* Check the parameters */
MACRUM 0:615f90842ce8 202 s_assert_param(IS_FREQUENCY_BAND(pxSRadioInitStruct->lFrequencyBase));
MACRUM 0:615f90842ce8 203 s_assert_param(IS_MODULATION_SELECTED(pxSRadioInitStruct->xModulationSelect));
MACRUM 0:615f90842ce8 204 s_assert_param(IS_DATARATE(pxSRadioInitStruct->lDatarate));
MACRUM 0:615f90842ce8 205 s_assert_param(IS_FREQUENCY_OFFSET(FOffsetTmp,s_lXtalFrequency));
MACRUM 0:615f90842ce8 206 s_assert_param(IS_CHANNEL_SPACE(pxSRadioInitStruct->nChannelSpace,s_lXtalFrequency));
MACRUM 0:615f90842ce8 207 s_assert_param(IS_F_DEV(pxSRadioInitStruct->lFreqDev,s_lXtalFrequency));
MACRUM 0:615f90842ce8 208
MACRUM 0:615f90842ce8 209 /* Disable the digital, ADC, SMPS reference clock divider if fXO>24MHz or fXO<26MHz */
MACRUM 0:615f90842ce8 210 SpiritSpiCommandStrobes(COMMAND_STANDBY);
MACRUM 0:615f90842ce8 211 do{
MACRUM 0:615f90842ce8 212 /* Delay for state transition */
MACRUM 0:615f90842ce8 213 for(volatile uint8_t i=0; i!=0xFF; i++);
MACRUM 0:615f90842ce8 214
MACRUM 0:615f90842ce8 215 /* Reads the MC_STATUS register */
MACRUM 0:615f90842ce8 216 SpiritRefreshStatus();
MACRUM 0:615f90842ce8 217 }while(g_xStatus.MC_STATE!=MC_STATE_STANDBY);
MACRUM 0:615f90842ce8 218
MACRUM 0:615f90842ce8 219 if(s_lXtalFrequency<DOUBLE_XTAL_THR)
MACRUM 0:615f90842ce8 220 {
MACRUM 0:615f90842ce8 221 SpiritRadioSetDigDiv(S_DISABLE);
MACRUM 0:615f90842ce8 222 s_assert_param(IS_CH_BW(pxSRadioInitStruct->lBandwidth,s_lXtalFrequency));
MACRUM 0:615f90842ce8 223 }
MACRUM 0:615f90842ce8 224 else
MACRUM 0:615f90842ce8 225 {
MACRUM 0:615f90842ce8 226 SpiritRadioSetDigDiv(S_ENABLE);
MACRUM 0:615f90842ce8 227 s_assert_param(IS_CH_BW(pxSRadioInitStruct->lBandwidth,(s_lXtalFrequency>>1)));
MACRUM 0:615f90842ce8 228 }
MACRUM 0:615f90842ce8 229
MACRUM 0:615f90842ce8 230 /* Goes in READY state */
MACRUM 0:615f90842ce8 231 SpiritSpiCommandStrobes(COMMAND_READY);
MACRUM 0:615f90842ce8 232 do{
MACRUM 0:615f90842ce8 233 /* Delay for state transition */
MACRUM 0:615f90842ce8 234 for(volatile uint8_t i=0; i!=0xFF; i++);
MACRUM 0:615f90842ce8 235
MACRUM 0:615f90842ce8 236 /* Reads the MC_STATUS register */
MACRUM 0:615f90842ce8 237 SpiritRefreshStatus();
MACRUM 0:615f90842ce8 238 }while(g_xStatus.MC_STATE!=MC_STATE_READY);
MACRUM 0:615f90842ce8 239
MACRUM 0:615f90842ce8 240 /* Calculates the FC_OFFSET parameter and cast as signed int: FOffsetTmp = (Fxtal/2^18)*FC_OFFSET */
MACRUM 0:615f90842ce8 241 xtalOffsetFactor = (int16_t)(((float)FOffsetTmp*FBASE_DIVIDER)/s_lXtalFrequency);
MACRUM 0:615f90842ce8 242 anaRadioRegArray[2] = (uint8_t)((((uint16_t)xtalOffsetFactor)>>8)&0x0F);
MACRUM 0:615f90842ce8 243 anaRadioRegArray[3] = (uint8_t)(xtalOffsetFactor);
MACRUM 0:615f90842ce8 244
MACRUM 0:615f90842ce8 245 /* Calculates the channel space factor */
MACRUM 0:615f90842ce8 246 anaRadioRegArray[0] =((uint32_t)pxSRadioInitStruct->nChannelSpace<<9)/(s_lXtalFrequency>>6)+1;
MACRUM 0:615f90842ce8 247
MACRUM 0:615f90842ce8 248 SpiritManagementWaTRxFcMem(pxSRadioInitStruct->lFrequencyBase);
MACRUM 0:615f90842ce8 249
MACRUM 0:615f90842ce8 250 /* 2nd order DEM algorithm enabling */
MACRUM 0:615f90842ce8 251 uint8_t tmpreg; SpiritSpiReadRegisters(0xA3, 1, &tmpreg);
MACRUM 0:615f90842ce8 252 tmpreg &= ~0x02; SpiritSpiWriteRegisters(0xA3, 1, &tmpreg);
MACRUM 0:615f90842ce8 253
MACRUM 0:615f90842ce8 254 /* Check the channel center frequency is in one of the possible range */
MACRUM 0:615f90842ce8 255 s_assert_param(IS_FREQUENCY_BAND((pxSRadioInitStruct->lFrequencyBase + ((xtalOffsetFactor*s_lXtalFrequency)/FBASE_DIVIDER) + pxSRadioInitStruct->nChannelSpace * pxSRadioInitStruct->cChannelNumber)));
MACRUM 0:615f90842ce8 256
MACRUM 0:615f90842ce8 257 /* Calculates the datarate mantissa and exponent */
MACRUM 0:615f90842ce8 258 SpiritRadioSearchDatarateME(pxSRadioInitStruct->lDatarate, &drM, &drE);
MACRUM 0:615f90842ce8 259 digRadioRegArray[0] = (uint8_t)(drM);
MACRUM 0:615f90842ce8 260 digRadioRegArray[1] = (uint8_t)(0x00 | pxSRadioInitStruct->xModulationSelect |drE);
MACRUM 0:615f90842ce8 261
MACRUM 0:615f90842ce8 262 /* Read the fdev register to preserve the clock recovery algo bit */
MACRUM 0:615f90842ce8 263 SpiritSpiReadRegisters(0x1C, 1, &tmpreg);
MACRUM 0:615f90842ce8 264
MACRUM 0:615f90842ce8 265 /* Calculates the frequency deviation mantissa and exponent */
MACRUM 0:615f90842ce8 266 SpiritRadioSearchFreqDevME(pxSRadioInitStruct->lFreqDev, &FdevM, &FdevE);
MACRUM 0:615f90842ce8 267 digRadioRegArray[2] = (uint8_t)((FdevE<<4) | (tmpreg&0x08) | FdevM);
MACRUM 0:615f90842ce8 268
MACRUM 0:615f90842ce8 269 /* Calculates the channel filter mantissa and exponent */
MACRUM 0:615f90842ce8 270 SpiritRadioSearchChannelBwME(pxSRadioInitStruct->lBandwidth, &bwM, &bwE);
MACRUM 0:615f90842ce8 271
MACRUM 0:615f90842ce8 272 digRadioRegArray[3] = (uint8_t)((bwM<<4) | bwE);
MACRUM 0:615f90842ce8 273
MACRUM 0:615f90842ce8 274 float if_off=(3.0*480140)/(s_lXtalFrequency>>12)-64;
MACRUM 0:615f90842ce8 275
MACRUM 0:615f90842ce8 276 uint8_t ifOffsetAna = ROUND(if_off);
MACRUM 0:615f90842ce8 277
MACRUM 0:615f90842ce8 278 if(s_lXtalFrequency<DOUBLE_XTAL_THR)
MACRUM 0:615f90842ce8 279 {
MACRUM 0:615f90842ce8 280 /* if offset digital is the same in case of single xtal */
MACRUM 0:615f90842ce8 281 anaRadioRegArray[1] = ifOffsetAna;
MACRUM 0:615f90842ce8 282 }
MACRUM 0:615f90842ce8 283 else
MACRUM 0:615f90842ce8 284 {
MACRUM 0:615f90842ce8 285 if_off=(3.0*480140)/(s_lXtalFrequency>>13)-64;
MACRUM 0:615f90842ce8 286
MACRUM 0:615f90842ce8 287 /* ... otherwise recompute it */
MACRUM 0:615f90842ce8 288 anaRadioRegArray[1] = ROUND(if_off);
MACRUM 0:615f90842ce8 289 }
MACRUM 0:615f90842ce8 290 // if(s_lXtalFrequency==24000000) {
MACRUM 0:615f90842ce8 291 // ifOffsetAna = 0xB6;
MACRUM 0:615f90842ce8 292 // anaRadioRegArray[1] = 0xB6;
MACRUM 0:615f90842ce8 293 // }
MACRUM 0:615f90842ce8 294 // if(s_lXtalFrequency==25000000) {
MACRUM 0:615f90842ce8 295 // ifOffsetAna = 0xAC;
MACRUM 0:615f90842ce8 296 // anaRadioRegArray[1] = 0xAC;
MACRUM 0:615f90842ce8 297 // }
MACRUM 0:615f90842ce8 298 // if(s_lXtalFrequency==26000000) {
MACRUM 0:615f90842ce8 299 // ifOffsetAna = 0xA3;
MACRUM 0:615f90842ce8 300 // anaRadioRegArray[1] = 0xA3;
MACRUM 0:615f90842ce8 301 // }
MACRUM 0:615f90842ce8 302 // if(s_lXtalFrequency==48000000) {
MACRUM 0:615f90842ce8 303 // ifOffsetAna = 0x3B;
MACRUM 0:615f90842ce8 304 // anaRadioRegArray[1] = 0xB6;
MACRUM 0:615f90842ce8 305 // }
MACRUM 0:615f90842ce8 306 // if(s_lXtalFrequency==50000000) {
MACRUM 0:615f90842ce8 307 // ifOffsetAna = 0x36;
MACRUM 0:615f90842ce8 308 // anaRadioRegArray[1] = 0xAC;
MACRUM 0:615f90842ce8 309 // }
MACRUM 0:615f90842ce8 310 // if(s_lXtalFrequency==52000000) {
MACRUM 0:615f90842ce8 311 // ifOffsetAna = 0x31;
MACRUM 0:615f90842ce8 312 // anaRadioRegArray[1] = 0xA3;
MACRUM 0:615f90842ce8 313 // }
MACRUM 0:615f90842ce8 314
MACRUM 0:615f90842ce8 315 g_xStatus = SpiritSpiWriteRegisters(IF_OFFSET_ANA_BASE, 1, &ifOffsetAna);
MACRUM 0:615f90842ce8 316
MACRUM 0:615f90842ce8 317
MACRUM 0:615f90842ce8 318 /* Sets Xtal configuration */
MACRUM 0:615f90842ce8 319 if(s_lXtalFrequency>DOUBLE_XTAL_THR)
MACRUM 0:615f90842ce8 320 {
MACRUM 0:615f90842ce8 321 SpiritRadioSetXtalFlag(XTAL_FLAG((s_lXtalFrequency/2)));
MACRUM 0:615f90842ce8 322 }
MACRUM 0:615f90842ce8 323 else
MACRUM 0:615f90842ce8 324 {
MACRUM 0:615f90842ce8 325 SpiritRadioSetXtalFlag(XTAL_FLAG(s_lXtalFrequency));
MACRUM 0:615f90842ce8 326 }
MACRUM 0:615f90842ce8 327
MACRUM 0:615f90842ce8 328 /* Sets the channel number in the corresponding register */
MACRUM 0:615f90842ce8 329 SpiritSpiWriteRegisters(CHNUM_BASE, 1, &pxSRadioInitStruct->cChannelNumber);
MACRUM 0:615f90842ce8 330
MACRUM 0:615f90842ce8 331 /* Configures the Analog Radio registers */
MACRUM 0:615f90842ce8 332 SpiritSpiWriteRegisters(CHSPACE_BASE, 4, anaRadioRegArray);
MACRUM 0:615f90842ce8 333
MACRUM 0:615f90842ce8 334 /* Configures the Digital Radio registers */
MACRUM 0:615f90842ce8 335 g_xStatus = SpiritSpiWriteRegisters(MOD1_BASE, 4, digRadioRegArray);
MACRUM 0:615f90842ce8 336
MACRUM 0:615f90842ce8 337 /* Enable the freeze option of the AFC on the SYNC word */
MACRUM 0:615f90842ce8 338 SpiritRadioAFCFreezeOnSync(S_ENABLE);
MACRUM 0:615f90842ce8 339
MACRUM 0:615f90842ce8 340 /* Set the IQC correction optimal value */
MACRUM 0:615f90842ce8 341 anaRadioRegArray[0]=0x80;
MACRUM 0:615f90842ce8 342 anaRadioRegArray[1]=0xE3;
MACRUM 0:615f90842ce8 343 g_xStatus = SpiritSpiWriteRegisters(0x99, 2, anaRadioRegArray);
MACRUM 0:615f90842ce8 344
MACRUM 0:615f90842ce8 345 return SpiritRadioSetFrequencyBase(pxSRadioInitStruct->lFrequencyBase);
MACRUM 0:615f90842ce8 346
MACRUM 0:615f90842ce8 347 }
MACRUM 0:615f90842ce8 348
MACRUM 0:615f90842ce8 349
MACRUM 0:615f90842ce8 350 /**
MACRUM 0:615f90842ce8 351 * @brief Returns the SPIRIT analog and digital radio structure according to the registers value.
MACRUM 0:615f90842ce8 352 * @param pxSRadioInitStruct pointer to a SRadioInit structure that
MACRUM 0:615f90842ce8 353 * contains the configuration information for the analog radio part of SPIRIT.
MACRUM 0:615f90842ce8 354 * @retval None.
MACRUM 0:615f90842ce8 355 */
MACRUM 0:615f90842ce8 356 void SpiritRadioGetInfo(SRadioInit* pxSRadioInitStruct)
MACRUM 0:615f90842ce8 357 {
MACRUM 0:615f90842ce8 358 uint8_t anaRadioRegArray[8], digRadioRegArray[4];
MACRUM 0:615f90842ce8 359 BandSelect band;
MACRUM 0:615f90842ce8 360 int16_t xtalOffsetFactor;
MACRUM 0:615f90842ce8 361
MACRUM 0:615f90842ce8 362 /* Get the RF board version */
MACRUM 0:615f90842ce8 363 //SpiritVersion xSpiritVersion = SpiritGeneralGetSpiritVersion();
MACRUM 0:615f90842ce8 364
MACRUM 0:615f90842ce8 365 /* Reads the Analog Radio registers */
MACRUM 0:615f90842ce8 366 SpiritSpiReadRegisters(SYNT3_BASE, 8, anaRadioRegArray);
MACRUM 0:615f90842ce8 367
MACRUM 0:615f90842ce8 368 /* Reads the Digital Radio registers */
MACRUM 0:615f90842ce8 369 g_xStatus = SpiritSpiReadRegisters(MOD1_BASE, 4, digRadioRegArray);
MACRUM 0:615f90842ce8 370
MACRUM 0:615f90842ce8 371 /* Reads the operating band masking the Band selected field */
MACRUM 0:615f90842ce8 372 if((anaRadioRegArray[3] & 0x07) == SYNT0_BS_6)
MACRUM 0:615f90842ce8 373 {
MACRUM 0:615f90842ce8 374 band = HIGH_BAND;
MACRUM 0:615f90842ce8 375 }
MACRUM 0:615f90842ce8 376 else if ((anaRadioRegArray[3] & 0x07) == SYNT0_BS_12)
MACRUM 0:615f90842ce8 377 {
MACRUM 0:615f90842ce8 378 band = MIDDLE_BAND;
MACRUM 0:615f90842ce8 379 }
MACRUM 0:615f90842ce8 380 else if ((anaRadioRegArray[3] & 0x07) == SYNT0_BS_16)
MACRUM 0:615f90842ce8 381 {
MACRUM 0:615f90842ce8 382 band = LOW_BAND;
MACRUM 0:615f90842ce8 383 }
MACRUM 0:615f90842ce8 384 else if ((anaRadioRegArray[3] & 0x07) == SYNT0_BS_32)
MACRUM 0:615f90842ce8 385 {
MACRUM 0:615f90842ce8 386 band = VERY_LOW_BAND;
MACRUM 0:615f90842ce8 387 }
MACRUM 0:615f90842ce8 388 else
MACRUM 0:615f90842ce8 389 {
MACRUM 0:615f90842ce8 390 /* if it is another value, set it to a valid one in order to avoid access violation */
MACRUM 0:615f90842ce8 391 uint8_t tmp=(anaRadioRegArray[3]&0xF8)|SYNT0_BS_6;
MACRUM 0:615f90842ce8 392 SpiritSpiWriteRegisters(SYNT0_BASE,1,&tmp);
MACRUM 0:615f90842ce8 393 band = HIGH_BAND;
MACRUM 0:615f90842ce8 394 }
MACRUM 0:615f90842ce8 395
MACRUM 0:615f90842ce8 396 /* Computes the synth word */
MACRUM 0:615f90842ce8 397 uint32_t synthWord = (uint32_t)((((uint32_t)(anaRadioRegArray[0]&0x1F))<<21)+(((uint32_t)(anaRadioRegArray[1]))<<13)+\
MACRUM 0:615f90842ce8 398 (((uint32_t)(anaRadioRegArray[2]))<<5)+(((uint32_t)(anaRadioRegArray[3]))>>3));
MACRUM 0:615f90842ce8 399
MACRUM 0:615f90842ce8 400 /* Calculates the frequency base */
MACRUM 0:615f90842ce8 401 uint8_t cRefDiv = (uint8_t)SpiritRadioGetRefDiv()+1;
MACRUM 0:615f90842ce8 402 pxSRadioInitStruct->lFrequencyBase = (uint32_t)round(synthWord*(((double)s_lXtalFrequency)/(FBASE_DIVIDER*cRefDiv*s_vectcBHalfFactor[band])));
MACRUM 0:615f90842ce8 403
MACRUM 0:615f90842ce8 404 /* Calculates the Offset Factor */
MACRUM 0:615f90842ce8 405 uint16_t xtalOffTemp = ((((uint16_t)anaRadioRegArray[6])<<8)+((uint16_t)anaRadioRegArray[7]));
MACRUM 0:615f90842ce8 406
MACRUM 0:615f90842ce8 407 /* If a negative number then convert the 12 bit 2-complement in a 16 bit number */
MACRUM 0:615f90842ce8 408 if(xtalOffTemp & 0x0800)
MACRUM 0:615f90842ce8 409 {
MACRUM 0:615f90842ce8 410 xtalOffTemp = xtalOffTemp | 0xF000;
MACRUM 0:615f90842ce8 411 }
MACRUM 0:615f90842ce8 412 else
MACRUM 0:615f90842ce8 413 {
MACRUM 0:615f90842ce8 414 xtalOffTemp = xtalOffTemp & 0x0FFF;
MACRUM 0:615f90842ce8 415 }
MACRUM 0:615f90842ce8 416
MACRUM 0:615f90842ce8 417 xtalOffsetFactor = *((int16_t*)(&xtalOffTemp));
MACRUM 0:615f90842ce8 418
MACRUM 0:615f90842ce8 419 /* Calculates the frequency offset in ppm */
MACRUM 0:615f90842ce8 420 pxSRadioInitStruct->nXtalOffsetPpm =(int16_t)((uint32_t)xtalOffsetFactor*s_lXtalFrequency*PPM_FACTOR)/((uint32_t)FBASE_DIVIDER*pxSRadioInitStruct->lFrequencyBase);
MACRUM 0:615f90842ce8 421
MACRUM 0:615f90842ce8 422 /* Channel space */
MACRUM 0:615f90842ce8 423 pxSRadioInitStruct->nChannelSpace = anaRadioRegArray[4]*(s_lXtalFrequency>>15);
MACRUM 0:615f90842ce8 424
MACRUM 0:615f90842ce8 425 /* Channel number */
MACRUM 0:615f90842ce8 426 pxSRadioInitStruct->cChannelNumber = SpiritRadioGetChannel();
MACRUM 0:615f90842ce8 427
MACRUM 0:615f90842ce8 428 /* Modulation select */
MACRUM 0:615f90842ce8 429 pxSRadioInitStruct->xModulationSelect = (ModulationSelect)(digRadioRegArray[1] & 0x70);
MACRUM 0:615f90842ce8 430
MACRUM 0:615f90842ce8 431 /* Reads the frequency deviation for mantissa and exponent */
MACRUM 0:615f90842ce8 432 uint8_t FDevM = digRadioRegArray[2]&0x07;
MACRUM 0:615f90842ce8 433 uint8_t FDevE = (digRadioRegArray[2]&0xF0)>>4;
MACRUM 0:615f90842ce8 434
MACRUM 0:615f90842ce8 435 /* Reads the channel filter register for mantissa and exponent */
MACRUM 0:615f90842ce8 436 uint8_t bwM = (digRadioRegArray[3]&0xF0)>>4;
MACRUM 0:615f90842ce8 437 uint8_t bwE = digRadioRegArray[3]&0x0F;
MACRUM 0:615f90842ce8 438
MACRUM 0:615f90842ce8 439 uint8_t cDivider = 0;
MACRUM 0:615f90842ce8 440 cDivider = SpiritRadioGetDigDiv();
MACRUM 0:615f90842ce8 441
MACRUM 0:615f90842ce8 442 /* Calculates the datarate */
MACRUM 0:615f90842ce8 443 pxSRadioInitStruct->lDatarate = ((s_lXtalFrequency>>(5+cDivider))*(256+digRadioRegArray[0]))>>(23-(digRadioRegArray[1]&0x0F));
MACRUM 0:615f90842ce8 444
MACRUM 0:615f90842ce8 445 /* Calculates the frequency deviation */
MACRUM 0:615f90842ce8 446 // (((s_lXtalFrequency>>6)*(8+FDevM))>>(12-FDevE+cCorrection));
MACRUM 0:615f90842ce8 447 pxSRadioInitStruct->lFreqDev =(uint32_t)((float)s_lXtalFrequency/(((uint32_t)1)<<18)*(uint32_t)((8.0+FDevM)/2*(1<<FDevE)));
MACRUM 0:615f90842ce8 448
MACRUM 0:615f90842ce8 449 /* Reads the channel filter bandwidth from the look-up table and return it */
MACRUM 0:615f90842ce8 450 pxSRadioInitStruct->lBandwidth = (uint32_t)(100.0*s_vectnBandwidth26M[bwM+(bwE*9)]*((s_lXtalFrequency>>cDivider)/26e6));
MACRUM 0:615f90842ce8 451
MACRUM 0:615f90842ce8 452 }
MACRUM 0:615f90842ce8 453
MACRUM 0:615f90842ce8 454
MACRUM 0:615f90842ce8 455 /**
MACRUM 0:615f90842ce8 456 * @brief Sets the Xtal configuration in the ANA_FUNC_CONF0 register.
MACRUM 0:615f90842ce8 457 * @param xXtal one of the possible value of the enum type XtalFrequency.
MACRUM 0:615f90842ce8 458 * @arg XTAL_FLAG_24_MHz: in case of 24 MHz crystal
MACRUM 0:615f90842ce8 459 * @arg XTAL_FLAG_26_MHz: in case of 26 MHz crystal
MACRUM 0:615f90842ce8 460 * @retval None.
MACRUM 0:615f90842ce8 461 */
MACRUM 0:615f90842ce8 462 void SpiritRadioSetXtalFlag(XtalFlag xXtal)
MACRUM 0:615f90842ce8 463 {
MACRUM 0:615f90842ce8 464 uint8_t tempRegValue = 0x00;
MACRUM 0:615f90842ce8 465
MACRUM 0:615f90842ce8 466 /* Check the parameters */
MACRUM 0:615f90842ce8 467 s_assert_param(IS_XTAL_FLAG(xXtal));
MACRUM 0:615f90842ce8 468
MACRUM 0:615f90842ce8 469 /* Reads the ANA_FUNC_CONF_0 register */
MACRUM 0:615f90842ce8 470 g_xStatus = SpiritSpiReadRegisters(ANA_FUNC_CONF0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 471 if(xXtal == XTAL_FLAG_26_MHz)
MACRUM 0:615f90842ce8 472 {
MACRUM 0:615f90842ce8 473 tempRegValue|=SELECT_24_26_MHZ_MASK;
MACRUM 0:615f90842ce8 474 }
MACRUM 0:615f90842ce8 475 else
MACRUM 0:615f90842ce8 476 {
MACRUM 0:615f90842ce8 477 tempRegValue &= (~SELECT_24_26_MHZ_MASK);
MACRUM 0:615f90842ce8 478 }
MACRUM 0:615f90842ce8 479
MACRUM 0:615f90842ce8 480 /* Sets the 24_26MHz_SELECT field in the ANA_FUNC_CONF_0 register */
MACRUM 0:615f90842ce8 481 g_xStatus = SpiritSpiWriteRegisters(ANA_FUNC_CONF0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 482
MACRUM 0:615f90842ce8 483 }
MACRUM 0:615f90842ce8 484
MACRUM 0:615f90842ce8 485
MACRUM 0:615f90842ce8 486 /**
MACRUM 0:615f90842ce8 487 * @brief Returns the Xtal configuration in the ANA_FUNC_CONF0 register.
MACRUM 0:615f90842ce8 488 * @param None.
MACRUM 0:615f90842ce8 489 * @retval XtalFrequency Settled Xtal configuration.
MACRUM 0:615f90842ce8 490 */
MACRUM 0:615f90842ce8 491 XtalFlag SpiritRadioGetXtalFlag(void)
MACRUM 0:615f90842ce8 492 {
MACRUM 0:615f90842ce8 493 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 494
MACRUM 0:615f90842ce8 495 /* Reads the Xtal configuration in the ANA_FUNC_CONF_0 register and return the value */
MACRUM 0:615f90842ce8 496 g_xStatus = SpiritSpiReadRegisters(ANA_FUNC_CONF0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 497
MACRUM 0:615f90842ce8 498 return (XtalFlag)((tempRegValue & 0x40)>>6);
MACRUM 0:615f90842ce8 499
MACRUM 0:615f90842ce8 500 }
MACRUM 0:615f90842ce8 501
MACRUM 0:615f90842ce8 502
MACRUM 0:615f90842ce8 503 /**
MACRUM 0:615f90842ce8 504 * @brief Returns the charge pump word for a given VCO frequency.
MACRUM 0:615f90842ce8 505 * @param lFc channel center frequency expressed in Hz.
MACRUM 0:615f90842ce8 506 * This parameter can be a value in one of the following ranges:<ul>
MACRUM 0:615f90842ce8 507 * <li> High_Band: from 779 MHz to 915 MHz </li>
MACRUM 0:615f90842ce8 508 * <li> Middle Band: from 387 MHz to 470 MHz </li>
MACRUM 0:615f90842ce8 509 * <li> Low Band: from 300 MHz to 348 MHz </li>
MACRUM 0:615f90842ce8 510 * <li> Very low Band: from 150 MHz to 174 MHz </li> </ul>
MACRUM 0:615f90842ce8 511 * @retval uint8_t Charge pump word.
MACRUM 0:615f90842ce8 512 */
MACRUM 0:615f90842ce8 513 uint8_t SpiritRadioSearchWCP(uint32_t lFc)
MACRUM 0:615f90842ce8 514 {
MACRUM 0:615f90842ce8 515 int8_t i;
MACRUM 0:615f90842ce8 516 uint32_t vcofreq;
MACRUM 0:615f90842ce8 517 uint8_t BFactor;
MACRUM 0:615f90842ce8 518
MACRUM 0:615f90842ce8 519 /* Check the channel center frequency is in one of the possible range */
MACRUM 0:615f90842ce8 520 s_assert_param(IS_FREQUENCY_BAND(lFc));
MACRUM 0:615f90842ce8 521
MACRUM 0:615f90842ce8 522 /* Search the operating band */
MACRUM 0:615f90842ce8 523 if(IS_FREQUENCY_BAND_HIGH(lFc))
MACRUM 0:615f90842ce8 524 {
MACRUM 0:615f90842ce8 525 BFactor = HIGH_BAND_FACTOR;
MACRUM 0:615f90842ce8 526 }
MACRUM 0:615f90842ce8 527 else if(IS_FREQUENCY_BAND_MIDDLE(lFc))
MACRUM 0:615f90842ce8 528 {
MACRUM 0:615f90842ce8 529 BFactor = MIDDLE_BAND_FACTOR;
MACRUM 0:615f90842ce8 530 }
MACRUM 0:615f90842ce8 531 else if(IS_FREQUENCY_BAND_LOW(lFc))
MACRUM 0:615f90842ce8 532 {
MACRUM 0:615f90842ce8 533 BFactor = LOW_BAND_FACTOR;
MACRUM 0:615f90842ce8 534 }
MACRUM 0:615f90842ce8 535 else
MACRUM 0:615f90842ce8 536 {
MACRUM 0:615f90842ce8 537 BFactor = VERY_LOW_BAND_FACTOR;
MACRUM 0:615f90842ce8 538 }
MACRUM 0:615f90842ce8 539
MACRUM 0:615f90842ce8 540 /* Calculates the VCO frequency VCOFreq = lFc*B */
MACRUM 0:615f90842ce8 541 vcofreq = (lFc/1000000)*BFactor;
MACRUM 0:615f90842ce8 542
MACRUM 0:615f90842ce8 543 /* Search in the vco frequency array the charge pump word */
MACRUM 0:615f90842ce8 544 if(vcofreq>=s_vectnVCOFreq[15])
MACRUM 0:615f90842ce8 545 {
MACRUM 0:615f90842ce8 546 i=15;
MACRUM 0:615f90842ce8 547 }
MACRUM 0:615f90842ce8 548 else
MACRUM 0:615f90842ce8 549 {
MACRUM 0:615f90842ce8 550 /* Search the value */
MACRUM 0:615f90842ce8 551 for(i=0 ; i<15 && vcofreq>s_vectnVCOFreq[i] ; i++);
MACRUM 0:615f90842ce8 552
MACRUM 0:615f90842ce8 553 /* Be sure that it is the best approssimation */
MACRUM 0:615f90842ce8 554 if (i!=0 && s_vectnVCOFreq[i]-vcofreq>vcofreq-s_vectnVCOFreq[i-1])
MACRUM 0:615f90842ce8 555 i--;
MACRUM 0:615f90842ce8 556 }
MACRUM 0:615f90842ce8 557
MACRUM 0:615f90842ce8 558 /* Return index */
MACRUM 0:615f90842ce8 559 return (i%8);
MACRUM 0:615f90842ce8 560
MACRUM 0:615f90842ce8 561 }
MACRUM 0:615f90842ce8 562
MACRUM 0:615f90842ce8 563 /**
MACRUM 0:615f90842ce8 564 * @brief Returns the synth word.
MACRUM 0:615f90842ce8 565 * @param None.
MACRUM 0:615f90842ce8 566 * @retval uint32_t Synth word.
MACRUM 0:615f90842ce8 567 */
MACRUM 0:615f90842ce8 568 uint32_t SpiritRadioGetSynthWord(void)
MACRUM 0:615f90842ce8 569 {
MACRUM 0:615f90842ce8 570 uint8_t regArray[4];
MACRUM 0:615f90842ce8 571
MACRUM 0:615f90842ce8 572 /* Reads the SYNTH registers, build the synth word and return it */
MACRUM 0:615f90842ce8 573 g_xStatus = SpiritSpiReadRegisters(SYNT3_BASE, 4, regArray);
MACRUM 0:615f90842ce8 574 return ((((uint32_t)(regArray[0]&0x1F))<<21)+(((uint32_t)(regArray[1]))<<13)+\
MACRUM 0:615f90842ce8 575 (((uint32_t)(regArray[2]))<<5)+(((uint32_t)(regArray[3]))>>3));
MACRUM 0:615f90842ce8 576
MACRUM 0:615f90842ce8 577 }
MACRUM 0:615f90842ce8 578
MACRUM 0:615f90842ce8 579
MACRUM 0:615f90842ce8 580 /**
MACRUM 0:615f90842ce8 581 * @brief Sets the SYNTH registers.
MACRUM 0:615f90842ce8 582 * @param lSynthWord the synth word to write in the SYNTH[3:0] registers.
MACRUM 0:615f90842ce8 583 * @retval None.
MACRUM 0:615f90842ce8 584 */
MACRUM 0:615f90842ce8 585 void SpiritRadioSetSynthWord(uint32_t lSynthWord)
MACRUM 0:615f90842ce8 586 {
MACRUM 0:615f90842ce8 587 uint8_t tempArray[4];
MACRUM 0:615f90842ce8 588 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 589
MACRUM 0:615f90842ce8 590 /* Reads the SYNT0 register */
MACRUM 0:615f90842ce8 591 g_xStatus = SpiritSpiReadRegisters(SYNT0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 592
MACRUM 0:615f90842ce8 593 /* Mask the Band selected field */
MACRUM 0:615f90842ce8 594 tempRegValue &= 0x07;
MACRUM 0:615f90842ce8 595
MACRUM 0:615f90842ce8 596 /* Build the array for SYNTH registers */
MACRUM 0:615f90842ce8 597 tempArray[0] = (uint8_t)((lSynthWord>>21)&(0x0000001F));
MACRUM 0:615f90842ce8 598 tempArray[1] = (uint8_t)((lSynthWord>>13)&(0x000000FF));
MACRUM 0:615f90842ce8 599 tempArray[2] = (uint8_t)((lSynthWord>>5)&(0x000000FF));
MACRUM 0:615f90842ce8 600 tempArray[3] = (uint8_t)(((lSynthWord&0x0000001F)<<3)| tempRegValue);
MACRUM 0:615f90842ce8 601
MACRUM 0:615f90842ce8 602 /* Writes the synth word in the SYNTH registers */
MACRUM 0:615f90842ce8 603 g_xStatus = SpiritSpiWriteRegisters(SYNT3_BASE, 4, tempArray);
MACRUM 0:615f90842ce8 604
MACRUM 0:615f90842ce8 605 }
MACRUM 0:615f90842ce8 606
MACRUM 0:615f90842ce8 607
MACRUM 0:615f90842ce8 608 /**
MACRUM 0:615f90842ce8 609 * @brief Sets the operating band.
MACRUM 0:615f90842ce8 610 * @param xBand the band to set.
MACRUM 0:615f90842ce8 611 * This parameter can be one of following parameters:
MACRUM 0:615f90842ce8 612 * @arg HIGH_BAND High_Band selected: from 779 MHz to 915 MHz
MACRUM 0:615f90842ce8 613 * @arg MIDDLE_BAND: Middle Band selected: from 387 MHz to 470 MHz
MACRUM 0:615f90842ce8 614 * @arg LOW_BAND: Low Band selected: from 300 MHz to 348 MHz
MACRUM 0:615f90842ce8 615 * @arg VERY_LOW_BAND: Very low Band selected: from 150 MHz to 174 MHz
MACRUM 0:615f90842ce8 616 * @retval None.
MACRUM 0:615f90842ce8 617 */
MACRUM 0:615f90842ce8 618 void SpiritRadioSetBand(BandSelect xBand)
MACRUM 0:615f90842ce8 619 {
MACRUM 0:615f90842ce8 620 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 621
MACRUM 0:615f90842ce8 622 /* Check the parameters */
MACRUM 0:615f90842ce8 623 s_assert_param(IS_BAND_SELECTED(xBand));
MACRUM 0:615f90842ce8 624
MACRUM 0:615f90842ce8 625 /* Reads the SYNT0 register*/
MACRUM 0:615f90842ce8 626 g_xStatus = SpiritSpiReadRegisters(SYNT0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 627
MACRUM 0:615f90842ce8 628 /* Mask the SYNTH[4;0] field and write the BS value */
MACRUM 0:615f90842ce8 629 tempRegValue &= 0xF8;
MACRUM 0:615f90842ce8 630 tempRegValue |= s_vectcBandRegValue[xBand];
MACRUM 0:615f90842ce8 631
MACRUM 0:615f90842ce8 632 /* Configures the SYNT0 register setting the operating band */
MACRUM 0:615f90842ce8 633 g_xStatus = SpiritSpiWriteRegisters(SYNT0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 634
MACRUM 0:615f90842ce8 635 }
MACRUM 0:615f90842ce8 636
MACRUM 0:615f90842ce8 637
MACRUM 0:615f90842ce8 638 /**
MACRUM 0:615f90842ce8 639 * @brief Returns the operating band.
MACRUM 0:615f90842ce8 640 * @param None.
MACRUM 0:615f90842ce8 641 * @retval BandSelect Settled band.
MACRUM 0:615f90842ce8 642 * This returned value can be one of the following parameters:
MACRUM 0:615f90842ce8 643 * @arg HIGH_BAND High_Band selected: from 779 MHz to 915 MHz
MACRUM 0:615f90842ce8 644 * @arg MIDDLE_BAND: Middle Band selected: from 387 MHz to 470 MHz
MACRUM 0:615f90842ce8 645 * @arg LOW_BAND: Low Band selected: from 300 MHz to 348 MHz
MACRUM 0:615f90842ce8 646 * @arg VERY_LOW_BAND: Very low Band selected: from 150 MHz to 174 MHz
MACRUM 0:615f90842ce8 647 */
MACRUM 0:615f90842ce8 648 BandSelect SpiritRadioGetBand(void)
MACRUM 0:615f90842ce8 649 {
MACRUM 0:615f90842ce8 650 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 651
MACRUM 0:615f90842ce8 652 /* Reads the SYNT0 register */
MACRUM 0:615f90842ce8 653 g_xStatus = SpiritSpiReadRegisters(SYNT0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 654
MACRUM 0:615f90842ce8 655 /* Mask the Band selected field */
MACRUM 0:615f90842ce8 656 if((tempRegValue & 0x07) == SYNT0_BS_6)
MACRUM 0:615f90842ce8 657 {
MACRUM 0:615f90842ce8 658 return HIGH_BAND;
MACRUM 0:615f90842ce8 659 }
MACRUM 0:615f90842ce8 660 else if ((tempRegValue & 0x07) == SYNT0_BS_12)
MACRUM 0:615f90842ce8 661 {
MACRUM 0:615f90842ce8 662 return MIDDLE_BAND;
MACRUM 0:615f90842ce8 663 }
MACRUM 0:615f90842ce8 664 else if ((tempRegValue & 0x07) == SYNT0_BS_16)
MACRUM 0:615f90842ce8 665 {
MACRUM 0:615f90842ce8 666 return LOW_BAND;
MACRUM 0:615f90842ce8 667 }
MACRUM 0:615f90842ce8 668 else
MACRUM 0:615f90842ce8 669 {
MACRUM 0:615f90842ce8 670 return VERY_LOW_BAND;
MACRUM 0:615f90842ce8 671 }
MACRUM 0:615f90842ce8 672
MACRUM 0:615f90842ce8 673 }
MACRUM 0:615f90842ce8 674
MACRUM 0:615f90842ce8 675
MACRUM 0:615f90842ce8 676 /**
MACRUM 0:615f90842ce8 677 * @brief Sets the channel number.
MACRUM 0:615f90842ce8 678 * @param cChannel the channel number.
MACRUM 0:615f90842ce8 679 * @retval None.
MACRUM 0:615f90842ce8 680 */
MACRUM 0:615f90842ce8 681 void SpiritRadioSetChannel(uint8_t cChannel)
MACRUM 0:615f90842ce8 682 {
MACRUM 0:615f90842ce8 683 /* Writes the CHNUM register */
MACRUM 0:615f90842ce8 684 g_xStatus = SpiritSpiWriteRegisters(CHNUM_BASE, 1, &cChannel);
MACRUM 0:615f90842ce8 685
MACRUM 0:615f90842ce8 686 }
MACRUM 0:615f90842ce8 687
MACRUM 0:615f90842ce8 688
MACRUM 0:615f90842ce8 689 /**
MACRUM 0:615f90842ce8 690 * @brief Returns the actual channel number.
MACRUM 0:615f90842ce8 691 * @param None.
MACRUM 0:615f90842ce8 692 * @retval uint8_t Actual channel number.
MACRUM 0:615f90842ce8 693 */
MACRUM 0:615f90842ce8 694 uint8_t SpiritRadioGetChannel(void)
MACRUM 0:615f90842ce8 695 {
MACRUM 0:615f90842ce8 696 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 697
MACRUM 0:615f90842ce8 698 /* Reads the CHNUM register and return the value */
MACRUM 0:615f90842ce8 699 g_xStatus = SpiritSpiReadRegisters(CHNUM_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 700
MACRUM 0:615f90842ce8 701 return tempRegValue;
MACRUM 0:615f90842ce8 702
MACRUM 0:615f90842ce8 703 }
MACRUM 0:615f90842ce8 704
MACRUM 0:615f90842ce8 705
MACRUM 0:615f90842ce8 706 /**
MACRUM 0:615f90842ce8 707 * @brief Sets the channel space factor in channel space register.
MACRUM 0:615f90842ce8 708 * The channel spacing step is computed as F_Xo/32768.
MACRUM 0:615f90842ce8 709 * @param fChannelSpace the channel space expressed in Hz.
MACRUM 0:615f90842ce8 710 * @retval None.
MACRUM 0:615f90842ce8 711 */
MACRUM 0:615f90842ce8 712 void SpiritRadioSetChannelSpace(uint32_t fChannelSpace)
MACRUM 0:615f90842ce8 713 {
MACRUM 0:615f90842ce8 714 uint8_t cChannelSpaceFactor;
MACRUM 0:615f90842ce8 715
MACRUM 0:615f90842ce8 716 /* Round to the nearest integer */
MACRUM 0:615f90842ce8 717 cChannelSpaceFactor = ((uint32_t)fChannelSpace*CHSPACE_DIVIDER)/s_lXtalFrequency;
MACRUM 0:615f90842ce8 718
MACRUM 0:615f90842ce8 719 /* Write value into the register */
MACRUM 0:615f90842ce8 720 g_xStatus = SpiritSpiWriteRegisters(CHSPACE_BASE, 1, &cChannelSpaceFactor);
MACRUM 0:615f90842ce8 721
MACRUM 0:615f90842ce8 722 }
MACRUM 0:615f90842ce8 723
MACRUM 0:615f90842ce8 724
MACRUM 0:615f90842ce8 725 /**
MACRUM 0:615f90842ce8 726 * @brief Returns the channel space register.
MACRUM 0:615f90842ce8 727 * @param None.
MACRUM 0:615f90842ce8 728 * @retval uint32_t Channel space. The channel space is: CS = channel_space_factor x XtalFrequency/2^15
MACRUM 0:615f90842ce8 729 * where channel_space_factor is the CHSPACE register value.
MACRUM 0:615f90842ce8 730 */
MACRUM 0:615f90842ce8 731 uint32_t SpiritRadioGetChannelSpace(void)
MACRUM 0:615f90842ce8 732 {
MACRUM 0:615f90842ce8 733 uint8_t channelSpaceFactor;
MACRUM 0:615f90842ce8 734
MACRUM 0:615f90842ce8 735 /* Reads the CHSPACE register, calculate the channel space and return it */
MACRUM 0:615f90842ce8 736 g_xStatus = SpiritSpiReadRegisters(CHSPACE_BASE, 1, &channelSpaceFactor);
MACRUM 0:615f90842ce8 737
MACRUM 0:615f90842ce8 738 /* Compute the Hertz value and return it */
MACRUM 0:615f90842ce8 739 return ((channelSpaceFactor*s_lXtalFrequency)/CHSPACE_DIVIDER);
MACRUM 0:615f90842ce8 740
MACRUM 0:615f90842ce8 741 }
MACRUM 0:615f90842ce8 742
MACRUM 0:615f90842ce8 743
MACRUM 0:615f90842ce8 744 /**
MACRUM 0:615f90842ce8 745 * @brief Sets the FC OFFSET register starting from xtal ppm value.
MACRUM 0:615f90842ce8 746 * @param nXtalPpm the xtal offset expressed in ppm.
MACRUM 0:615f90842ce8 747 * @retval None.
MACRUM 0:615f90842ce8 748 */
MACRUM 0:615f90842ce8 749 void SpiritRadioSetFrequencyOffsetPpm(int16_t nXtalPpm)
MACRUM 0:615f90842ce8 750 {
MACRUM 0:615f90842ce8 751 uint8_t tempArray[2];
MACRUM 0:615f90842ce8 752 int16_t xtalOffsetFactor;
MACRUM 0:615f90842ce8 753 uint32_t synthWord, fBase;
MACRUM 0:615f90842ce8 754 int32_t FOffsetTmp;
MACRUM 0:615f90842ce8 755 BandSelect band;
MACRUM 0:615f90842ce8 756
MACRUM 0:615f90842ce8 757 /* Reads the synth word */
MACRUM 0:615f90842ce8 758 synthWord = SpiritRadioGetSynthWord();
MACRUM 0:615f90842ce8 759
MACRUM 0:615f90842ce8 760 /* Reads the operating band */
MACRUM 0:615f90842ce8 761 band = SpiritRadioGetBand();
MACRUM 0:615f90842ce8 762
MACRUM 0:615f90842ce8 763 /* Calculates the frequency base */
MACRUM 0:615f90842ce8 764 uint8_t cRefDiv = (uint8_t)SpiritRadioGetRefDiv()+1;
MACRUM 0:615f90842ce8 765 fBase = synthWord*(s_lXtalFrequency/(s_vectcBHalfFactor[band]*cRefDiv)/FBASE_DIVIDER);
MACRUM 0:615f90842ce8 766
MACRUM 0:615f90842ce8 767 /* Calculates the offset respect to RF frequency and according to xtal_ppm parameter */
MACRUM 0:615f90842ce8 768 FOffsetTmp = (int32_t)(((float)nXtalPpm*fBase)/PPM_FACTOR);
MACRUM 0:615f90842ce8 769
MACRUM 0:615f90842ce8 770 /* Check the Offset is in the correct range */
MACRUM 0:615f90842ce8 771 s_assert_param(IS_FREQUENCY_OFFSET(FOffsetTmp,s_lXtalFrequency));
MACRUM 0:615f90842ce8 772
MACRUM 0:615f90842ce8 773 /* Calculates the FC_OFFSET value to write in the corresponding register */
MACRUM 0:615f90842ce8 774 xtalOffsetFactor = (int16_t)(((float)FOffsetTmp*FBASE_DIVIDER)/s_lXtalFrequency);
MACRUM 0:615f90842ce8 775
MACRUM 0:615f90842ce8 776 /* Build the array related to the FC_OFFSET_1 and FC_OFFSET_0 register */
MACRUM 0:615f90842ce8 777 tempArray[0]=(uint8_t)((((uint16_t)xtalOffsetFactor)>>8)&0x0F);
MACRUM 0:615f90842ce8 778 tempArray[1]=(uint8_t)(xtalOffsetFactor);
MACRUM 0:615f90842ce8 779
MACRUM 0:615f90842ce8 780 /* Writes the FC_OFFSET registers */
MACRUM 0:615f90842ce8 781 g_xStatus = SpiritSpiWriteRegisters(FC_OFFSET1_BASE, 2, tempArray);
MACRUM 0:615f90842ce8 782
MACRUM 0:615f90842ce8 783 }
MACRUM 0:615f90842ce8 784
MACRUM 0:615f90842ce8 785
MACRUM 0:615f90842ce8 786 /**
MACRUM 0:615f90842ce8 787 * @brief Sets the FC OFFSET register starting from frequency offset expressed in Hz.
MACRUM 0:615f90842ce8 788 * @param lFOffset frequency offset expressed in Hz as signed word.
MACRUM 0:615f90842ce8 789 * @retval None.
MACRUM 0:615f90842ce8 790 */
MACRUM 0:615f90842ce8 791 void SpiritRadioSetFrequencyOffset(int32_t lFOffset)
MACRUM 0:615f90842ce8 792 {
MACRUM 0:615f90842ce8 793 uint8_t tempArray[2];
MACRUM 0:615f90842ce8 794 int16_t offset;
MACRUM 0:615f90842ce8 795
MACRUM 0:615f90842ce8 796 /* Check that the Offset is in the correct range */
MACRUM 0:615f90842ce8 797 s_assert_param(IS_FREQUENCY_OFFSET(lFOffset,s_lXtalFrequency));
MACRUM 0:615f90842ce8 798
MACRUM 0:615f90842ce8 799 /* Calculates the offset value to write in the FC_OFFSET register */
MACRUM 0:615f90842ce8 800 offset = (int16_t)(((float)lFOffset*FBASE_DIVIDER)/s_lXtalFrequency);
MACRUM 0:615f90842ce8 801
MACRUM 0:615f90842ce8 802 /* Build the array related to the FC_OFFSET_1 and FC_OFFSET_0 register */
MACRUM 0:615f90842ce8 803 tempArray[0]=(uint8_t)((((uint16_t)offset)>>8)&0x0F);
MACRUM 0:615f90842ce8 804 tempArray[1]=(uint8_t)(offset);
MACRUM 0:615f90842ce8 805
MACRUM 0:615f90842ce8 806 /* Writes the FC_OFFSET registers */
MACRUM 0:615f90842ce8 807 g_xStatus = SpiritSpiWriteRegisters(FC_OFFSET1_BASE, 2, tempArray);
MACRUM 0:615f90842ce8 808
MACRUM 0:615f90842ce8 809 }
MACRUM 0:615f90842ce8 810
MACRUM 0:615f90842ce8 811
MACRUM 0:615f90842ce8 812 /**
MACRUM 0:615f90842ce8 813 * @brief Returns the actual frequency offset.
MACRUM 0:615f90842ce8 814 * @param None.
MACRUM 0:615f90842ce8 815 * @retval int32_t Frequency offset expressed in Hz as signed word.
MACRUM 0:615f90842ce8 816 */
MACRUM 0:615f90842ce8 817 int32_t SpiritRadioGetFrequencyOffset(void)
MACRUM 0:615f90842ce8 818 {
MACRUM 0:615f90842ce8 819 uint8_t tempArray[2];
MACRUM 0:615f90842ce8 820 int16_t xtalOffsetFactor;
MACRUM 0:615f90842ce8 821
MACRUM 0:615f90842ce8 822 /* Reads the FC_OFFSET registers */
MACRUM 0:615f90842ce8 823 g_xStatus = SpiritSpiReadRegisters(FC_OFFSET1_BASE, 2, tempArray);
MACRUM 0:615f90842ce8 824
MACRUM 0:615f90842ce8 825 /* Calculates the Offset Factor */
MACRUM 0:615f90842ce8 826 uint16_t xtalOffTemp = ((((uint16_t)tempArray[0])<<8)+((uint16_t)tempArray[1]));
MACRUM 0:615f90842ce8 827
MACRUM 0:615f90842ce8 828 if(xtalOffTemp & 0x0800)
MACRUM 0:615f90842ce8 829 {
MACRUM 0:615f90842ce8 830 xtalOffTemp = xtalOffTemp | 0xF000;
MACRUM 0:615f90842ce8 831 }
MACRUM 0:615f90842ce8 832 else
MACRUM 0:615f90842ce8 833 {
MACRUM 0:615f90842ce8 834 xtalOffTemp = xtalOffTemp & 0x0FFF;
MACRUM 0:615f90842ce8 835 }
MACRUM 0:615f90842ce8 836
MACRUM 0:615f90842ce8 837 xtalOffsetFactor = *((int16_t*)(&xtalOffTemp));
MACRUM 0:615f90842ce8 838
MACRUM 0:615f90842ce8 839 /* Calculates the frequency offset and return it */
MACRUM 0:615f90842ce8 840 return ((int32_t)(xtalOffsetFactor*s_lXtalFrequency)/FBASE_DIVIDER);
MACRUM 0:615f90842ce8 841
MACRUM 0:615f90842ce8 842 }
MACRUM 0:615f90842ce8 843
MACRUM 0:615f90842ce8 844
MACRUM 0:615f90842ce8 845
MACRUM 0:615f90842ce8 846 /**
MACRUM 0:615f90842ce8 847 * @brief Sets the Synth word and the Band Select register according to desired base carrier frequency.
MACRUM 0:615f90842ce8 848 * In this API the Xtal configuration is read out from
MACRUM 0:615f90842ce8 849 * the corresponding register. The user shall fix it before call this API.
MACRUM 0:615f90842ce8 850 * @param lFBase the base carrier frequency expressed in Hz as unsigned word.
MACRUM 0:615f90842ce8 851 * @retval Error code: 0=no error, 1=error during calibration of VCO.
MACRUM 0:615f90842ce8 852 */
MACRUM 0:615f90842ce8 853 uint8_t SpiritRadioSetFrequencyBase(uint32_t lFBase)
MACRUM 0:615f90842ce8 854 {
MACRUM 0:615f90842ce8 855 uint32_t synthWord, Fc;
MACRUM 0:615f90842ce8 856 uint8_t band, anaRadioRegArray[4], wcp;
MACRUM 0:615f90842ce8 857
MACRUM 0:615f90842ce8 858 /* Check the parameter */
MACRUM 0:615f90842ce8 859 s_assert_param(IS_FREQUENCY_BAND(lFBase));
MACRUM 0:615f90842ce8 860
MACRUM 0:615f90842ce8 861 /* Search the operating band */
MACRUM 0:615f90842ce8 862 if(IS_FREQUENCY_BAND_HIGH(lFBase))
MACRUM 0:615f90842ce8 863 {
MACRUM 0:615f90842ce8 864 band = HIGH_BAND;
MACRUM 0:615f90842ce8 865 }
MACRUM 0:615f90842ce8 866 else if(IS_FREQUENCY_BAND_MIDDLE(lFBase))
MACRUM 0:615f90842ce8 867 {
MACRUM 0:615f90842ce8 868 band = MIDDLE_BAND;
MACRUM 0:615f90842ce8 869 }
MACRUM 0:615f90842ce8 870 else if(IS_FREQUENCY_BAND_LOW(lFBase))
MACRUM 0:615f90842ce8 871 {
MACRUM 0:615f90842ce8 872 band = LOW_BAND;
MACRUM 0:615f90842ce8 873 }
MACRUM 0:615f90842ce8 874 else
MACRUM 0:615f90842ce8 875 {
MACRUM 0:615f90842ce8 876 band = VERY_LOW_BAND;
MACRUM 0:615f90842ce8 877 }
MACRUM 0:615f90842ce8 878
MACRUM 0:615f90842ce8 879 int32_t FOffset = SpiritRadioGetFrequencyOffset();
MACRUM 0:615f90842ce8 880 uint32_t lChannelSpace = SpiritRadioGetChannelSpace();
MACRUM 0:615f90842ce8 881 uint8_t cChannelNum = SpiritRadioGetChannel();
MACRUM 0:615f90842ce8 882
MACRUM 0:615f90842ce8 883 /* Calculates the channel center frequency */
MACRUM 0:615f90842ce8 884 Fc = lFBase + FOffset + lChannelSpace*cChannelNum;
MACRUM 0:615f90842ce8 885
MACRUM 0:615f90842ce8 886 /* Reads the reference divider */
MACRUM 0:615f90842ce8 887 uint8_t cRefDiv = (uint8_t)SpiritRadioGetRefDiv()+1;
MACRUM 0:615f90842ce8 888
MACRUM 0:615f90842ce8 889 /* Selects the VCO */
MACRUM 0:615f90842ce8 890 switch(band)
MACRUM 0:615f90842ce8 891 {
MACRUM 0:615f90842ce8 892 case VERY_LOW_BAND:
MACRUM 0:615f90842ce8 893 if(Fc<161281250)
MACRUM 0:615f90842ce8 894 {
MACRUM 0:615f90842ce8 895 SpiritCalibrationSelectVco(VCO_L);
MACRUM 0:615f90842ce8 896 }
MACRUM 0:615f90842ce8 897 else
MACRUM 0:615f90842ce8 898 {
MACRUM 0:615f90842ce8 899 SpiritCalibrationSelectVco(VCO_H);
MACRUM 0:615f90842ce8 900 }
MACRUM 0:615f90842ce8 901 break;
MACRUM 0:615f90842ce8 902
MACRUM 0:615f90842ce8 903 case LOW_BAND:
MACRUM 0:615f90842ce8 904 if(Fc<322562500)
MACRUM 0:615f90842ce8 905 {
MACRUM 0:615f90842ce8 906 SpiritCalibrationSelectVco(VCO_L);
MACRUM 0:615f90842ce8 907 }
MACRUM 0:615f90842ce8 908 else
MACRUM 0:615f90842ce8 909 {
MACRUM 0:615f90842ce8 910 SpiritCalibrationSelectVco(VCO_H);
MACRUM 0:615f90842ce8 911 }
MACRUM 0:615f90842ce8 912 break;
MACRUM 0:615f90842ce8 913
MACRUM 0:615f90842ce8 914 case MIDDLE_BAND:
MACRUM 0:615f90842ce8 915 if(Fc<430083334)
MACRUM 0:615f90842ce8 916 {
MACRUM 0:615f90842ce8 917 SpiritCalibrationSelectVco(VCO_L);
MACRUM 0:615f90842ce8 918 }
MACRUM 0:615f90842ce8 919 else
MACRUM 0:615f90842ce8 920 {
MACRUM 0:615f90842ce8 921 SpiritCalibrationSelectVco(VCO_H);
MACRUM 0:615f90842ce8 922 }
MACRUM 0:615f90842ce8 923 break;
MACRUM 0:615f90842ce8 924
MACRUM 0:615f90842ce8 925 case HIGH_BAND:
MACRUM 0:615f90842ce8 926 if(Fc<860166667)
MACRUM 0:615f90842ce8 927 {
MACRUM 0:615f90842ce8 928 SpiritCalibrationSelectVco(VCO_L);
MACRUM 0:615f90842ce8 929 }
MACRUM 0:615f90842ce8 930 else
MACRUM 0:615f90842ce8 931 {
MACRUM 0:615f90842ce8 932 SpiritCalibrationSelectVco(VCO_H);
MACRUM 0:615f90842ce8 933 }
MACRUM 0:615f90842ce8 934 }
MACRUM 0:615f90842ce8 935
MACRUM 0:615f90842ce8 936 /* Search the VCO charge pump word and set the corresponding register */
MACRUM 0:615f90842ce8 937 wcp = SpiritRadioSearchWCP(Fc);
MACRUM 0:615f90842ce8 938
MACRUM 0:615f90842ce8 939 synthWord = (uint32_t)(lFBase*s_vectcBHalfFactor[band]*(((double)(FBASE_DIVIDER*cRefDiv))/s_lXtalFrequency));
MACRUM 0:615f90842ce8 940
MACRUM 0:615f90842ce8 941 /* Build the array of registers values for the analog part */
MACRUM 0:615f90842ce8 942 anaRadioRegArray[0] = (uint8_t)(((synthWord>>21)&(0x0000001F))|(wcp<<5));
MACRUM 0:615f90842ce8 943 anaRadioRegArray[1] = (uint8_t)((synthWord>>13)&(0x000000FF));
MACRUM 0:615f90842ce8 944 anaRadioRegArray[2] = (uint8_t)((synthWord>>5)&(0x000000FF));
MACRUM 0:615f90842ce8 945 anaRadioRegArray[3] = (uint8_t)(((synthWord&0x0000001F)<<3)| s_vectcBandRegValue[band]);
MACRUM 0:615f90842ce8 946
MACRUM 0:615f90842ce8 947 /* Configures the needed Analog Radio registers */
MACRUM 0:615f90842ce8 948 g_xStatus = SpiritSpiWriteRegisters(SYNT3_BASE, 4, anaRadioRegArray);
MACRUM 0:615f90842ce8 949
MACRUM 0:615f90842ce8 950 if(xDoVcoCalibrationWA==S_ENABLE)
MACRUM 0:615f90842ce8 951 return SpiritManagementWaVcoCalibration();
MACRUM 0:615f90842ce8 952
MACRUM 0:615f90842ce8 953 return 0;
MACRUM 0:615f90842ce8 954 }
MACRUM 0:615f90842ce8 955
MACRUM 0:615f90842ce8 956 /**
MACRUM 0:615f90842ce8 957 * @brief To say to the set frequency base if do or not the VCO calibration WA.
MACRUM 0:615f90842ce8 958 * @param S_ENABLE or S_DISABLE the WA procedure.
MACRUM 0:615f90842ce8 959 * @retval None.
MACRUM 0:615f90842ce8 960 */
MACRUM 0:615f90842ce8 961 void SpiritRadioVcoCalibrationWAFB(SpiritFunctionalState xNewstate)
MACRUM 0:615f90842ce8 962 {
MACRUM 0:615f90842ce8 963 xDoVcoCalibrationWA=xNewstate;
MACRUM 0:615f90842ce8 964 }
MACRUM 0:615f90842ce8 965
MACRUM 0:615f90842ce8 966 /**
MACRUM 0:615f90842ce8 967 * @brief Returns the base carrier frequency.
MACRUM 0:615f90842ce8 968 * @param None.
MACRUM 0:615f90842ce8 969 * @retval uint32_t Base carrier frequency expressed in Hz as unsigned word.
MACRUM 0:615f90842ce8 970 */
MACRUM 0:615f90842ce8 971 uint32_t SpiritRadioGetFrequencyBase(void)
MACRUM 0:615f90842ce8 972 {
MACRUM 0:615f90842ce8 973 uint32_t synthWord;
MACRUM 0:615f90842ce8 974 BandSelect band;
MACRUM 0:615f90842ce8 975
MACRUM 0:615f90842ce8 976 /* Reads the synth word */
MACRUM 0:615f90842ce8 977 synthWord = SpiritRadioGetSynthWord();
MACRUM 0:615f90842ce8 978
MACRUM 0:615f90842ce8 979 /* Reads the operating band */
MACRUM 0:615f90842ce8 980 band = SpiritRadioGetBand();
MACRUM 0:615f90842ce8 981
MACRUM 0:615f90842ce8 982 uint8_t cRefDiv = (uint8_t)SpiritRadioGetRefDiv() + 1;
MACRUM 0:615f90842ce8 983
MACRUM 0:615f90842ce8 984 /* Calculates the frequency base and return it */
MACRUM 0:615f90842ce8 985 return (uint32_t)round(synthWord*(((double)s_lXtalFrequency)/(FBASE_DIVIDER*cRefDiv*s_vectcBHalfFactor[band])));
MACRUM 0:615f90842ce8 986 }
MACRUM 0:615f90842ce8 987
MACRUM 0:615f90842ce8 988
MACRUM 0:615f90842ce8 989 /**
MACRUM 0:615f90842ce8 990 * @brief Returns the actual channel center frequency.
MACRUM 0:615f90842ce8 991 * @param None.
MACRUM 0:615f90842ce8 992 * @retval uint32_t Actual channel center frequency expressed in Hz.
MACRUM 0:615f90842ce8 993 */
MACRUM 0:615f90842ce8 994 uint32_t SpiritRadioGetCenterFrequency(void)
MACRUM 0:615f90842ce8 995 {
MACRUM 0:615f90842ce8 996 int32_t offset;
MACRUM 0:615f90842ce8 997 uint8_t channel;
MACRUM 0:615f90842ce8 998 uint32_t fBase;
MACRUM 0:615f90842ce8 999 uint32_t channelSpace;
MACRUM 0:615f90842ce8 1000
MACRUM 0:615f90842ce8 1001 /* Reads the frequency base */
MACRUM 0:615f90842ce8 1002 fBase = SpiritRadioGetFrequencyBase();
MACRUM 0:615f90842ce8 1003
MACRUM 0:615f90842ce8 1004 /* Reads the frequency offset */
MACRUM 0:615f90842ce8 1005 offset = SpiritRadioGetFrequencyOffset();
MACRUM 0:615f90842ce8 1006
MACRUM 0:615f90842ce8 1007 /* Reads the channel space */
MACRUM 0:615f90842ce8 1008 channelSpace = SpiritRadioGetChannelSpace();
MACRUM 0:615f90842ce8 1009
MACRUM 0:615f90842ce8 1010 /* Reads the channel number */
MACRUM 0:615f90842ce8 1011 channel = SpiritRadioGetChannel();
MACRUM 0:615f90842ce8 1012
MACRUM 0:615f90842ce8 1013 /* Calculates the channel center frequency and return it */
MACRUM 0:615f90842ce8 1014 return (uint32_t)(fBase + offset + (uint32_t)(channelSpace*channel));
MACRUM 0:615f90842ce8 1015
MACRUM 0:615f90842ce8 1016 }
MACRUM 0:615f90842ce8 1017
MACRUM 0:615f90842ce8 1018
MACRUM 0:615f90842ce8 1019 /**
MACRUM 0:615f90842ce8 1020 * @brief Returns the mantissa and exponent, whose value used in the datarate formula
MACRUM 0:615f90842ce8 1021 * will give the datarate value closer to the given datarate.
MACRUM 0:615f90842ce8 1022 * @param fDatarate datarate expressed in bps. This parameter ranging between 100 and 500000.
MACRUM 0:615f90842ce8 1023 * @param pcM pointer to the returned mantissa value.
MACRUM 0:615f90842ce8 1024 * @param pcE pointer to the returned exponent value.
MACRUM 0:615f90842ce8 1025 * @retval None.
MACRUM 0:615f90842ce8 1026 */
MACRUM 0:615f90842ce8 1027 void SpiritRadioSearchDatarateME(uint32_t lDatarate, uint8_t* pcM, uint8_t* pcE)
MACRUM 0:615f90842ce8 1028 {
MACRUM 0:615f90842ce8 1029 volatile SpiritBool find = S_FALSE;
MACRUM 0:615f90842ce8 1030 int8_t i=15;
MACRUM 0:615f90842ce8 1031 uint8_t cMantissaTmp;
MACRUM 0:615f90842ce8 1032 uint8_t cDivider = 0;
MACRUM 0:615f90842ce8 1033
MACRUM 0:615f90842ce8 1034 /* Check the parameters */
MACRUM 0:615f90842ce8 1035 s_assert_param(IS_DATARATE(lDatarate));
MACRUM 0:615f90842ce8 1036
MACRUM 0:615f90842ce8 1037 cDivider = (uint8_t)SpiritRadioGetDigDiv();
MACRUM 0:615f90842ce8 1038
MACRUM 0:615f90842ce8 1039 /* Search in the datarate array the exponent value */
MACRUM 0:615f90842ce8 1040 while(!find && i>=0)
MACRUM 0:615f90842ce8 1041 {
MACRUM 0:615f90842ce8 1042 if(lDatarate>=(s_lXtalFrequency>>(20-i+cDivider)))
MACRUM 0:615f90842ce8 1043 {
MACRUM 0:615f90842ce8 1044 find = S_TRUE;
MACRUM 0:615f90842ce8 1045 }
MACRUM 0:615f90842ce8 1046 else
MACRUM 0:615f90842ce8 1047 {
MACRUM 0:615f90842ce8 1048 i--;
MACRUM 0:615f90842ce8 1049 }
MACRUM 0:615f90842ce8 1050 }
MACRUM 0:615f90842ce8 1051 i<0 ? i=0 : i;
MACRUM 0:615f90842ce8 1052 *pcE = i;
MACRUM 0:615f90842ce8 1053
MACRUM 0:615f90842ce8 1054 /* Calculates the mantissa value according to the datarate formula */
MACRUM 0:615f90842ce8 1055 cMantissaTmp = (lDatarate*((uint32_t)1<<(23-i)))/(s_lXtalFrequency>>(5+cDivider))-256;
MACRUM 0:615f90842ce8 1056
MACRUM 0:615f90842ce8 1057 /* Finds the mantissa value with less approximation */
MACRUM 0:615f90842ce8 1058 int16_t mantissaCalculation[3];
MACRUM 0:615f90842ce8 1059 for(uint8_t j=0;j<3;j++)
MACRUM 0:615f90842ce8 1060 {
MACRUM 0:615f90842ce8 1061 if((cMantissaTmp+j-1))
MACRUM 0:615f90842ce8 1062 {
MACRUM 0:615f90842ce8 1063 mantissaCalculation[j]=lDatarate-(((256+cMantissaTmp+j-1)*(s_lXtalFrequency>>(5+cDivider)))>>(23-i));
MACRUM 0:615f90842ce8 1064 }
MACRUM 0:615f90842ce8 1065 else
MACRUM 0:615f90842ce8 1066 {
MACRUM 0:615f90842ce8 1067 mantissaCalculation[j]=0x7FFF;
MACRUM 0:615f90842ce8 1068 }
MACRUM 0:615f90842ce8 1069 }
MACRUM 0:615f90842ce8 1070 uint16_t mantissaCalculationDelta = 0xFFFF;
MACRUM 0:615f90842ce8 1071 for(uint8_t j=0;j<3;j++)
MACRUM 0:615f90842ce8 1072 {
MACRUM 0:615f90842ce8 1073 if(S_ABS(mantissaCalculation[j])<mantissaCalculationDelta)
MACRUM 0:615f90842ce8 1074 {
MACRUM 0:615f90842ce8 1075 mantissaCalculationDelta = S_ABS(mantissaCalculation[j]);
MACRUM 0:615f90842ce8 1076 *pcM = cMantissaTmp+j-1;
MACRUM 0:615f90842ce8 1077 }
MACRUM 0:615f90842ce8 1078 }
MACRUM 0:615f90842ce8 1079
MACRUM 0:615f90842ce8 1080 }
MACRUM 0:615f90842ce8 1081
MACRUM 0:615f90842ce8 1082
MACRUM 0:615f90842ce8 1083 /**
MACRUM 0:615f90842ce8 1084 * @brief Returns the mantissa and exponent for a given bandwidth.
MACRUM 0:615f90842ce8 1085 * Even if it is possible to pass as parameter any value in the below mentioned range,
MACRUM 0:615f90842ce8 1086 * the API will search the closer value according to a fixed table of channel
MACRUM 0:615f90842ce8 1087 * bandwidth values (@ref s_vectnBandwidth), as defined in the datasheet, returning the corresponding mantissa
MACRUM 0:615f90842ce8 1088 * and exponent value.
MACRUM 0:615f90842ce8 1089 * @param lBandwidth bandwidth expressed in Hz. This parameter ranging between 1100 and 800100.
MACRUM 0:615f90842ce8 1090 * @param pcM pointer to the returned mantissa value.
MACRUM 0:615f90842ce8 1091 * @param pcE pointer to the returned exponent value.
MACRUM 0:615f90842ce8 1092 * @retval None.
MACRUM 0:615f90842ce8 1093 */
MACRUM 0:615f90842ce8 1094 void SpiritRadioSearchChannelBwME(uint32_t lBandwidth, uint8_t* pcM, uint8_t* pcE)
MACRUM 0:615f90842ce8 1095 {
MACRUM 0:615f90842ce8 1096 int8_t i, i_tmp;
MACRUM 0:615f90842ce8 1097 uint8_t cDivider = 1;
MACRUM 0:615f90842ce8 1098
MACRUM 0:615f90842ce8 1099 /* Search in the channel filter bandwidth table the exponent value */
MACRUM 0:615f90842ce8 1100 if(SpiritRadioGetDigDiv())
MACRUM 0:615f90842ce8 1101 {
MACRUM 0:615f90842ce8 1102 cDivider = 2;
MACRUM 0:615f90842ce8 1103 }
MACRUM 0:615f90842ce8 1104 else
MACRUM 0:615f90842ce8 1105 {
MACRUM 0:615f90842ce8 1106 cDivider = 1;
MACRUM 0:615f90842ce8 1107 }
MACRUM 0:615f90842ce8 1108
MACRUM 0:615f90842ce8 1109 s_assert_param(IS_CH_BW(lBandwidth,s_lXtalFrequency/cDivider));
MACRUM 0:615f90842ce8 1110
MACRUM 0:615f90842ce8 1111 uint32_t lChfltFactor = (s_lXtalFrequency/cDivider)/100;
MACRUM 0:615f90842ce8 1112
MACRUM 0:615f90842ce8 1113 for(i=0;i<90 && (lBandwidth<(uint32_t)((s_vectnBandwidth26M[i]*lChfltFactor)/2600));i++);
MACRUM 0:615f90842ce8 1114
MACRUM 0:615f90842ce8 1115 if(i!=0)
MACRUM 0:615f90842ce8 1116 {
MACRUM 0:615f90842ce8 1117 /* Finds the mantissa value with less approximation */
MACRUM 0:615f90842ce8 1118 i_tmp=i;
MACRUM 0:615f90842ce8 1119 int16_t chfltCalculation[3];
MACRUM 0:615f90842ce8 1120 for(uint8_t j=0;j<3;j++)
MACRUM 0:615f90842ce8 1121 {
MACRUM 0:615f90842ce8 1122 if(((i_tmp+j-1)>=0) || ((i_tmp+j-1)<=89))
MACRUM 0:615f90842ce8 1123 {
MACRUM 0:615f90842ce8 1124 chfltCalculation[j] = lBandwidth - (uint32_t)((s_vectnBandwidth26M[i_tmp+j-1]*lChfltFactor)/2600);
MACRUM 0:615f90842ce8 1125 }
MACRUM 0:615f90842ce8 1126 else
MACRUM 0:615f90842ce8 1127 {
MACRUM 0:615f90842ce8 1128 chfltCalculation[j] = 0x7FFF;
MACRUM 0:615f90842ce8 1129 }
MACRUM 0:615f90842ce8 1130 }
MACRUM 0:615f90842ce8 1131 uint16_t chfltDelta = 0xFFFF;
MACRUM 0:615f90842ce8 1132
MACRUM 0:615f90842ce8 1133 for(uint8_t j=0;j<3;j++)
MACRUM 0:615f90842ce8 1134 {
MACRUM 0:615f90842ce8 1135 if(S_ABS(chfltCalculation[j])<chfltDelta)
MACRUM 0:615f90842ce8 1136 {
MACRUM 0:615f90842ce8 1137 chfltDelta = S_ABS(chfltCalculation[j]);
MACRUM 0:615f90842ce8 1138 i=i_tmp+j-1;
MACRUM 0:615f90842ce8 1139 }
MACRUM 0:615f90842ce8 1140 }
MACRUM 0:615f90842ce8 1141 }
MACRUM 0:615f90842ce8 1142 (*pcE) = (uint8_t)(i/9);
MACRUM 0:615f90842ce8 1143 (*pcM) = (uint8_t)(i%9);
MACRUM 0:615f90842ce8 1144
MACRUM 0:615f90842ce8 1145 }
MACRUM 0:615f90842ce8 1146
MACRUM 0:615f90842ce8 1147 /**
MACRUM 0:615f90842ce8 1148 * @brief Returns the mantissa and exponent, whose value used in the frequency deviation formula
MACRUM 0:615f90842ce8 1149 * will give a frequency deviation value most closer to the given frequency deviation.
MACRUM 0:615f90842ce8 1150 * @param fFDev frequency deviation expressed in Hz. This parameter can be a value in the range [F_Xo*8/2^18, F_Xo*7680/2^18].
MACRUM 0:615f90842ce8 1151 * @param pcM pointer to the returned mantissa value.
MACRUM 0:615f90842ce8 1152 * @param pcE pointer to the returned exponent value.
MACRUM 0:615f90842ce8 1153 * @retval None.
MACRUM 0:615f90842ce8 1154 */
MACRUM 0:615f90842ce8 1155 void SpiritRadioSearchFreqDevME(uint32_t lFDev, uint8_t* pcM, uint8_t* pcE)
MACRUM 0:615f90842ce8 1156 {
MACRUM 0:615f90842ce8 1157 uint8_t i;
MACRUM 0:615f90842ce8 1158 uint32_t a,bp,b=0;
MACRUM 0:615f90842ce8 1159 float xtalDivtmp=(float)s_lXtalFrequency/(((uint32_t)1)<<18);
MACRUM 0:615f90842ce8 1160
MACRUM 0:615f90842ce8 1161 /* Check the parameters */
MACRUM 0:615f90842ce8 1162 s_assert_param(IS_F_DEV(lFDev,s_lXtalFrequency));
MACRUM 0:615f90842ce8 1163
MACRUM 0:615f90842ce8 1164 for(i=0;i<10;i++)
MACRUM 0:615f90842ce8 1165 {
MACRUM 0:615f90842ce8 1166 a=(uint32_t)(xtalDivtmp*(uint32_t)(7.5*(1<<i)));
MACRUM 0:615f90842ce8 1167 if(lFDev<a)
MACRUM 0:615f90842ce8 1168 break;
MACRUM 0:615f90842ce8 1169 }
MACRUM 0:615f90842ce8 1170 (*pcE) = i;
MACRUM 0:615f90842ce8 1171
MACRUM 0:615f90842ce8 1172 for(i=0;i<8;i++)
MACRUM 0:615f90842ce8 1173 {
MACRUM 0:615f90842ce8 1174 bp=b;
MACRUM 0:615f90842ce8 1175 b=(uint32_t)(xtalDivtmp*(uint32_t)((8.0+i)/2*(1<<(*pcE))));
MACRUM 0:615f90842ce8 1176 if(lFDev<b)
MACRUM 0:615f90842ce8 1177 break;
MACRUM 0:615f90842ce8 1178 }
MACRUM 0:615f90842ce8 1179
MACRUM 0:615f90842ce8 1180 (*pcM)=i;
MACRUM 0:615f90842ce8 1181 if((lFDev-bp)<(b-lFDev))
MACRUM 0:615f90842ce8 1182 (*pcM)--;
MACRUM 0:615f90842ce8 1183
MACRUM 0:615f90842ce8 1184 }
MACRUM 0:615f90842ce8 1185
MACRUM 0:615f90842ce8 1186
MACRUM 0:615f90842ce8 1187 /**
MACRUM 0:615f90842ce8 1188 * @brief Sets the datarate.
MACRUM 0:615f90842ce8 1189 * @param fDatarate datarate expressed in bps. This value shall be in the range
MACRUM 0:615f90842ce8 1190 * [100 500000].
MACRUM 0:615f90842ce8 1191 * @retval None.
MACRUM 0:615f90842ce8 1192 */
MACRUM 0:615f90842ce8 1193 void SpiritRadioSetDatarate(uint32_t lDatarate)
MACRUM 0:615f90842ce8 1194 {
MACRUM 0:615f90842ce8 1195 uint8_t drE, tempRegValue[2];
MACRUM 0:615f90842ce8 1196
MACRUM 0:615f90842ce8 1197 /* Check the parameters */
MACRUM 0:615f90842ce8 1198 s_assert_param(IS_DATARATE(lDatarate));
MACRUM 0:615f90842ce8 1199
MACRUM 0:615f90842ce8 1200 /* Calculates the datarate mantissa and exponent */
MACRUM 0:615f90842ce8 1201 SpiritRadioSearchDatarateME(lDatarate, &tempRegValue[0], &drE);
MACRUM 0:615f90842ce8 1202
MACRUM 0:615f90842ce8 1203 /* Reads the MOD_O register*/
MACRUM 0:615f90842ce8 1204 SpiritSpiReadRegisters(MOD0_BASE, 1, &tempRegValue[1]);
MACRUM 0:615f90842ce8 1205
MACRUM 0:615f90842ce8 1206 /* Mask the other fields and set the datarate exponent */
MACRUM 0:615f90842ce8 1207 tempRegValue[1] &= 0xF0;
MACRUM 0:615f90842ce8 1208 tempRegValue[1] |= drE;
MACRUM 0:615f90842ce8 1209
MACRUM 0:615f90842ce8 1210 /* Writes the Datarate registers */
MACRUM 0:615f90842ce8 1211 g_xStatus = SpiritSpiWriteRegisters(MOD1_BASE, 2, tempRegValue);
MACRUM 0:615f90842ce8 1212
MACRUM 0:615f90842ce8 1213 }
MACRUM 0:615f90842ce8 1214
MACRUM 0:615f90842ce8 1215
MACRUM 0:615f90842ce8 1216 /**
MACRUM 0:615f90842ce8 1217 * @brief Returns the datarate.
MACRUM 0:615f90842ce8 1218 * @param None.
MACRUM 0:615f90842ce8 1219 * @retval uint32_t Settled datarate expressed in bps.
MACRUM 0:615f90842ce8 1220 */
MACRUM 0:615f90842ce8 1221 uint32_t SpiritRadioGetDatarate(void)
MACRUM 0:615f90842ce8 1222 {
MACRUM 0:615f90842ce8 1223 uint8_t tempRegValue[2];
MACRUM 0:615f90842ce8 1224 uint8_t cDivider=0;
MACRUM 0:615f90842ce8 1225
MACRUM 0:615f90842ce8 1226 /* Reads the datarate registers for mantissa and exponent */
MACRUM 0:615f90842ce8 1227 g_xStatus = SpiritSpiReadRegisters(MOD1_BASE, 2, tempRegValue);
MACRUM 0:615f90842ce8 1228
MACRUM 0:615f90842ce8 1229 /* Calculates the datarate */
MACRUM 0:615f90842ce8 1230 cDivider = (uint8_t)SpiritRadioGetDigDiv();
MACRUM 0:615f90842ce8 1231
MACRUM 0:615f90842ce8 1232 return (((s_lXtalFrequency>>(5+cDivider))*(256+tempRegValue[0]))>>(23-(tempRegValue[1]&0x0F)));
MACRUM 0:615f90842ce8 1233 }
MACRUM 0:615f90842ce8 1234
MACRUM 0:615f90842ce8 1235
MACRUM 0:615f90842ce8 1236 /**
MACRUM 0:615f90842ce8 1237 * @brief Sets the frequency deviation.
MACRUM 0:615f90842ce8 1238 * @param fFDev frequency deviation expressed in Hz. Be sure that this value
MACRUM 0:615f90842ce8 1239 * is in the correct range [F_Xo*8/2^18, F_Xo*7680/2^18] Hz.
MACRUM 0:615f90842ce8 1240 * @retval None.
MACRUM 0:615f90842ce8 1241 */
MACRUM 0:615f90842ce8 1242 void SpiritRadioSetFrequencyDev(uint32_t lFDev)
MACRUM 0:615f90842ce8 1243 {
MACRUM 0:615f90842ce8 1244 uint8_t FDevM, FDevE, tempRegValue;
MACRUM 0:615f90842ce8 1245
MACRUM 0:615f90842ce8 1246 /* Check the parameters */
MACRUM 0:615f90842ce8 1247 s_assert_param(IS_F_DEV(lFDev, s_lXtalFrequency));
MACRUM 0:615f90842ce8 1248
MACRUM 0:615f90842ce8 1249 /* Calculates the frequency deviation mantissa and exponent */
MACRUM 0:615f90842ce8 1250 SpiritRadioSearchFreqDevME(lFDev, &FDevM, &FDevE);
MACRUM 0:615f90842ce8 1251
MACRUM 0:615f90842ce8 1252 /* Reads the FDEV0 register */
MACRUM 0:615f90842ce8 1253 SpiritSpiReadRegisters(FDEV0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 1254
MACRUM 0:615f90842ce8 1255 /* Mask the other fields and set the frequency deviation mantissa and exponent */
MACRUM 0:615f90842ce8 1256 tempRegValue &= 0x08;
MACRUM 0:615f90842ce8 1257 tempRegValue |= ((FDevE<<4)|(FDevM));
MACRUM 0:615f90842ce8 1258
MACRUM 0:615f90842ce8 1259 /* Writes the Frequency deviation register */
MACRUM 0:615f90842ce8 1260 g_xStatus = SpiritSpiWriteRegisters(FDEV0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 1261
MACRUM 0:615f90842ce8 1262 }
MACRUM 0:615f90842ce8 1263
MACRUM 0:615f90842ce8 1264
MACRUM 0:615f90842ce8 1265 /**
MACRUM 0:615f90842ce8 1266 * @brief Returns the frequency deviation.
MACRUM 0:615f90842ce8 1267 * @param None.
MACRUM 0:615f90842ce8 1268 * @retval uint32_t Frequency deviation value expressed in Hz.
MACRUM 0:615f90842ce8 1269 * This value will be in the range [F_Xo*8/2^18, F_Xo*7680/2^18] Hz.
MACRUM 0:615f90842ce8 1270 */
MACRUM 0:615f90842ce8 1271 uint32_t SpiritRadioGetFrequencyDev(void)
MACRUM 0:615f90842ce8 1272 {
MACRUM 0:615f90842ce8 1273 uint8_t tempRegValue, FDevM, FDevE;
MACRUM 0:615f90842ce8 1274
MACRUM 0:615f90842ce8 1275
MACRUM 0:615f90842ce8 1276 /* Reads the frequency deviation register for mantissa and exponent */
MACRUM 0:615f90842ce8 1277 g_xStatus = SpiritSpiReadRegisters(FDEV0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 1278 FDevM = tempRegValue&0x07;
MACRUM 0:615f90842ce8 1279 FDevE = (tempRegValue&0xF0)>>4;
MACRUM 0:615f90842ce8 1280
MACRUM 0:615f90842ce8 1281 /* Calculates the frequency deviation and return it */
MACRUM 0:615f90842ce8 1282 //return (((s_lXtalFrequency>>6)*(8+FDevM))>>(13-FDevE));
MACRUM 0:615f90842ce8 1283
MACRUM 0:615f90842ce8 1284 return (uint32_t)((float)s_lXtalFrequency/(((uint32_t)1)<<18)*(uint32_t)((8.0+FDevM)/2*(1<<FDevE)));
MACRUM 0:615f90842ce8 1285
MACRUM 0:615f90842ce8 1286 }
MACRUM 0:615f90842ce8 1287
MACRUM 0:615f90842ce8 1288
MACRUM 0:615f90842ce8 1289 /**
MACRUM 0:615f90842ce8 1290 * @brief Sets the channel filter bandwidth.
MACRUM 0:615f90842ce8 1291 * @param lBandwidth channel filter bandwidth expressed in Hz. This parameter shall be in the range [1100 800100]
MACRUM 0:615f90842ce8 1292 * Even if it is possible to pass as parameter any value in the above mentioned range,
MACRUM 0:615f90842ce8 1293 * the API will search the most closer value according to a fixed table of channel
MACRUM 0:615f90842ce8 1294 * bandwidth values (@ref s_vectnBandwidth), as defined in the datasheet. To verify the settled channel bandwidth
MACRUM 0:615f90842ce8 1295 * it is possible to use the SpiritRadioGetChannelBW() API.
MACRUM 0:615f90842ce8 1296 * @retval None.
MACRUM 0:615f90842ce8 1297 */
MACRUM 0:615f90842ce8 1298 void SpiritRadioSetChannelBW(uint32_t lBandwidth)
MACRUM 0:615f90842ce8 1299 {
MACRUM 0:615f90842ce8 1300 uint8_t bwM, bwE, tempRegValue;
MACRUM 0:615f90842ce8 1301
MACRUM 0:615f90842ce8 1302 /* Search in the channel filter bandwidth table the exponent value */
MACRUM 0:615f90842ce8 1303 if(SpiritRadioGetDigDiv())
MACRUM 0:615f90842ce8 1304 {
MACRUM 0:615f90842ce8 1305 s_assert_param(IS_CH_BW(lBandwidth,(s_lXtalFrequency/2)));
MACRUM 0:615f90842ce8 1306 }
MACRUM 0:615f90842ce8 1307 else
MACRUM 0:615f90842ce8 1308 {
MACRUM 0:615f90842ce8 1309 s_assert_param(IS_CH_BW(lBandwidth,(s_lXtalFrequency)));
MACRUM 0:615f90842ce8 1310 }
MACRUM 0:615f90842ce8 1311
MACRUM 0:615f90842ce8 1312 /* Calculates the channel bandwidth mantissa and exponent */
MACRUM 0:615f90842ce8 1313 SpiritRadioSearchChannelBwME(lBandwidth, &bwM, &bwE);
MACRUM 0:615f90842ce8 1314 tempRegValue = (bwM<<4)|(bwE);
MACRUM 0:615f90842ce8 1315
MACRUM 0:615f90842ce8 1316 /* Writes the Channel filter register */
MACRUM 0:615f90842ce8 1317 g_xStatus = SpiritSpiWriteRegisters(CHFLT_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 1318
MACRUM 0:615f90842ce8 1319 }
MACRUM 0:615f90842ce8 1320
MACRUM 0:615f90842ce8 1321 /**
MACRUM 0:615f90842ce8 1322 * @brief Returns the channel filter bandwidth.
MACRUM 0:615f90842ce8 1323 * @param None.
MACRUM 0:615f90842ce8 1324 * @retval uint32_t Channel filter bandwidth expressed in Hz.
MACRUM 0:615f90842ce8 1325 */
MACRUM 0:615f90842ce8 1326 uint32_t SpiritRadioGetChannelBW(void)
MACRUM 0:615f90842ce8 1327 {
MACRUM 0:615f90842ce8 1328 uint8_t tempRegValue, bwM, bwE;
MACRUM 0:615f90842ce8 1329
MACRUM 0:615f90842ce8 1330 /* Reads the channel filter register for mantissa and exponent */
MACRUM 0:615f90842ce8 1331 g_xStatus = SpiritSpiReadRegisters(CHFLT_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 1332 bwM = (tempRegValue&0xF0)>>4;
MACRUM 0:615f90842ce8 1333 bwE = tempRegValue&0x0F;
MACRUM 0:615f90842ce8 1334
MACRUM 0:615f90842ce8 1335 /* Reads the channel filter bandwidth from the look-up table and return it */
MACRUM 0:615f90842ce8 1336 return (uint32_t)(100.0*s_vectnBandwidth26M[bwM+(bwE*9)]*s_lXtalFrequency/26e6);
MACRUM 0:615f90842ce8 1337
MACRUM 0:615f90842ce8 1338 }
MACRUM 0:615f90842ce8 1339
MACRUM 0:615f90842ce8 1340
MACRUM 0:615f90842ce8 1341 /**
MACRUM 0:615f90842ce8 1342 * @brief Sets the modulation type.
MACRUM 0:615f90842ce8 1343 * @param xModulation modulation to set.
MACRUM 0:615f90842ce8 1344 * This parameter shall be of type @ref ModulationSelect .
MACRUM 0:615f90842ce8 1345 * @retval None.
MACRUM 0:615f90842ce8 1346 */
MACRUM 0:615f90842ce8 1347 void SpiritRadioSetModulation(ModulationSelect xModulation)
MACRUM 0:615f90842ce8 1348 {
MACRUM 0:615f90842ce8 1349 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 1350
MACRUM 0:615f90842ce8 1351 /* Check the parameters */
MACRUM 0:615f90842ce8 1352 s_assert_param(IS_MODULATION_SELECTED(xModulation));
MACRUM 0:615f90842ce8 1353
MACRUM 0:615f90842ce8 1354 /* Reads the modulation register */
MACRUM 0:615f90842ce8 1355 SpiritSpiReadRegisters(MOD0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 1356
MACRUM 0:615f90842ce8 1357 /* Mask the other fields and set the modulation type */
MACRUM 0:615f90842ce8 1358 tempRegValue &=0x8F;
MACRUM 0:615f90842ce8 1359 tempRegValue |= xModulation;
MACRUM 0:615f90842ce8 1360
MACRUM 0:615f90842ce8 1361 /* Writes the modulation register */
MACRUM 0:615f90842ce8 1362 g_xStatus = SpiritSpiWriteRegisters(MOD0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 1363
MACRUM 0:615f90842ce8 1364 }
MACRUM 0:615f90842ce8 1365
MACRUM 0:615f90842ce8 1366
MACRUM 0:615f90842ce8 1367 /**
MACRUM 0:615f90842ce8 1368 * @brief Returns the modulation type used.
MACRUM 0:615f90842ce8 1369 * @param None.
MACRUM 0:615f90842ce8 1370 * @retval ModulationSelect Settled modulation type.
MACRUM 0:615f90842ce8 1371 */
MACRUM 0:615f90842ce8 1372 ModulationSelect SpiritRadioGetModulation(void)
MACRUM 0:615f90842ce8 1373 {
MACRUM 0:615f90842ce8 1374 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 1375
MACRUM 0:615f90842ce8 1376 /* Reads the modulation register MOD0*/
MACRUM 0:615f90842ce8 1377 g_xStatus = SpiritSpiReadRegisters(MOD0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 1378
MACRUM 0:615f90842ce8 1379 /* Return the modulation type */
MACRUM 0:615f90842ce8 1380 return (ModulationSelect)(tempRegValue&0x70);
MACRUM 0:615f90842ce8 1381
MACRUM 0:615f90842ce8 1382 }
MACRUM 0:615f90842ce8 1383
MACRUM 0:615f90842ce8 1384
MACRUM 0:615f90842ce8 1385 /**
MACRUM 0:615f90842ce8 1386 * @brief Enables or Disables the Continuous Wave transmit mode.
MACRUM 0:615f90842ce8 1387 * @param xNewState new state for power ramping.
MACRUM 0:615f90842ce8 1388 * This parameter can be: S_ENABLE or S_DISABLE .
MACRUM 0:615f90842ce8 1389 * @retval None.
MACRUM 0:615f90842ce8 1390 */
MACRUM 0:615f90842ce8 1391 void SpiritRadioCWTransmitMode(SpiritFunctionalState xNewState)
MACRUM 0:615f90842ce8 1392 {
MACRUM 0:615f90842ce8 1393 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 1394
MACRUM 0:615f90842ce8 1395 /* Check the parameters */
MACRUM 0:615f90842ce8 1396 s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(xNewState));
MACRUM 0:615f90842ce8 1397
MACRUM 0:615f90842ce8 1398 /* Reads the modulation register MOD0 and mask the CW field */
MACRUM 0:615f90842ce8 1399 SpiritSpiReadRegisters(MOD0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 1400 if(xNewState == S_ENABLE)
MACRUM 0:615f90842ce8 1401 {
MACRUM 0:615f90842ce8 1402 tempRegValue |=MOD0_CW;
MACRUM 0:615f90842ce8 1403 }
MACRUM 0:615f90842ce8 1404 else
MACRUM 0:615f90842ce8 1405 {
MACRUM 0:615f90842ce8 1406 tempRegValue &= (~MOD0_CW);
MACRUM 0:615f90842ce8 1407 }
MACRUM 0:615f90842ce8 1408
MACRUM 0:615f90842ce8 1409 /* Writes the new value in the MOD0 register */
MACRUM 0:615f90842ce8 1410 g_xStatus = SpiritSpiWriteRegisters(MOD0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 1411
MACRUM 0:615f90842ce8 1412 }
MACRUM 0:615f90842ce8 1413
MACRUM 0:615f90842ce8 1414
MACRUM 0:615f90842ce8 1415 /**
MACRUM 0:615f90842ce8 1416 * @brief Sets the OOK Peak Decay.
MACRUM 0:615f90842ce8 1417 * @param xOokDecay Peak decay control for OOK.
MACRUM 0:615f90842ce8 1418 * This parameter shall be of type @ref OokPeakDecay .
MACRUM 0:615f90842ce8 1419 * @retval None.
MACRUM 0:615f90842ce8 1420 */
MACRUM 0:615f90842ce8 1421 void SpiritRadioSetOokPeakDecay(OokPeakDecay xOokDecay)
MACRUM 0:615f90842ce8 1422 {
MACRUM 0:615f90842ce8 1423 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 1424
MACRUM 0:615f90842ce8 1425 /* Check the parameters */
MACRUM 0:615f90842ce8 1426 s_assert_param(IS_OOK_PEAK_DECAY(xOokDecay));
MACRUM 0:615f90842ce8 1427
MACRUM 0:615f90842ce8 1428 /* Reads the RSSI_FLT register */
MACRUM 0:615f90842ce8 1429 SpiritSpiReadRegisters(RSSI_FLT_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 1430
MACRUM 0:615f90842ce8 1431 /* Mask the other fields and set OOK Peak Decay */
MACRUM 0:615f90842ce8 1432 tempRegValue &= 0xFC;
MACRUM 0:615f90842ce8 1433 tempRegValue |= xOokDecay;
MACRUM 0:615f90842ce8 1434
MACRUM 0:615f90842ce8 1435 /* Writes the RSSI_FLT register to set the new OOK peak dacay value */
MACRUM 0:615f90842ce8 1436 g_xStatus = SpiritSpiWriteRegisters(RSSI_FLT_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 1437
MACRUM 0:615f90842ce8 1438 }
MACRUM 0:615f90842ce8 1439
MACRUM 0:615f90842ce8 1440
MACRUM 0:615f90842ce8 1441 /**
MACRUM 0:615f90842ce8 1442 * @brief Returns the OOK Peak Decay.
MACRUM 0:615f90842ce8 1443 * @param None
MACRUM 0:615f90842ce8 1444 * @retval OokPeakDecay Ook peak decay value.
MACRUM 0:615f90842ce8 1445 */
MACRUM 0:615f90842ce8 1446 OokPeakDecay SpiritRadioGetOokPeakDecay(void)
MACRUM 0:615f90842ce8 1447 {
MACRUM 0:615f90842ce8 1448 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 1449
MACRUM 0:615f90842ce8 1450 /* Reads the OOK peak decay register RSSI_FLT_BASE*/
MACRUM 0:615f90842ce8 1451 g_xStatus = SpiritSpiReadRegisters(RSSI_FLT_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 1452
MACRUM 0:615f90842ce8 1453 /* Returns the OOK peak decay */
MACRUM 0:615f90842ce8 1454 return (OokPeakDecay) (tempRegValue & 0x03);
MACRUM 0:615f90842ce8 1455
MACRUM 0:615f90842ce8 1456 }
MACRUM 0:615f90842ce8 1457
MACRUM 0:615f90842ce8 1458 /**
MACRUM 0:615f90842ce8 1459 * @brief Returns the PA register value that corresponds to the passed dBm power.
MACRUM 0:615f90842ce8 1460 * @param lFbase Frequency base expressed in Hz.
MACRUM 0:615f90842ce8 1461 * @param fPowerdBm Desired power in dBm.
MACRUM 0:615f90842ce8 1462 * @retval Register value as byte.
MACRUM 0:615f90842ce8 1463 * @note The power interpolation curves used by this function have been extracted
MACRUM 0:615f90842ce8 1464 * by measurements done on the divisional evaluation boards.
MACRUM 0:615f90842ce8 1465 */
MACRUM 0:615f90842ce8 1466 uint8_t SpiritRadioGetdBm2Reg(uint32_t lFBase, float fPowerdBm)
MACRUM 0:615f90842ce8 1467 {
MACRUM 0:615f90842ce8 1468 uint8_t i=0;
MACRUM 0:615f90842ce8 1469 uint8_t j=0;
MACRUM 0:615f90842ce8 1470 float fReg;
MACRUM 0:615f90842ce8 1471
MACRUM 0:615f90842ce8 1472 if(IS_FREQUENCY_BAND_HIGH(lFBase))
MACRUM 0:615f90842ce8 1473 {
MACRUM 0:615f90842ce8 1474 i=0;
MACRUM 0:615f90842ce8 1475 if(lFBase<900000000) i=1;// 868
MACRUM 0:615f90842ce8 1476 }
MACRUM 0:615f90842ce8 1477 else if(IS_FREQUENCY_BAND_MIDDLE(lFBase))
MACRUM 0:615f90842ce8 1478 {
MACRUM 0:615f90842ce8 1479 i=2;
MACRUM 0:615f90842ce8 1480 }
MACRUM 0:615f90842ce8 1481 else if(IS_FREQUENCY_BAND_LOW(lFBase))
MACRUM 0:615f90842ce8 1482 {
MACRUM 0:615f90842ce8 1483 i=3;
MACRUM 0:615f90842ce8 1484 }
MACRUM 0:615f90842ce8 1485 else if(IS_FREQUENCY_BAND_VERY_LOW(lFBase))
MACRUM 0:615f90842ce8 1486 {
MACRUM 0:615f90842ce8 1487 i=4;
MACRUM 0:615f90842ce8 1488 }
MACRUM 0:615f90842ce8 1489
MACRUM 0:615f90842ce8 1490 j=1;
MACRUM 0:615f90842ce8 1491 if(fPowerdBm>0 && 13.0/fPowerFactors[i][2]-fPowerFactors[i][3]/fPowerFactors[i][2]<fPowerdBm)
MACRUM 0:615f90842ce8 1492 j=0;
MACRUM 0:615f90842ce8 1493 else if(fPowerdBm<=0 && 40.0/fPowerFactors[i][2]-fPowerFactors[i][3]/fPowerFactors[i][2]>fPowerdBm)
MACRUM 0:615f90842ce8 1494 j=2;
MACRUM 0:615f90842ce8 1495
MACRUM 0:615f90842ce8 1496 fReg=fPowerFactors[i][2*j]*fPowerdBm+fPowerFactors[i][2*j+1];
MACRUM 0:615f90842ce8 1497
MACRUM 0:615f90842ce8 1498 if(fReg<1)
MACRUM 0:615f90842ce8 1499 fReg=1;
MACRUM 0:615f90842ce8 1500 else if(fReg>90)
MACRUM 0:615f90842ce8 1501 fReg=90;
MACRUM 0:615f90842ce8 1502
MACRUM 0:615f90842ce8 1503 return ((uint8_t)fReg);
MACRUM 0:615f90842ce8 1504 }
MACRUM 0:615f90842ce8 1505
MACRUM 0:615f90842ce8 1506
MACRUM 0:615f90842ce8 1507 /**
MACRUM 0:615f90842ce8 1508 * @brief Returns the dBm power that corresponds to the value of PA register.
MACRUM 0:615f90842ce8 1509 * @param lFbase Frequency base expressed in Hz.
MACRUM 0:615f90842ce8 1510 * @param cPowerReg Register value of the PA.
MACRUM 0:615f90842ce8 1511 * @retval Power in dBm as float.
MACRUM 0:615f90842ce8 1512 * @note The power interpolation curves used by this function have been extracted
MACRUM 0:615f90842ce8 1513 * by measurements done on the divisional evaluation boards.
MACRUM 0:615f90842ce8 1514 */
MACRUM 0:615f90842ce8 1515 float SpiritRadioGetReg2dBm(uint32_t lFBase, uint8_t cPowerReg)
MACRUM 0:615f90842ce8 1516 {
MACRUM 0:615f90842ce8 1517 uint8_t i=0;
MACRUM 0:615f90842ce8 1518 uint8_t j=0;
MACRUM 0:615f90842ce8 1519 float fPower;
MACRUM 0:615f90842ce8 1520
MACRUM 0:615f90842ce8 1521 if(cPowerReg==0 || cPowerReg>90)
MACRUM 0:615f90842ce8 1522 return (-130.0);
MACRUM 0:615f90842ce8 1523
MACRUM 0:615f90842ce8 1524 if(IS_FREQUENCY_BAND_HIGH(lFBase))
MACRUM 0:615f90842ce8 1525 {
MACRUM 0:615f90842ce8 1526 i=0;
MACRUM 0:615f90842ce8 1527 if(lFBase<900000000) i=1;// 868
MACRUM 0:615f90842ce8 1528 }
MACRUM 0:615f90842ce8 1529 else if(IS_FREQUENCY_BAND_MIDDLE(lFBase))
MACRUM 0:615f90842ce8 1530 {
MACRUM 0:615f90842ce8 1531 i=2;
MACRUM 0:615f90842ce8 1532 }
MACRUM 0:615f90842ce8 1533 else if(IS_FREQUENCY_BAND_LOW(lFBase))
MACRUM 0:615f90842ce8 1534 {
MACRUM 0:615f90842ce8 1535 i=3;
MACRUM 0:615f90842ce8 1536 }
MACRUM 0:615f90842ce8 1537 else if(IS_FREQUENCY_BAND_VERY_LOW(lFBase))
MACRUM 0:615f90842ce8 1538 {
MACRUM 0:615f90842ce8 1539 i=4;
MACRUM 0:615f90842ce8 1540 }
MACRUM 0:615f90842ce8 1541
MACRUM 0:615f90842ce8 1542 j=1;
MACRUM 0:615f90842ce8 1543 if(cPowerReg<13) j=0;
MACRUM 0:615f90842ce8 1544 else if(cPowerReg>40) j=2;
MACRUM 0:615f90842ce8 1545
MACRUM 0:615f90842ce8 1546 fPower=(((float)cPowerReg)/fPowerFactors[i][2*j]-fPowerFactors[i][2*j+1]/fPowerFactors[i][2*j]);
MACRUM 0:615f90842ce8 1547
MACRUM 0:615f90842ce8 1548 return fPower;
MACRUM 0:615f90842ce8 1549 }
MACRUM 0:615f90842ce8 1550
MACRUM 0:615f90842ce8 1551 /**
MACRUM 0:615f90842ce8 1552 * @brief Configures the Power Amplifier Table and registers with value expressed in dBm.
MACRUM 0:615f90842ce8 1553 * @param cPALevelMaxIndex number of levels to set. This parameter shall be in the range [0:7].
MACRUM 0:615f90842ce8 1554 * @param cWidth step width expressed in terms of bit period units Tb/8.
MACRUM 0:615f90842ce8 1555 * This parameter shall be in the range [1:4].
MACRUM 0:615f90842ce8 1556 * @param xCLoad one of the possible value of the enum type PALoadCapacitor.
MACRUM 0:615f90842ce8 1557 * @arg LOAD_0_PF No additional PA load capacitor
MACRUM 0:615f90842ce8 1558 * @arg LOAD_1_2_PF 1.2pF additional PA load capacitor
MACRUM 0:615f90842ce8 1559 * @arg LOAD_2_4_PF 2.4pF additional PA load capacitor
MACRUM 0:615f90842ce8 1560 * @arg LOAD_3_6_PF 3.6pF additional PA load capacitor
MACRUM 0:615f90842ce8 1561 * @param pfPAtabledBm pointer to an array of PA values in dbm between [-PA_LOWER_LIMIT: PA_UPPER_LIMIT] dbm.
MACRUM 0:615f90842ce8 1562 * The first element shall be the lower level (PA_LEVEL[0]) value and the last element
MACRUM 0:615f90842ce8 1563 * the higher level one (PA_LEVEL[paLevelMaxIndex]).
MACRUM 0:615f90842ce8 1564 * @retval None.
MACRUM 0:615f90842ce8 1565 */
MACRUM 0:615f90842ce8 1566 void SpiritRadioSetPATabledBm(uint8_t cPALevelMaxIndex, uint8_t cWidth, PALoadCapacitor xCLoad, float* pfPAtabledBm)
MACRUM 0:615f90842ce8 1567 {
MACRUM 0:615f90842ce8 1568 uint8_t palevel[9], address, paLevelValue;
MACRUM 0:615f90842ce8 1569 uint32_t lFBase=SpiritRadioGetFrequencyBase();
MACRUM 0:615f90842ce8 1570
MACRUM 0:615f90842ce8 1571 /* Check the parameters */
MACRUM 0:615f90842ce8 1572 s_assert_param(IS_PA_MAX_INDEX(cPALevelMaxIndex));
MACRUM 0:615f90842ce8 1573 s_assert_param(IS_PA_STEP_WIDTH(cWidth));
MACRUM 0:615f90842ce8 1574 s_assert_param(IS_PA_LOAD_CAP(xCLoad));
MACRUM 0:615f90842ce8 1575
MACRUM 0:615f90842ce8 1576 /* Check the PA level in dBm is in the range and calculate the PA_LEVEL value
MACRUM 0:615f90842ce8 1577 to write in the corresponding register using the linearization formula */
MACRUM 0:615f90842ce8 1578 for(int i=0; i<=cPALevelMaxIndex; i++)
MACRUM 0:615f90842ce8 1579 {
MACRUM 0:615f90842ce8 1580 s_assert_param(IS_PAPOWER_DBM(*pfPAtabledBm));
MACRUM 0:615f90842ce8 1581 paLevelValue=SpiritRadioGetdBm2Reg(lFBase,(*pfPAtabledBm));
MACRUM 0:615f90842ce8 1582 palevel[cPALevelMaxIndex-i]=paLevelValue;
MACRUM 0:615f90842ce8 1583 pfPAtabledBm++;
MACRUM 0:615f90842ce8 1584 }
MACRUM 0:615f90842ce8 1585
MACRUM 0:615f90842ce8 1586 /* Sets the PA_POWER[0] register */
MACRUM 0:615f90842ce8 1587 palevel[cPALevelMaxIndex+1]=xCLoad|(cWidth-1)<<3|cPALevelMaxIndex;
MACRUM 0:615f90842ce8 1588
MACRUM 0:615f90842ce8 1589 /* Sets the base address */
MACRUM 0:615f90842ce8 1590 address=PA_POWER8_BASE+7-cPALevelMaxIndex;
MACRUM 0:615f90842ce8 1591
MACRUM 0:615f90842ce8 1592 /* Configures the PA_POWER registers */
MACRUM 0:615f90842ce8 1593 g_xStatus = SpiritSpiWriteRegisters(address, cPALevelMaxIndex+2, palevel);
MACRUM 0:615f90842ce8 1594
MACRUM 0:615f90842ce8 1595 }
MACRUM 0:615f90842ce8 1596
MACRUM 0:615f90842ce8 1597
MACRUM 0:615f90842ce8 1598 /**
MACRUM 0:615f90842ce8 1599 * @brief Returns the Power Amplifier Table and registers, returning values in dBm.
MACRUM 0:615f90842ce8 1600 * @param pcPALevelMaxIndex pointer to the number of levels settled.
MACRUM 0:615f90842ce8 1601 * This parameter will be in the range [0:7].
MACRUM 0:615f90842ce8 1602 * @param pfPAtabledBm pointer to an array of 8 elements containing the PA value in dbm.
MACRUM 0:615f90842ce8 1603 * The first element will be the PA_LEVEL_0 and the last element
MACRUM 0:615f90842ce8 1604 * will be PA_LEVEL_7. Any value higher than PA_UPPER_LIMIT implies no output
MACRUM 0:615f90842ce8 1605 * power (output stage is in high impedance).
MACRUM 0:615f90842ce8 1606 * @retval None.
MACRUM 0:615f90842ce8 1607 */
MACRUM 0:615f90842ce8 1608 void SpiritRadioGetPATabledBm(uint8_t* pcPALevelMaxIndex, float* pfPAtabledBm)
MACRUM 0:615f90842ce8 1609 {
MACRUM 0:615f90842ce8 1610 uint8_t palevelvect[9];
MACRUM 0:615f90842ce8 1611 uint32_t lFBase=SpiritRadioGetFrequencyBase();
MACRUM 0:615f90842ce8 1612
MACRUM 0:615f90842ce8 1613 /* Reads the PA_LEVEL_x registers and the PA_POWER_0 register */
MACRUM 0:615f90842ce8 1614 g_xStatus = SpiritSpiReadRegisters(PA_POWER8_BASE, 9, palevelvect);
MACRUM 0:615f90842ce8 1615
MACRUM 0:615f90842ce8 1616 /* Fill the PAtable */
MACRUM 0:615f90842ce8 1617 for(int i=7; i>=0; i--)
MACRUM 0:615f90842ce8 1618 {
MACRUM 0:615f90842ce8 1619 (*pfPAtabledBm)=SpiritRadioGetReg2dBm(lFBase,palevelvect[i]);
MACRUM 0:615f90842ce8 1620 pfPAtabledBm++;
MACRUM 0:615f90842ce8 1621 }
MACRUM 0:615f90842ce8 1622
MACRUM 0:615f90842ce8 1623 /* Return the settled index */
MACRUM 0:615f90842ce8 1624 *pcPALevelMaxIndex = palevelvect[8]&0x07;
MACRUM 0:615f90842ce8 1625
MACRUM 0:615f90842ce8 1626 }
MACRUM 0:615f90842ce8 1627
MACRUM 0:615f90842ce8 1628
MACRUM 0:615f90842ce8 1629
MACRUM 0:615f90842ce8 1630
MACRUM 0:615f90842ce8 1631
MACRUM 0:615f90842ce8 1632
MACRUM 0:615f90842ce8 1633 /**
MACRUM 0:615f90842ce8 1634 * @brief Sets a specific PA_LEVEL register, with a value given in dBm.
MACRUM 0:615f90842ce8 1635 * @param cIndex PA_LEVEL to set. This parameter shall be in the range [0:7].
MACRUM 0:615f90842ce8 1636 * @param fPowerdBm PA value to write expressed in dBm . Be sure that this values is in the
MACRUM 0:615f90842ce8 1637 * correct range [-PA_LOWER_LIMIT: PA_UPPER_LIMIT] dBm.
MACRUM 0:615f90842ce8 1638 * @retval None.
MACRUM 0:615f90842ce8 1639 * @note This function makes use of the @ref SpiritRadioGetdBm2Reg fcn to interpolate the
MACRUM 0:615f90842ce8 1640 * power value.
MACRUM 0:615f90842ce8 1641 */
MACRUM 0:615f90842ce8 1642 void SpiritRadioSetPALeveldBm(uint8_t cIndex, float fPowerdBm)
MACRUM 0:615f90842ce8 1643 {
MACRUM 0:615f90842ce8 1644 uint8_t address, paLevelValue;
MACRUM 0:615f90842ce8 1645
MACRUM 0:615f90842ce8 1646 /* Check the parameters */
MACRUM 0:615f90842ce8 1647 s_assert_param(IS_PA_MAX_INDEX(cIndex));
MACRUM 0:615f90842ce8 1648 s_assert_param(IS_PAPOWER_DBM(fPowerdBm));
MACRUM 0:615f90842ce8 1649
MACRUM 0:615f90842ce8 1650 /* interpolate the power level */
MACRUM 0:615f90842ce8 1651 paLevelValue=SpiritRadioGetdBm2Reg(SpiritRadioGetFrequencyBase(),fPowerdBm);
MACRUM 0:615f90842ce8 1652
MACRUM 0:615f90842ce8 1653 /* Sets the base address */
MACRUM 0:615f90842ce8 1654 address=PA_POWER8_BASE+7-cIndex;
MACRUM 0:615f90842ce8 1655
MACRUM 0:615f90842ce8 1656 /* Configures the PA_LEVEL register */
MACRUM 0:615f90842ce8 1657 g_xStatus = SpiritSpiWriteRegisters(address, 1, &paLevelValue);
MACRUM 0:615f90842ce8 1658
MACRUM 0:615f90842ce8 1659 }
MACRUM 0:615f90842ce8 1660
MACRUM 0:615f90842ce8 1661
MACRUM 0:615f90842ce8 1662 /**
MACRUM 0:615f90842ce8 1663 * @brief Returns a specific PA_LEVEL register, returning a value in dBm.
MACRUM 0:615f90842ce8 1664 * @param cIndex PA_LEVEL to read. This parameter shall be in the range [0:7]
MACRUM 0:615f90842ce8 1665 * @retval float Settled power level expressed in dBm. A value
MACRUM 0:615f90842ce8 1666 * higher than PA_UPPER_LIMIT dBm implies no output power
MACRUM 0:615f90842ce8 1667 * (output stage is in high impedance).
MACRUM 0:615f90842ce8 1668 * @note This function makes use of the @ref SpiritRadioGetReg2dBm fcn to interpolate the
MACRUM 0:615f90842ce8 1669 * power value.
MACRUM 0:615f90842ce8 1670 */
MACRUM 0:615f90842ce8 1671 float SpiritRadioGetPALeveldBm(uint8_t cIndex)
MACRUM 0:615f90842ce8 1672 {
MACRUM 0:615f90842ce8 1673 uint8_t address, paLevelValue;
MACRUM 0:615f90842ce8 1674
MACRUM 0:615f90842ce8 1675 /* Check the parameters */
MACRUM 0:615f90842ce8 1676 s_assert_param(IS_PA_MAX_INDEX(cIndex));
MACRUM 0:615f90842ce8 1677
MACRUM 0:615f90842ce8 1678 /* Sets the base address */
MACRUM 0:615f90842ce8 1679 address=PA_POWER8_BASE+7-cIndex;
MACRUM 0:615f90842ce8 1680
MACRUM 0:615f90842ce8 1681 /* Reads the PA_LEVEL[cIndex] register */
MACRUM 0:615f90842ce8 1682 g_xStatus = SpiritSpiReadRegisters(address, 1, &paLevelValue);
MACRUM 0:615f90842ce8 1683
MACRUM 0:615f90842ce8 1684 return SpiritRadioGetReg2dBm(SpiritRadioGetFrequencyBase(),paLevelValue);
MACRUM 0:615f90842ce8 1685 }
MACRUM 0:615f90842ce8 1686
MACRUM 0:615f90842ce8 1687
MACRUM 0:615f90842ce8 1688 /**
MACRUM 0:615f90842ce8 1689 * @brief Configures the Power Amplifier Table and registers.
MACRUM 0:615f90842ce8 1690 * @param cPALevelMaxIndex number of levels to set. This parameter shall be in the range [0:7].
MACRUM 0:615f90842ce8 1691 * @param cWidth step width expressed in terms of bit period units Tb/8.
MACRUM 0:615f90842ce8 1692 * This parameter shall be in the range [1:4].
MACRUM 0:615f90842ce8 1693 * @param xCLoad one of the possible value of the enum type PALoadCapacitor.
MACRUM 0:615f90842ce8 1694 * @arg LOAD_0_PF No additional PA load capacitor
MACRUM 0:615f90842ce8 1695 * @arg LOAD_1_2_PF 1.2pF additional PA load capacitor
MACRUM 0:615f90842ce8 1696 * @arg LOAD_2_4_PF 2.4pF additional PA load capacitor
MACRUM 0:615f90842ce8 1697 * @arg LOAD_3_6_PF 3.6pF additional PA load capacitor
MACRUM 0:615f90842ce8 1698 * @param pcPAtable pointer to an array of PA values in the range [0: 90], where 0 implies no
MACRUM 0:615f90842ce8 1699 * output power, 1 will be the maximum level and 90 the minimum one
MACRUM 0:615f90842ce8 1700 * The first element shall be the lower level (PA_LEVEL[0]) value and the last element
MACRUM 0:615f90842ce8 1701 * the higher level one (PA_LEVEL[paLevelMaxIndex]).
MACRUM 0:615f90842ce8 1702 * @retval None.
MACRUM 0:615f90842ce8 1703 */
MACRUM 0:615f90842ce8 1704 void SpiritRadioSetPATable(uint8_t cPALevelMaxIndex, uint8_t cWidth, PALoadCapacitor xCLoad, uint8_t* pcPAtable)
MACRUM 0:615f90842ce8 1705 {
MACRUM 0:615f90842ce8 1706 uint8_t palevel[9], address;
MACRUM 0:615f90842ce8 1707
MACRUM 0:615f90842ce8 1708 /* Check the parameters */
MACRUM 0:615f90842ce8 1709 s_assert_param(IS_PA_MAX_INDEX(cPALevelMaxIndex));
MACRUM 0:615f90842ce8 1710 s_assert_param(IS_PA_STEP_WIDTH(cWidth));
MACRUM 0:615f90842ce8 1711 s_assert_param(IS_PA_LOAD_CAP(xCLoad));
MACRUM 0:615f90842ce8 1712
MACRUM 0:615f90842ce8 1713 /* Check the PA levels are in the range */
MACRUM 0:615f90842ce8 1714 for(int i=0; i<=cPALevelMaxIndex; i++)
MACRUM 0:615f90842ce8 1715 {
MACRUM 0:615f90842ce8 1716 s_assert_param(IS_PAPOWER(*pcPAtable));
MACRUM 0:615f90842ce8 1717 palevel[cPALevelMaxIndex-i]=*pcPAtable;
MACRUM 0:615f90842ce8 1718 pcPAtable++;
MACRUM 0:615f90842ce8 1719 }
MACRUM 0:615f90842ce8 1720
MACRUM 0:615f90842ce8 1721 /* Sets the PA_POWER[0] register */
MACRUM 0:615f90842ce8 1722 palevel[cPALevelMaxIndex+1]=xCLoad|((cWidth-1)<<3)|cPALevelMaxIndex;
MACRUM 0:615f90842ce8 1723
MACRUM 0:615f90842ce8 1724 /* Sets the base address */
MACRUM 0:615f90842ce8 1725 address=PA_POWER8_BASE+7-cPALevelMaxIndex;
MACRUM 0:615f90842ce8 1726
MACRUM 0:615f90842ce8 1727 /* Configures the PA_POWER registers */
MACRUM 0:615f90842ce8 1728 g_xStatus = SpiritSpiWriteRegisters(address, cPALevelMaxIndex+2, palevel);
MACRUM 0:615f90842ce8 1729
MACRUM 0:615f90842ce8 1730 }
MACRUM 0:615f90842ce8 1731
MACRUM 0:615f90842ce8 1732
MACRUM 0:615f90842ce8 1733 /**
MACRUM 0:615f90842ce8 1734 * @brief Returns the Power Amplifier Table and registers.
MACRUM 0:615f90842ce8 1735 * @param pcPALevelMaxIndex pointer to the number of levels settled.
MACRUM 0:615f90842ce8 1736 * This parameter shall be in the range [0:7].
MACRUM 0:615f90842ce8 1737 * @param pcPAtable pointer to an array of 8 elements containing the PA value.
MACRUM 0:615f90842ce8 1738 * The first element will be the PA_LEVEL_0 and the last element
MACRUM 0:615f90842ce8 1739 * will be PA_LEVEL_7. Any value equals to 0 implies that level has
MACRUM 0:615f90842ce8 1740 * no output power (output stage is in high impedance).
MACRUM 0:615f90842ce8 1741 * @retval None
MACRUM 0:615f90842ce8 1742 */
MACRUM 0:615f90842ce8 1743 void SpiritRadioGetPATable(uint8_t* pcPALevelMaxIndex, uint8_t* pcPAtable)
MACRUM 0:615f90842ce8 1744 {
MACRUM 0:615f90842ce8 1745 uint8_t palevelvect[9];
MACRUM 0:615f90842ce8 1746
MACRUM 0:615f90842ce8 1747 /* Reads the PA_LEVEL_x registers and the PA_POWER_0 register */
MACRUM 0:615f90842ce8 1748 g_xStatus = SpiritSpiReadRegisters(PA_POWER8_BASE, 9, palevelvect);
MACRUM 0:615f90842ce8 1749
MACRUM 0:615f90842ce8 1750 /* Fill the PAtable */
MACRUM 0:615f90842ce8 1751 for(int i=7; i>=0; i--)
MACRUM 0:615f90842ce8 1752 {
MACRUM 0:615f90842ce8 1753 *pcPAtable = palevelvect[i];
MACRUM 0:615f90842ce8 1754 pcPAtable++;
MACRUM 0:615f90842ce8 1755 }
MACRUM 0:615f90842ce8 1756
MACRUM 0:615f90842ce8 1757 /* Return the settled index */
MACRUM 0:615f90842ce8 1758 *pcPALevelMaxIndex = palevelvect[8]&0x07;
MACRUM 0:615f90842ce8 1759
MACRUM 0:615f90842ce8 1760 }
MACRUM 0:615f90842ce8 1761
MACRUM 0:615f90842ce8 1762
MACRUM 0:615f90842ce8 1763 /**
MACRUM 0:615f90842ce8 1764 * @brief Sets a specific PA_LEVEL register.
MACRUM 0:615f90842ce8 1765 * @param cIndex PA_LEVEL to set. This parameter shall be in the range [0:7].
MACRUM 0:615f90842ce8 1766 * @param cPower PA value to write in the register. Be sure that this values is in the
MACRUM 0:615f90842ce8 1767 * correct range [0 : 90].
MACRUM 0:615f90842ce8 1768 * @retval None.
MACRUM 0:615f90842ce8 1769 */
MACRUM 0:615f90842ce8 1770 void SpiritRadioSetPALevel(uint8_t cIndex, uint8_t cPower)
MACRUM 0:615f90842ce8 1771 {
MACRUM 0:615f90842ce8 1772 uint8_t address;
MACRUM 0:615f90842ce8 1773
MACRUM 0:615f90842ce8 1774 /* Check the parameters */
MACRUM 0:615f90842ce8 1775 s_assert_param(IS_PA_MAX_INDEX(cIndex));
MACRUM 0:615f90842ce8 1776 s_assert_param(IS_PAPOWER(cPower));
MACRUM 0:615f90842ce8 1777
MACRUM 0:615f90842ce8 1778 /* Sets the base address */
MACRUM 0:615f90842ce8 1779 address=PA_POWER8_BASE+7-cIndex;
MACRUM 0:615f90842ce8 1780
MACRUM 0:615f90842ce8 1781 /* Configures the PA_LEVEL register */
MACRUM 0:615f90842ce8 1782 g_xStatus = SpiritSpiWriteRegisters(address, 1, &cPower);
MACRUM 0:615f90842ce8 1783
MACRUM 0:615f90842ce8 1784 }
MACRUM 0:615f90842ce8 1785
MACRUM 0:615f90842ce8 1786
MACRUM 0:615f90842ce8 1787 /**
MACRUM 0:615f90842ce8 1788 * @brief Returns a specific PA_LEVEL register.
MACRUM 0:615f90842ce8 1789 * @param cIndex PA_LEVEL to read. This parameter shall be in the range [0:7].
MACRUM 0:615f90842ce8 1790 * @retval uint8_t PA_LEVEL value. A value equal to zero
MACRUM 0:615f90842ce8 1791 * implies no output power (output stage is in high impedance).
MACRUM 0:615f90842ce8 1792 */
MACRUM 0:615f90842ce8 1793 uint8_t SpiritRadioGetPALevel(uint8_t cIndex)
MACRUM 0:615f90842ce8 1794 {
MACRUM 0:615f90842ce8 1795 uint8_t address, tempRegValue;
MACRUM 0:615f90842ce8 1796
MACRUM 0:615f90842ce8 1797 /* Check the parameters */
MACRUM 0:615f90842ce8 1798 s_assert_param(IS_PA_MAX_INDEX(cIndex));
MACRUM 0:615f90842ce8 1799
MACRUM 0:615f90842ce8 1800 /* Sets the base address */
MACRUM 0:615f90842ce8 1801 address=PA_POWER8_BASE+7-cIndex;
MACRUM 0:615f90842ce8 1802
MACRUM 0:615f90842ce8 1803 /* Reads the PA_LEVEL[cIndex] register and return the value */
MACRUM 0:615f90842ce8 1804 g_xStatus = SpiritSpiReadRegisters(address, 1, &tempRegValue);
MACRUM 0:615f90842ce8 1805 return tempRegValue;
MACRUM 0:615f90842ce8 1806
MACRUM 0:615f90842ce8 1807 }
MACRUM 0:615f90842ce8 1808
MACRUM 0:615f90842ce8 1809
MACRUM 0:615f90842ce8 1810 /**
MACRUM 0:615f90842ce8 1811 * @brief Sets the output stage additional load capacitor bank.
MACRUM 0:615f90842ce8 1812 * @param xCLoad one of the possible value of the enum type PALoadCapacitor.
MACRUM 0:615f90842ce8 1813 * @arg LOAD_0_PF No additional PA load capacitor
MACRUM 0:615f90842ce8 1814 * @arg LOAD_1_2_PF 1.2pF additional PA load capacitor
MACRUM 0:615f90842ce8 1815 * @arg LOAD_2_4_PF 2.4pF additional PA load capacitor
MACRUM 0:615f90842ce8 1816 * @arg LOAD_3_6_PF 3.6pF additional PA load capacitor
MACRUM 0:615f90842ce8 1817 * @retval None.
MACRUM 0:615f90842ce8 1818 */
MACRUM 0:615f90842ce8 1819 void SpiritRadioSetPACwc(PALoadCapacitor xCLoad)
MACRUM 0:615f90842ce8 1820 {
MACRUM 0:615f90842ce8 1821 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 1822
MACRUM 0:615f90842ce8 1823 /* Check the parameters */
MACRUM 0:615f90842ce8 1824 s_assert_param(IS_PA_LOAD_CAP(xCLoad));
MACRUM 0:615f90842ce8 1825
MACRUM 0:615f90842ce8 1826 /* Reads the PA_POWER_0 register */
MACRUM 0:615f90842ce8 1827 SpiritSpiReadRegisters(PA_POWER0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 1828
MACRUM 0:615f90842ce8 1829 /* Mask the CWC[1:0] field and write the new value */
MACRUM 0:615f90842ce8 1830 tempRegValue &= 0x3F;
MACRUM 0:615f90842ce8 1831 tempRegValue |= xCLoad;
MACRUM 0:615f90842ce8 1832
MACRUM 0:615f90842ce8 1833 /* Configures the PA_POWER_0 register */
MACRUM 0:615f90842ce8 1834 g_xStatus = SpiritSpiWriteRegisters(PA_POWER0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 1835
MACRUM 0:615f90842ce8 1836 }
MACRUM 0:615f90842ce8 1837
MACRUM 0:615f90842ce8 1838
MACRUM 0:615f90842ce8 1839 /**
MACRUM 0:615f90842ce8 1840 * @brief Returns the output stage additional load capacitor bank.
MACRUM 0:615f90842ce8 1841 * @param None.
MACRUM 0:615f90842ce8 1842 * @retval PALoadCapacitor Output stage additional load capacitor bank.
MACRUM 0:615f90842ce8 1843 * This parameter can be:
MACRUM 0:615f90842ce8 1844 * @arg LOAD_0_PF No additional PA load capacitor
MACRUM 0:615f90842ce8 1845 * @arg LOAD_1_2_PF 1.2pF additional PA load capacitor
MACRUM 0:615f90842ce8 1846 * @arg LOAD_2_4_PF 2.4pF additional PA load capacitor
MACRUM 0:615f90842ce8 1847 * @arg LOAD_3_6_PF 3.6pF additional PA load capacitor
MACRUM 0:615f90842ce8 1848 */
MACRUM 0:615f90842ce8 1849 PALoadCapacitor SpiritRadioGetPACwc(void)
MACRUM 0:615f90842ce8 1850 {
MACRUM 0:615f90842ce8 1851 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 1852
MACRUM 0:615f90842ce8 1853 /* Reads the PA_POWER_0 register */
MACRUM 0:615f90842ce8 1854 g_xStatus = SpiritSpiReadRegisters(PA_POWER0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 1855
MACRUM 0:615f90842ce8 1856 /* Mask the CWC[1:0] field and return the value*/
MACRUM 0:615f90842ce8 1857 return (PALoadCapacitor)(tempRegValue & 0xC0);
MACRUM 0:615f90842ce8 1858
MACRUM 0:615f90842ce8 1859 }
MACRUM 0:615f90842ce8 1860
MACRUM 0:615f90842ce8 1861
MACRUM 0:615f90842ce8 1862 /**
MACRUM 0:615f90842ce8 1863 * @brief Sets a specific PA_LEVEL_MAX_INDEX.
MACRUM 0:615f90842ce8 1864 * @param cIndex PA_LEVEL_MAX_INDEX to set. This parameter shall be in the range [0:7].
MACRUM 0:615f90842ce8 1865 * @retval None
MACRUM 0:615f90842ce8 1866 */
MACRUM 0:615f90842ce8 1867 void SpiritRadioSetPALevelMaxIndex(uint8_t cIndex)
MACRUM 0:615f90842ce8 1868 {
MACRUM 0:615f90842ce8 1869 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 1870
MACRUM 0:615f90842ce8 1871 /* Check the parameters */
MACRUM 0:615f90842ce8 1872 s_assert_param(IS_PA_MAX_INDEX(cIndex));
MACRUM 0:615f90842ce8 1873
MACRUM 0:615f90842ce8 1874 /* Reads the PA_POWER_0 register */
MACRUM 0:615f90842ce8 1875 SpiritSpiReadRegisters(PA_POWER0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 1876
MACRUM 0:615f90842ce8 1877 /* Mask the PA_LEVEL_MAX_INDEX[1:0] field and write the new value */
MACRUM 0:615f90842ce8 1878 tempRegValue &= 0xF8;
MACRUM 0:615f90842ce8 1879 tempRegValue |= cIndex;
MACRUM 0:615f90842ce8 1880
MACRUM 0:615f90842ce8 1881 /* Configures the PA_POWER_0 register */
MACRUM 0:615f90842ce8 1882 g_xStatus = SpiritSpiWriteRegisters(PA_POWER0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 1883
MACRUM 0:615f90842ce8 1884 }
MACRUM 0:615f90842ce8 1885
MACRUM 0:615f90842ce8 1886
MACRUM 0:615f90842ce8 1887 /**
MACRUM 0:615f90842ce8 1888 * @brief Returns the actual PA_LEVEL_MAX_INDEX.
MACRUM 0:615f90842ce8 1889 * @param None.
MACRUM 0:615f90842ce8 1890 * @retval uint8_t Actual PA_LEVEL_MAX_INDEX. This parameter will be in the range [0:7].
MACRUM 0:615f90842ce8 1891 */
MACRUM 0:615f90842ce8 1892 uint8_t SpiritRadioGetPALevelMaxIndex(void)
MACRUM 0:615f90842ce8 1893 {
MACRUM 0:615f90842ce8 1894 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 1895
MACRUM 0:615f90842ce8 1896 /* Reads the PA_POWER_0 register */
MACRUM 0:615f90842ce8 1897 g_xStatus = SpiritSpiReadRegisters(PA_POWER0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 1898
MACRUM 0:615f90842ce8 1899 /* Mask the PA_LEVEL_MAX_INDEX[1:0] field and return the value */
MACRUM 0:615f90842ce8 1900 return (tempRegValue & 0x07);
MACRUM 0:615f90842ce8 1901
MACRUM 0:615f90842ce8 1902 }
MACRUM 0:615f90842ce8 1903
MACRUM 0:615f90842ce8 1904
MACRUM 0:615f90842ce8 1905 /**
MACRUM 0:615f90842ce8 1906 * @brief Sets a specific PA_RAMP_STEP_WIDTH.
MACRUM 0:615f90842ce8 1907 * @param cWidth step width expressed in terms of bit period units Tb/8.
MACRUM 0:615f90842ce8 1908 * This parameter shall be in the range [1:4].
MACRUM 0:615f90842ce8 1909 * @retval None.
MACRUM 0:615f90842ce8 1910 */
MACRUM 0:615f90842ce8 1911 void SpiritRadioSetPAStepWidth(uint8_t cWidth)
MACRUM 0:615f90842ce8 1912 {
MACRUM 0:615f90842ce8 1913 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 1914
MACRUM 0:615f90842ce8 1915 /* Check the parameters */
MACRUM 0:615f90842ce8 1916 s_assert_param(IS_PA_STEP_WIDTH(cWidth));
MACRUM 0:615f90842ce8 1917
MACRUM 0:615f90842ce8 1918 /* Reads the PA_POWER_0 register */
MACRUM 0:615f90842ce8 1919 SpiritSpiReadRegisters(PA_POWER0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 1920
MACRUM 0:615f90842ce8 1921 /* Mask the PA_RAMP_STEP_WIDTH[1:0] field and write the new value */
MACRUM 0:615f90842ce8 1922 tempRegValue &= 0xE7;
MACRUM 0:615f90842ce8 1923 tempRegValue |= (cWidth-1)<<3;
MACRUM 0:615f90842ce8 1924
MACRUM 0:615f90842ce8 1925 /* Configures the PA_POWER_0 register */
MACRUM 0:615f90842ce8 1926 g_xStatus = SpiritSpiWriteRegisters(PA_POWER0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 1927
MACRUM 0:615f90842ce8 1928 }
MACRUM 0:615f90842ce8 1929
MACRUM 0:615f90842ce8 1930
MACRUM 0:615f90842ce8 1931 /**
MACRUM 0:615f90842ce8 1932 * @brief Returns the actual PA_RAMP_STEP_WIDTH.
MACRUM 0:615f90842ce8 1933 * @param None.
MACRUM 0:615f90842ce8 1934 * @retval uint8_t Step width value expressed in terms of bit period units Tb/8.
MACRUM 0:615f90842ce8 1935 * This parameter will be in the range [1:4].
MACRUM 0:615f90842ce8 1936 */
MACRUM 0:615f90842ce8 1937 uint8_t SpiritRadioGetPAStepWidth(void)
MACRUM 0:615f90842ce8 1938 {
MACRUM 0:615f90842ce8 1939 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 1940
MACRUM 0:615f90842ce8 1941 /* Reads the PA_POWER_0 register */
MACRUM 0:615f90842ce8 1942 g_xStatus = SpiritSpiReadRegisters(PA_POWER0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 1943
MACRUM 0:615f90842ce8 1944 /* Mask the PA_RAMP_STEP_WIDTH[1:0] field and return the value */
MACRUM 0:615f90842ce8 1945 tempRegValue &= 0x18;
MACRUM 0:615f90842ce8 1946 return ((tempRegValue>>3)+1);
MACRUM 0:615f90842ce8 1947
MACRUM 0:615f90842ce8 1948 }
MACRUM 0:615f90842ce8 1949
MACRUM 0:615f90842ce8 1950
MACRUM 0:615f90842ce8 1951 /**
MACRUM 0:615f90842ce8 1952 * @brief Enables or Disables the Power Ramping.
MACRUM 0:615f90842ce8 1953 * @param xNewState new state for power ramping.
MACRUM 0:615f90842ce8 1954 * This parameter can be: S_ENABLE or S_DISABLE.
MACRUM 0:615f90842ce8 1955 * @retval None.
MACRUM 0:615f90842ce8 1956 */
MACRUM 0:615f90842ce8 1957 void SpiritRadioPARamping(SpiritFunctionalState xNewState)
MACRUM 0:615f90842ce8 1958 {
MACRUM 0:615f90842ce8 1959 uint8_t tempRegValue = 0x00;
MACRUM 0:615f90842ce8 1960
MACRUM 0:615f90842ce8 1961 /* Check the parameters */
MACRUM 0:615f90842ce8 1962 s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(xNewState));
MACRUM 0:615f90842ce8 1963
MACRUM 0:615f90842ce8 1964 /* Reads the PA_POWER_0 register and configure the PA_RAMP_ENABLE field */
MACRUM 0:615f90842ce8 1965 SpiritSpiReadRegisters(PA_POWER0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 1966 if(xNewState == S_ENABLE)
MACRUM 0:615f90842ce8 1967 {
MACRUM 0:615f90842ce8 1968 tempRegValue |= PA_POWER0_PA_RAMP_MASK;
MACRUM 0:615f90842ce8 1969 }
MACRUM 0:615f90842ce8 1970 else
MACRUM 0:615f90842ce8 1971 {
MACRUM 0:615f90842ce8 1972 tempRegValue &= (~PA_POWER0_PA_RAMP_MASK);
MACRUM 0:615f90842ce8 1973 }
MACRUM 0:615f90842ce8 1974
MACRUM 0:615f90842ce8 1975 /* Sets the PA_POWER_0 register */
MACRUM 0:615f90842ce8 1976 g_xStatus = SpiritSpiWriteRegisters(PA_POWER0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 1977
MACRUM 0:615f90842ce8 1978 }
MACRUM 0:615f90842ce8 1979
MACRUM 0:615f90842ce8 1980 /**
MACRUM 0:615f90842ce8 1981 * @brief Returns the Power Ramping enable bit.
MACRUM 0:615f90842ce8 1982 * @param xNewState new state for power ramping.
MACRUM 0:615f90842ce8 1983 * This parameter can be: S_ENABLE or S_DISABLE.
MACRUM 0:615f90842ce8 1984 * @retval None.
MACRUM 0:615f90842ce8 1985 */
MACRUM 0:615f90842ce8 1986 SpiritFunctionalState SpiritRadioGetPARamping(void)
MACRUM 0:615f90842ce8 1987 {
MACRUM 0:615f90842ce8 1988 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 1989
MACRUM 0:615f90842ce8 1990 /* Reads the PA_POWER_0 register and configure the PA_RAMP_ENABLE field */
MACRUM 0:615f90842ce8 1991 g_xStatus = SpiritSpiReadRegisters(PA_POWER0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 1992
MACRUM 0:615f90842ce8 1993 /* Mask and return data */
MACRUM 0:615f90842ce8 1994 return (SpiritFunctionalState)((tempRegValue>>5) & 0x01);
MACRUM 0:615f90842ce8 1995
MACRUM 0:615f90842ce8 1996 }
MACRUM 0:615f90842ce8 1997
MACRUM 0:615f90842ce8 1998
MACRUM 0:615f90842ce8 1999 /**
MACRUM 0:615f90842ce8 2000 * @brief Enables or Disables the AFC.
MACRUM 0:615f90842ce8 2001 * @param xNewState new state for AFC.
MACRUM 0:615f90842ce8 2002 * This parameter can be: S_ENABLE or S_DISABLE.
MACRUM 0:615f90842ce8 2003 * @retval None.
MACRUM 0:615f90842ce8 2004 */
MACRUM 0:615f90842ce8 2005 void SpiritRadioAFC(SpiritFunctionalState xNewState)
MACRUM 0:615f90842ce8 2006 {
MACRUM 0:615f90842ce8 2007 uint8_t tempRegValue = 0x00;
MACRUM 0:615f90842ce8 2008
MACRUM 0:615f90842ce8 2009 /* Check the parameters */
MACRUM 0:615f90842ce8 2010 s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(xNewState));
MACRUM 0:615f90842ce8 2011
MACRUM 0:615f90842ce8 2012 /* Reads the AFC_2 register and configure the AFC Enabled field */
MACRUM 0:615f90842ce8 2013 SpiritSpiReadRegisters(AFC2_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2014 if(xNewState == S_ENABLE)
MACRUM 0:615f90842ce8 2015 {
MACRUM 0:615f90842ce8 2016 tempRegValue |= AFC2_AFC_MASK;
MACRUM 0:615f90842ce8 2017 }
MACRUM 0:615f90842ce8 2018 else
MACRUM 0:615f90842ce8 2019 {
MACRUM 0:615f90842ce8 2020 tempRegValue &= (~AFC2_AFC_MASK);
MACRUM 0:615f90842ce8 2021 }
MACRUM 0:615f90842ce8 2022
MACRUM 0:615f90842ce8 2023 /* Sets the AFC_2 register */
MACRUM 0:615f90842ce8 2024 g_xStatus = SpiritSpiWriteRegisters(AFC2_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2025
MACRUM 0:615f90842ce8 2026 }
MACRUM 0:615f90842ce8 2027
MACRUM 0:615f90842ce8 2028
MACRUM 0:615f90842ce8 2029 /**
MACRUM 0:615f90842ce8 2030 * @brief Enables or Disables the AFC freeze on sync word detection.
MACRUM 0:615f90842ce8 2031 * @param xNewState new state for AFC freeze on sync word detection.
MACRUM 0:615f90842ce8 2032 * This parameter can be: S_ENABLE or S_DISABLE.
MACRUM 0:615f90842ce8 2033 * @retval None.
MACRUM 0:615f90842ce8 2034 */
MACRUM 0:615f90842ce8 2035 void SpiritRadioAFCFreezeOnSync(SpiritFunctionalState xNewState)
MACRUM 0:615f90842ce8 2036 {
MACRUM 0:615f90842ce8 2037 uint8_t tempRegValue = 0x00;
MACRUM 0:615f90842ce8 2038
MACRUM 0:615f90842ce8 2039 /* Check the parameters */
MACRUM 0:615f90842ce8 2040 s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(xNewState));
MACRUM 0:615f90842ce8 2041
MACRUM 0:615f90842ce8 2042 /* Reads the AFC_2 register and configure the AFC Freeze on Sync field */
MACRUM 0:615f90842ce8 2043 SpiritSpiReadRegisters(AFC2_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2044 if(xNewState == S_ENABLE)
MACRUM 0:615f90842ce8 2045 {
MACRUM 0:615f90842ce8 2046 tempRegValue |= AFC2_AFC_FREEZE_ON_SYNC_MASK;
MACRUM 0:615f90842ce8 2047 }
MACRUM 0:615f90842ce8 2048 else
MACRUM 0:615f90842ce8 2049 {
MACRUM 0:615f90842ce8 2050 tempRegValue &= (~AFC2_AFC_FREEZE_ON_SYNC_MASK);
MACRUM 0:615f90842ce8 2051 }
MACRUM 0:615f90842ce8 2052
MACRUM 0:615f90842ce8 2053 /* Sets the AFC_2 register */
MACRUM 0:615f90842ce8 2054 g_xStatus = SpiritSpiWriteRegisters(AFC2_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2055
MACRUM 0:615f90842ce8 2056 }
MACRUM 0:615f90842ce8 2057
MACRUM 0:615f90842ce8 2058
MACRUM 0:615f90842ce8 2059 /**
MACRUM 0:615f90842ce8 2060 * @brief Sets the AFC working mode.
MACRUM 0:615f90842ce8 2061 * @param xMode the AFC mode. This parameter can be one of the values defined in @ref AFCMode :
MACRUM 0:615f90842ce8 2062 * @arg AFC_SLICER_CORRECTION AFC loop closed on slicer
MACRUM 0:615f90842ce8 2063 * @arg AFC_2ND_IF_CORRECTION AFC loop closed on 2nd conversion stage
MACRUM 0:615f90842ce8 2064 * @retval None.
MACRUM 0:615f90842ce8 2065 */
MACRUM 0:615f90842ce8 2066 void SpiritRadioSetAFCMode(AFCMode xMode)
MACRUM 0:615f90842ce8 2067 {
MACRUM 0:615f90842ce8 2068 uint8_t tempRegValue = 0x00;
MACRUM 0:615f90842ce8 2069
MACRUM 0:615f90842ce8 2070 /* Check the parameters */
MACRUM 0:615f90842ce8 2071 s_assert_param(IS_AFC_MODE(xMode));
MACRUM 0:615f90842ce8 2072
MACRUM 0:615f90842ce8 2073 /* Reads the AFC_2 register and configure the AFC Mode field */
MACRUM 0:615f90842ce8 2074 SpiritSpiReadRegisters(AFC2_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2075 if(xMode == AFC_2ND_IF_CORRECTION)
MACRUM 0:615f90842ce8 2076 {
MACRUM 0:615f90842ce8 2077 tempRegValue |= AFC_2ND_IF_CORRECTION;
MACRUM 0:615f90842ce8 2078 }
MACRUM 0:615f90842ce8 2079 else
MACRUM 0:615f90842ce8 2080 {
MACRUM 0:615f90842ce8 2081 tempRegValue &= (~AFC_2ND_IF_CORRECTION);
MACRUM 0:615f90842ce8 2082 }
MACRUM 0:615f90842ce8 2083
MACRUM 0:615f90842ce8 2084 /* Sets the AFC_2 register */
MACRUM 0:615f90842ce8 2085 g_xStatus = SpiritSpiWriteRegisters(AFC2_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2086
MACRUM 0:615f90842ce8 2087 }
MACRUM 0:615f90842ce8 2088
MACRUM 0:615f90842ce8 2089
MACRUM 0:615f90842ce8 2090 /**
MACRUM 0:615f90842ce8 2091 * @brief Returns the AFC working mode.
MACRUM 0:615f90842ce8 2092 * @param None.
MACRUM 0:615f90842ce8 2093 * @retval AFCMode Settled AFC mode. This parameter will be one of the values defined in @ref AFCMode :
MACRUM 0:615f90842ce8 2094 * @arg AFC_SLICER_CORRECTION AFC loop closed on slicer
MACRUM 0:615f90842ce8 2095 * @arg AFC_2ND_IF_CORRECTION AFC loop closed on 2nd conversion stage
MACRUM 0:615f90842ce8 2096 */
MACRUM 0:615f90842ce8 2097 AFCMode SpiritRadioGetAFCMode(void)
MACRUM 0:615f90842ce8 2098 {
MACRUM 0:615f90842ce8 2099 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 2100
MACRUM 0:615f90842ce8 2101 /* Reads the AFC_2 register */
MACRUM 0:615f90842ce8 2102 g_xStatus = SpiritSpiReadRegisters(AFC2_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2103
MACRUM 0:615f90842ce8 2104 /* Mask the AFC Mode field and returns the value */
MACRUM 0:615f90842ce8 2105 return (AFCMode)(tempRegValue & 0x20);
MACRUM 0:615f90842ce8 2106
MACRUM 0:615f90842ce8 2107 }
MACRUM 0:615f90842ce8 2108
MACRUM 0:615f90842ce8 2109
MACRUM 0:615f90842ce8 2110 /**
MACRUM 0:615f90842ce8 2111 * @brief Sets the AFC peak detector leakage.
MACRUM 0:615f90842ce8 2112 * @param cLeakage the peak detector leakage. This parameter shall be in the range:
MACRUM 0:615f90842ce8 2113 * [0:31].
MACRUM 0:615f90842ce8 2114 * @retval None.
MACRUM 0:615f90842ce8 2115 */
MACRUM 0:615f90842ce8 2116 void SpiritRadioSetAFCPDLeakage(uint8_t cLeakage)
MACRUM 0:615f90842ce8 2117 {
MACRUM 0:615f90842ce8 2118 uint8_t tempRegValue = 0x00;
MACRUM 0:615f90842ce8 2119
MACRUM 0:615f90842ce8 2120 /* Check the parameters */
MACRUM 0:615f90842ce8 2121 s_assert_param(IS_AFC_PD_LEAKAGE(cLeakage));
MACRUM 0:615f90842ce8 2122
MACRUM 0:615f90842ce8 2123 /* Reads the AFC_2 register and configure the AFC PD leakage field */
MACRUM 0:615f90842ce8 2124 SpiritSpiReadRegisters(AFC2_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2125 tempRegValue &= 0xE0;
MACRUM 0:615f90842ce8 2126 tempRegValue |= cLeakage;
MACRUM 0:615f90842ce8 2127
MACRUM 0:615f90842ce8 2128 /* Sets the AFC_2 register */
MACRUM 0:615f90842ce8 2129 g_xStatus = SpiritSpiWriteRegisters(AFC2_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2130
MACRUM 0:615f90842ce8 2131 }
MACRUM 0:615f90842ce8 2132
MACRUM 0:615f90842ce8 2133
MACRUM 0:615f90842ce8 2134 /**
MACRUM 0:615f90842ce8 2135 * @brief Returns the AFC peak detector leakage.
MACRUM 0:615f90842ce8 2136 * @param None.
MACRUM 0:615f90842ce8 2137 * @retval uint8_t Peak detector leakage value. This parameter will be in the range:
MACRUM 0:615f90842ce8 2138 * [0:31].
MACRUM 0:615f90842ce8 2139 */
MACRUM 0:615f90842ce8 2140 uint8_t SpiritRadioGetAFCPDLeakage(void)
MACRUM 0:615f90842ce8 2141 {
MACRUM 0:615f90842ce8 2142 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 2143
MACRUM 0:615f90842ce8 2144 /* Reads the AFC_2 register */
MACRUM 0:615f90842ce8 2145 g_xStatus = SpiritSpiReadRegisters(AFC2_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2146
MACRUM 0:615f90842ce8 2147 /* Mask the AFC PD leakage field and return the value */
MACRUM 0:615f90842ce8 2148 return (tempRegValue & 0x1F);
MACRUM 0:615f90842ce8 2149
MACRUM 0:615f90842ce8 2150 }
MACRUM 0:615f90842ce8 2151
MACRUM 0:615f90842ce8 2152
MACRUM 0:615f90842ce8 2153 /**
MACRUM 0:615f90842ce8 2154 * @brief Sets the length of the AFC fast period expressed as number of samples.
MACRUM 0:615f90842ce8 2155 * @param cLength length of the fast period in number of samples.
MACRUM 0:615f90842ce8 2156 * @retval None.
MACRUM 0:615f90842ce8 2157 */
MACRUM 0:615f90842ce8 2158 void SpiritRadioSetAFCFastPeriod(uint8_t cLength)
MACRUM 0:615f90842ce8 2159 {
MACRUM 0:615f90842ce8 2160 /* Sets the AFC_1 register */
MACRUM 0:615f90842ce8 2161 g_xStatus = SpiritSpiWriteRegisters(AFC1_BASE, 1, &cLength);
MACRUM 0:615f90842ce8 2162
MACRUM 0:615f90842ce8 2163 }
MACRUM 0:615f90842ce8 2164
MACRUM 0:615f90842ce8 2165
MACRUM 0:615f90842ce8 2166 /**
MACRUM 0:615f90842ce8 2167 * @brief Returns the AFC fast period expressed as number of samples.
MACRUM 0:615f90842ce8 2168 * @param None.
MACRUM 0:615f90842ce8 2169 * @retval uint8_t Length of the fast period in number of samples.
MACRUM 0:615f90842ce8 2170 */
MACRUM 0:615f90842ce8 2171 uint8_t SpiritRadioGetAFCFastPeriod(void)
MACRUM 0:615f90842ce8 2172 {
MACRUM 0:615f90842ce8 2173 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 2174
MACRUM 0:615f90842ce8 2175 /* Reads the AFC 1 register and return the value */
MACRUM 0:615f90842ce8 2176 g_xStatus = SpiritSpiReadRegisters(AFC1_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2177
MACRUM 0:615f90842ce8 2178 return tempRegValue;
MACRUM 0:615f90842ce8 2179
MACRUM 0:615f90842ce8 2180 }
MACRUM 0:615f90842ce8 2181
MACRUM 0:615f90842ce8 2182
MACRUM 0:615f90842ce8 2183 /**
MACRUM 0:615f90842ce8 2184 * @brief Sets the AFC loop gain in fast mode.
MACRUM 0:615f90842ce8 2185 * @param cGain AFC loop gain in fast mode. This parameter shall be in the range:
MACRUM 0:615f90842ce8 2186 * [0:15].
MACRUM 0:615f90842ce8 2187 * @retval None.
MACRUM 0:615f90842ce8 2188 */
MACRUM 0:615f90842ce8 2189 void SpiritRadioSetAFCFastGain(uint8_t cGain)
MACRUM 0:615f90842ce8 2190 {
MACRUM 0:615f90842ce8 2191 uint8_t tempRegValue = 0x00;
MACRUM 0:615f90842ce8 2192
MACRUM 0:615f90842ce8 2193 /* Check the parameters */
MACRUM 0:615f90842ce8 2194 s_assert_param(IS_AFC_FAST_GAIN(cGain));
MACRUM 0:615f90842ce8 2195
MACRUM 0:615f90842ce8 2196 /* Reads the AFC_0 register and configure the AFC Fast Gain field */
MACRUM 0:615f90842ce8 2197 SpiritSpiReadRegisters(AFC0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2198 tempRegValue &= 0x0F;
MACRUM 0:615f90842ce8 2199 tempRegValue |= cGain<<4;
MACRUM 0:615f90842ce8 2200
MACRUM 0:615f90842ce8 2201 /* Sets the AFC_0 register */
MACRUM 0:615f90842ce8 2202 g_xStatus = SpiritSpiWriteRegisters(AFC0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2203
MACRUM 0:615f90842ce8 2204 }
MACRUM 0:615f90842ce8 2205
MACRUM 0:615f90842ce8 2206
MACRUM 0:615f90842ce8 2207 /**
MACRUM 0:615f90842ce8 2208 * @brief Returns the AFC loop gain in fast mode.
MACRUM 0:615f90842ce8 2209 * @param None.
MACRUM 0:615f90842ce8 2210 * @retval uint8_t AFC loop gain in fast mode. This parameter will be in the range:
MACRUM 0:615f90842ce8 2211 * [0:15].
MACRUM 0:615f90842ce8 2212 */
MACRUM 0:615f90842ce8 2213 uint8_t SpiritRadioGetAFCFastGain(void)
MACRUM 0:615f90842ce8 2214 {
MACRUM 0:615f90842ce8 2215 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 2216
MACRUM 0:615f90842ce8 2217 /* Reads the AFC_0 register, mask the AFC Fast Gain field and return the value */
MACRUM 0:615f90842ce8 2218 g_xStatus = SpiritSpiReadRegisters(AFC0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2219
MACRUM 0:615f90842ce8 2220 return ((tempRegValue & 0xF0)>>4);
MACRUM 0:615f90842ce8 2221
MACRUM 0:615f90842ce8 2222 }
MACRUM 0:615f90842ce8 2223
MACRUM 0:615f90842ce8 2224
MACRUM 0:615f90842ce8 2225 /**
MACRUM 0:615f90842ce8 2226 * @brief Sets the AFC loop gain in slow mode.
MACRUM 0:615f90842ce8 2227 * @param cGain AFC loop gain in slow mode. This parameter shall be in the range:
MACRUM 0:615f90842ce8 2228 * [0:15].
MACRUM 0:615f90842ce8 2229 * @retval None.
MACRUM 0:615f90842ce8 2230 */
MACRUM 0:615f90842ce8 2231 void SpiritRadioSetAFCSlowGain(uint8_t cGain)
MACRUM 0:615f90842ce8 2232 {
MACRUM 0:615f90842ce8 2233 uint8_t tempRegValue = 0x00;
MACRUM 0:615f90842ce8 2234
MACRUM 0:615f90842ce8 2235 /* Check the parameters */
MACRUM 0:615f90842ce8 2236 s_assert_param(IS_AFC_SLOW_GAIN(cGain));
MACRUM 0:615f90842ce8 2237
MACRUM 0:615f90842ce8 2238 /* Reads the AFC_0 register and configure the AFC Slow Gain field */
MACRUM 0:615f90842ce8 2239 SpiritSpiReadRegisters(AFC0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2240 tempRegValue &= 0xF0;
MACRUM 0:615f90842ce8 2241 tempRegValue |= cGain;
MACRUM 0:615f90842ce8 2242
MACRUM 0:615f90842ce8 2243 /* Sets the AFC_0 register */
MACRUM 0:615f90842ce8 2244 g_xStatus = SpiritSpiWriteRegisters(AFC0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2245
MACRUM 0:615f90842ce8 2246 }
MACRUM 0:615f90842ce8 2247
MACRUM 0:615f90842ce8 2248
MACRUM 0:615f90842ce8 2249 /**
MACRUM 0:615f90842ce8 2250 * @brief Returns the AFC loop gain in slow mode.
MACRUM 0:615f90842ce8 2251 * @param None.
MACRUM 0:615f90842ce8 2252 * @retval uint8_t AFC loop gain in slow mode. This parameter will be in the range:
MACRUM 0:615f90842ce8 2253 * [0:15].
MACRUM 0:615f90842ce8 2254 */
MACRUM 0:615f90842ce8 2255 uint8_t SpiritRadioGetAFCSlowGain(void)
MACRUM 0:615f90842ce8 2256 {
MACRUM 0:615f90842ce8 2257 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 2258
MACRUM 0:615f90842ce8 2259 /* Reads the AFC_0 register, mask the AFC Slow Gain field and return the value */
MACRUM 0:615f90842ce8 2260 g_xStatus = SpiritSpiReadRegisters(AFC0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2261
MACRUM 0:615f90842ce8 2262 return (tempRegValue & 0x0F);
MACRUM 0:615f90842ce8 2263
MACRUM 0:615f90842ce8 2264 }
MACRUM 0:615f90842ce8 2265
MACRUM 0:615f90842ce8 2266
MACRUM 0:615f90842ce8 2267 /**
MACRUM 0:615f90842ce8 2268 * @brief Returns the AFC correction from the corresponding register.
MACRUM 0:615f90842ce8 2269 * @param None.
MACRUM 0:615f90842ce8 2270 * @retval int8_t AFC correction, read from the corresponding register.
MACRUM 0:615f90842ce8 2271 * This parameter will be in the range [-128:127].
MACRUM 0:615f90842ce8 2272 */
MACRUM 0:615f90842ce8 2273 int8_t SpiritRadioGetAFCCorrectionReg(void)
MACRUM 0:615f90842ce8 2274 {
MACRUM 0:615f90842ce8 2275 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 2276
MACRUM 0:615f90842ce8 2277 /* Reads the AFC_CORR register, cast the read value as signed char and return it */
MACRUM 0:615f90842ce8 2278 g_xStatus = SpiritSpiReadRegisters(AFC_CORR_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2279
MACRUM 0:615f90842ce8 2280 return (int8_t)tempRegValue;
MACRUM 0:615f90842ce8 2281
MACRUM 0:615f90842ce8 2282 }
MACRUM 0:615f90842ce8 2283
MACRUM 0:615f90842ce8 2284
MACRUM 0:615f90842ce8 2285 /**
MACRUM 0:615f90842ce8 2286 * @brief Returns the AFC correction expressed in Hz.
MACRUM 0:615f90842ce8 2287 * @param None.
MACRUM 0:615f90842ce8 2288 * @retval int32_t AFC correction expressed in Hz
MACRUM 0:615f90842ce8 2289 * according to the following formula:<ul>
MACRUM 0:615f90842ce8 2290 * <li> Fafc[Hz]= (Fdig/(12*2^10))*AFC_CORR where </li>
MACRUM 0:615f90842ce8 2291 * <li> AFC_CORR is the value read in the AFC_CORR register </li> </ul>
MACRUM 0:615f90842ce8 2292 */
MACRUM 0:615f90842ce8 2293 int32_t SpiritRadioGetAFCCorrectionHz(void)
MACRUM 0:615f90842ce8 2294 {
MACRUM 0:615f90842ce8 2295 int8_t correction;
MACRUM 0:615f90842ce8 2296 uint32_t xtal = s_lXtalFrequency;
MACRUM 0:615f90842ce8 2297
MACRUM 0:615f90842ce8 2298 /* Reads the AFC correction register */
MACRUM 0:615f90842ce8 2299 correction = SpiritRadioGetAFCCorrectionReg();
MACRUM 0:615f90842ce8 2300
MACRUM 0:615f90842ce8 2301 if(xtal>DOUBLE_XTAL_THR)
MACRUM 0:615f90842ce8 2302 {
MACRUM 0:615f90842ce8 2303 xtal /= 2;
MACRUM 0:615f90842ce8 2304 }
MACRUM 0:615f90842ce8 2305
MACRUM 0:615f90842ce8 2306 /* Calculates and return the Frequency Correction */
MACRUM 0:615f90842ce8 2307 return (int32_t)(xtal/(12*pow(2,10))*correction);
MACRUM 0:615f90842ce8 2308
MACRUM 0:615f90842ce8 2309 }
MACRUM 0:615f90842ce8 2310
MACRUM 0:615f90842ce8 2311
MACRUM 0:615f90842ce8 2312 /**
MACRUM 0:615f90842ce8 2313 * @brief Enables or Disables the AGC.
MACRUM 0:615f90842ce8 2314 * @param xNewState new state for AGC.
MACRUM 0:615f90842ce8 2315 * This parameter can be: S_ENABLE or S_DISABLE
MACRUM 0:615f90842ce8 2316 * @retval None.
MACRUM 0:615f90842ce8 2317 */
MACRUM 0:615f90842ce8 2318 void SpiritRadioAGC(SpiritFunctionalState xNewState)
MACRUM 0:615f90842ce8 2319 {
MACRUM 0:615f90842ce8 2320 uint8_t tempRegValue = 0x00;
MACRUM 0:615f90842ce8 2321
MACRUM 0:615f90842ce8 2322 /* Check the parameters */
MACRUM 0:615f90842ce8 2323 s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(xNewState));
MACRUM 0:615f90842ce8 2324
MACRUM 0:615f90842ce8 2325 /* Reads the AGCCTRL_0 register and configure the AGC Enabled field */
MACRUM 0:615f90842ce8 2326 SpiritSpiReadRegisters(AGCCTRL0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2327 if(xNewState == S_ENABLE)
MACRUM 0:615f90842ce8 2328 {
MACRUM 0:615f90842ce8 2329 tempRegValue |= AGCCTRL0_AGC_MASK;
MACRUM 0:615f90842ce8 2330 }
MACRUM 0:615f90842ce8 2331 else
MACRUM 0:615f90842ce8 2332 {
MACRUM 0:615f90842ce8 2333 tempRegValue &= (~AGCCTRL0_AGC_MASK);
MACRUM 0:615f90842ce8 2334 }
MACRUM 0:615f90842ce8 2335
MACRUM 0:615f90842ce8 2336 /* Sets the AGCCTRL_0 register */
MACRUM 0:615f90842ce8 2337 g_xStatus = SpiritSpiWriteRegisters(AGCCTRL0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2338
MACRUM 0:615f90842ce8 2339 }
MACRUM 0:615f90842ce8 2340
MACRUM 0:615f90842ce8 2341
MACRUM 0:615f90842ce8 2342 /**
MACRUM 0:615f90842ce8 2343 * @brief Sets the AGC working mode.
MACRUM 0:615f90842ce8 2344 * @param xMode the AGC mode. This parameter can be one of the values defined in @ref AGCMode :
MACRUM 0:615f90842ce8 2345 * @arg AGC_LINEAR_MODE AGC works in linear mode
MACRUM 0:615f90842ce8 2346 * @arg AGC_BINARY_MODE AGC works in binary mode
MACRUM 0:615f90842ce8 2347 * @retval None.
MACRUM 0:615f90842ce8 2348 */
MACRUM 0:615f90842ce8 2349 void SpiritRadioSetAGCMode(AGCMode xMode)
MACRUM 0:615f90842ce8 2350 {
MACRUM 0:615f90842ce8 2351 uint8_t tempRegValue = 0x00;
MACRUM 0:615f90842ce8 2352
MACRUM 0:615f90842ce8 2353 /* Check the parameters */
MACRUM 0:615f90842ce8 2354 s_assert_param(IS_AGC_MODE(xMode));
MACRUM 0:615f90842ce8 2355
MACRUM 0:615f90842ce8 2356 /* Reads the AGCCTRL_0 register and configure the AGC Mode field */
MACRUM 0:615f90842ce8 2357 SpiritSpiReadRegisters(AGCCTRL0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2358 if(xMode == AGC_BINARY_MODE)
MACRUM 0:615f90842ce8 2359 {
MACRUM 0:615f90842ce8 2360 tempRegValue |= AGC_BINARY_MODE;
MACRUM 0:615f90842ce8 2361 }
MACRUM 0:615f90842ce8 2362 else
MACRUM 0:615f90842ce8 2363 {
MACRUM 0:615f90842ce8 2364 tempRegValue &= (~AGC_BINARY_MODE);
MACRUM 0:615f90842ce8 2365 }
MACRUM 0:615f90842ce8 2366
MACRUM 0:615f90842ce8 2367 /* Sets the AGCCTRL_0 register */
MACRUM 0:615f90842ce8 2368 g_xStatus = SpiritSpiWriteRegisters(AGCCTRL0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2369
MACRUM 0:615f90842ce8 2370 }
MACRUM 0:615f90842ce8 2371
MACRUM 0:615f90842ce8 2372
MACRUM 0:615f90842ce8 2373 /**
MACRUM 0:615f90842ce8 2374 * @brief Returns the AGC working mode.
MACRUM 0:615f90842ce8 2375 * @param None.
MACRUM 0:615f90842ce8 2376 * @retval AGCMode Settled AGC mode. This parameter can be one of the values defined in @ref AGCMode :
MACRUM 0:615f90842ce8 2377 * @arg AGC_LINEAR_MODE AGC works in linear mode
MACRUM 0:615f90842ce8 2378 * @arg AGC_BINARY_MODE AGC works in binary mode
MACRUM 0:615f90842ce8 2379 */
MACRUM 0:615f90842ce8 2380 AGCMode SpiritRadioGetAGCMode(void)
MACRUM 0:615f90842ce8 2381 {
MACRUM 0:615f90842ce8 2382 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 2383
MACRUM 0:615f90842ce8 2384 /* Reads the AGCCTRL_0 register, mask the AGC Mode field and return the value */
MACRUM 0:615f90842ce8 2385 g_xStatus = SpiritSpiReadRegisters(AGCCTRL0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2386
MACRUM 0:615f90842ce8 2387 return (AGCMode)(tempRegValue & 0x40);
MACRUM 0:615f90842ce8 2388
MACRUM 0:615f90842ce8 2389 }
MACRUM 0:615f90842ce8 2390
MACRUM 0:615f90842ce8 2391
MACRUM 0:615f90842ce8 2392 /**
MACRUM 0:615f90842ce8 2393 * @brief Enables or Disables the AGC freeze on steady state.
MACRUM 0:615f90842ce8 2394 * @param xNewState new state for AGC freeze on steady state.
MACRUM 0:615f90842ce8 2395 * This parameter can be: S_ENABLE or S_DISABLE.
MACRUM 0:615f90842ce8 2396 * @retval None.
MACRUM 0:615f90842ce8 2397 */
MACRUM 0:615f90842ce8 2398 void SpiritRadioAGCFreezeOnSteady(SpiritFunctionalState xNewState)
MACRUM 0:615f90842ce8 2399 {
MACRUM 0:615f90842ce8 2400 uint8_t tempRegValue = 0x00;
MACRUM 0:615f90842ce8 2401
MACRUM 0:615f90842ce8 2402 /* Check the parameters */
MACRUM 0:615f90842ce8 2403 s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(xNewState));
MACRUM 0:615f90842ce8 2404
MACRUM 0:615f90842ce8 2405 /* Reads the AGCCTRL_2 register and configure the AGC Freeze On Steady field */
MACRUM 0:615f90842ce8 2406 SpiritSpiReadRegisters(AGCCTRL2_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2407 if(xNewState == S_ENABLE)
MACRUM 0:615f90842ce8 2408 {
MACRUM 0:615f90842ce8 2409 tempRegValue |= AGCCTRL2_FREEZE_ON_STEADY_MASK;
MACRUM 0:615f90842ce8 2410 }
MACRUM 0:615f90842ce8 2411 else
MACRUM 0:615f90842ce8 2412 {
MACRUM 0:615f90842ce8 2413 tempRegValue &= (~AGCCTRL2_FREEZE_ON_STEADY_MASK);
MACRUM 0:615f90842ce8 2414 }
MACRUM 0:615f90842ce8 2415
MACRUM 0:615f90842ce8 2416 /* Sets the AGCCTRL_2 register */
MACRUM 0:615f90842ce8 2417 g_xStatus = SpiritSpiWriteRegisters(AGCCTRL2_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2418
MACRUM 0:615f90842ce8 2419 }
MACRUM 0:615f90842ce8 2420
MACRUM 0:615f90842ce8 2421
MACRUM 0:615f90842ce8 2422 /**
MACRUM 0:615f90842ce8 2423 * @brief Enable or Disable the AGC freeze on sync detection.
MACRUM 0:615f90842ce8 2424 * @param xNewState new state for AGC freeze on sync detection.
MACRUM 0:615f90842ce8 2425 * This parameter can be: S_ENABLE or S_DISABLE.
MACRUM 0:615f90842ce8 2426 * @retval None.
MACRUM 0:615f90842ce8 2427 */
MACRUM 0:615f90842ce8 2428 void SpiritRadioAGCFreezeOnSync(SpiritFunctionalState xNewState)
MACRUM 0:615f90842ce8 2429 {
MACRUM 0:615f90842ce8 2430 uint8_t tempRegValue = 0x00;
MACRUM 0:615f90842ce8 2431
MACRUM 0:615f90842ce8 2432 /* Check the parameters */
MACRUM 0:615f90842ce8 2433 s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(xNewState));
MACRUM 0:615f90842ce8 2434
MACRUM 0:615f90842ce8 2435 /* Reads the AGCCTRL_2 register and configure the AGC Freeze On Sync field */
MACRUM 0:615f90842ce8 2436 SpiritSpiReadRegisters(AGCCTRL2_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2437 if(xNewState == S_ENABLE)
MACRUM 0:615f90842ce8 2438 {
MACRUM 0:615f90842ce8 2439 tempRegValue |= AGCCTRL2_FREEZE_ON_SYNC_MASK;
MACRUM 0:615f90842ce8 2440 }
MACRUM 0:615f90842ce8 2441 else
MACRUM 0:615f90842ce8 2442 {
MACRUM 0:615f90842ce8 2443 tempRegValue &= (~AGCCTRL2_FREEZE_ON_SYNC_MASK);
MACRUM 0:615f90842ce8 2444 }
MACRUM 0:615f90842ce8 2445
MACRUM 0:615f90842ce8 2446 /* Sets the AGCCTRL_2 register */
MACRUM 0:615f90842ce8 2447 g_xStatus = SpiritSpiWriteRegisters(AGCCTRL2_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2448
MACRUM 0:615f90842ce8 2449 }
MACRUM 0:615f90842ce8 2450
MACRUM 0:615f90842ce8 2451
MACRUM 0:615f90842ce8 2452 /**
MACRUM 0:615f90842ce8 2453 * @brief Enable or Disable the AGC to start with max attenuation.
MACRUM 0:615f90842ce8 2454 * @param xNewState new state for AGC start with max attenuation mode.
MACRUM 0:615f90842ce8 2455 * This parameter can be: S_ENABLE or S_DISABLE.
MACRUM 0:615f90842ce8 2456 * @retval None.
MACRUM 0:615f90842ce8 2457 */
MACRUM 0:615f90842ce8 2458 void SpiritRadioAGCStartMaxAttenuation(SpiritFunctionalState xNewState)
MACRUM 0:615f90842ce8 2459 {
MACRUM 0:615f90842ce8 2460 uint8_t tempRegValue = 0x00;
MACRUM 0:615f90842ce8 2461
MACRUM 0:615f90842ce8 2462 /* Check the parameters */
MACRUM 0:615f90842ce8 2463 s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(xNewState));
MACRUM 0:615f90842ce8 2464
MACRUM 0:615f90842ce8 2465 /* Reads the AGCCTRL_2 register and configure the AGC Start Max Attenuation field */
MACRUM 0:615f90842ce8 2466 SpiritSpiReadRegisters(AGCCTRL2_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2467 if(xNewState == S_ENABLE)
MACRUM 0:615f90842ce8 2468 {
MACRUM 0:615f90842ce8 2469 tempRegValue |= AGCCTRL2_START_MAX_ATTENUATION_MASK;
MACRUM 0:615f90842ce8 2470 }
MACRUM 0:615f90842ce8 2471 else
MACRUM 0:615f90842ce8 2472 {
MACRUM 0:615f90842ce8 2473 tempRegValue &= (~AGCCTRL2_START_MAX_ATTENUATION_MASK);
MACRUM 0:615f90842ce8 2474 }
MACRUM 0:615f90842ce8 2475
MACRUM 0:615f90842ce8 2476 /* Sets the AGCCTRL_2 register */
MACRUM 0:615f90842ce8 2477 g_xStatus = SpiritSpiWriteRegisters(AGCCTRL2_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2478
MACRUM 0:615f90842ce8 2479 }
MACRUM 0:615f90842ce8 2480
MACRUM 0:615f90842ce8 2481
MACRUM 0:615f90842ce8 2482 /**
MACRUM 0:615f90842ce8 2483 * @brief Sets the AGC measure time.
MACRUM 0:615f90842ce8 2484 * @param nTime AGC measure time expressed in us. This parameter shall be in the range [0, 393216/F_Xo].
MACRUM 0:615f90842ce8 2485 * @retval None.
MACRUM 0:615f90842ce8 2486 */
MACRUM 0:615f90842ce8 2487 void SpiritRadioSetAGCMeasureTimeUs(uint16_t nTime)
MACRUM 0:615f90842ce8 2488 {
MACRUM 0:615f90842ce8 2489 uint8_t tempRegValue, measure;
MACRUM 0:615f90842ce8 2490
MACRUM 0:615f90842ce8 2491 /* Check the parameter */
MACRUM 0:615f90842ce8 2492 s_assert_param(IS_AGC_MEASURE_TIME_US(nTime,s_lXtalFrequency));
MACRUM 0:615f90842ce8 2493
MACRUM 0:615f90842ce8 2494 /* Reads the AGCCTRL_2 register */
MACRUM 0:615f90842ce8 2495 SpiritSpiReadRegisters(AGCCTRL2_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2496
MACRUM 0:615f90842ce8 2497 /* Calculates the measure time value to write in the register */
MACRUM 0:615f90842ce8 2498 measure = (uint8_t)lroundf(log2((float)nTime/1e6 * s_lXtalFrequency/12));
MACRUM 0:615f90842ce8 2499 (measure>15) ? (measure=15):(measure);
MACRUM 0:615f90842ce8 2500
MACRUM 0:615f90842ce8 2501 /* Mask the MEAS_TIME field and write the new value */
MACRUM 0:615f90842ce8 2502 tempRegValue &= 0xF0;
MACRUM 0:615f90842ce8 2503 tempRegValue |= measure;
MACRUM 0:615f90842ce8 2504
MACRUM 0:615f90842ce8 2505 /* Sets the AGCCTRL_2 register */
MACRUM 0:615f90842ce8 2506 g_xStatus = SpiritSpiWriteRegisters(AGCCTRL2_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2507
MACRUM 0:615f90842ce8 2508 }
MACRUM 0:615f90842ce8 2509
MACRUM 0:615f90842ce8 2510
MACRUM 0:615f90842ce8 2511 /**
MACRUM 0:615f90842ce8 2512 * @brief Returns the AGC measure time.
MACRUM 0:615f90842ce8 2513 * @param None.
MACRUM 0:615f90842ce8 2514 * @retval uint16_t AGC measure time expressed in us. This parameter will be in the range [0, 393216/F_Xo].
MACRUM 0:615f90842ce8 2515 */
MACRUM 0:615f90842ce8 2516 uint16_t SpiritRadioGetAGCMeasureTimeUs(void)
MACRUM 0:615f90842ce8 2517 {
MACRUM 0:615f90842ce8 2518 uint8_t measure;
MACRUM 0:615f90842ce8 2519
MACRUM 0:615f90842ce8 2520 /* Reads the AGCCTRL_2 register */
MACRUM 0:615f90842ce8 2521 g_xStatus = SpiritSpiReadRegisters(AGCCTRL2_BASE, 1, &measure);
MACRUM 0:615f90842ce8 2522
MACRUM 0:615f90842ce8 2523 /* Mask the MEAS_TIME field */
MACRUM 0:615f90842ce8 2524 measure &= 0x0F;
MACRUM 0:615f90842ce8 2525
MACRUM 0:615f90842ce8 2526 /* Calculates the measure time value to write in the register */
MACRUM 0:615f90842ce8 2527 return (uint16_t)((12.0/s_lXtalFrequency)*(float)pow(2,measure)*1e6);
MACRUM 0:615f90842ce8 2528
MACRUM 0:615f90842ce8 2529 }
MACRUM 0:615f90842ce8 2530
MACRUM 0:615f90842ce8 2531
MACRUM 0:615f90842ce8 2532 /**
MACRUM 0:615f90842ce8 2533 * @brief Sets the AGC measure time.
MACRUM 0:615f90842ce8 2534 * @param cTime AGC measure time to write in the MEAS_TIME field of AGCCTRL_2 register.
MACRUM 0:615f90842ce8 2535 * This parameter shall be in the range [0:15].
MACRUM 0:615f90842ce8 2536 * @retval None.
MACRUM 0:615f90842ce8 2537 */
MACRUM 0:615f90842ce8 2538 void SpiritRadioSetAGCMeasureTime(uint8_t cTime)
MACRUM 0:615f90842ce8 2539 {
MACRUM 0:615f90842ce8 2540 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 2541
MACRUM 0:615f90842ce8 2542 /* Check the parameter */
MACRUM 0:615f90842ce8 2543 s_assert_param(IS_AGC_MEASURE_TIME(cTime));
MACRUM 0:615f90842ce8 2544
MACRUM 0:615f90842ce8 2545 /* Reads the AGCCTRL_2 register */
MACRUM 0:615f90842ce8 2546 SpiritSpiReadRegisters(AGCCTRL2_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2547
MACRUM 0:615f90842ce8 2548 /* Mask the MEAS_TIME field and write the new value */
MACRUM 0:615f90842ce8 2549 tempRegValue &= 0xF0;
MACRUM 0:615f90842ce8 2550 tempRegValue |= cTime;
MACRUM 0:615f90842ce8 2551
MACRUM 0:615f90842ce8 2552 /* Sets the AGCCTRL_2 register */
MACRUM 0:615f90842ce8 2553 g_xStatus = SpiritSpiWriteRegisters(AGCCTRL2_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2554
MACRUM 0:615f90842ce8 2555 }
MACRUM 0:615f90842ce8 2556
MACRUM 0:615f90842ce8 2557
MACRUM 0:615f90842ce8 2558 /**
MACRUM 0:615f90842ce8 2559 * @brief Returns the AGC measure time.
MACRUM 0:615f90842ce8 2560 * @param None.
MACRUM 0:615f90842ce8 2561 * @retval uint8_t AGC measure time read from the MEAS_TIME field of AGCCTRL_2 register.
MACRUM 0:615f90842ce8 2562 * This parameter will be in the range [0:15].
MACRUM 0:615f90842ce8 2563 */
MACRUM 0:615f90842ce8 2564 uint8_t SpiritRadioGetAGCMeasureTime(void)
MACRUM 0:615f90842ce8 2565 {
MACRUM 0:615f90842ce8 2566 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 2567
MACRUM 0:615f90842ce8 2568 /* Reads the AGCCTRL_2 register, mask the MEAS_TIME field and return the value */
MACRUM 0:615f90842ce8 2569 g_xStatus = SpiritSpiReadRegisters(AGCCTRL2_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2570
MACRUM 0:615f90842ce8 2571 return (tempRegValue & 0x0F);
MACRUM 0:615f90842ce8 2572
MACRUM 0:615f90842ce8 2573 }
MACRUM 0:615f90842ce8 2574
MACRUM 0:615f90842ce8 2575
MACRUM 0:615f90842ce8 2576 /**
MACRUM 0:615f90842ce8 2577 * @brief Sets the AGC hold time.
MACRUM 0:615f90842ce8 2578 * @param cTime AGC hold time expressed in us. This parameter shall be in the range[0, 756/F_Xo].
MACRUM 0:615f90842ce8 2579 * @retval None.
MACRUM 0:615f90842ce8 2580 */
MACRUM 0:615f90842ce8 2581 void SpiritRadioSetAGCHoldTimeUs(uint8_t cTime)
MACRUM 0:615f90842ce8 2582 {
MACRUM 0:615f90842ce8 2583 uint8_t tempRegValue, hold;
MACRUM 0:615f90842ce8 2584
MACRUM 0:615f90842ce8 2585 /* Check the parameter */
MACRUM 0:615f90842ce8 2586 s_assert_param(IS_AGC_HOLD_TIME_US(cTime,s_lXtalFrequency));
MACRUM 0:615f90842ce8 2587
MACRUM 0:615f90842ce8 2588 /* Reads the AGCCTRL_0 register */
MACRUM 0:615f90842ce8 2589 SpiritSpiReadRegisters(AGCCTRL0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2590
MACRUM 0:615f90842ce8 2591 /* Calculates the hold time value to write in the register */
MACRUM 0:615f90842ce8 2592 hold = (uint8_t)lroundf(((float)cTime/1e6 * s_lXtalFrequency)/12);
MACRUM 0:615f90842ce8 2593 (hold>63) ? (hold=63):(hold);
MACRUM 0:615f90842ce8 2594
MACRUM 0:615f90842ce8 2595 /* Mask the HOLD_TIME field and write the new value */
MACRUM 0:615f90842ce8 2596 tempRegValue &= 0xC0;
MACRUM 0:615f90842ce8 2597 tempRegValue |= hold;
MACRUM 0:615f90842ce8 2598
MACRUM 0:615f90842ce8 2599 /* Sets the AGCCTRL_0 register */
MACRUM 0:615f90842ce8 2600 g_xStatus = SpiritSpiWriteRegisters(AGCCTRL0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2601
MACRUM 0:615f90842ce8 2602 }
MACRUM 0:615f90842ce8 2603
MACRUM 0:615f90842ce8 2604
MACRUM 0:615f90842ce8 2605 /**
MACRUM 0:615f90842ce8 2606 * @brief Returns the AGC hold time.
MACRUM 0:615f90842ce8 2607 * @param None.
MACRUM 0:615f90842ce8 2608 * @retval uint8_t AGC hold time expressed in us. This parameter will be in the range:
MACRUM 0:615f90842ce8 2609 * [0, 756/F_Xo].
MACRUM 0:615f90842ce8 2610 */
MACRUM 0:615f90842ce8 2611 uint8_t SpiritRadioGetAGCHoldTimeUs(void)
MACRUM 0:615f90842ce8 2612 {
MACRUM 0:615f90842ce8 2613 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 2614
MACRUM 0:615f90842ce8 2615 /* Reads the AGCCTRL_0 register */
MACRUM 0:615f90842ce8 2616 g_xStatus = SpiritSpiReadRegisters(AGCCTRL0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2617
MACRUM 0:615f90842ce8 2618 /* Mask the HOLD_TIME field */
MACRUM 0:615f90842ce8 2619 tempRegValue &= 0x3F;
MACRUM 0:615f90842ce8 2620
MACRUM 0:615f90842ce8 2621 /* Calculates the hold time value and return it */
MACRUM 0:615f90842ce8 2622 return (uint8_t)lroundf ((12.0/s_lXtalFrequency)*(tempRegValue*1e6));
MACRUM 0:615f90842ce8 2623
MACRUM 0:615f90842ce8 2624 }
MACRUM 0:615f90842ce8 2625
MACRUM 0:615f90842ce8 2626
MACRUM 0:615f90842ce8 2627 /**
MACRUM 0:615f90842ce8 2628 * @brief Sets the AGC hold time.
MACRUM 0:615f90842ce8 2629 * @param cTime AGC hold time to write in the HOLD_TIME field of AGCCTRL_0 register.
MACRUM 0:615f90842ce8 2630 * This parameter shall be in the range [0:63].
MACRUM 0:615f90842ce8 2631 * @retval None.
MACRUM 0:615f90842ce8 2632 */
MACRUM 0:615f90842ce8 2633 void SpiritRadioSetAGCHoldTime(uint8_t cTime)
MACRUM 0:615f90842ce8 2634 {
MACRUM 0:615f90842ce8 2635 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 2636
MACRUM 0:615f90842ce8 2637 /* Check the parameter */
MACRUM 0:615f90842ce8 2638 s_assert_param(IS_AGC_HOLD_TIME(cTime));
MACRUM 0:615f90842ce8 2639
MACRUM 0:615f90842ce8 2640 /* Reads the AGCCTRL_0 register */
MACRUM 0:615f90842ce8 2641 SpiritSpiReadRegisters(AGCCTRL0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2642
MACRUM 0:615f90842ce8 2643 /* Mask the HOLD_TIME field and write the new value */
MACRUM 0:615f90842ce8 2644 tempRegValue &= 0xC0;
MACRUM 0:615f90842ce8 2645 tempRegValue |= cTime;
MACRUM 0:615f90842ce8 2646
MACRUM 0:615f90842ce8 2647 /* Sets the AGCCTRL_0 register */
MACRUM 0:615f90842ce8 2648 g_xStatus = SpiritSpiWriteRegisters(AGCCTRL0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2649
MACRUM 0:615f90842ce8 2650 }
MACRUM 0:615f90842ce8 2651
MACRUM 0:615f90842ce8 2652
MACRUM 0:615f90842ce8 2653 /**
MACRUM 0:615f90842ce8 2654 * @brief Returns the AGC hold time.
MACRUM 0:615f90842ce8 2655 * @param None.
MACRUM 0:615f90842ce8 2656 * @retval uint8_t AGC hold time read from the HOLD_TIME field of AGCCTRL_0 register.
MACRUM 0:615f90842ce8 2657 * This parameter will be in the range [0:63].
MACRUM 0:615f90842ce8 2658 */
MACRUM 0:615f90842ce8 2659 uint8_t SpiritRadioGetAGCHoldTime(void)
MACRUM 0:615f90842ce8 2660 {
MACRUM 0:615f90842ce8 2661 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 2662
MACRUM 0:615f90842ce8 2663 /* Reads the AGCCTRL_0 register, mask the MEAS_TIME field and return the value */
MACRUM 0:615f90842ce8 2664 g_xStatus = SpiritSpiReadRegisters(AGCCTRL0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2665
MACRUM 0:615f90842ce8 2666 return (tempRegValue & 0x3F);
MACRUM 0:615f90842ce8 2667
MACRUM 0:615f90842ce8 2668 }
MACRUM 0:615f90842ce8 2669
MACRUM 0:615f90842ce8 2670
MACRUM 0:615f90842ce8 2671 /**
MACRUM 0:615f90842ce8 2672 * @brief Sets the AGC high threshold.
MACRUM 0:615f90842ce8 2673 * @param cHighThreshold AGC high threshold to write in the THRESHOLD_HIGH field of AGCCTRL_1 register.
MACRUM 0:615f90842ce8 2674 * This parameter shall be in the range [0:15].
MACRUM 0:615f90842ce8 2675 * @retval None.
MACRUM 0:615f90842ce8 2676 */
MACRUM 0:615f90842ce8 2677 void SpiritRadioSetAGCHighThreshold(uint8_t cHighThreshold)
MACRUM 0:615f90842ce8 2678 {
MACRUM 0:615f90842ce8 2679 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 2680
MACRUM 0:615f90842ce8 2681 /* Check the parameter */
MACRUM 0:615f90842ce8 2682 s_assert_param(IS_AGC_THRESHOLD(cHighThreshold));
MACRUM 0:615f90842ce8 2683
MACRUM 0:615f90842ce8 2684 /* Reads the AGCCTRL_1 register */
MACRUM 0:615f90842ce8 2685 SpiritSpiReadRegisters(AGCCTRL1_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2686
MACRUM 0:615f90842ce8 2687 /* Mask the THRESHOLD_HIGH field and write the new value */
MACRUM 0:615f90842ce8 2688 tempRegValue &= 0x0F;
MACRUM 0:615f90842ce8 2689 tempRegValue |= cHighThreshold<<4;
MACRUM 0:615f90842ce8 2690
MACRUM 0:615f90842ce8 2691 /* Sets the AGCCTRL_1 register */
MACRUM 0:615f90842ce8 2692 g_xStatus = SpiritSpiWriteRegisters(AGCCTRL1_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2693
MACRUM 0:615f90842ce8 2694 }
MACRUM 0:615f90842ce8 2695
MACRUM 0:615f90842ce8 2696
MACRUM 0:615f90842ce8 2697 /**
MACRUM 0:615f90842ce8 2698 * @brief Returns the AGC high threshold.
MACRUM 0:615f90842ce8 2699 * @param None.
MACRUM 0:615f90842ce8 2700 * @retval uint8_t AGC high threshold read from the THRESHOLD_HIGH field of AGCCTRL_1 register.
MACRUM 0:615f90842ce8 2701 * This parameter will be in the range [0:15].
MACRUM 0:615f90842ce8 2702 */
MACRUM 0:615f90842ce8 2703 uint8_t SpiritRadioGetAGCHighThreshold(void)
MACRUM 0:615f90842ce8 2704 {
MACRUM 0:615f90842ce8 2705 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 2706
MACRUM 0:615f90842ce8 2707 /* Reads the AGCCTRL_1 register, mask the THRESHOLD_HIGH field and return the value */
MACRUM 0:615f90842ce8 2708 g_xStatus = SpiritSpiReadRegisters(AGCCTRL1_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2709
MACRUM 0:615f90842ce8 2710 return ((tempRegValue & 0xF0)>>4);
MACRUM 0:615f90842ce8 2711
MACRUM 0:615f90842ce8 2712 }
MACRUM 0:615f90842ce8 2713
MACRUM 0:615f90842ce8 2714
MACRUM 0:615f90842ce8 2715 /**
MACRUM 0:615f90842ce8 2716 * @brief Sets the AGC low threshold.
MACRUM 0:615f90842ce8 2717 * @param cLowThreshold AGC low threshold to write in the THRESHOLD_LOW field of AGCCTRL_1 register.
MACRUM 0:615f90842ce8 2718 * This parameter shall be in the range [0:15].
MACRUM 0:615f90842ce8 2719 * @retval None.
MACRUM 0:615f90842ce8 2720 */
MACRUM 0:615f90842ce8 2721 void SpiritRadioSetAGCLowThreshold(uint8_t cLowThreshold)
MACRUM 0:615f90842ce8 2722 {
MACRUM 0:615f90842ce8 2723 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 2724
MACRUM 0:615f90842ce8 2725 /* Check the parameter */
MACRUM 0:615f90842ce8 2726 s_assert_param(IS_AGC_THRESHOLD(cLowThreshold));
MACRUM 0:615f90842ce8 2727
MACRUM 0:615f90842ce8 2728 /* Reads the AGCCTRL_1 register */
MACRUM 0:615f90842ce8 2729 SpiritSpiReadRegisters(AGCCTRL1_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2730
MACRUM 0:615f90842ce8 2731 /* Mask the THRESHOLD_LOW field and write the new value */
MACRUM 0:615f90842ce8 2732 tempRegValue &= 0xF0;
MACRUM 0:615f90842ce8 2733 tempRegValue |= cLowThreshold;
MACRUM 0:615f90842ce8 2734
MACRUM 0:615f90842ce8 2735 /* Sets the AGCCTRL_1 register */
MACRUM 0:615f90842ce8 2736 g_xStatus = SpiritSpiWriteRegisters(AGCCTRL1_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2737
MACRUM 0:615f90842ce8 2738 }
MACRUM 0:615f90842ce8 2739
MACRUM 0:615f90842ce8 2740
MACRUM 0:615f90842ce8 2741 /**
MACRUM 0:615f90842ce8 2742 * @brief Returns the AGC low threshold.
MACRUM 0:615f90842ce8 2743 * @param None.
MACRUM 0:615f90842ce8 2744 * @retval uint8_t AGC low threshold read from the THRESHOLD_LOW field of AGCCTRL_1 register.
MACRUM 0:615f90842ce8 2745 * This parameter will be in the range [0:15].
MACRUM 0:615f90842ce8 2746 */
MACRUM 0:615f90842ce8 2747 uint8_t SpiritRadioGetAGCLowThreshold(void)
MACRUM 0:615f90842ce8 2748 {
MACRUM 0:615f90842ce8 2749 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 2750
MACRUM 0:615f90842ce8 2751 /* Reads the AGCCTRL_1 register, mask the THRESHOLD_LOW field and return the value */
MACRUM 0:615f90842ce8 2752 g_xStatus = SpiritSpiReadRegisters(AGCCTRL1_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2753
MACRUM 0:615f90842ce8 2754 return (tempRegValue & 0x0F);
MACRUM 0:615f90842ce8 2755
MACRUM 0:615f90842ce8 2756 }
MACRUM 0:615f90842ce8 2757
MACRUM 0:615f90842ce8 2758
MACRUM 0:615f90842ce8 2759 /**
MACRUM 0:615f90842ce8 2760 * @brief Sets the clock recovery algorithm.
MACRUM 0:615f90842ce8 2761 * @param xMode the Clock Recovery mode. This parameter can be one of the values defined in @ref ClkRecMode :
MACRUM 0:615f90842ce8 2762 * @arg CLK_REC_PLL PLL alogrithm for clock recovery
MACRUM 0:615f90842ce8 2763 * @arg CLK_REC_DLL DLL alogrithm for clock recovery
MACRUM 0:615f90842ce8 2764 * @retval None.
MACRUM 0:615f90842ce8 2765 */
MACRUM 0:615f90842ce8 2766 void SpiritRadioSetClkRecMode(ClkRecMode xMode)
MACRUM 0:615f90842ce8 2767 {
MACRUM 0:615f90842ce8 2768 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 2769
MACRUM 0:615f90842ce8 2770 /* Check the parameter */
MACRUM 0:615f90842ce8 2771 s_assert_param(IS_CLK_REC_MODE(xMode));
MACRUM 0:615f90842ce8 2772
MACRUM 0:615f90842ce8 2773 /* Reads the FDEV_0 register */
MACRUM 0:615f90842ce8 2774 SpiritSpiReadRegisters(FDEV0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2775
MACRUM 0:615f90842ce8 2776 /* Mask the CLOCK_REC_ALGO_SEL field and write the new value */
MACRUM 0:615f90842ce8 2777 tempRegValue &= 0xF7;
MACRUM 0:615f90842ce8 2778 tempRegValue |= (uint8_t)xMode;
MACRUM 0:615f90842ce8 2779
MACRUM 0:615f90842ce8 2780 /* Sets the FDEV_0 register */
MACRUM 0:615f90842ce8 2781 g_xStatus = SpiritSpiWriteRegisters(FDEV0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2782
MACRUM 0:615f90842ce8 2783 }
MACRUM 0:615f90842ce8 2784
MACRUM 0:615f90842ce8 2785
MACRUM 0:615f90842ce8 2786 /**
MACRUM 0:615f90842ce8 2787 * @brief Returns the Clock Recovery working mode.
MACRUM 0:615f90842ce8 2788 * @param None.
MACRUM 0:615f90842ce8 2789 * @retval ClkRecMode Clock Recovery mode. This parameter can be one of the values defined in @ref ClkRecMode :
MACRUM 0:615f90842ce8 2790 * @arg CLK_REC_PLL PLL alogrithm for clock recovery
MACRUM 0:615f90842ce8 2791 * @arg CLK_REC_DLL DLL alogrithm for clock recovery
MACRUM 0:615f90842ce8 2792 */
MACRUM 0:615f90842ce8 2793 ClkRecMode SpiritRadioGetClkRecMode(void)
MACRUM 0:615f90842ce8 2794 {
MACRUM 0:615f90842ce8 2795 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 2796
MACRUM 0:615f90842ce8 2797 /* Reads the FDEV_0 register, mask the CLOCK_REC_ALGO_SEL field and return the value */
MACRUM 0:615f90842ce8 2798 g_xStatus = SpiritSpiReadRegisters(FDEV0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2799
MACRUM 0:615f90842ce8 2800 return (ClkRecMode)(tempRegValue & 0x08);
MACRUM 0:615f90842ce8 2801
MACRUM 0:615f90842ce8 2802 }
MACRUM 0:615f90842ce8 2803
MACRUM 0:615f90842ce8 2804
MACRUM 0:615f90842ce8 2805 /**
MACRUM 0:615f90842ce8 2806 * @brief Sets the clock recovery proportional gain.
MACRUM 0:615f90842ce8 2807 * @param cPGain the Clock Recovery proportional gain to write in the CLK_REC_P_GAIN field of CLOCKREC register.
MACRUM 0:615f90842ce8 2808 * It represents is log2 value of the clock recovery proportional gain.
MACRUM 0:615f90842ce8 2809 * This parameter shall be in the range [0:7].
MACRUM 0:615f90842ce8 2810 * @retval None.
MACRUM 0:615f90842ce8 2811 */
MACRUM 0:615f90842ce8 2812 void SpiritRadioSetClkRecPGain(uint8_t cPGain)
MACRUM 0:615f90842ce8 2813 {
MACRUM 0:615f90842ce8 2814 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 2815
MACRUM 0:615f90842ce8 2816 /* Check the parameter */
MACRUM 0:615f90842ce8 2817 s_assert_param(IS_CLK_REC_P_GAIN(cPGain));
MACRUM 0:615f90842ce8 2818
MACRUM 0:615f90842ce8 2819 /* Reads the CLOCKREC register */
MACRUM 0:615f90842ce8 2820 SpiritSpiReadRegisters(CLOCKREC_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2821
MACRUM 0:615f90842ce8 2822 /* Mask the CLK_REC_P_GAIN field and write the new value */
MACRUM 0:615f90842ce8 2823 tempRegValue &= 0x1F;
MACRUM 0:615f90842ce8 2824 tempRegValue |= (cPGain<<5);
MACRUM 0:615f90842ce8 2825
MACRUM 0:615f90842ce8 2826 /* Sets the CLOCKREC register */
MACRUM 0:615f90842ce8 2827 g_xStatus = SpiritSpiWriteRegisters(CLOCKREC_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2828
MACRUM 0:615f90842ce8 2829 }
MACRUM 0:615f90842ce8 2830
MACRUM 0:615f90842ce8 2831
MACRUM 0:615f90842ce8 2832 /**
MACRUM 0:615f90842ce8 2833 * @brief Returns the log2 of the clock recovery proportional gain.
MACRUM 0:615f90842ce8 2834 * @param None.
MACRUM 0:615f90842ce8 2835 * @retval uint8_t Clock Recovery proportional gain read from the CLK_REC_P_GAIN field of CLOCKREC register.
MACRUM 0:615f90842ce8 2836 * This parameter will be in the range [0:7].
MACRUM 0:615f90842ce8 2837 */
MACRUM 0:615f90842ce8 2838 uint8_t SpiritRadioGetClkRecPGain(void)
MACRUM 0:615f90842ce8 2839 {
MACRUM 0:615f90842ce8 2840 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 2841
MACRUM 0:615f90842ce8 2842 /* Reads the CLOCKREC register, mask the CLK_REC_P_GAIN field and return the value */
MACRUM 0:615f90842ce8 2843 g_xStatus = SpiritSpiReadRegisters(CLOCKREC_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2844
MACRUM 0:615f90842ce8 2845 return ((tempRegValue & 0xEF)>>5);
MACRUM 0:615f90842ce8 2846
MACRUM 0:615f90842ce8 2847 }
MACRUM 0:615f90842ce8 2848
MACRUM 0:615f90842ce8 2849
MACRUM 0:615f90842ce8 2850 /**
MACRUM 0:615f90842ce8 2851 * @brief Sets the clock recovery integral gain.
MACRUM 0:615f90842ce8 2852 * @param cIGain the Clock Recovery integral gain to write in the CLK_REC_I_GAIN field of CLOCKREC register.
MACRUM 0:615f90842ce8 2853 * This parameter shall be in the range [0:15].
MACRUM 0:615f90842ce8 2854 * @retval None.
MACRUM 0:615f90842ce8 2855 */
MACRUM 0:615f90842ce8 2856 void SpiritRadioSetClkRecIGain(uint8_t cIGain)
MACRUM 0:615f90842ce8 2857 {
MACRUM 0:615f90842ce8 2858 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 2859
MACRUM 0:615f90842ce8 2860 /* Check the parameter */
MACRUM 0:615f90842ce8 2861 s_assert_param(IS_CLK_REC_I_GAIN(cIGain));
MACRUM 0:615f90842ce8 2862
MACRUM 0:615f90842ce8 2863 /* Reads the CLOCKREC register */
MACRUM 0:615f90842ce8 2864 SpiritSpiReadRegisters(CLOCKREC_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2865
MACRUM 0:615f90842ce8 2866 /* Mask the CLK_REC_P_GAIN field and write the new value */
MACRUM 0:615f90842ce8 2867 tempRegValue &= 0xF0;
MACRUM 0:615f90842ce8 2868 tempRegValue |= cIGain;
MACRUM 0:615f90842ce8 2869
MACRUM 0:615f90842ce8 2870 /* Sets the CLOCKREC register */
MACRUM 0:615f90842ce8 2871 g_xStatus = SpiritSpiWriteRegisters(CLOCKREC_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2872
MACRUM 0:615f90842ce8 2873 }
MACRUM 0:615f90842ce8 2874
MACRUM 0:615f90842ce8 2875
MACRUM 0:615f90842ce8 2876 /**
MACRUM 0:615f90842ce8 2877 * @brief Returns the clock recovery integral gain.
MACRUM 0:615f90842ce8 2878 * @param None.
MACRUM 0:615f90842ce8 2879 * @retval uint8_t Clock Recovery integral gain read from the
MACRUM 0:615f90842ce8 2880 * CLK_REC_I_GAIN field of CLOCKREC register.
MACRUM 0:615f90842ce8 2881 * This parameter will be in the range [0:15].
MACRUM 0:615f90842ce8 2882 */
MACRUM 0:615f90842ce8 2883 uint8_t SpiritRadioGetClkRecIGain(void)
MACRUM 0:615f90842ce8 2884 {
MACRUM 0:615f90842ce8 2885 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 2886
MACRUM 0:615f90842ce8 2887 /* Reads the CLOCKREC register, mask the CLK_REC_I_GAIN field and return the value */
MACRUM 0:615f90842ce8 2888 g_xStatus = SpiritSpiReadRegisters(CLOCKREC_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2889
MACRUM 0:615f90842ce8 2890 return (tempRegValue & 0x0F);
MACRUM 0:615f90842ce8 2891
MACRUM 0:615f90842ce8 2892 }
MACRUM 0:615f90842ce8 2893
MACRUM 0:615f90842ce8 2894
MACRUM 0:615f90842ce8 2895 /**
MACRUM 0:615f90842ce8 2896 * @brief Sets the postfilter length for clock recovery algorithm.
MACRUM 0:615f90842ce8 2897 * @param xLength the postfilter length in symbols. This parameter can be one of the values defined in @ref PstFltLength :
MACRUM 0:615f90842ce8 2898 * @arg PSTFLT_LENGTH_8 Postfilter length is 8 symbols
MACRUM 0:615f90842ce8 2899 * @arg PSTFLT_LENGTH_16 Postfilter length is 16 symbols
MACRUM 0:615f90842ce8 2900 * @retval None.
MACRUM 0:615f90842ce8 2901 */
MACRUM 0:615f90842ce8 2902 void SpiritRadioSetClkRecPstFltLength(PstFltLength xLength)
MACRUM 0:615f90842ce8 2903 {
MACRUM 0:615f90842ce8 2904 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 2905
MACRUM 0:615f90842ce8 2906 /* Check the parameter */
MACRUM 0:615f90842ce8 2907 s_assert_param(IS_PST_FLT_LENGTH(xLength));
MACRUM 0:615f90842ce8 2908
MACRUM 0:615f90842ce8 2909 /* Reads the CLOCKREC register */
MACRUM 0:615f90842ce8 2910 SpiritSpiReadRegisters(CLOCKREC_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2911
MACRUM 0:615f90842ce8 2912 /* Mask the PSTFLT_LEN field and write the new value */
MACRUM 0:615f90842ce8 2913 tempRegValue &= 0xEF;
MACRUM 0:615f90842ce8 2914 tempRegValue |= (uint8_t)xLength;
MACRUM 0:615f90842ce8 2915
MACRUM 0:615f90842ce8 2916 /* Sets the CLOCKREC register */
MACRUM 0:615f90842ce8 2917 g_xStatus = SpiritSpiWriteRegisters(CLOCKREC_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2918
MACRUM 0:615f90842ce8 2919 }
MACRUM 0:615f90842ce8 2920
MACRUM 0:615f90842ce8 2921
MACRUM 0:615f90842ce8 2922 /**
MACRUM 0:615f90842ce8 2923 * @brief Returns the postfilter length for clock recovery algorithm.
MACRUM 0:615f90842ce8 2924 * @param None.
MACRUM 0:615f90842ce8 2925 * @retval PstFltLength Postfilter length in symbols. This parameter can be one of the values defined in @ref PstFltLength :
MACRUM 0:615f90842ce8 2926 * @arg PSTFLT_LENGTH_8 Postfilter length is 8 symbols
MACRUM 0:615f90842ce8 2927 * @arg PSTFLT_LENGTH_16 Postfilter length is 16 symbols
MACRUM 0:615f90842ce8 2928 */
MACRUM 0:615f90842ce8 2929 PstFltLength SpiritRadioGetClkRecPstFltLength(void)
MACRUM 0:615f90842ce8 2930 {
MACRUM 0:615f90842ce8 2931 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 2932
MACRUM 0:615f90842ce8 2933 /* Reads the CLOCKREC register, mask the PSTFLT_LEN field and return the value */
MACRUM 0:615f90842ce8 2934 g_xStatus = SpiritSpiReadRegisters(CLOCKREC_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2935
MACRUM 0:615f90842ce8 2936 return (PstFltLength)(tempRegValue & 0x10);
MACRUM 0:615f90842ce8 2937
MACRUM 0:615f90842ce8 2938 }
MACRUM 0:615f90842ce8 2939
MACRUM 0:615f90842ce8 2940
MACRUM 0:615f90842ce8 2941 /**
MACRUM 0:615f90842ce8 2942 * @brief Enables or Disables the received data blanking when the CS is under the threshold.
MACRUM 0:615f90842ce8 2943 * @param xNewState new state of this mode.
MACRUM 0:615f90842ce8 2944 * This parameter can be: S_ENABLE or S_DISABLE .
MACRUM 0:615f90842ce8 2945 * @retval None.
MACRUM 0:615f90842ce8 2946 */
MACRUM 0:615f90842ce8 2947 void SpiritRadioCsBlanking(SpiritFunctionalState xNewState)
MACRUM 0:615f90842ce8 2948 {
MACRUM 0:615f90842ce8 2949 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 2950
MACRUM 0:615f90842ce8 2951 /* Check the parameters */
MACRUM 0:615f90842ce8 2952 s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(xNewState));
MACRUM 0:615f90842ce8 2953
MACRUM 0:615f90842ce8 2954 /* Reads the ANT_SELECT_CONF_BASE and mask the CS_BLANKING BIT field */
MACRUM 0:615f90842ce8 2955 SpiritSpiReadRegisters(ANT_SELECT_CONF_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2956
MACRUM 0:615f90842ce8 2957 if(xNewState == S_ENABLE)
MACRUM 0:615f90842ce8 2958 {
MACRUM 0:615f90842ce8 2959 tempRegValue |= ANT_SELECT_CS_BLANKING_MASK;
MACRUM 0:615f90842ce8 2960 }
MACRUM 0:615f90842ce8 2961 else
MACRUM 0:615f90842ce8 2962 {
MACRUM 0:615f90842ce8 2963 tempRegValue &= (~ANT_SELECT_CS_BLANKING_MASK);
MACRUM 0:615f90842ce8 2964 }
MACRUM 0:615f90842ce8 2965
MACRUM 0:615f90842ce8 2966 /* Writes the new value in the ANT_SELECT_CONF register */
MACRUM 0:615f90842ce8 2967 g_xStatus = SpiritSpiWriteRegisters(ANT_SELECT_CONF_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2968
MACRUM 0:615f90842ce8 2969
MACRUM 0:615f90842ce8 2970 }
MACRUM 0:615f90842ce8 2971
MACRUM 0:615f90842ce8 2972 /**
MACRUM 0:615f90842ce8 2973 * @brief Enables or Disables the persistent RX mode.
MACRUM 0:615f90842ce8 2974 * @param xNewState new state of this mode.
MACRUM 0:615f90842ce8 2975 * This parameter can be: S_ENABLE or S_DISABLE .
MACRUM 0:615f90842ce8 2976 * @retval None.
MACRUM 0:615f90842ce8 2977 */
MACRUM 0:615f90842ce8 2978 void SpiritRadioPersistenRx(SpiritFunctionalState xNewState)
MACRUM 0:615f90842ce8 2979 {
MACRUM 0:615f90842ce8 2980 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 2981
MACRUM 0:615f90842ce8 2982 /* Check the parameters */
MACRUM 0:615f90842ce8 2983 s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(xNewState));
MACRUM 0:615f90842ce8 2984
MACRUM 0:615f90842ce8 2985 /* Reads the PROTOCOL0_BASE and mask the PROTOCOL0_PERS_RX_MASK bitfield */
MACRUM 0:615f90842ce8 2986 SpiritSpiReadRegisters(PROTOCOL0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2987
MACRUM 0:615f90842ce8 2988 if(xNewState == S_ENABLE)
MACRUM 0:615f90842ce8 2989 {
MACRUM 0:615f90842ce8 2990 tempRegValue |= PROTOCOL0_PERS_RX_MASK;
MACRUM 0:615f90842ce8 2991 }
MACRUM 0:615f90842ce8 2992 else
MACRUM 0:615f90842ce8 2993 {
MACRUM 0:615f90842ce8 2994 tempRegValue &= (~PROTOCOL0_PERS_RX_MASK);
MACRUM 0:615f90842ce8 2995 }
MACRUM 0:615f90842ce8 2996
MACRUM 0:615f90842ce8 2997 /* Writes the new value in the PROTOCOL0_BASE register */
MACRUM 0:615f90842ce8 2998 g_xStatus = SpiritSpiWriteRegisters(PROTOCOL0_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 2999
MACRUM 0:615f90842ce8 3000 }
MACRUM 0:615f90842ce8 3001
MACRUM 0:615f90842ce8 3002 /**
MACRUM 0:615f90842ce8 3003 * @brief Enables or Disables the synthesizer reference divider.
MACRUM 0:615f90842ce8 3004 * @param xNewState new state for synthesizer reference divider.
MACRUM 0:615f90842ce8 3005 * This parameter can be: S_ENABLE or S_DISABLE .
MACRUM 0:615f90842ce8 3006 * @retval None.
MACRUM 0:615f90842ce8 3007 */
MACRUM 0:615f90842ce8 3008 void SpiritRadioSetRefDiv(SpiritFunctionalState xNewState)
MACRUM 0:615f90842ce8 3009 {
MACRUM 0:615f90842ce8 3010 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 3011
MACRUM 0:615f90842ce8 3012 /* Check the parameters */
MACRUM 0:615f90842ce8 3013 s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(xNewState));
MACRUM 0:615f90842ce8 3014
MACRUM 0:615f90842ce8 3015 /* Reads the SYNTH_CONFIG1_BASE and mask the REFDIV bit field */
MACRUM 0:615f90842ce8 3016 SpiritSpiReadRegisters(SYNTH_CONFIG1_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 3017
MACRUM 0:615f90842ce8 3018 if(xNewState == S_ENABLE)
MACRUM 0:615f90842ce8 3019 {
MACRUM 0:615f90842ce8 3020 tempRegValue |= 0x80;
MACRUM 0:615f90842ce8 3021 }
MACRUM 0:615f90842ce8 3022 else
MACRUM 0:615f90842ce8 3023 {
MACRUM 0:615f90842ce8 3024 tempRegValue &= 0x7F;
MACRUM 0:615f90842ce8 3025 }
MACRUM 0:615f90842ce8 3026
MACRUM 0:615f90842ce8 3027 /* Writes the new value in the SYNTH_CONFIG1_BASE register */
MACRUM 0:615f90842ce8 3028 g_xStatus = SpiritSpiWriteRegisters(SYNTH_CONFIG1_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 3029
MACRUM 0:615f90842ce8 3030 }
MACRUM 0:615f90842ce8 3031
MACRUM 0:615f90842ce8 3032 /**
MACRUM 0:615f90842ce8 3033 * @brief Get the the synthesizer reference divider state.
MACRUM 0:615f90842ce8 3034 * @param void.
MACRUM 0:615f90842ce8 3035 * @retval None.
MACRUM 0:615f90842ce8 3036 */
MACRUM 0:615f90842ce8 3037 SpiritFunctionalState SpiritRadioGetRefDiv(void)
MACRUM 0:615f90842ce8 3038 {
MACRUM 0:615f90842ce8 3039 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 3040
MACRUM 0:615f90842ce8 3041 g_xStatus = SpiritSpiReadRegisters(SYNTH_CONFIG1_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 3042
MACRUM 0:615f90842ce8 3043 if(((tempRegValue>>7)&0x1))
MACRUM 0:615f90842ce8 3044 {
MACRUM 0:615f90842ce8 3045 return S_ENABLE;
MACRUM 0:615f90842ce8 3046 }
MACRUM 0:615f90842ce8 3047 else
MACRUM 0:615f90842ce8 3048 {
MACRUM 0:615f90842ce8 3049 return S_DISABLE;
MACRUM 0:615f90842ce8 3050 }
MACRUM 0:615f90842ce8 3051
MACRUM 0:615f90842ce8 3052 }
MACRUM 0:615f90842ce8 3053
MACRUM 0:615f90842ce8 3054 /**
MACRUM 0:615f90842ce8 3055 * @brief Enables or Disables the synthesizer reference divider.
MACRUM 0:615f90842ce8 3056 * @param xNewState new state for synthesizer reference divider.
MACRUM 0:615f90842ce8 3057 * This parameter can be: S_ENABLE or S_DISABLE .
MACRUM 0:615f90842ce8 3058 * @retval None.
MACRUM 0:615f90842ce8 3059 */
MACRUM 0:615f90842ce8 3060 void SpiritRadioSetDigDiv(SpiritFunctionalState xNewState)
MACRUM 0:615f90842ce8 3061 {
MACRUM 0:615f90842ce8 3062 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 3063
MACRUM 0:615f90842ce8 3064 /* Check the parameters */
MACRUM 0:615f90842ce8 3065 s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(xNewState));
MACRUM 0:615f90842ce8 3066
MACRUM 0:615f90842ce8 3067 /* Reads the XO_RCO_TEST_BASE and mask the PD_CLKDIV bit field */
MACRUM 0:615f90842ce8 3068 SpiritSpiReadRegisters(XO_RCO_TEST_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 3069
MACRUM 0:615f90842ce8 3070 if(xNewState == S_ENABLE)
MACRUM 0:615f90842ce8 3071 {
MACRUM 0:615f90842ce8 3072 tempRegValue &= 0xf7;
MACRUM 0:615f90842ce8 3073 }
MACRUM 0:615f90842ce8 3074 else
MACRUM 0:615f90842ce8 3075 {
MACRUM 0:615f90842ce8 3076
MACRUM 0:615f90842ce8 3077 tempRegValue |= 0x08;
MACRUM 0:615f90842ce8 3078 }
MACRUM 0:615f90842ce8 3079
MACRUM 0:615f90842ce8 3080 /* Writes the new value in the XO_RCO_TEST_BASE register */
MACRUM 0:615f90842ce8 3081 g_xStatus = SpiritSpiWriteRegisters(XO_RCO_TEST_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 3082
MACRUM 0:615f90842ce8 3083 }
MACRUM 0:615f90842ce8 3084
MACRUM 0:615f90842ce8 3085 /**
MACRUM 0:615f90842ce8 3086 * @brief Get the the synthesizer reference divider state.
MACRUM 0:615f90842ce8 3087 * @param void.
MACRUM 0:615f90842ce8 3088 * @retval None.
MACRUM 0:615f90842ce8 3089 */
MACRUM 0:615f90842ce8 3090 SpiritFunctionalState SpiritRadioGetDigDiv(void)
MACRUM 0:615f90842ce8 3091 {
MACRUM 0:615f90842ce8 3092 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 3093
MACRUM 0:615f90842ce8 3094 g_xStatus = SpiritSpiReadRegisters(XO_RCO_TEST_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 3095
MACRUM 0:615f90842ce8 3096 if(((tempRegValue>>3)&0x1))
MACRUM 0:615f90842ce8 3097 {
MACRUM 0:615f90842ce8 3098 return S_DISABLE;
MACRUM 0:615f90842ce8 3099 }
MACRUM 0:615f90842ce8 3100 else
MACRUM 0:615f90842ce8 3101 {
MACRUM 0:615f90842ce8 3102 return S_ENABLE;
MACRUM 0:615f90842ce8 3103 }
MACRUM 0:615f90842ce8 3104
MACRUM 0:615f90842ce8 3105 }
MACRUM 0:615f90842ce8 3106
MACRUM 0:615f90842ce8 3107 /**
MACRUM 0:615f90842ce8 3108 * @brief Returns the XTAL frequency.
MACRUM 0:615f90842ce8 3109 * @param void.
MACRUM 0:615f90842ce8 3110 * @retval uint32_t XTAL frequency.
MACRUM 0:615f90842ce8 3111 */
MACRUM 0:615f90842ce8 3112 uint32_t SpiritRadioGetXtalFrequency(void)
MACRUM 0:615f90842ce8 3113 {
MACRUM 0:615f90842ce8 3114 return s_lXtalFrequency;
MACRUM 0:615f90842ce8 3115 }
MACRUM 0:615f90842ce8 3116
MACRUM 0:615f90842ce8 3117 /**
MACRUM 0:615f90842ce8 3118 * @brief Sets the XTAL frequency.
MACRUM 0:615f90842ce8 3119 * @param uint32_t XTAL frequency.
MACRUM 0:615f90842ce8 3120 * @retval void.
MACRUM 0:615f90842ce8 3121 */
MACRUM 0:615f90842ce8 3122 void SpiritRadioSetXtalFrequency(uint32_t lXtalFrequency)
MACRUM 0:615f90842ce8 3123 {
MACRUM 0:615f90842ce8 3124 s_lXtalFrequency = lXtalFrequency;
MACRUM 0:615f90842ce8 3125 }
MACRUM 0:615f90842ce8 3126
MACRUM 0:615f90842ce8 3127 /**
MACRUM 0:615f90842ce8 3128 * @}
MACRUM 0:615f90842ce8 3129 */
MACRUM 0:615f90842ce8 3130
MACRUM 0:615f90842ce8 3131
MACRUM 0:615f90842ce8 3132 /**
MACRUM 0:615f90842ce8 3133 * @}
MACRUM 0:615f90842ce8 3134 */
MACRUM 0:615f90842ce8 3135
MACRUM 0:615f90842ce8 3136
MACRUM 0:615f90842ce8 3137 /**
MACRUM 0:615f90842ce8 3138 * @}
MACRUM 0:615f90842ce8 3139 */
MACRUM 0:615f90842ce8 3140
MACRUM 0:615f90842ce8 3141
MACRUM 0:615f90842ce8 3142
MACRUM 0:615f90842ce8 3143 /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/
MACRUM 0:615f90842ce8 3144