wifi test
Dependencies: X_NUCLEO_IKS01A2 mbed-http
easy-connect/stm-spirit1-rf-driver/source/libs/spirit1/SPIRIT1_Library/Src/SPIRIT_DirectRF.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_DirectRF.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 direct transmission / receive modes. |
| JMF | 0:24d3eb812fd4 | 8 | * @details |
| JMF | 0:24d3eb812fd4 | 9 | * @attention |
| JMF | 0:24d3eb812fd4 | 10 | * |
| JMF | 0:24d3eb812fd4 | 11 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
| JMF | 0:24d3eb812fd4 | 12 | * |
| JMF | 0:24d3eb812fd4 | 13 | * Redistribution and use in source and binary forms, with or without modification, |
| JMF | 0:24d3eb812fd4 | 14 | * are permitted provided that the following conditions are met: |
| JMF | 0:24d3eb812fd4 | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
| JMF | 0:24d3eb812fd4 | 16 | * this list of conditions and the following disclaimer. |
| JMF | 0:24d3eb812fd4 | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| JMF | 0:24d3eb812fd4 | 18 | * this list of conditions and the following disclaimer in the documentation |
| JMF | 0:24d3eb812fd4 | 19 | * and/or other materials provided with the distribution. |
| JMF | 0:24d3eb812fd4 | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
| JMF | 0:24d3eb812fd4 | 21 | * may be used to endorse or promote products derived from this software |
| JMF | 0:24d3eb812fd4 | 22 | * without specific prior written permission. |
| JMF | 0:24d3eb812fd4 | 23 | * |
| JMF | 0:24d3eb812fd4 | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| JMF | 0:24d3eb812fd4 | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| JMF | 0:24d3eb812fd4 | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| JMF | 0:24d3eb812fd4 | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| JMF | 0:24d3eb812fd4 | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| JMF | 0:24d3eb812fd4 | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| JMF | 0:24d3eb812fd4 | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| JMF | 0:24d3eb812fd4 | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| JMF | 0:24d3eb812fd4 | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| JMF | 0:24d3eb812fd4 | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| JMF | 0:24d3eb812fd4 | 34 | * |
| JMF | 0:24d3eb812fd4 | 35 | ****************************************************************************** |
| JMF | 0:24d3eb812fd4 | 36 | */ |
| JMF | 0:24d3eb812fd4 | 37 | |
| JMF | 0:24d3eb812fd4 | 38 | /* Includes ------------------------------------------------------------------*/ |
| JMF | 0:24d3eb812fd4 | 39 | #include "SPIRIT_DirectRF.h" |
| JMF | 0:24d3eb812fd4 | 40 | #include "MCU_Interface.h" |
| JMF | 0:24d3eb812fd4 | 41 | |
| JMF | 0:24d3eb812fd4 | 42 | |
| JMF | 0:24d3eb812fd4 | 43 | |
| JMF | 0:24d3eb812fd4 | 44 | /** |
| JMF | 0:24d3eb812fd4 | 45 | * @addtogroup SPIRIT_Libraries |
| JMF | 0:24d3eb812fd4 | 46 | * @{ |
| JMF | 0:24d3eb812fd4 | 47 | */ |
| JMF | 0:24d3eb812fd4 | 48 | |
| JMF | 0:24d3eb812fd4 | 49 | |
| JMF | 0:24d3eb812fd4 | 50 | /** |
| JMF | 0:24d3eb812fd4 | 51 | * @addtogroup SPIRIT_DirectRf |
| JMF | 0:24d3eb812fd4 | 52 | * @{ |
| JMF | 0:24d3eb812fd4 | 53 | */ |
| JMF | 0:24d3eb812fd4 | 54 | |
| JMF | 0:24d3eb812fd4 | 55 | |
| JMF | 0:24d3eb812fd4 | 56 | /** |
| JMF | 0:24d3eb812fd4 | 57 | * @defgroup DirectRf_Private_TypesDefinitions Direct RF Private Types Definitions |
| JMF | 0:24d3eb812fd4 | 58 | * @{ |
| 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 | * @defgroup DirectRf_Private_Defines Direct RF Private Defines |
| JMF | 0:24d3eb812fd4 | 68 | * @{ |
| 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 | * @defgroup DirectRf_Private_Macros Direct RF Private Macros |
| JMF | 0:24d3eb812fd4 | 78 | * @{ |
| 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 | * @defgroup DirectRf_Private_Variables Direct RF Private Variables |
| JMF | 0:24d3eb812fd4 | 88 | * @{ |
| 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 DirectRf_Private_FunctionPrototypes Direct RF 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 DirectRf_Private_Functions Direct RF Private Functions |
| JMF | 0:24d3eb812fd4 | 109 | * @{ |
| JMF | 0:24d3eb812fd4 | 110 | */ |
| JMF | 0:24d3eb812fd4 | 111 | |
| JMF | 0:24d3eb812fd4 | 112 | /** |
| JMF | 0:24d3eb812fd4 | 113 | * @brief Sets the DirectRF RX mode of SPIRIT. |
| JMF | 0:24d3eb812fd4 | 114 | * @param xDirectRx code of the desired mode. |
| JMF | 0:24d3eb812fd4 | 115 | * This parameter can be any value of @ref DirectRx. |
| JMF | 0:24d3eb812fd4 | 116 | * @retval None. |
| JMF | 0:24d3eb812fd4 | 117 | */ |
| JMF | 0:24d3eb812fd4 | 118 | void SpiritDirectRfSetRxMode(DirectRx xDirectRx) |
| JMF | 0:24d3eb812fd4 | 119 | { |
| JMF | 0:24d3eb812fd4 | 120 | uint8_t tempRegValue; |
| JMF | 0:24d3eb812fd4 | 121 | |
| JMF | 0:24d3eb812fd4 | 122 | /* Check the parameters */ |
| JMF | 0:24d3eb812fd4 | 123 | s_assert_param(IS_DIRECT_RX(xDirectRx)); |
| JMF | 0:24d3eb812fd4 | 124 | |
| JMF | 0:24d3eb812fd4 | 125 | /* Reads the register value */ |
| JMF | 0:24d3eb812fd4 | 126 | SpiritSpiReadRegisters(PCKTCTRL3_BASE, 1, &tempRegValue); |
| JMF | 0:24d3eb812fd4 | 127 | |
| JMF | 0:24d3eb812fd4 | 128 | /* Build the value to be stored */ |
| JMF | 0:24d3eb812fd4 | 129 | tempRegValue &= ~PCKTCTRL3_RX_MODE_MASK; |
| JMF | 0:24d3eb812fd4 | 130 | tempRegValue |= (uint8_t)xDirectRx; |
| JMF | 0:24d3eb812fd4 | 131 | |
| JMF | 0:24d3eb812fd4 | 132 | /* Writes value on register */ |
| JMF | 0:24d3eb812fd4 | 133 | g_xStatus = SpiritSpiWriteRegisters(PCKTCTRL3_BASE, 1, &tempRegValue); |
| JMF | 0:24d3eb812fd4 | 134 | |
| JMF | 0:24d3eb812fd4 | 135 | } |
| JMF | 0:24d3eb812fd4 | 136 | |
| JMF | 0:24d3eb812fd4 | 137 | |
| JMF | 0:24d3eb812fd4 | 138 | /** |
| JMF | 0:24d3eb812fd4 | 139 | * @brief Returns the DirectRF RX mode of SPIRIT. |
| JMF | 0:24d3eb812fd4 | 140 | * @param None. |
| JMF | 0:24d3eb812fd4 | 141 | * @retval DirectRx Direct Rx mode. |
| JMF | 0:24d3eb812fd4 | 142 | */ |
| JMF | 0:24d3eb812fd4 | 143 | DirectRx SpiritDirectRfGetRxMode(void) |
| JMF | 0:24d3eb812fd4 | 144 | { |
| JMF | 0:24d3eb812fd4 | 145 | uint8_t tempRegValue; |
| JMF | 0:24d3eb812fd4 | 146 | |
| JMF | 0:24d3eb812fd4 | 147 | /* Reads the register value and mask the RX_Mode field */ |
| JMF | 0:24d3eb812fd4 | 148 | g_xStatus = SpiritSpiReadRegisters(PCKTCTRL3_BASE, 1, &tempRegValue); |
| JMF | 0:24d3eb812fd4 | 149 | |
| JMF | 0:24d3eb812fd4 | 150 | /* Rebuild and return value */ |
| JMF | 0:24d3eb812fd4 | 151 | return (DirectRx)(tempRegValue & 0x30); |
| JMF | 0:24d3eb812fd4 | 152 | |
| JMF | 0:24d3eb812fd4 | 153 | } |
| JMF | 0:24d3eb812fd4 | 154 | |
| JMF | 0:24d3eb812fd4 | 155 | |
| JMF | 0:24d3eb812fd4 | 156 | /** |
| JMF | 0:24d3eb812fd4 | 157 | * @brief Sets the TX mode of SPIRIT. |
| JMF | 0:24d3eb812fd4 | 158 | * @param xDirectTx code of the desired source. |
| JMF | 0:24d3eb812fd4 | 159 | * This parameter can be any value of @ref DirectTx. |
| JMF | 0:24d3eb812fd4 | 160 | * @retval None. |
| JMF | 0:24d3eb812fd4 | 161 | */ |
| JMF | 0:24d3eb812fd4 | 162 | void SpiritDirectRfSetTxMode(DirectTx xDirectTx) |
| JMF | 0:24d3eb812fd4 | 163 | { |
| JMF | 0:24d3eb812fd4 | 164 | uint8_t tempRegValue; |
| JMF | 0:24d3eb812fd4 | 165 | |
| JMF | 0:24d3eb812fd4 | 166 | /* Check the parameters */ |
| JMF | 0:24d3eb812fd4 | 167 | s_assert_param(IS_DIRECT_TX(xDirectTx)); |
| JMF | 0:24d3eb812fd4 | 168 | |
| JMF | 0:24d3eb812fd4 | 169 | /* Reads the register value */ |
| JMF | 0:24d3eb812fd4 | 170 | SpiritSpiReadRegisters(PCKTCTRL1_BASE, 1, &tempRegValue); |
| JMF | 0:24d3eb812fd4 | 171 | |
| JMF | 0:24d3eb812fd4 | 172 | /* Build the value to be stored */ |
| JMF | 0:24d3eb812fd4 | 173 | tempRegValue &= ~PCKTCTRL1_TX_SOURCE_MASK; |
| JMF | 0:24d3eb812fd4 | 174 | tempRegValue |= (uint8_t)xDirectTx; |
| JMF | 0:24d3eb812fd4 | 175 | |
| JMF | 0:24d3eb812fd4 | 176 | /* Writes value on register */ |
| JMF | 0:24d3eb812fd4 | 177 | g_xStatus = SpiritSpiWriteRegisters(PCKTCTRL1_BASE, 1, &tempRegValue); |
| JMF | 0:24d3eb812fd4 | 178 | |
| JMF | 0:24d3eb812fd4 | 179 | } |
| JMF | 0:24d3eb812fd4 | 180 | |
| JMF | 0:24d3eb812fd4 | 181 | |
| JMF | 0:24d3eb812fd4 | 182 | /** |
| JMF | 0:24d3eb812fd4 | 183 | * @brief Returns the DirectRF TX mode of SPIRIT. |
| JMF | 0:24d3eb812fd4 | 184 | * @param None. |
| JMF | 0:24d3eb812fd4 | 185 | * @retval DirectTx Direct Tx mode. |
| JMF | 0:24d3eb812fd4 | 186 | */ |
| JMF | 0:24d3eb812fd4 | 187 | DirectTx SpiritDirectRfGetTxMode(void) |
| JMF | 0:24d3eb812fd4 | 188 | { |
| JMF | 0:24d3eb812fd4 | 189 | uint8_t tempRegValue; |
| JMF | 0:24d3eb812fd4 | 190 | |
| JMF | 0:24d3eb812fd4 | 191 | /* Reads the register value and mask the RX_Mode field */ |
| JMF | 0:24d3eb812fd4 | 192 | g_xStatus = SpiritSpiReadRegisters(PCKTCTRL1_BASE, 1, &tempRegValue); |
| JMF | 0:24d3eb812fd4 | 193 | |
| JMF | 0:24d3eb812fd4 | 194 | /* Returns value */ |
| JMF | 0:24d3eb812fd4 | 195 | return (DirectTx)(tempRegValue & 0x0C); |
| JMF | 0:24d3eb812fd4 | 196 | |
| JMF | 0:24d3eb812fd4 | 197 | } |
| JMF | 0:24d3eb812fd4 | 198 | |
| JMF | 0:24d3eb812fd4 | 199 | |
| JMF | 0:24d3eb812fd4 | 200 | /** |
| JMF | 0:24d3eb812fd4 | 201 | *@} |
| JMF | 0:24d3eb812fd4 | 202 | */ |
| JMF | 0:24d3eb812fd4 | 203 | |
| JMF | 0:24d3eb812fd4 | 204 | /** |
| JMF | 0:24d3eb812fd4 | 205 | *@} |
| JMF | 0:24d3eb812fd4 | 206 | */ |
| JMF | 0:24d3eb812fd4 | 207 | |
| JMF | 0:24d3eb812fd4 | 208 | |
| JMF | 0:24d3eb812fd4 | 209 | /** |
| JMF | 0:24d3eb812fd4 | 210 | *@} |
| JMF | 0:24d3eb812fd4 | 211 | */ |
| JMF | 0:24d3eb812fd4 | 212 | |
| JMF | 0:24d3eb812fd4 | 213 | |
| JMF | 0:24d3eb812fd4 | 214 | |
| JMF | 0:24d3eb812fd4 | 215 | /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/ |