Easily add all supported connectivity methods to your mbed OS project
stm-spirit1-rf-driver/source/libs/spirit1/SPIRIT1_Library/Src/SPIRIT_Qi.c@0:615f90842ce8, 2017-07-12 (annotated)
- Committer:
- MACRUM
- Date:
- Wed Jul 12 10:52:58 2017 +0000
- Revision:
- 0:615f90842ce8
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MACRUM | 0:615f90842ce8 | 1 | /** |
MACRUM | 0:615f90842ce8 | 2 | ****************************************************************************** |
MACRUM | 0:615f90842ce8 | 3 | * @file SPIRIT_Qi.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 Configuration and management of SPIRIT QI. |
MACRUM | 0:615f90842ce8 | 8 | * @details |
MACRUM | 0:615f90842ce8 | 9 | * |
MACRUM | 0:615f90842ce8 | 10 | * @attention |
MACRUM | 0:615f90842ce8 | 11 | * |
MACRUM | 0:615f90842ce8 | 12 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
MACRUM | 0:615f90842ce8 | 13 | * |
MACRUM | 0:615f90842ce8 | 14 | * Redistribution and use in source and binary forms, with or without modification, |
MACRUM | 0:615f90842ce8 | 15 | * are permitted provided that the following conditions are met: |
MACRUM | 0:615f90842ce8 | 16 | * 1. Redistributions of source code must retain the above copyright notice, |
MACRUM | 0:615f90842ce8 | 17 | * this list of conditions and the following disclaimer. |
MACRUM | 0:615f90842ce8 | 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
MACRUM | 0:615f90842ce8 | 19 | * this list of conditions and the following disclaimer in the documentation |
MACRUM | 0:615f90842ce8 | 20 | * and/or other materials provided with the distribution. |
MACRUM | 0:615f90842ce8 | 21 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
MACRUM | 0:615f90842ce8 | 22 | * may be used to endorse or promote products derived from this software |
MACRUM | 0:615f90842ce8 | 23 | * without specific prior written permission. |
MACRUM | 0:615f90842ce8 | 24 | * |
MACRUM | 0:615f90842ce8 | 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
MACRUM | 0:615f90842ce8 | 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
MACRUM | 0:615f90842ce8 | 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
MACRUM | 0:615f90842ce8 | 28 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
MACRUM | 0:615f90842ce8 | 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
MACRUM | 0:615f90842ce8 | 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
MACRUM | 0:615f90842ce8 | 31 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
MACRUM | 0:615f90842ce8 | 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
MACRUM | 0:615f90842ce8 | 33 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
MACRUM | 0:615f90842ce8 | 34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
MACRUM | 0:615f90842ce8 | 35 | * |
MACRUM | 0:615f90842ce8 | 36 | ****************************************************************************** |
MACRUM | 0:615f90842ce8 | 37 | */ |
MACRUM | 0:615f90842ce8 | 38 | |
MACRUM | 0:615f90842ce8 | 39 | /* Includes ------------------------------------------------------------------*/ |
MACRUM | 0:615f90842ce8 | 40 | #include "SPIRIT_Qi.h" |
MACRUM | 0:615f90842ce8 | 41 | #include "MCU_Interface.h" |
MACRUM | 0:615f90842ce8 | 42 | |
MACRUM | 0:615f90842ce8 | 43 | |
MACRUM | 0:615f90842ce8 | 44 | |
MACRUM | 0:615f90842ce8 | 45 | /** |
MACRUM | 0:615f90842ce8 | 46 | * @addtogroup SPIRIT_Libraries |
MACRUM | 0:615f90842ce8 | 47 | * @{ |
MACRUM | 0:615f90842ce8 | 48 | */ |
MACRUM | 0:615f90842ce8 | 49 | |
MACRUM | 0:615f90842ce8 | 50 | |
MACRUM | 0:615f90842ce8 | 51 | /** |
MACRUM | 0:615f90842ce8 | 52 | * @addtogroup SPIRIT_Qi |
MACRUM | 0:615f90842ce8 | 53 | * @{ |
MACRUM | 0:615f90842ce8 | 54 | */ |
MACRUM | 0:615f90842ce8 | 55 | |
MACRUM | 0:615f90842ce8 | 56 | |
MACRUM | 0:615f90842ce8 | 57 | /** |
MACRUM | 0:615f90842ce8 | 58 | * @defgroup Qi_Private_TypesDefinitions QI Private Types Definitions |
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 | |
MACRUM | 0:615f90842ce8 | 66 | |
MACRUM | 0:615f90842ce8 | 67 | /** |
MACRUM | 0:615f90842ce8 | 68 | * @defgroup Qi_Private_Defines QI Private Defines |
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 | /** |
MACRUM | 0:615f90842ce8 | 78 | * @defgroup Qi_Private_Macros QI Private Macros |
MACRUM | 0:615f90842ce8 | 79 | * @{ |
MACRUM | 0:615f90842ce8 | 80 | */ |
MACRUM | 0:615f90842ce8 | 81 | |
MACRUM | 0:615f90842ce8 | 82 | /** |
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 Qi_Private_Variables QI Private Variables |
MACRUM | 0:615f90842ce8 | 89 | * @{ |
MACRUM | 0:615f90842ce8 | 90 | */ |
MACRUM | 0:615f90842ce8 | 91 | |
MACRUM | 0:615f90842ce8 | 92 | /** |
MACRUM | 0:615f90842ce8 | 93 | *@} |
MACRUM | 0:615f90842ce8 | 94 | */ |
MACRUM | 0:615f90842ce8 | 95 | |
MACRUM | 0:615f90842ce8 | 96 | |
MACRUM | 0:615f90842ce8 | 97 | /** |
MACRUM | 0:615f90842ce8 | 98 | * @defgroup Qi_Private_FunctionPrototypes QI Private Function Prototypes |
MACRUM | 0:615f90842ce8 | 99 | * @{ |
MACRUM | 0:615f90842ce8 | 100 | */ |
MACRUM | 0:615f90842ce8 | 101 | |
MACRUM | 0:615f90842ce8 | 102 | /** |
MACRUM | 0:615f90842ce8 | 103 | *@} |
MACRUM | 0:615f90842ce8 | 104 | */ |
MACRUM | 0:615f90842ce8 | 105 | |
MACRUM | 0:615f90842ce8 | 106 | |
MACRUM | 0:615f90842ce8 | 107 | /** |
MACRUM | 0:615f90842ce8 | 108 | * @defgroup Qi_Private_Functions QI Private Functions |
MACRUM | 0:615f90842ce8 | 109 | * @{ |
MACRUM | 0:615f90842ce8 | 110 | */ |
MACRUM | 0:615f90842ce8 | 111 | |
MACRUM | 0:615f90842ce8 | 112 | /** |
MACRUM | 0:615f90842ce8 | 113 | * @brief Enables/Disables the PQI Preamble Quality Indicator check. The running peak PQI is |
MACRUM | 0:615f90842ce8 | 114 | * compared to a threshold value and the preamble valid IRQ is asserted as soon as the threshold is passed. |
MACRUM | 0:615f90842ce8 | 115 | * @param xNewState new state for PQI check. |
MACRUM | 0:615f90842ce8 | 116 | * This parameter can be: S_ENABLE or S_DISABLE. |
MACRUM | 0:615f90842ce8 | 117 | * @retval None. |
MACRUM | 0:615f90842ce8 | 118 | */ |
MACRUM | 0:615f90842ce8 | 119 | void SpiritQiPqiCheck(SpiritFunctionalState xNewState) |
MACRUM | 0:615f90842ce8 | 120 | { |
MACRUM | 0:615f90842ce8 | 121 | uint8_t tempRegValue; |
MACRUM | 0:615f90842ce8 | 122 | |
MACRUM | 0:615f90842ce8 | 123 | /* Check the parameters */ |
MACRUM | 0:615f90842ce8 | 124 | s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(xNewState)); |
MACRUM | 0:615f90842ce8 | 125 | |
MACRUM | 0:615f90842ce8 | 126 | /* Reads the QI register value */ |
MACRUM | 0:615f90842ce8 | 127 | g_xStatus = SpiritSpiReadRegisters(QI_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 128 | |
MACRUM | 0:615f90842ce8 | 129 | /* Enables or disables the PQI Check bit on the QI_BASE register */ |
MACRUM | 0:615f90842ce8 | 130 | if(xNewState == S_ENABLE) |
MACRUM | 0:615f90842ce8 | 131 | { |
MACRUM | 0:615f90842ce8 | 132 | tempRegValue |= QI_PQI_MASK; |
MACRUM | 0:615f90842ce8 | 133 | } |
MACRUM | 0:615f90842ce8 | 134 | else |
MACRUM | 0:615f90842ce8 | 135 | { |
MACRUM | 0:615f90842ce8 | 136 | tempRegValue &= ~QI_PQI_MASK; |
MACRUM | 0:615f90842ce8 | 137 | } |
MACRUM | 0:615f90842ce8 | 138 | |
MACRUM | 0:615f90842ce8 | 139 | /* Writes value on the QI register */ |
MACRUM | 0:615f90842ce8 | 140 | g_xStatus = SpiritSpiWriteRegisters(QI_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 141 | |
MACRUM | 0:615f90842ce8 | 142 | } |
MACRUM | 0:615f90842ce8 | 143 | |
MACRUM | 0:615f90842ce8 | 144 | |
MACRUM | 0:615f90842ce8 | 145 | /** |
MACRUM | 0:615f90842ce8 | 146 | * @brief Enables/Disables the Synchronization Quality Indicator check. The running peak SQI is |
MACRUM | 0:615f90842ce8 | 147 | * compared to a threshold value and the sync valid IRQ is asserted as soon as the threshold is passed. |
MACRUM | 0:615f90842ce8 | 148 | * @param xNewState new state for SQI check. |
MACRUM | 0:615f90842ce8 | 149 | * This parameter can be: S_ENABLE or S_DISABLE. |
MACRUM | 0:615f90842ce8 | 150 | * @retval None. |
MACRUM | 0:615f90842ce8 | 151 | */ |
MACRUM | 0:615f90842ce8 | 152 | void SpiritQiSqiCheck(SpiritFunctionalState xNewState) |
MACRUM | 0:615f90842ce8 | 153 | { |
MACRUM | 0:615f90842ce8 | 154 | uint8_t tempRegValue; |
MACRUM | 0:615f90842ce8 | 155 | |
MACRUM | 0:615f90842ce8 | 156 | /* Check the parameters */ |
MACRUM | 0:615f90842ce8 | 157 | s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(xNewState)); |
MACRUM | 0:615f90842ce8 | 158 | |
MACRUM | 0:615f90842ce8 | 159 | /* Reads the QI register value */ |
MACRUM | 0:615f90842ce8 | 160 | g_xStatus = SpiritSpiReadRegisters(QI_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 161 | |
MACRUM | 0:615f90842ce8 | 162 | /* Enables or disables the SQI Check bit on the QI_BASE register */ |
MACRUM | 0:615f90842ce8 | 163 | if(xNewState == S_ENABLE) |
MACRUM | 0:615f90842ce8 | 164 | { |
MACRUM | 0:615f90842ce8 | 165 | tempRegValue |= QI_SQI_MASK; |
MACRUM | 0:615f90842ce8 | 166 | } |
MACRUM | 0:615f90842ce8 | 167 | else |
MACRUM | 0:615f90842ce8 | 168 | { |
MACRUM | 0:615f90842ce8 | 169 | tempRegValue &= ~QI_SQI_MASK; |
MACRUM | 0:615f90842ce8 | 170 | } |
MACRUM | 0:615f90842ce8 | 171 | |
MACRUM | 0:615f90842ce8 | 172 | /* Writes value on the QI register */ |
MACRUM | 0:615f90842ce8 | 173 | g_xStatus = SpiritSpiWriteRegisters(QI_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 174 | |
MACRUM | 0:615f90842ce8 | 175 | } |
MACRUM | 0:615f90842ce8 | 176 | |
MACRUM | 0:615f90842ce8 | 177 | |
MACRUM | 0:615f90842ce8 | 178 | /** |
MACRUM | 0:615f90842ce8 | 179 | * @brief Sets the PQI threshold. The preamble quality threshold is 4*PQI_TH (PQI_TH = 0..15). |
MACRUM | 0:615f90842ce8 | 180 | * @param xPqiThr parameter of the formula above. |
MACRUM | 0:615f90842ce8 | 181 | * This variable is a @ref PqiThreshold. |
MACRUM | 0:615f90842ce8 | 182 | * @retval None. |
MACRUM | 0:615f90842ce8 | 183 | */ |
MACRUM | 0:615f90842ce8 | 184 | void SpiritQiSetPqiThreshold(PqiThreshold xPqiThr) |
MACRUM | 0:615f90842ce8 | 185 | { |
MACRUM | 0:615f90842ce8 | 186 | uint8_t tempRegValue; |
MACRUM | 0:615f90842ce8 | 187 | |
MACRUM | 0:615f90842ce8 | 188 | /* Check the parameters */ |
MACRUM | 0:615f90842ce8 | 189 | s_assert_param(IS_PQI_THR(xPqiThr)); |
MACRUM | 0:615f90842ce8 | 190 | |
MACRUM | 0:615f90842ce8 | 191 | /* Reads the QI register value */ |
MACRUM | 0:615f90842ce8 | 192 | g_xStatus = SpiritSpiReadRegisters(QI_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 193 | |
MACRUM | 0:615f90842ce8 | 194 | /* Build the PQI threshold value to be written */ |
MACRUM | 0:615f90842ce8 | 195 | tempRegValue &= 0xC3; |
MACRUM | 0:615f90842ce8 | 196 | tempRegValue |= ((uint8_t)xPqiThr); |
MACRUM | 0:615f90842ce8 | 197 | |
MACRUM | 0:615f90842ce8 | 198 | /* Writes value on the QI register */ |
MACRUM | 0:615f90842ce8 | 199 | g_xStatus = SpiritSpiWriteRegisters(QI_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 200 | |
MACRUM | 0:615f90842ce8 | 201 | } |
MACRUM | 0:615f90842ce8 | 202 | |
MACRUM | 0:615f90842ce8 | 203 | |
MACRUM | 0:615f90842ce8 | 204 | /** |
MACRUM | 0:615f90842ce8 | 205 | * @brief Returns the PQI threshold. The preamble quality threshold is 4*PQI_TH (PQI_TH = 0..15). |
MACRUM | 0:615f90842ce8 | 206 | * @param None. |
MACRUM | 0:615f90842ce8 | 207 | * @retval PqiThreshold PQI threshold (PQI_TH of the formula above). |
MACRUM | 0:615f90842ce8 | 208 | */ |
MACRUM | 0:615f90842ce8 | 209 | PqiThreshold SpiritQiGetPqiThreshold(void) |
MACRUM | 0:615f90842ce8 | 210 | { |
MACRUM | 0:615f90842ce8 | 211 | uint8_t tempRegValue; |
MACRUM | 0:615f90842ce8 | 212 | |
MACRUM | 0:615f90842ce8 | 213 | /* Reads the QI register value */ |
MACRUM | 0:615f90842ce8 | 214 | g_xStatus = SpiritSpiReadRegisters(QI_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 215 | |
MACRUM | 0:615f90842ce8 | 216 | /* Rebuild and return the PQI threshold value */ |
MACRUM | 0:615f90842ce8 | 217 | return (PqiThreshold)(tempRegValue & 0x3C); |
MACRUM | 0:615f90842ce8 | 218 | |
MACRUM | 0:615f90842ce8 | 219 | } |
MACRUM | 0:615f90842ce8 | 220 | |
MACRUM | 0:615f90842ce8 | 221 | |
MACRUM | 0:615f90842ce8 | 222 | /** |
MACRUM | 0:615f90842ce8 | 223 | * @brief Sets the SQI threshold. The synchronization quality |
MACRUM | 0:615f90842ce8 | 224 | * threshold is equal to 8 * SYNC_LEN - 2 * SQI_TH with SQI_TH = 0..3. When SQI_TH is 0 perfect match is required; when |
MACRUM | 0:615f90842ce8 | 225 | * SQI_TH = 1, 2, 3 then 1, 2, or 3 bit errors are respectively accepted. It is recommended that the SQI check is always |
MACRUM | 0:615f90842ce8 | 226 | * enabled. |
MACRUM | 0:615f90842ce8 | 227 | * @param xSqiThr parameter of the formula above. |
MACRUM | 0:615f90842ce8 | 228 | * This parameter is a @ref SqiThreshold. |
MACRUM | 0:615f90842ce8 | 229 | * @retval None. |
MACRUM | 0:615f90842ce8 | 230 | */ |
MACRUM | 0:615f90842ce8 | 231 | void SpiritQiSetSqiThreshold(SqiThreshold xSqiThr) |
MACRUM | 0:615f90842ce8 | 232 | { |
MACRUM | 0:615f90842ce8 | 233 | uint8_t tempRegValue; |
MACRUM | 0:615f90842ce8 | 234 | |
MACRUM | 0:615f90842ce8 | 235 | /* Check the parameters */ |
MACRUM | 0:615f90842ce8 | 236 | s_assert_param(IS_SQI_THR(xSqiThr)); |
MACRUM | 0:615f90842ce8 | 237 | |
MACRUM | 0:615f90842ce8 | 238 | /* Reads the QI register value */ |
MACRUM | 0:615f90842ce8 | 239 | g_xStatus = SpiritSpiReadRegisters(QI_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 240 | |
MACRUM | 0:615f90842ce8 | 241 | /* Build the SQI threshold value to be written */ |
MACRUM | 0:615f90842ce8 | 242 | tempRegValue &= 0x3F; |
MACRUM | 0:615f90842ce8 | 243 | tempRegValue |= ((uint8_t)xSqiThr); |
MACRUM | 0:615f90842ce8 | 244 | |
MACRUM | 0:615f90842ce8 | 245 | /* Writes the new value on the QI register */ |
MACRUM | 0:615f90842ce8 | 246 | g_xStatus = SpiritSpiWriteRegisters(QI_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 247 | |
MACRUM | 0:615f90842ce8 | 248 | } |
MACRUM | 0:615f90842ce8 | 249 | |
MACRUM | 0:615f90842ce8 | 250 | |
MACRUM | 0:615f90842ce8 | 251 | /** |
MACRUM | 0:615f90842ce8 | 252 | * @brief Returns the SQI threshold. The synchronization quality threshold is equal to 8 * SYNC_LEN - 2 * SQI_TH with SQI_TH = 0..3. |
MACRUM | 0:615f90842ce8 | 253 | * @param None. |
MACRUM | 0:615f90842ce8 | 254 | * @retval SqiThreshold SQI threshold (SQI_TH of the formula above). |
MACRUM | 0:615f90842ce8 | 255 | */ |
MACRUM | 0:615f90842ce8 | 256 | SqiThreshold SpiritQiGetSqiThreshold(void) |
MACRUM | 0:615f90842ce8 | 257 | { |
MACRUM | 0:615f90842ce8 | 258 | uint8_t tempRegValue; |
MACRUM | 0:615f90842ce8 | 259 | |
MACRUM | 0:615f90842ce8 | 260 | /* Reads the QI register value */ |
MACRUM | 0:615f90842ce8 | 261 | g_xStatus = SpiritSpiReadRegisters(QI_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 262 | |
MACRUM | 0:615f90842ce8 | 263 | /* Rebuild and return the SQI threshold value */ |
MACRUM | 0:615f90842ce8 | 264 | return (SqiThreshold)(tempRegValue & 0xC0); |
MACRUM | 0:615f90842ce8 | 265 | |
MACRUM | 0:615f90842ce8 | 266 | } |
MACRUM | 0:615f90842ce8 | 267 | |
MACRUM | 0:615f90842ce8 | 268 | |
MACRUM | 0:615f90842ce8 | 269 | /** |
MACRUM | 0:615f90842ce8 | 270 | * @brief Returns the PQI value. |
MACRUM | 0:615f90842ce8 | 271 | * @param None. |
MACRUM | 0:615f90842ce8 | 272 | * @retval uint8_t PQI value. |
MACRUM | 0:615f90842ce8 | 273 | */ |
MACRUM | 0:615f90842ce8 | 274 | uint8_t SpiritQiGetPqi(void) |
MACRUM | 0:615f90842ce8 | 275 | { |
MACRUM | 0:615f90842ce8 | 276 | uint8_t tempRegValue; |
MACRUM | 0:615f90842ce8 | 277 | |
MACRUM | 0:615f90842ce8 | 278 | /* Reads the LINK_QUALIF2 register value */ |
MACRUM | 0:615f90842ce8 | 279 | g_xStatus = SpiritSpiReadRegisters(LINK_QUALIF2_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 280 | |
MACRUM | 0:615f90842ce8 | 281 | /* Returns the PQI value */ |
MACRUM | 0:615f90842ce8 | 282 | return tempRegValue; |
MACRUM | 0:615f90842ce8 | 283 | |
MACRUM | 0:615f90842ce8 | 284 | } |
MACRUM | 0:615f90842ce8 | 285 | |
MACRUM | 0:615f90842ce8 | 286 | |
MACRUM | 0:615f90842ce8 | 287 | /** |
MACRUM | 0:615f90842ce8 | 288 | * @brief Returns the SQI value. |
MACRUM | 0:615f90842ce8 | 289 | * @param None. |
MACRUM | 0:615f90842ce8 | 290 | * @retval uint8_t SQI value. |
MACRUM | 0:615f90842ce8 | 291 | */ |
MACRUM | 0:615f90842ce8 | 292 | uint8_t SpiritQiGetSqi(void) |
MACRUM | 0:615f90842ce8 | 293 | { |
MACRUM | 0:615f90842ce8 | 294 | uint8_t tempRegValue; |
MACRUM | 0:615f90842ce8 | 295 | |
MACRUM | 0:615f90842ce8 | 296 | /* Reads the register LINK_QUALIF1 value */ |
MACRUM | 0:615f90842ce8 | 297 | g_xStatus = SpiritSpiReadRegisters(LINK_QUALIF1_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 298 | |
MACRUM | 0:615f90842ce8 | 299 | /* Rebuild and return the SQI value */ |
MACRUM | 0:615f90842ce8 | 300 | return (tempRegValue & 0x7F); |
MACRUM | 0:615f90842ce8 | 301 | |
MACRUM | 0:615f90842ce8 | 302 | } |
MACRUM | 0:615f90842ce8 | 303 | |
MACRUM | 0:615f90842ce8 | 304 | |
MACRUM | 0:615f90842ce8 | 305 | /** |
MACRUM | 0:615f90842ce8 | 306 | * @brief Returns the LQI value. |
MACRUM | 0:615f90842ce8 | 307 | * @param None. |
MACRUM | 0:615f90842ce8 | 308 | * @retval uint8_t LQI value. |
MACRUM | 0:615f90842ce8 | 309 | */ |
MACRUM | 0:615f90842ce8 | 310 | uint8_t SpiritQiGetLqi(void) |
MACRUM | 0:615f90842ce8 | 311 | { |
MACRUM | 0:615f90842ce8 | 312 | uint8_t tempRegValue; |
MACRUM | 0:615f90842ce8 | 313 | |
MACRUM | 0:615f90842ce8 | 314 | /* Reads the LINK_QUALIF0 register value */ |
MACRUM | 0:615f90842ce8 | 315 | g_xStatus = SpiritSpiReadRegisters(LINK_QUALIF0_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 316 | |
MACRUM | 0:615f90842ce8 | 317 | /* Rebuild and return the LQI value */ |
MACRUM | 0:615f90842ce8 | 318 | return ((tempRegValue & 0xF0)>> 4); |
MACRUM | 0:615f90842ce8 | 319 | |
MACRUM | 0:615f90842ce8 | 320 | } |
MACRUM | 0:615f90842ce8 | 321 | |
MACRUM | 0:615f90842ce8 | 322 | |
MACRUM | 0:615f90842ce8 | 323 | /** |
MACRUM | 0:615f90842ce8 | 324 | * @brief Returns the CS status. |
MACRUM | 0:615f90842ce8 | 325 | * @param None. |
MACRUM | 0:615f90842ce8 | 326 | * @retval SpiritFlagStatus CS value (S_SET or S_RESET). |
MACRUM | 0:615f90842ce8 | 327 | */ |
MACRUM | 0:615f90842ce8 | 328 | SpiritFlagStatus SpiritQiGetCs(void) |
MACRUM | 0:615f90842ce8 | 329 | { |
MACRUM | 0:615f90842ce8 | 330 | uint8_t tempRegValue; |
MACRUM | 0:615f90842ce8 | 331 | |
MACRUM | 0:615f90842ce8 | 332 | /* Reads the LINK_QUALIF1 register value */ |
MACRUM | 0:615f90842ce8 | 333 | g_xStatus = SpiritSpiReadRegisters(LINK_QUALIF1_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 334 | |
MACRUM | 0:615f90842ce8 | 335 | /* Rebuild and returns the CS status value */ |
MACRUM | 0:615f90842ce8 | 336 | if((tempRegValue & 0x80) == 0) |
MACRUM | 0:615f90842ce8 | 337 | { |
MACRUM | 0:615f90842ce8 | 338 | return S_RESET; |
MACRUM | 0:615f90842ce8 | 339 | } |
MACRUM | 0:615f90842ce8 | 340 | else |
MACRUM | 0:615f90842ce8 | 341 | { |
MACRUM | 0:615f90842ce8 | 342 | return S_SET; |
MACRUM | 0:615f90842ce8 | 343 | } |
MACRUM | 0:615f90842ce8 | 344 | |
MACRUM | 0:615f90842ce8 | 345 | } |
MACRUM | 0:615f90842ce8 | 346 | |
MACRUM | 0:615f90842ce8 | 347 | |
MACRUM | 0:615f90842ce8 | 348 | /** |
MACRUM | 0:615f90842ce8 | 349 | * @brief Returns the RSSI value. The measured power is reported in steps of half a dB from 0 to 255 and is offset in such a way that -120 dBm corresponds |
MACRUM | 0:615f90842ce8 | 350 | * to 20. |
MACRUM | 0:615f90842ce8 | 351 | * @param None. |
MACRUM | 0:615f90842ce8 | 352 | * @retval uint8_t RSSI value. |
MACRUM | 0:615f90842ce8 | 353 | */ |
MACRUM | 0:615f90842ce8 | 354 | uint8_t SpiritQiGetRssi(void) |
MACRUM | 0:615f90842ce8 | 355 | { |
MACRUM | 0:615f90842ce8 | 356 | uint8_t tempRegValue; |
MACRUM | 0:615f90842ce8 | 357 | |
MACRUM | 0:615f90842ce8 | 358 | /* Reads the RSSI_LEVEL register value */ |
MACRUM | 0:615f90842ce8 | 359 | g_xStatus = SpiritSpiReadRegisters(RSSI_LEVEL_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 360 | |
MACRUM | 0:615f90842ce8 | 361 | /* Returns the RSSI value */ |
MACRUM | 0:615f90842ce8 | 362 | return tempRegValue; |
MACRUM | 0:615f90842ce8 | 363 | |
MACRUM | 0:615f90842ce8 | 364 | } |
MACRUM | 0:615f90842ce8 | 365 | |
MACRUM | 0:615f90842ce8 | 366 | |
MACRUM | 0:615f90842ce8 | 367 | /** |
MACRUM | 0:615f90842ce8 | 368 | * @brief Sets the RSSI threshold. |
MACRUM | 0:615f90842ce8 | 369 | * @param cRssiThr RSSI threshold reported in steps of half a dBm with a -130 dBm offset. |
MACRUM | 0:615f90842ce8 | 370 | * This parameter must be a uint8_t. |
MACRUM | 0:615f90842ce8 | 371 | * @retval None. |
MACRUM | 0:615f90842ce8 | 372 | */ |
MACRUM | 0:615f90842ce8 | 373 | void SpiritQiSetRssiThreshold(uint8_t cRssiThr) |
MACRUM | 0:615f90842ce8 | 374 | { |
MACRUM | 0:615f90842ce8 | 375 | /* Writes the new value on the RSSI_TH register */ |
MACRUM | 0:615f90842ce8 | 376 | g_xStatus = SpiritSpiWriteRegisters(RSSI_TH_BASE, 1, &cRssiThr); |
MACRUM | 0:615f90842ce8 | 377 | |
MACRUM | 0:615f90842ce8 | 378 | } |
MACRUM | 0:615f90842ce8 | 379 | |
MACRUM | 0:615f90842ce8 | 380 | |
MACRUM | 0:615f90842ce8 | 381 | /** |
MACRUM | 0:615f90842ce8 | 382 | * @brief Returns the RSSI threshold. |
MACRUM | 0:615f90842ce8 | 383 | * @param None. |
MACRUM | 0:615f90842ce8 | 384 | * @retval uint8_t RSSI threshold. |
MACRUM | 0:615f90842ce8 | 385 | */ |
MACRUM | 0:615f90842ce8 | 386 | uint8_t SpiritQiGetRssiThreshold(void) |
MACRUM | 0:615f90842ce8 | 387 | { |
MACRUM | 0:615f90842ce8 | 388 | uint8_t tempRegValue; |
MACRUM | 0:615f90842ce8 | 389 | |
MACRUM | 0:615f90842ce8 | 390 | /* Reads the RSSI_TH register value */ |
MACRUM | 0:615f90842ce8 | 391 | g_xStatus = SpiritSpiReadRegisters(RSSI_TH_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 392 | |
MACRUM | 0:615f90842ce8 | 393 | /* Returns RSSI threshold */ |
MACRUM | 0:615f90842ce8 | 394 | return tempRegValue; |
MACRUM | 0:615f90842ce8 | 395 | |
MACRUM | 0:615f90842ce8 | 396 | } |
MACRUM | 0:615f90842ce8 | 397 | |
MACRUM | 0:615f90842ce8 | 398 | |
MACRUM | 0:615f90842ce8 | 399 | /** |
MACRUM | 0:615f90842ce8 | 400 | * @brief Computes the RSSI threshold from its dBm value according to the formula: (RSSI[Dbm] + 130)/0.5 |
MACRUM | 0:615f90842ce8 | 401 | * @param nDbmValue RSSI threshold reported in dBm. |
MACRUM | 0:615f90842ce8 | 402 | * This parameter must be a sint16_t. |
MACRUM | 0:615f90842ce8 | 403 | * @retval uint8_t RSSI threshold corresponding to dBm value. |
MACRUM | 0:615f90842ce8 | 404 | */ |
MACRUM | 0:615f90842ce8 | 405 | uint8_t SpiritQiComputeRssiThreshold(int nDbmValue) |
MACRUM | 0:615f90842ce8 | 406 | { |
MACRUM | 0:615f90842ce8 | 407 | /* Check the parameters */ |
MACRUM | 0:615f90842ce8 | 408 | s_assert_param(IS_RSSI_THR_DBM(nDbmValue)); |
MACRUM | 0:615f90842ce8 | 409 | |
MACRUM | 0:615f90842ce8 | 410 | /* Computes the RSSI threshold for register */ |
MACRUM | 0:615f90842ce8 | 411 | return 2*(nDbmValue+130); |
MACRUM | 0:615f90842ce8 | 412 | |
MACRUM | 0:615f90842ce8 | 413 | } |
MACRUM | 0:615f90842ce8 | 414 | |
MACRUM | 0:615f90842ce8 | 415 | /** |
MACRUM | 0:615f90842ce8 | 416 | * @brief Sets the RSSI threshold from its dBm value according to the formula: (RSSI[Dbm] + 130)/0.5. |
MACRUM | 0:615f90842ce8 | 417 | * @param nDbmValue RSSI threshold reported in dBm. |
MACRUM | 0:615f90842ce8 | 418 | * This parameter must be a sint16_t. |
MACRUM | 0:615f90842ce8 | 419 | * @retval None. |
MACRUM | 0:615f90842ce8 | 420 | */ |
MACRUM | 0:615f90842ce8 | 421 | void SpiritQiSetRssiThresholddBm(int nDbmValue) |
MACRUM | 0:615f90842ce8 | 422 | { |
MACRUM | 0:615f90842ce8 | 423 | uint8_t tempRegValue=2*(nDbmValue+130); |
MACRUM | 0:615f90842ce8 | 424 | |
MACRUM | 0:615f90842ce8 | 425 | /* Check the parameters */ |
MACRUM | 0:615f90842ce8 | 426 | s_assert_param(IS_RSSI_THR_DBM(nDbmValue)); |
MACRUM | 0:615f90842ce8 | 427 | |
MACRUM | 0:615f90842ce8 | 428 | /* Writes the new value on the RSSI_TH register */ |
MACRUM | 0:615f90842ce8 | 429 | g_xStatus = SpiritSpiWriteRegisters(RSSI_TH_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 430 | |
MACRUM | 0:615f90842ce8 | 431 | } |
MACRUM | 0:615f90842ce8 | 432 | |
MACRUM | 0:615f90842ce8 | 433 | /** |
MACRUM | 0:615f90842ce8 | 434 | * @brief Sets the RSSI filter gain. This parameter sets the bandwidth of a low pass IIR filter (RSSI_FLT register, allowed values 0..15), a |
MACRUM | 0:615f90842ce8 | 435 | * lower values gives a faster settling of the measurements but lower precision. The recommended value for such parameter is 14. |
MACRUM | 0:615f90842ce8 | 436 | * @param xRssiFg RSSI filter gain value. |
MACRUM | 0:615f90842ce8 | 437 | * This parameter can be any value of @ref RssiFilterGain. |
MACRUM | 0:615f90842ce8 | 438 | * @retval None. |
MACRUM | 0:615f90842ce8 | 439 | */ |
MACRUM | 0:615f90842ce8 | 440 | void SpiritQiSetRssiFilterGain(RssiFilterGain xRssiFg) |
MACRUM | 0:615f90842ce8 | 441 | { |
MACRUM | 0:615f90842ce8 | 442 | uint8_t tempRegValue; |
MACRUM | 0:615f90842ce8 | 443 | |
MACRUM | 0:615f90842ce8 | 444 | /* Check the parameters */ |
MACRUM | 0:615f90842ce8 | 445 | s_assert_param(IS_RSSI_FILTER_GAIN(xRssiFg)); |
MACRUM | 0:615f90842ce8 | 446 | |
MACRUM | 0:615f90842ce8 | 447 | /* Reads the RSSI_FLT register */ |
MACRUM | 0:615f90842ce8 | 448 | g_xStatus = SpiritSpiReadRegisters(RSSI_FLT_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 449 | |
MACRUM | 0:615f90842ce8 | 450 | /* Sets the specified filter gain */ |
MACRUM | 0:615f90842ce8 | 451 | tempRegValue &= 0x0F; |
MACRUM | 0:615f90842ce8 | 452 | tempRegValue |= ((uint8_t)xRssiFg); |
MACRUM | 0:615f90842ce8 | 453 | |
MACRUM | 0:615f90842ce8 | 454 | /* Writes the new value on the RSSI_FLT register */ |
MACRUM | 0:615f90842ce8 | 455 | g_xStatus = SpiritSpiWriteRegisters(RSSI_FLT_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 456 | |
MACRUM | 0:615f90842ce8 | 457 | } |
MACRUM | 0:615f90842ce8 | 458 | |
MACRUM | 0:615f90842ce8 | 459 | |
MACRUM | 0:615f90842ce8 | 460 | /** |
MACRUM | 0:615f90842ce8 | 461 | * @brief Returns the RSSI filter gain. |
MACRUM | 0:615f90842ce8 | 462 | * @param None. |
MACRUM | 0:615f90842ce8 | 463 | * @retval RssiFilterGain RSSI filter gain. |
MACRUM | 0:615f90842ce8 | 464 | */ |
MACRUM | 0:615f90842ce8 | 465 | RssiFilterGain SpiritQiGetRssiFilterGain(void) |
MACRUM | 0:615f90842ce8 | 466 | { |
MACRUM | 0:615f90842ce8 | 467 | uint8_t tempRegValue; |
MACRUM | 0:615f90842ce8 | 468 | |
MACRUM | 0:615f90842ce8 | 469 | /* Reads the RSSI_FLT register */ |
MACRUM | 0:615f90842ce8 | 470 | g_xStatus = SpiritSpiReadRegisters(RSSI_FLT_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 471 | |
MACRUM | 0:615f90842ce8 | 472 | /* Rebuild and returns the filter gain value */ |
MACRUM | 0:615f90842ce8 | 473 | return (RssiFilterGain)(tempRegValue & 0xF0); |
MACRUM | 0:615f90842ce8 | 474 | |
MACRUM | 0:615f90842ce8 | 475 | } |
MACRUM | 0:615f90842ce8 | 476 | |
MACRUM | 0:615f90842ce8 | 477 | |
MACRUM | 0:615f90842ce8 | 478 | /** |
MACRUM | 0:615f90842ce8 | 479 | * @brief Sets the CS Mode. When static carrier sensing is used (cs_mode = 0), the carrier sense signal is asserted when the measured RSSI is above the |
MACRUM | 0:615f90842ce8 | 480 | * value specified in the RSSI_TH register and is deasserted when the RSSI falls 3 dB below the same threshold. |
MACRUM | 0:615f90842ce8 | 481 | * When dynamic carrier sense is used (cs_mode = 1, 2, 3), the carrier sense signal is asserted if the signal is above the |
MACRUM | 0:615f90842ce8 | 482 | * threshold and a fast power increase of 6, 12 or 18 dB is detected; it is deasserted if a power fall of the same amplitude is |
MACRUM | 0:615f90842ce8 | 483 | * detected. |
MACRUM | 0:615f90842ce8 | 484 | * @param xCsMode CS mode selector. |
MACRUM | 0:615f90842ce8 | 485 | * This parameter can be any value of @ref CSMode. |
MACRUM | 0:615f90842ce8 | 486 | * @retval None. |
MACRUM | 0:615f90842ce8 | 487 | */ |
MACRUM | 0:615f90842ce8 | 488 | void SpiritQiSetCsMode(CSMode xCsMode) |
MACRUM | 0:615f90842ce8 | 489 | { |
MACRUM | 0:615f90842ce8 | 490 | uint8_t tempRegValue; |
MACRUM | 0:615f90842ce8 | 491 | |
MACRUM | 0:615f90842ce8 | 492 | /* Check the parameters */ |
MACRUM | 0:615f90842ce8 | 493 | s_assert_param(IS_CS_MODE(xCsMode)); |
MACRUM | 0:615f90842ce8 | 494 | |
MACRUM | 0:615f90842ce8 | 495 | /* Reads the RSSI_FLT register */ |
MACRUM | 0:615f90842ce8 | 496 | g_xStatus = SpiritSpiReadRegisters(RSSI_FLT_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 497 | |
MACRUM | 0:615f90842ce8 | 498 | /* Sets bit to select the CS mode */ |
MACRUM | 0:615f90842ce8 | 499 | tempRegValue &= ~0x0C; |
MACRUM | 0:615f90842ce8 | 500 | tempRegValue |= ((uint8_t)xCsMode); |
MACRUM | 0:615f90842ce8 | 501 | |
MACRUM | 0:615f90842ce8 | 502 | /* Writes the new value on the RSSI_FLT register */ |
MACRUM | 0:615f90842ce8 | 503 | g_xStatus = SpiritSpiWriteRegisters(RSSI_FLT_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 504 | |
MACRUM | 0:615f90842ce8 | 505 | } |
MACRUM | 0:615f90842ce8 | 506 | |
MACRUM | 0:615f90842ce8 | 507 | |
MACRUM | 0:615f90842ce8 | 508 | /** |
MACRUM | 0:615f90842ce8 | 509 | * @brief Returns the CS Mode. |
MACRUM | 0:615f90842ce8 | 510 | * @param None. |
MACRUM | 0:615f90842ce8 | 511 | * @retval CSMode CS mode. |
MACRUM | 0:615f90842ce8 | 512 | */ |
MACRUM | 0:615f90842ce8 | 513 | CSMode SpiritQiGetCsMode(void) |
MACRUM | 0:615f90842ce8 | 514 | { |
MACRUM | 0:615f90842ce8 | 515 | uint8_t tempRegValue; |
MACRUM | 0:615f90842ce8 | 516 | |
MACRUM | 0:615f90842ce8 | 517 | /* Reads the RSSI_FLT register */ |
MACRUM | 0:615f90842ce8 | 518 | g_xStatus = SpiritSpiReadRegisters(RSSI_FLT_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 519 | |
MACRUM | 0:615f90842ce8 | 520 | /* Rebuild and returns the CS mode value */ |
MACRUM | 0:615f90842ce8 | 521 | return (CSMode)(tempRegValue & 0x0C); |
MACRUM | 0:615f90842ce8 | 522 | |
MACRUM | 0:615f90842ce8 | 523 | } |
MACRUM | 0:615f90842ce8 | 524 | |
MACRUM | 0:615f90842ce8 | 525 | /** |
MACRUM | 0:615f90842ce8 | 526 | * @brief Enables/Disables the CS Timeout Mask. If enabled CS value contributes to timeout disabling. |
MACRUM | 0:615f90842ce8 | 527 | * @param xNewState new state for CS Timeout Mask. |
MACRUM | 0:615f90842ce8 | 528 | * This parameter can be S_ENABLE or S_DISABLE. |
MACRUM | 0:615f90842ce8 | 529 | * @retval None. |
MACRUM | 0:615f90842ce8 | 530 | */ |
MACRUM | 0:615f90842ce8 | 531 | void SpiritQiCsTimeoutMask(SpiritFunctionalState xNewState) |
MACRUM | 0:615f90842ce8 | 532 | { |
MACRUM | 0:615f90842ce8 | 533 | uint8_t tempRegValue; |
MACRUM | 0:615f90842ce8 | 534 | |
MACRUM | 0:615f90842ce8 | 535 | /* Check the parameters */ |
MACRUM | 0:615f90842ce8 | 536 | s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(xNewState)); |
MACRUM | 0:615f90842ce8 | 537 | |
MACRUM | 0:615f90842ce8 | 538 | /* Reads the PROTOCOL2 register value */ |
MACRUM | 0:615f90842ce8 | 539 | g_xStatus = SpiritSpiReadRegisters(PROTOCOL2_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 540 | |
MACRUM | 0:615f90842ce8 | 541 | /* Enables or disables the CS timeout mask */ |
MACRUM | 0:615f90842ce8 | 542 | if(xNewState == S_ENABLE) |
MACRUM | 0:615f90842ce8 | 543 | { |
MACRUM | 0:615f90842ce8 | 544 | tempRegValue |= PROTOCOL2_CS_TIMEOUT_MASK; |
MACRUM | 0:615f90842ce8 | 545 | } |
MACRUM | 0:615f90842ce8 | 546 | else |
MACRUM | 0:615f90842ce8 | 547 | { |
MACRUM | 0:615f90842ce8 | 548 | tempRegValue &= ~PROTOCOL2_CS_TIMEOUT_MASK; |
MACRUM | 0:615f90842ce8 | 549 | } |
MACRUM | 0:615f90842ce8 | 550 | |
MACRUM | 0:615f90842ce8 | 551 | /* Writes the new value on the PROTOCOL2 register */ |
MACRUM | 0:615f90842ce8 | 552 | g_xStatus = SpiritSpiWriteRegisters(PROTOCOL2_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 553 | |
MACRUM | 0:615f90842ce8 | 554 | } |
MACRUM | 0:615f90842ce8 | 555 | |
MACRUM | 0:615f90842ce8 | 556 | |
MACRUM | 0:615f90842ce8 | 557 | /** |
MACRUM | 0:615f90842ce8 | 558 | * @brief Enables/Disables the PQI Timeout Mask. If enabled PQI value contributes to timeout disabling. |
MACRUM | 0:615f90842ce8 | 559 | * @param xNewState new state for PQI Timeout Mask. |
MACRUM | 0:615f90842ce8 | 560 | * This parameter can be S_ENABLE or S_DISABLE. |
MACRUM | 0:615f90842ce8 | 561 | * @retval None. |
MACRUM | 0:615f90842ce8 | 562 | */ |
MACRUM | 0:615f90842ce8 | 563 | void SpiritQiPqiTimeoutMask(SpiritFunctionalState xNewState) |
MACRUM | 0:615f90842ce8 | 564 | { |
MACRUM | 0:615f90842ce8 | 565 | uint8_t tempRegValue; |
MACRUM | 0:615f90842ce8 | 566 | |
MACRUM | 0:615f90842ce8 | 567 | /* Check the parameters */ |
MACRUM | 0:615f90842ce8 | 568 | s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(xNewState)); |
MACRUM | 0:615f90842ce8 | 569 | |
MACRUM | 0:615f90842ce8 | 570 | /* Reads the PROTOCOL2 register */ |
MACRUM | 0:615f90842ce8 | 571 | g_xStatus = SpiritSpiReadRegisters(PROTOCOL2_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 572 | |
MACRUM | 0:615f90842ce8 | 573 | /* Enables or disables the PQI timeout mask */ |
MACRUM | 0:615f90842ce8 | 574 | if(xNewState == S_ENABLE) |
MACRUM | 0:615f90842ce8 | 575 | { |
MACRUM | 0:615f90842ce8 | 576 | tempRegValue |= PROTOCOL2_PQI_TIMEOUT_MASK; |
MACRUM | 0:615f90842ce8 | 577 | } |
MACRUM | 0:615f90842ce8 | 578 | else |
MACRUM | 0:615f90842ce8 | 579 | { |
MACRUM | 0:615f90842ce8 | 580 | tempRegValue &= ~PROTOCOL2_PQI_TIMEOUT_MASK; |
MACRUM | 0:615f90842ce8 | 581 | } |
MACRUM | 0:615f90842ce8 | 582 | |
MACRUM | 0:615f90842ce8 | 583 | /* Writes the new value on the PROTOCOL2 register */ |
MACRUM | 0:615f90842ce8 | 584 | g_xStatus = SpiritSpiWriteRegisters(PROTOCOL2_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 585 | |
MACRUM | 0:615f90842ce8 | 586 | } |
MACRUM | 0:615f90842ce8 | 587 | |
MACRUM | 0:615f90842ce8 | 588 | |
MACRUM | 0:615f90842ce8 | 589 | /** |
MACRUM | 0:615f90842ce8 | 590 | * @brief Enables/Disables the SQI Timeout Mask. If enabled SQI value contributes to timeout disabling. |
MACRUM | 0:615f90842ce8 | 591 | * @param xNewState new state for SQI Timeout Mask. |
MACRUM | 0:615f90842ce8 | 592 | * This parameter can be S_ENABLE or S_DISABLE. |
MACRUM | 0:615f90842ce8 | 593 | * @retval None. |
MACRUM | 0:615f90842ce8 | 594 | */ |
MACRUM | 0:615f90842ce8 | 595 | void SpiritQiSqiTimeoutMask(SpiritFunctionalState xNewState) |
MACRUM | 0:615f90842ce8 | 596 | { |
MACRUM | 0:615f90842ce8 | 597 | uint8_t tempRegValue; |
MACRUM | 0:615f90842ce8 | 598 | |
MACRUM | 0:615f90842ce8 | 599 | /* Check the parameters */ |
MACRUM | 0:615f90842ce8 | 600 | s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(xNewState)); |
MACRUM | 0:615f90842ce8 | 601 | |
MACRUM | 0:615f90842ce8 | 602 | /* Reads the PROTOCOL2 register */ |
MACRUM | 0:615f90842ce8 | 603 | g_xStatus = SpiritSpiReadRegisters(PROTOCOL2_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 604 | |
MACRUM | 0:615f90842ce8 | 605 | /* Enables or disables the SQI timeout mask */ |
MACRUM | 0:615f90842ce8 | 606 | if(xNewState == S_ENABLE) |
MACRUM | 0:615f90842ce8 | 607 | { |
MACRUM | 0:615f90842ce8 | 608 | tempRegValue |= PROTOCOL2_SQI_TIMEOUT_MASK; |
MACRUM | 0:615f90842ce8 | 609 | } |
MACRUM | 0:615f90842ce8 | 610 | else |
MACRUM | 0:615f90842ce8 | 611 | { |
MACRUM | 0:615f90842ce8 | 612 | tempRegValue &= ~PROTOCOL2_SQI_TIMEOUT_MASK; |
MACRUM | 0:615f90842ce8 | 613 | } |
MACRUM | 0:615f90842ce8 | 614 | |
MACRUM | 0:615f90842ce8 | 615 | /* Writes the new value on the PROTOCOL2 register */ |
MACRUM | 0:615f90842ce8 | 616 | g_xStatus = SpiritSpiWriteRegisters(PROTOCOL2_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 617 | |
MACRUM | 0:615f90842ce8 | 618 | } |
MACRUM | 0:615f90842ce8 | 619 | |
MACRUM | 0:615f90842ce8 | 620 | |
MACRUM | 0:615f90842ce8 | 621 | /** |
MACRUM | 0:615f90842ce8 | 622 | *@} |
MACRUM | 0:615f90842ce8 | 623 | */ |
MACRUM | 0:615f90842ce8 | 624 | |
MACRUM | 0:615f90842ce8 | 625 | /** |
MACRUM | 0:615f90842ce8 | 626 | *@} |
MACRUM | 0:615f90842ce8 | 627 | */ |
MACRUM | 0:615f90842ce8 | 628 | |
MACRUM | 0:615f90842ce8 | 629 | |
MACRUM | 0:615f90842ce8 | 630 | /** |
MACRUM | 0:615f90842ce8 | 631 | *@} |
MACRUM | 0:615f90842ce8 | 632 | */ |
MACRUM | 0:615f90842ce8 | 633 | |
MACRUM | 0:615f90842ce8 | 634 | |
MACRUM | 0:615f90842ce8 | 635 | |
MACRUM | 0:615f90842ce8 | 636 | /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/ |