Added support for WNC M14A2A Cellular LTE Data Module.
Dependencies: WNC14A2AInterface
Dependents: http-example-wnc http-example-wnc-modified
SPIRIT_LinearFifo.c
00001 /** 00002 ****************************************************************************** 00003 * @file SPIRIT_LinearFifo.c 00004 * @author VMA division - AMS 00005 * @version 3.2.2 00006 * @date 08-July-2015 00007 * @brief Configuration and management of SPIRIT Fifo. 00008 * @details 00009 * 00010 * @attention 00011 * 00012 * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> 00013 * 00014 * Redistribution and use in source and binary forms, with or without modification, 00015 * are permitted provided that the following conditions are met: 00016 * 1. Redistributions of source code must retain the above copyright notice, 00017 * this list of conditions and the following disclaimer. 00018 * 2. Redistributions in binary form must reproduce the above copyright notice, 00019 * this list of conditions and the following disclaimer in the documentation 00020 * and/or other materials provided with the distribution. 00021 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00022 * may be used to endorse or promote products derived from this software 00023 * without specific prior written permission. 00024 * 00025 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00026 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00027 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00028 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00029 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00030 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00031 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00032 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00033 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00034 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00035 * 00036 ****************************************************************************** 00037 */ 00038 00039 /* Includes ------------------------------------------------------------------*/ 00040 #include "SPIRIT_LinearFifo.h" 00041 #include "MCU_Interface.h" 00042 00043 00044 /** 00045 * @addtogroup SPIRIT_Libraries 00046 * @{ 00047 */ 00048 00049 00050 /** 00051 * @addtogroup SPIRIT_LinearFifo 00052 * @{ 00053 */ 00054 00055 00056 /** 00057 * @defgroup LinearFifo_Private_TypesDefinitions Linear FIFO Private Types Definitions 00058 * @{ 00059 */ 00060 00061 /** 00062 *@} 00063 */ 00064 00065 00066 /** 00067 * @defgroup LinearFifo_Private_Defines Linear FIFO Private Defines 00068 * @{ 00069 */ 00070 00071 /** 00072 *@} 00073 */ 00074 00075 00076 /** 00077 * @defgroup LinearFifo_Private_Macros Linear FIFO Private Macros 00078 * @{ 00079 */ 00080 00081 /** 00082 *@} 00083 */ 00084 00085 00086 /** 00087 * @defgroup LinearFifo_Private_Variables Linear FIFO Private Variables 00088 * @{ 00089 */ 00090 00091 /** 00092 *@} 00093 */ 00094 00095 00096 /** 00097 * @defgroup LinearFifo_Private_FunctionPrototypes Linear FIFO Private Function Prototypes 00098 * @{ 00099 */ 00100 00101 /** 00102 *@} 00103 */ 00104 00105 00106 /** 00107 * @defgroup LinearFifo_Private_Functions Linear FIFO Private Functions 00108 * @{ 00109 */ 00110 00111 /** 00112 * @brief Returns the number of elements in the Rx FIFO. 00113 * @param None. 00114 * @retval uint8_t Number of elements in the Rx FIFO. 00115 */ 00116 uint8_t SpiritLinearFifoReadNumElementsRxFifo(void) 00117 { 00118 uint8_t tempRegValue; 00119 00120 /* Reads the register value */ 00121 g_xStatus = SpiritSpiReadRegisters(LINEAR_FIFO_STATUS0_BASE, 1, &tempRegValue); 00122 00123 /* Build and return value */ 00124 return (tempRegValue & 0x7F); 00125 00126 } 00127 00128 00129 /** 00130 * @brief Returns the number of elements in the Tx FIFO. 00131 * @param None. 00132 * @retval uint8_t Number of elements in the Tx FIFO. 00133 */ 00134 uint8_t SpiritLinearFifoReadNumElementsTxFifo(void) 00135 { 00136 uint8_t tempRegValue; 00137 00138 /* Reads the number of elements in TX FIFO and return the value */ 00139 g_xStatus = SpiritSpiReadRegisters(LINEAR_FIFO_STATUS1_BASE, 1, &tempRegValue); 00140 00141 /* Build and return value */ 00142 return (tempRegValue & 0x7F); 00143 } 00144 00145 00146 /** 00147 * @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. 00148 * @note The almost full threshold is encountered from the top of the FIFO. For example, if it is set to 7 the almost 00149 * full FIFO irq will be raised when the number of elements is equals to 96-7 = 89. 00150 * @param cThrRxFifo almost full threshold. 00151 * This parameter is an uint8_t. 00152 * @retval None. 00153 */ 00154 void SpiritLinearFifoSetAlmostFullThresholdRx(uint8_t cThrRxFifo) 00155 { 00156 uint8_t tempRegValue; 00157 00158 /* Check the parameters */ 00159 s_assert_param(IS_FIFO_THR(cThrRxFifo)); 00160 00161 /* Build the register value */ 00162 tempRegValue = cThrRxFifo & 0x7F; 00163 00164 /* Writes the Almost Full threshold for RX in the corresponding register */ 00165 g_xStatus = SpiritSpiWriteRegisters(FIFO_CONFIG3_RXAFTHR_BASE, 1, &tempRegValue); 00166 00167 } 00168 00169 00170 /** 00171 * @brief Returns the almost full threshold for RX FIFO. 00172 * @note The almost full threshold is encountered from the top of the FIFO. For example, if it is 7 the almost 00173 * full FIFO irq will be raised when the number of elements is equals to 96-7 = 89. 00174 * @param None. 00175 * @retval uint8_t Almost full threshold for Rx FIFO. 00176 */ 00177 uint8_t SpiritLinearFifoGetAlmostFullThresholdRx(void) 00178 { 00179 uint8_t tempRegValue; 00180 00181 /* Reads the almost full threshold for RX FIFO and return the value */ 00182 g_xStatus = SpiritSpiReadRegisters(FIFO_CONFIG3_RXAFTHR_BASE, 1, &tempRegValue); 00183 00184 /* Build and return value */ 00185 return (tempRegValue & 0x7F); 00186 00187 } 00188 00189 00190 /** 00191 * @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. 00192 * @param cThrRxFifo almost empty threshold. 00193 * This parameter is an uint8_t. 00194 * @retval None. 00195 */ 00196 void SpiritLinearFifoSetAlmostEmptyThresholdRx(uint8_t cThrRxFifo) 00197 { 00198 uint8_t tempRegValue; 00199 00200 /* Check the parameters */ 00201 s_assert_param(IS_FIFO_THR(cThrRxFifo)); 00202 00203 /* Build the register value */ 00204 tempRegValue = cThrRxFifo & 0x7F; 00205 00206 /* Writes the Almost Empty threshold for RX in the corresponding register */ 00207 g_xStatus = SpiritSpiWriteRegisters(FIFO_CONFIG2_RXAETHR_BASE, 1, &tempRegValue); 00208 00209 } 00210 00211 00212 /** 00213 * @brief Returns the almost empty threshold for Rx FIFO. 00214 * @param None. 00215 * @retval uint8_t Almost empty threshold for Rx FIFO. 00216 */ 00217 uint8_t SpiritLinearFifoGetAlmostEmptyThresholdRx(void) 00218 { 00219 uint8_t tempRegValue; 00220 00221 /* Reads the almost empty threshold for RX FIFO and returns the value */ 00222 g_xStatus = SpiritSpiReadRegisters(FIFO_CONFIG2_RXAETHR_BASE, 1, &tempRegValue); 00223 00224 /* Build and return value */ 00225 return (tempRegValue & 0x7F); 00226 00227 } 00228 00229 00230 /** 00231 * @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. 00232 * @note The almost full threshold is encountered from the top of the FIFO. For example, if it is set to 7 the almost 00233 * full FIFO irq will be raised when the number of elements is equals to 96-7 = 89. 00234 * @param cThrTxFifo almost full threshold. 00235 * This parameter is an uint8_t. 00236 * @retval None. 00237 */ 00238 void SpiritLinearFifoSetAlmostFullThresholdTx(uint8_t cThrTxFifo) 00239 { 00240 uint8_t tempRegValue; 00241 00242 /* Check the parameters */ 00243 s_assert_param(IS_FIFO_THR(cThrTxFifo)); 00244 00245 /* Reads the register value */ 00246 g_xStatus = SpiritSpiReadRegisters(FIFO_CONFIG1_TXAFTHR_BASE, 1, &tempRegValue); 00247 00248 /* Build the register value */ 00249 tempRegValue &= 0x80; 00250 tempRegValue |= cThrTxFifo; 00251 00252 /* Writes the Almost Full threshold for Tx in the corresponding register */ 00253 g_xStatus = SpiritSpiWriteRegisters(FIFO_CONFIG1_TXAFTHR_BASE, 1, &tempRegValue); 00254 00255 } 00256 00257 00258 /** 00259 * @brief Returns the almost full threshold for Tx FIFO. 00260 * @note The almost full threshold is encountered from the top of the FIFO. For example, if it is set to 7 the almost 00261 * full FIFO irq will be raised when the number of elements is equals to 96-7 = 89. 00262 * @param None. 00263 * @retval uint8_t Almost full threshold for Tx FIFO. 00264 */ 00265 uint8_t SpiritLinearFifoGetAlmostFullThresholdTx(void) 00266 { 00267 uint8_t tempRegValue; 00268 00269 /* Reads the almost full threshold for Tx FIFO and returns the value */ 00270 g_xStatus = SpiritSpiReadRegisters(FIFO_CONFIG1_TXAFTHR_BASE, 1, &tempRegValue); 00271 00272 /* Build and returns value */ 00273 return (tempRegValue & 0x7F); 00274 00275 } 00276 00277 00278 /** 00279 * @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. 00280 * @param cThrTxFifo: almost empty threshold. 00281 * This parameter is an uint8_t. 00282 * @retval None. 00283 */ 00284 void SpiritLinearFifoSetAlmostEmptyThresholdTx(uint8_t cThrTxFifo) 00285 { 00286 uint8_t tempRegValue; 00287 00288 /* Check the parameters */ 00289 s_assert_param(IS_FIFO_THR(cThrTxFifo)); 00290 00291 /* Reads the register value */ 00292 g_xStatus = SpiritSpiReadRegisters(FIFO_CONFIG0_TXAETHR_BASE, 1, &tempRegValue); 00293 00294 /* Build the register value */ 00295 tempRegValue &= 0x80; 00296 tempRegValue |= cThrTxFifo; 00297 00298 /* Writes the Almost Empty threshold for Tx in the corresponding register */ 00299 g_xStatus = SpiritSpiWriteRegisters(FIFO_CONFIG0_TXAETHR_BASE, 1, &tempRegValue); 00300 00301 } 00302 00303 00304 /** 00305 * @brief Returns the almost empty threshold for Tx FIFO. 00306 * @param None. 00307 * @retval uint8_t Almost empty threshold for Tx FIFO. 00308 */ 00309 uint8_t SpiritLinearFifoGetAlmostEmptyThresholdTx(void) 00310 { 00311 uint8_t tempRegValue; 00312 00313 /* Reads the almost empty threshold for TX FIFO and returns the value */ 00314 g_xStatus = SpiritSpiReadRegisters(FIFO_CONFIG0_TXAETHR_BASE, 1, &tempRegValue); 00315 00316 /* Build and return value */ 00317 return (tempRegValue & 0x7F); 00318 00319 } 00320 00321 00322 /** 00323 *@} 00324 */ 00325 00326 /** 00327 *@} 00328 */ 00329 00330 00331 /** 00332 *@} 00333 */ 00334 00335 00336 00337 /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/
Generated on Tue Jul 12 2022 17:40:25 by 1.7.2