Easily add all supported connectivity methods to your mbed OS project
stm-spirit1-rf-driver/source/libs/spirit1/SPIRIT1_Library/Src/SPIRIT_LinearFifo.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_LinearFifo.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 Fifo. |
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_LinearFifo.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 | * @addtogroup SPIRIT_Libraries |
MACRUM | 0:615f90842ce8 | 46 | * @{ |
MACRUM | 0:615f90842ce8 | 47 | */ |
MACRUM | 0:615f90842ce8 | 48 | |
MACRUM | 0:615f90842ce8 | 49 | |
MACRUM | 0:615f90842ce8 | 50 | /** |
MACRUM | 0:615f90842ce8 | 51 | * @addtogroup SPIRIT_LinearFifo |
MACRUM | 0:615f90842ce8 | 52 | * @{ |
MACRUM | 0:615f90842ce8 | 53 | */ |
MACRUM | 0:615f90842ce8 | 54 | |
MACRUM | 0:615f90842ce8 | 55 | |
MACRUM | 0:615f90842ce8 | 56 | /** |
MACRUM | 0:615f90842ce8 | 57 | * @defgroup LinearFifo_Private_TypesDefinitions Linear FIFO Private Types Definitions |
MACRUM | 0:615f90842ce8 | 58 | * @{ |
MACRUM | 0:615f90842ce8 | 59 | */ |
MACRUM | 0:615f90842ce8 | 60 | |
MACRUM | 0:615f90842ce8 | 61 | /** |
MACRUM | 0:615f90842ce8 | 62 | *@} |
MACRUM | 0:615f90842ce8 | 63 | */ |
MACRUM | 0:615f90842ce8 | 64 | |
MACRUM | 0:615f90842ce8 | 65 | |
MACRUM | 0:615f90842ce8 | 66 | /** |
MACRUM | 0:615f90842ce8 | 67 | * @defgroup LinearFifo_Private_Defines Linear FIFO Private Defines |
MACRUM | 0:615f90842ce8 | 68 | * @{ |
MACRUM | 0:615f90842ce8 | 69 | */ |
MACRUM | 0:615f90842ce8 | 70 | |
MACRUM | 0:615f90842ce8 | 71 | /** |
MACRUM | 0:615f90842ce8 | 72 | *@} |
MACRUM | 0:615f90842ce8 | 73 | */ |
MACRUM | 0:615f90842ce8 | 74 | |
MACRUM | 0:615f90842ce8 | 75 | |
MACRUM | 0:615f90842ce8 | 76 | /** |
MACRUM | 0:615f90842ce8 | 77 | * @defgroup LinearFifo_Private_Macros Linear FIFO Private Macros |
MACRUM | 0:615f90842ce8 | 78 | * @{ |
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 | * @defgroup LinearFifo_Private_Variables Linear FIFO Private Variables |
MACRUM | 0:615f90842ce8 | 88 | * @{ |
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 | * @defgroup LinearFifo_Private_FunctionPrototypes Linear FIFO Private Function Prototypes |
MACRUM | 0:615f90842ce8 | 98 | * @{ |
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 | * @defgroup LinearFifo_Private_Functions Linear FIFO Private Functions |
MACRUM | 0:615f90842ce8 | 108 | * @{ |
MACRUM | 0:615f90842ce8 | 109 | */ |
MACRUM | 0:615f90842ce8 | 110 | |
MACRUM | 0:615f90842ce8 | 111 | /** |
MACRUM | 0:615f90842ce8 | 112 | * @brief Returns the number of elements in the Rx FIFO. |
MACRUM | 0:615f90842ce8 | 113 | * @param None. |
MACRUM | 0:615f90842ce8 | 114 | * @retval uint8_t Number of elements in the Rx FIFO. |
MACRUM | 0:615f90842ce8 | 115 | */ |
MACRUM | 0:615f90842ce8 | 116 | uint8_t SpiritLinearFifoReadNumElementsRxFifo(void) |
MACRUM | 0:615f90842ce8 | 117 | { |
MACRUM | 0:615f90842ce8 | 118 | uint8_t tempRegValue; |
MACRUM | 0:615f90842ce8 | 119 | |
MACRUM | 0:615f90842ce8 | 120 | /* Reads the register value */ |
MACRUM | 0:615f90842ce8 | 121 | g_xStatus = SpiritSpiReadRegisters(LINEAR_FIFO_STATUS0_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 122 | |
MACRUM | 0:615f90842ce8 | 123 | /* Build and return value */ |
MACRUM | 0:615f90842ce8 | 124 | return (tempRegValue & 0x7F); |
MACRUM | 0:615f90842ce8 | 125 | |
MACRUM | 0:615f90842ce8 | 126 | } |
MACRUM | 0:615f90842ce8 | 127 | |
MACRUM | 0:615f90842ce8 | 128 | |
MACRUM | 0:615f90842ce8 | 129 | /** |
MACRUM | 0:615f90842ce8 | 130 | * @brief Returns the number of elements in the Tx FIFO. |
MACRUM | 0:615f90842ce8 | 131 | * @param None. |
MACRUM | 0:615f90842ce8 | 132 | * @retval uint8_t Number of elements in the Tx FIFO. |
MACRUM | 0:615f90842ce8 | 133 | */ |
MACRUM | 0:615f90842ce8 | 134 | uint8_t SpiritLinearFifoReadNumElementsTxFifo(void) |
MACRUM | 0:615f90842ce8 | 135 | { |
MACRUM | 0:615f90842ce8 | 136 | uint8_t tempRegValue; |
MACRUM | 0:615f90842ce8 | 137 | |
MACRUM | 0:615f90842ce8 | 138 | /* Reads the number of elements in TX FIFO and return the value */ |
MACRUM | 0:615f90842ce8 | 139 | g_xStatus = SpiritSpiReadRegisters(LINEAR_FIFO_STATUS1_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 140 | |
MACRUM | 0:615f90842ce8 | 141 | /* Build and return value */ |
MACRUM | 0:615f90842ce8 | 142 | return (tempRegValue & 0x7F); |
MACRUM | 0:615f90842ce8 | 143 | } |
MACRUM | 0:615f90842ce8 | 144 | |
MACRUM | 0:615f90842ce8 | 145 | |
MACRUM | 0:615f90842ce8 | 146 | /** |
MACRUM | 0:615f90842ce8 | 147 | * @brief Sets the almost full threshold for the Rx FIFO. When the number of elements in RX FIFO reaches this value an interrupt can be generated to the MCU. |
MACRUM | 0:615f90842ce8 | 148 | * @note The almost full threshold is encountered from the top of the FIFO. For example, if it is set to 7 the almost |
MACRUM | 0:615f90842ce8 | 149 | * full FIFO irq will be raised when the number of elements is equals to 96-7 = 89. |
MACRUM | 0:615f90842ce8 | 150 | * @param cThrRxFifo almost full threshold. |
MACRUM | 0:615f90842ce8 | 151 | * This parameter is an uint8_t. |
MACRUM | 0:615f90842ce8 | 152 | * @retval None. |
MACRUM | 0:615f90842ce8 | 153 | */ |
MACRUM | 0:615f90842ce8 | 154 | void SpiritLinearFifoSetAlmostFullThresholdRx(uint8_t cThrRxFifo) |
MACRUM | 0:615f90842ce8 | 155 | { |
MACRUM | 0:615f90842ce8 | 156 | uint8_t tempRegValue; |
MACRUM | 0:615f90842ce8 | 157 | |
MACRUM | 0:615f90842ce8 | 158 | /* Check the parameters */ |
MACRUM | 0:615f90842ce8 | 159 | s_assert_param(IS_FIFO_THR(cThrRxFifo)); |
MACRUM | 0:615f90842ce8 | 160 | |
MACRUM | 0:615f90842ce8 | 161 | /* Build the register value */ |
MACRUM | 0:615f90842ce8 | 162 | tempRegValue = cThrRxFifo & 0x7F; |
MACRUM | 0:615f90842ce8 | 163 | |
MACRUM | 0:615f90842ce8 | 164 | /* Writes the Almost Full threshold for RX in the corresponding register */ |
MACRUM | 0:615f90842ce8 | 165 | g_xStatus = SpiritSpiWriteRegisters(FIFO_CONFIG3_RXAFTHR_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 166 | |
MACRUM | 0:615f90842ce8 | 167 | } |
MACRUM | 0:615f90842ce8 | 168 | |
MACRUM | 0:615f90842ce8 | 169 | |
MACRUM | 0:615f90842ce8 | 170 | /** |
MACRUM | 0:615f90842ce8 | 171 | * @brief Returns the almost full threshold for RX FIFO. |
MACRUM | 0:615f90842ce8 | 172 | * @note The almost full threshold is encountered from the top of the FIFO. For example, if it is 7 the almost |
MACRUM | 0:615f90842ce8 | 173 | * full FIFO irq will be raised when the number of elements is equals to 96-7 = 89. |
MACRUM | 0:615f90842ce8 | 174 | * @param None. |
MACRUM | 0:615f90842ce8 | 175 | * @retval uint8_t Almost full threshold for Rx FIFO. |
MACRUM | 0:615f90842ce8 | 176 | */ |
MACRUM | 0:615f90842ce8 | 177 | uint8_t SpiritLinearFifoGetAlmostFullThresholdRx(void) |
MACRUM | 0:615f90842ce8 | 178 | { |
MACRUM | 0:615f90842ce8 | 179 | uint8_t tempRegValue; |
MACRUM | 0:615f90842ce8 | 180 | |
MACRUM | 0:615f90842ce8 | 181 | /* Reads the almost full threshold for RX FIFO and return the value */ |
MACRUM | 0:615f90842ce8 | 182 | g_xStatus = SpiritSpiReadRegisters(FIFO_CONFIG3_RXAFTHR_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 183 | |
MACRUM | 0:615f90842ce8 | 184 | /* Build and return value */ |
MACRUM | 0:615f90842ce8 | 185 | return (tempRegValue & 0x7F); |
MACRUM | 0:615f90842ce8 | 186 | |
MACRUM | 0:615f90842ce8 | 187 | } |
MACRUM | 0:615f90842ce8 | 188 | |
MACRUM | 0:615f90842ce8 | 189 | |
MACRUM | 0:615f90842ce8 | 190 | /** |
MACRUM | 0:615f90842ce8 | 191 | * @brief Sets the almost empty threshold for the Rx FIFO. When the number of elements in RX FIFO reaches this value an interrupt can be generated to the MCU. |
MACRUM | 0:615f90842ce8 | 192 | * @param cThrRxFifo almost empty threshold. |
MACRUM | 0:615f90842ce8 | 193 | * This parameter is an uint8_t. |
MACRUM | 0:615f90842ce8 | 194 | * @retval None. |
MACRUM | 0:615f90842ce8 | 195 | */ |
MACRUM | 0:615f90842ce8 | 196 | void SpiritLinearFifoSetAlmostEmptyThresholdRx(uint8_t cThrRxFifo) |
MACRUM | 0:615f90842ce8 | 197 | { |
MACRUM | 0:615f90842ce8 | 198 | uint8_t tempRegValue; |
MACRUM | 0:615f90842ce8 | 199 | |
MACRUM | 0:615f90842ce8 | 200 | /* Check the parameters */ |
MACRUM | 0:615f90842ce8 | 201 | s_assert_param(IS_FIFO_THR(cThrRxFifo)); |
MACRUM | 0:615f90842ce8 | 202 | |
MACRUM | 0:615f90842ce8 | 203 | /* Build the register value */ |
MACRUM | 0:615f90842ce8 | 204 | tempRegValue = cThrRxFifo & 0x7F; |
MACRUM | 0:615f90842ce8 | 205 | |
MACRUM | 0:615f90842ce8 | 206 | /* Writes the Almost Empty threshold for RX in the corresponding register */ |
MACRUM | 0:615f90842ce8 | 207 | g_xStatus = SpiritSpiWriteRegisters(FIFO_CONFIG2_RXAETHR_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 208 | |
MACRUM | 0:615f90842ce8 | 209 | } |
MACRUM | 0:615f90842ce8 | 210 | |
MACRUM | 0:615f90842ce8 | 211 | |
MACRUM | 0:615f90842ce8 | 212 | /** |
MACRUM | 0:615f90842ce8 | 213 | * @brief Returns the almost empty threshold for Rx FIFO. |
MACRUM | 0:615f90842ce8 | 214 | * @param None. |
MACRUM | 0:615f90842ce8 | 215 | * @retval uint8_t Almost empty threshold for Rx FIFO. |
MACRUM | 0:615f90842ce8 | 216 | */ |
MACRUM | 0:615f90842ce8 | 217 | uint8_t SpiritLinearFifoGetAlmostEmptyThresholdRx(void) |
MACRUM | 0:615f90842ce8 | 218 | { |
MACRUM | 0:615f90842ce8 | 219 | uint8_t tempRegValue; |
MACRUM | 0:615f90842ce8 | 220 | |
MACRUM | 0:615f90842ce8 | 221 | /* Reads the almost empty threshold for RX FIFO and returns the value */ |
MACRUM | 0:615f90842ce8 | 222 | g_xStatus = SpiritSpiReadRegisters(FIFO_CONFIG2_RXAETHR_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 223 | |
MACRUM | 0:615f90842ce8 | 224 | /* Build and return value */ |
MACRUM | 0:615f90842ce8 | 225 | return (tempRegValue & 0x7F); |
MACRUM | 0:615f90842ce8 | 226 | |
MACRUM | 0:615f90842ce8 | 227 | } |
MACRUM | 0:615f90842ce8 | 228 | |
MACRUM | 0:615f90842ce8 | 229 | |
MACRUM | 0:615f90842ce8 | 230 | /** |
MACRUM | 0:615f90842ce8 | 231 | * @brief Sets the almost full threshold for the Tx FIFO. When the number of elements in TX FIFO reaches this value an interrupt can be generated to the MCU. |
MACRUM | 0:615f90842ce8 | 232 | * @note The almost full threshold is encountered from the top of the FIFO. For example, if it is set to 7 the almost |
MACRUM | 0:615f90842ce8 | 233 | * full FIFO irq will be raised when the number of elements is equals to 96-7 = 89. |
MACRUM | 0:615f90842ce8 | 234 | * @param cThrTxFifo almost full threshold. |
MACRUM | 0:615f90842ce8 | 235 | * This parameter is an uint8_t. |
MACRUM | 0:615f90842ce8 | 236 | * @retval None. |
MACRUM | 0:615f90842ce8 | 237 | */ |
MACRUM | 0:615f90842ce8 | 238 | void SpiritLinearFifoSetAlmostFullThresholdTx(uint8_t cThrTxFifo) |
MACRUM | 0:615f90842ce8 | 239 | { |
MACRUM | 0:615f90842ce8 | 240 | uint8_t tempRegValue; |
MACRUM | 0:615f90842ce8 | 241 | |
MACRUM | 0:615f90842ce8 | 242 | /* Check the parameters */ |
MACRUM | 0:615f90842ce8 | 243 | s_assert_param(IS_FIFO_THR(cThrTxFifo)); |
MACRUM | 0:615f90842ce8 | 244 | |
MACRUM | 0:615f90842ce8 | 245 | /* Reads the register value */ |
MACRUM | 0:615f90842ce8 | 246 | g_xStatus = SpiritSpiReadRegisters(FIFO_CONFIG1_TXAFTHR_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 247 | |
MACRUM | 0:615f90842ce8 | 248 | /* Build the register value */ |
MACRUM | 0:615f90842ce8 | 249 | tempRegValue &= 0x80; |
MACRUM | 0:615f90842ce8 | 250 | tempRegValue |= cThrTxFifo; |
MACRUM | 0:615f90842ce8 | 251 | |
MACRUM | 0:615f90842ce8 | 252 | /* Writes the Almost Full threshold for Tx in the corresponding register */ |
MACRUM | 0:615f90842ce8 | 253 | g_xStatus = SpiritSpiWriteRegisters(FIFO_CONFIG1_TXAFTHR_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 254 | |
MACRUM | 0:615f90842ce8 | 255 | } |
MACRUM | 0:615f90842ce8 | 256 | |
MACRUM | 0:615f90842ce8 | 257 | |
MACRUM | 0:615f90842ce8 | 258 | /** |
MACRUM | 0:615f90842ce8 | 259 | * @brief Returns the almost full threshold for Tx FIFO. |
MACRUM | 0:615f90842ce8 | 260 | * @note The almost full threshold is encountered from the top of the FIFO. For example, if it is set to 7 the almost |
MACRUM | 0:615f90842ce8 | 261 | * full FIFO irq will be raised when the number of elements is equals to 96-7 = 89. |
MACRUM | 0:615f90842ce8 | 262 | * @param None. |
MACRUM | 0:615f90842ce8 | 263 | * @retval uint8_t Almost full threshold for Tx FIFO. |
MACRUM | 0:615f90842ce8 | 264 | */ |
MACRUM | 0:615f90842ce8 | 265 | uint8_t SpiritLinearFifoGetAlmostFullThresholdTx(void) |
MACRUM | 0:615f90842ce8 | 266 | { |
MACRUM | 0:615f90842ce8 | 267 | uint8_t tempRegValue; |
MACRUM | 0:615f90842ce8 | 268 | |
MACRUM | 0:615f90842ce8 | 269 | /* Reads the almost full threshold for Tx FIFO and returns the value */ |
MACRUM | 0:615f90842ce8 | 270 | g_xStatus = SpiritSpiReadRegisters(FIFO_CONFIG1_TXAFTHR_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 271 | |
MACRUM | 0:615f90842ce8 | 272 | /* Build and returns value */ |
MACRUM | 0:615f90842ce8 | 273 | return (tempRegValue & 0x7F); |
MACRUM | 0:615f90842ce8 | 274 | |
MACRUM | 0:615f90842ce8 | 275 | } |
MACRUM | 0:615f90842ce8 | 276 | |
MACRUM | 0:615f90842ce8 | 277 | |
MACRUM | 0:615f90842ce8 | 278 | /** |
MACRUM | 0:615f90842ce8 | 279 | * @brief Sets the almost empty threshold for the Tx FIFO. When the number of elements in Tx FIFO reaches this value an interrupt can can be generated to the MCU. |
MACRUM | 0:615f90842ce8 | 280 | * @param cThrTxFifo: almost empty threshold. |
MACRUM | 0:615f90842ce8 | 281 | * This parameter is an uint8_t. |
MACRUM | 0:615f90842ce8 | 282 | * @retval None. |
MACRUM | 0:615f90842ce8 | 283 | */ |
MACRUM | 0:615f90842ce8 | 284 | void SpiritLinearFifoSetAlmostEmptyThresholdTx(uint8_t cThrTxFifo) |
MACRUM | 0:615f90842ce8 | 285 | { |
MACRUM | 0:615f90842ce8 | 286 | uint8_t tempRegValue; |
MACRUM | 0:615f90842ce8 | 287 | |
MACRUM | 0:615f90842ce8 | 288 | /* Check the parameters */ |
MACRUM | 0:615f90842ce8 | 289 | s_assert_param(IS_FIFO_THR(cThrTxFifo)); |
MACRUM | 0:615f90842ce8 | 290 | |
MACRUM | 0:615f90842ce8 | 291 | /* Reads the register value */ |
MACRUM | 0:615f90842ce8 | 292 | g_xStatus = SpiritSpiReadRegisters(FIFO_CONFIG0_TXAETHR_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 293 | |
MACRUM | 0:615f90842ce8 | 294 | /* Build the register value */ |
MACRUM | 0:615f90842ce8 | 295 | tempRegValue &= 0x80; |
MACRUM | 0:615f90842ce8 | 296 | tempRegValue |= cThrTxFifo; |
MACRUM | 0:615f90842ce8 | 297 | |
MACRUM | 0:615f90842ce8 | 298 | /* Writes the Almost Empty threshold for Tx in the corresponding register */ |
MACRUM | 0:615f90842ce8 | 299 | g_xStatus = SpiritSpiWriteRegisters(FIFO_CONFIG0_TXAETHR_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 300 | |
MACRUM | 0:615f90842ce8 | 301 | } |
MACRUM | 0:615f90842ce8 | 302 | |
MACRUM | 0:615f90842ce8 | 303 | |
MACRUM | 0:615f90842ce8 | 304 | /** |
MACRUM | 0:615f90842ce8 | 305 | * @brief Returns the almost empty threshold for Tx FIFO. |
MACRUM | 0:615f90842ce8 | 306 | * @param None. |
MACRUM | 0:615f90842ce8 | 307 | * @retval uint8_t Almost empty threshold for Tx FIFO. |
MACRUM | 0:615f90842ce8 | 308 | */ |
MACRUM | 0:615f90842ce8 | 309 | uint8_t SpiritLinearFifoGetAlmostEmptyThresholdTx(void) |
MACRUM | 0:615f90842ce8 | 310 | { |
MACRUM | 0:615f90842ce8 | 311 | uint8_t tempRegValue; |
MACRUM | 0:615f90842ce8 | 312 | |
MACRUM | 0:615f90842ce8 | 313 | /* Reads the almost empty threshold for TX FIFO and returns the value */ |
MACRUM | 0:615f90842ce8 | 314 | g_xStatus = SpiritSpiReadRegisters(FIFO_CONFIG0_TXAETHR_BASE, 1, &tempRegValue); |
MACRUM | 0:615f90842ce8 | 315 | |
MACRUM | 0:615f90842ce8 | 316 | /* Build and return value */ |
MACRUM | 0:615f90842ce8 | 317 | return (tempRegValue & 0x7F); |
MACRUM | 0:615f90842ce8 | 318 | |
MACRUM | 0:615f90842ce8 | 319 | } |
MACRUM | 0:615f90842ce8 | 320 | |
MACRUM | 0:615f90842ce8 | 321 | |
MACRUM | 0:615f90842ce8 | 322 | /** |
MACRUM | 0:615f90842ce8 | 323 | *@} |
MACRUM | 0:615f90842ce8 | 324 | */ |
MACRUM | 0:615f90842ce8 | 325 | |
MACRUM | 0:615f90842ce8 | 326 | /** |
MACRUM | 0:615f90842ce8 | 327 | *@} |
MACRUM | 0:615f90842ce8 | 328 | */ |
MACRUM | 0:615f90842ce8 | 329 | |
MACRUM | 0:615f90842ce8 | 330 | |
MACRUM | 0:615f90842ce8 | 331 | /** |
MACRUM | 0:615f90842ce8 | 332 | *@} |
MACRUM | 0:615f90842ce8 | 333 | */ |
MACRUM | 0:615f90842ce8 | 334 | |
MACRUM | 0:615f90842ce8 | 335 | |
MACRUM | 0:615f90842ce8 | 336 | |
MACRUM | 0:615f90842ce8 | 337 | /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/ |