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