Prototype RF driver for STM Sub-1 GHz RF expansion board based on the SPSGRF-868 module for STM32 Nucleo.

Prototype RF Driver for STM Sub-1 GHz RF Expansion Boards based on the SPSGRF-868 and SPSGRF-915 Modules for STM32 Nucleo

Currently supported boards:

Note, in order to use expansion board X-NUCLEO-IDS01A4 in mbed you need to perform the following HW modifications on the board:

  • Unmount resistor R4
  • Mount resistor R7

Furthermore, on some Nucleo development boards (e.g. the NUCLEO_F429ZI), in order to be able to use Ethernet together with these Sub-1 GHz RF expansion boards, you need to compile this driver with macro SPIRIT1_SPI_MOSI=PB_5 defined, while the development board typically requires some HW modification as e.g. described here!

This driver can be used together with the 6LoWPAN stack (a.k.a. Nanostack).

Committer:
Wolfgang Betz
Date:
Thu Oct 13 15:41:39 2016 +0200
Revision:
0:4fb29d9ee571
First compiling version (without warnings)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Wolfgang Betz 0:4fb29d9ee571 1 /**
Wolfgang Betz 0:4fb29d9ee571 2 ******************************************************************************
Wolfgang Betz 0:4fb29d9ee571 3 * @file SPIRIT_Calibration.h
Wolfgang Betz 0:4fb29d9ee571 4 * @author VMA division - AMS
Wolfgang Betz 0:4fb29d9ee571 5 * @version 3.2.2
Wolfgang Betz 0:4fb29d9ee571 6 * @date 08-July-2015
Wolfgang Betz 0:4fb29d9ee571 7 * @brief Configuration and management of SPIRIT VCO-RCO calibration.
Wolfgang Betz 0:4fb29d9ee571 8 *
Wolfgang Betz 0:4fb29d9ee571 9 * @details
Wolfgang Betz 0:4fb29d9ee571 10 *
Wolfgang Betz 0:4fb29d9ee571 11 * This module allows the user to set some parameters which deal
Wolfgang Betz 0:4fb29d9ee571 12 * with the oscillators calibration.
Wolfgang Betz 0:4fb29d9ee571 13 * The state machine of Spirit contemplates some optional calibrating operations
Wolfgang Betz 0:4fb29d9ee571 14 * in the transition between the READY and the LOCK state.
Wolfgang Betz 0:4fb29d9ee571 15 * The user is allowed to enable or disable the automatic RCO/VCO calibration
Wolfgang Betz 0:4fb29d9ee571 16 * by calling the functions <i>@ref SpiritCalibrationVco()</i> and <i>@ref SpiritCalibrationRco()</i>.
Wolfgang Betz 0:4fb29d9ee571 17 * The following example shows how to do an initial calibration of VCO.
Wolfgang Betz 0:4fb29d9ee571 18 *
Wolfgang Betz 0:4fb29d9ee571 19 * <b>Example:</b>
Wolfgang Betz 0:4fb29d9ee571 20 * @code
Wolfgang Betz 0:4fb29d9ee571 21 * uint8_t calData;
Wolfgang Betz 0:4fb29d9ee571 22 *
Wolfgang Betz 0:4fb29d9ee571 23 * SpiritCalibrationVco(S_ENABLE);
Wolfgang Betz 0:4fb29d9ee571 24 * SpiritCmdStrobeLockTx();
Wolfgang Betz 0:4fb29d9ee571 25 *
Wolfgang Betz 0:4fb29d9ee571 26 * while(g_xStatus.MC_STATE != MC_STATE_LOCK){
Wolfgang Betz 0:4fb29d9ee571 27 * SpiritRefreshStatus();
Wolfgang Betz 0:4fb29d9ee571 28 * }
Wolfgang Betz 0:4fb29d9ee571 29 *
Wolfgang Betz 0:4fb29d9ee571 30 * calData = SpiritCalibrationGetVcoCalDataTx();
Wolfgang Betz 0:4fb29d9ee571 31 * SpiritCalibrationSetVcoCalDataTx(calData);
Wolfgang Betz 0:4fb29d9ee571 32 *
Wolfgang Betz 0:4fb29d9ee571 33 * SpiritCmdStrobeReady();
Wolfgang Betz 0:4fb29d9ee571 34 * SpiritCalibrationVco(S_DISABLE);
Wolfgang Betz 0:4fb29d9ee571 35 *
Wolfgang Betz 0:4fb29d9ee571 36 * @endcode
Wolfgang Betz 0:4fb29d9ee571 37 *
Wolfgang Betz 0:4fb29d9ee571 38 * Similar operations can be done for the RCO calibrator.
Wolfgang Betz 0:4fb29d9ee571 39 *
Wolfgang Betz 0:4fb29d9ee571 40 * @attention
Wolfgang Betz 0:4fb29d9ee571 41 *
Wolfgang Betz 0:4fb29d9ee571 42 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
Wolfgang Betz 0:4fb29d9ee571 43 *
Wolfgang Betz 0:4fb29d9ee571 44 * Redistribution and use in source and binary forms, with or without modification,
Wolfgang Betz 0:4fb29d9ee571 45 * are permitted provided that the following conditions are met:
Wolfgang Betz 0:4fb29d9ee571 46 * 1. Redistributions of source code must retain the above copyright notice,
Wolfgang Betz 0:4fb29d9ee571 47 * this list of conditions and the following disclaimer.
Wolfgang Betz 0:4fb29d9ee571 48 * 2. Redistributions in binary form must reproduce the above copyright notice,
Wolfgang Betz 0:4fb29d9ee571 49 * this list of conditions and the following disclaimer in the documentation
Wolfgang Betz 0:4fb29d9ee571 50 * and/or other materials provided with the distribution.
Wolfgang Betz 0:4fb29d9ee571 51 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Wolfgang Betz 0:4fb29d9ee571 52 * may be used to endorse or promote products derived from this software
Wolfgang Betz 0:4fb29d9ee571 53 * without specific prior written permission.
Wolfgang Betz 0:4fb29d9ee571 54 *
Wolfgang Betz 0:4fb29d9ee571 55 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Wolfgang Betz 0:4fb29d9ee571 56 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Wolfgang Betz 0:4fb29d9ee571 57 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Wolfgang Betz 0:4fb29d9ee571 58 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Wolfgang Betz 0:4fb29d9ee571 59 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Wolfgang Betz 0:4fb29d9ee571 60 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Wolfgang Betz 0:4fb29d9ee571 61 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Wolfgang Betz 0:4fb29d9ee571 62 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Wolfgang Betz 0:4fb29d9ee571 63 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Wolfgang Betz 0:4fb29d9ee571 64 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Wolfgang Betz 0:4fb29d9ee571 65 *
Wolfgang Betz 0:4fb29d9ee571 66 ******************************************************************************
Wolfgang Betz 0:4fb29d9ee571 67 */
Wolfgang Betz 0:4fb29d9ee571 68
Wolfgang Betz 0:4fb29d9ee571 69 /* Define to prevent recursive inclusion -------------------------------------*/
Wolfgang Betz 0:4fb29d9ee571 70 #ifndef __SPIRIT_CALIBRATION_H
Wolfgang Betz 0:4fb29d9ee571 71 #define __SPIRIT_CALIBRATION_H
Wolfgang Betz 0:4fb29d9ee571 72
Wolfgang Betz 0:4fb29d9ee571 73
Wolfgang Betz 0:4fb29d9ee571 74 /* Includes ------------------------------------------------------------------*/
Wolfgang Betz 0:4fb29d9ee571 75
Wolfgang Betz 0:4fb29d9ee571 76 #include "SPIRIT_Regs.h"
Wolfgang Betz 0:4fb29d9ee571 77 #include "SPIRIT_Types.h"
Wolfgang Betz 0:4fb29d9ee571 78
Wolfgang Betz 0:4fb29d9ee571 79
Wolfgang Betz 0:4fb29d9ee571 80 #ifdef __cplusplus
Wolfgang Betz 0:4fb29d9ee571 81 extern "C" {
Wolfgang Betz 0:4fb29d9ee571 82 #endif
Wolfgang Betz 0:4fb29d9ee571 83
Wolfgang Betz 0:4fb29d9ee571 84
Wolfgang Betz 0:4fb29d9ee571 85 /**
Wolfgang Betz 0:4fb29d9ee571 86 * @addtogroup SPIRIT_Libraries
Wolfgang Betz 0:4fb29d9ee571 87 * @{
Wolfgang Betz 0:4fb29d9ee571 88 */
Wolfgang Betz 0:4fb29d9ee571 89
Wolfgang Betz 0:4fb29d9ee571 90
Wolfgang Betz 0:4fb29d9ee571 91 /**
Wolfgang Betz 0:4fb29d9ee571 92 * @defgroup SPIRIT_Calibration Calibration
Wolfgang Betz 0:4fb29d9ee571 93 * @brief Configuration and management of SPIRIT VCO-RCO calibration.
Wolfgang Betz 0:4fb29d9ee571 94 * @details See the file <i>@ref SPIRIT_Calibration.h</i> for more details.
Wolfgang Betz 0:4fb29d9ee571 95 * @{
Wolfgang Betz 0:4fb29d9ee571 96 */
Wolfgang Betz 0:4fb29d9ee571 97
Wolfgang Betz 0:4fb29d9ee571 98 /**
Wolfgang Betz 0:4fb29d9ee571 99 * @defgroup Calibration_Exported_Types Calibration Exported Types
Wolfgang Betz 0:4fb29d9ee571 100 * @{
Wolfgang Betz 0:4fb29d9ee571 101 */
Wolfgang Betz 0:4fb29d9ee571 102
Wolfgang Betz 0:4fb29d9ee571 103
Wolfgang Betz 0:4fb29d9ee571 104 /**
Wolfgang Betz 0:4fb29d9ee571 105 * @brief VCO / RCO calibration window.
Wolfgang Betz 0:4fb29d9ee571 106 */
Wolfgang Betz 0:4fb29d9ee571 107 typedef enum
Wolfgang Betz 0:4fb29d9ee571 108 {
Wolfgang Betz 0:4fb29d9ee571 109
Wolfgang Betz 0:4fb29d9ee571 110 CALIB_TIME_7_33_US_24MHZ = 0x00, /*!< calibration window of 7.33 us with XTAL=24MHz */
Wolfgang Betz 0:4fb29d9ee571 111 CALIB_TIME_14_67_US_24MHZ, /*!< calibration window of 14.67 us with XTAL=24MHz */
Wolfgang Betz 0:4fb29d9ee571 112 CALIB_TIME_29_33_US_24MHZ, /*!< calibration window of 29.33 us with XTAL=24MHz */
Wolfgang Betz 0:4fb29d9ee571 113 CALIB_TIME_58_67_US_24MHZ, /*!< calibration window of 58.67 us with XTAL=24MHz */
Wolfgang Betz 0:4fb29d9ee571 114
Wolfgang Betz 0:4fb29d9ee571 115 CALIB_TIME_6_77_US_26MHZ = 0x00, /*!< calibration window of 6.77 us with XTAL=26MHz */
Wolfgang Betz 0:4fb29d9ee571 116 CALIB_TIME_13_54_US_26MHZ, /*!< calibration window of 13.54 us with XTAL=26MHz */
Wolfgang Betz 0:4fb29d9ee571 117 CALIB_TIME_27_08_US_26MHZ, /*!< calibration window of 27.08 us with XTAL=26MHz */
Wolfgang Betz 0:4fb29d9ee571 118 CALIB_TIME_54_15_US_26MHZ /*!< calibration window of 54.15 us with XTAL=26MHz */
Wolfgang Betz 0:4fb29d9ee571 119
Wolfgang Betz 0:4fb29d9ee571 120 } VcoWin;
Wolfgang Betz 0:4fb29d9ee571 121
Wolfgang Betz 0:4fb29d9ee571 122
Wolfgang Betz 0:4fb29d9ee571 123 #define IS_VCO_WIN(REF) (REF == CALIB_TIME_7_33_US_24MHZ ||\
Wolfgang Betz 0:4fb29d9ee571 124 REF == CALIB_TIME_14_67_US_24MHZ ||\
Wolfgang Betz 0:4fb29d9ee571 125 REF == CALIB_TIME_29_33_US_24MHZ ||\
Wolfgang Betz 0:4fb29d9ee571 126 REF == CALIB_TIME_58_67_US_24MHZ ||\
Wolfgang Betz 0:4fb29d9ee571 127 REF == CALIB_TIME_6_77_US_26MHZ ||\
Wolfgang Betz 0:4fb29d9ee571 128 REF == CALIB_TIME_13_54_US_26MHZ ||\
Wolfgang Betz 0:4fb29d9ee571 129 REF == CALIB_TIME_27_08_US_26MHZ ||\
Wolfgang Betz 0:4fb29d9ee571 130 REF == CALIB_TIME_54_15_US_26MHZ \
Wolfgang Betz 0:4fb29d9ee571 131 )
Wolfgang Betz 0:4fb29d9ee571 132
Wolfgang Betz 0:4fb29d9ee571 133 /**
Wolfgang Betz 0:4fb29d9ee571 134 * @brief VCO_H / VCO_L selection.
Wolfgang Betz 0:4fb29d9ee571 135 */
Wolfgang Betz 0:4fb29d9ee571 136 typedef enum
Wolfgang Betz 0:4fb29d9ee571 137 {
Wolfgang Betz 0:4fb29d9ee571 138
Wolfgang Betz 0:4fb29d9ee571 139 VCO_L = 0x00, /*!< VCO lower */
Wolfgang Betz 0:4fb29d9ee571 140 VCO_H, /*!< VCO higher */
Wolfgang Betz 0:4fb29d9ee571 141 } VcoSel;
Wolfgang Betz 0:4fb29d9ee571 142
Wolfgang Betz 0:4fb29d9ee571 143
Wolfgang Betz 0:4fb29d9ee571 144 #define IS_VCO_SEL(REF) (REF == VCO_L ||\
Wolfgang Betz 0:4fb29d9ee571 145 REF == VCO_H \
Wolfgang Betz 0:4fb29d9ee571 146 )
Wolfgang Betz 0:4fb29d9ee571 147
Wolfgang Betz 0:4fb29d9ee571 148
Wolfgang Betz 0:4fb29d9ee571 149 /**
Wolfgang Betz 0:4fb29d9ee571 150 * @}
Wolfgang Betz 0:4fb29d9ee571 151 */
Wolfgang Betz 0:4fb29d9ee571 152
Wolfgang Betz 0:4fb29d9ee571 153
Wolfgang Betz 0:4fb29d9ee571 154 /**
Wolfgang Betz 0:4fb29d9ee571 155 * @defgroup Calibration_Exported_Constants Calibration Exported Constants
Wolfgang Betz 0:4fb29d9ee571 156 * @{
Wolfgang Betz 0:4fb29d9ee571 157 */
Wolfgang Betz 0:4fb29d9ee571 158
Wolfgang Betz 0:4fb29d9ee571 159 /**
Wolfgang Betz 0:4fb29d9ee571 160 * @}
Wolfgang Betz 0:4fb29d9ee571 161 */
Wolfgang Betz 0:4fb29d9ee571 162
Wolfgang Betz 0:4fb29d9ee571 163
Wolfgang Betz 0:4fb29d9ee571 164
Wolfgang Betz 0:4fb29d9ee571 165 /** @defgroup VCO_Calibration VCO Calibration
Wolfgang Betz 0:4fb29d9ee571 166 * @{
Wolfgang Betz 0:4fb29d9ee571 167 */
Wolfgang Betz 0:4fb29d9ee571 168
Wolfgang Betz 0:4fb29d9ee571 169 /**
Wolfgang Betz 0:4fb29d9ee571 170 * @}
Wolfgang Betz 0:4fb29d9ee571 171 */
Wolfgang Betz 0:4fb29d9ee571 172
Wolfgang Betz 0:4fb29d9ee571 173
Wolfgang Betz 0:4fb29d9ee571 174
Wolfgang Betz 0:4fb29d9ee571 175
Wolfgang Betz 0:4fb29d9ee571 176 /**
Wolfgang Betz 0:4fb29d9ee571 177 * @defgroup Calibration_Exported_Macros Calibration Exported Macros
Wolfgang Betz 0:4fb29d9ee571 178 * @{
Wolfgang Betz 0:4fb29d9ee571 179 */
Wolfgang Betz 0:4fb29d9ee571 180
Wolfgang Betz 0:4fb29d9ee571 181
Wolfgang Betz 0:4fb29d9ee571 182 /**
Wolfgang Betz 0:4fb29d9ee571 183 * @}
Wolfgang Betz 0:4fb29d9ee571 184 */
Wolfgang Betz 0:4fb29d9ee571 185
Wolfgang Betz 0:4fb29d9ee571 186
Wolfgang Betz 0:4fb29d9ee571 187 /**
Wolfgang Betz 0:4fb29d9ee571 188 * @defgroup Calibration_Exported_Functions Calibration Exported Functions
Wolfgang Betz 0:4fb29d9ee571 189 * @{
Wolfgang Betz 0:4fb29d9ee571 190 */
Wolfgang Betz 0:4fb29d9ee571 191
Wolfgang Betz 0:4fb29d9ee571 192 void SpiritCalibrationRco(SpiritFunctionalState xNewState);
Wolfgang Betz 0:4fb29d9ee571 193 void SpiritCalibrationVco(SpiritFunctionalState xNewState);
Wolfgang Betz 0:4fb29d9ee571 194 void SpiritCalibrationSetRcoCalWords(uint8_t cRwt, uint8_t cRfb);
Wolfgang Betz 0:4fb29d9ee571 195 void SpiritCalibrationGetRcoCalWords(uint8_t* pcRwt, uint8_t* pcRfb);
Wolfgang Betz 0:4fb29d9ee571 196 uint8_t SpiritCalibrationGetVcoCalData(void);
Wolfgang Betz 0:4fb29d9ee571 197 void SpiritCalibrationSetVcoCalDataTx(uint8_t cVcoCalData);
Wolfgang Betz 0:4fb29d9ee571 198 uint8_t SpiritCalibrationGetVcoCalDataTx(void);
Wolfgang Betz 0:4fb29d9ee571 199 void SpiritCalibrationSetVcoCalDataRx(uint8_t cVcoCalData);
Wolfgang Betz 0:4fb29d9ee571 200 uint8_t SpiritCalibrationGetVcoCalDataRx(void);
Wolfgang Betz 0:4fb29d9ee571 201 void SpiritCalibrationSetVcoWindow(VcoWin xRefWord);
Wolfgang Betz 0:4fb29d9ee571 202 VcoWin SpiritCalibrationGetVcoWindow(void);
Wolfgang Betz 0:4fb29d9ee571 203 VcoSel SpiritCalibrationGetVcoSelecttion(void);
Wolfgang Betz 0:4fb29d9ee571 204 void SpiritCalibrationSelectVco(VcoSel xVco);
Wolfgang Betz 0:4fb29d9ee571 205
Wolfgang Betz 0:4fb29d9ee571 206 /**
Wolfgang Betz 0:4fb29d9ee571 207 * @}
Wolfgang Betz 0:4fb29d9ee571 208 */
Wolfgang Betz 0:4fb29d9ee571 209
Wolfgang Betz 0:4fb29d9ee571 210
Wolfgang Betz 0:4fb29d9ee571 211 /**
Wolfgang Betz 0:4fb29d9ee571 212 * @}
Wolfgang Betz 0:4fb29d9ee571 213 */
Wolfgang Betz 0:4fb29d9ee571 214
Wolfgang Betz 0:4fb29d9ee571 215
Wolfgang Betz 0:4fb29d9ee571 216 /**
Wolfgang Betz 0:4fb29d9ee571 217 * @}
Wolfgang Betz 0:4fb29d9ee571 218 */
Wolfgang Betz 0:4fb29d9ee571 219
Wolfgang Betz 0:4fb29d9ee571 220 #ifdef __cplusplus
Wolfgang Betz 0:4fb29d9ee571 221 }
Wolfgang Betz 0:4fb29d9ee571 222 #endif
Wolfgang Betz 0:4fb29d9ee571 223
Wolfgang Betz 0:4fb29d9ee571 224 #endif
Wolfgang Betz 0:4fb29d9ee571 225
Wolfgang Betz 0:4fb29d9ee571 226 /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/