Added support for WNC M14A2A Cellular LTE Data Module.
Dependencies: WNC14A2AInterface
Dependents: http-example-wnc http-example-wnc-modified
SPIRIT_Csma.h
00001 /** 00002 ****************************************************************************** 00003 * @file SPIRIT_Csma.h 00004 * @author VMA division - AMS 00005 * @version 3.2.2 00006 * @date 08-July-2015 00007 * @brief Configuration and management of SPIRIT CSMA. 00008 * @details 00009 * 00010 * The Spirit CSMA feature, when configured and enabled, is transparent 00011 * for the user. It means the user has only to call the <i>@ref SpiritCsmaInit()</i> 00012 * function on a filled structure and then enable the CSMA policy using the <i>@ref SpiritCsma()</i> 00013 * function. 00014 * 00015 * <b>Example:</b> 00016 * @code 00017 * 00018 * CsmaInit csmaInit={ 00019 * S_DISABLE, // persistent mode 00020 * TBIT_TIME_64, // Tbit time 00021 * TCCA_TIME_3, // Tcca time 00022 * 5, // max number of backoffs 00023 * 0xFA21, // BU counter seed 00024 * 32 // CU prescaler 00025 * }; 00026 * 00027 * ... 00028 * 00029 * SpiritCsmaInit(&csmaInit); 00030 * SpiritCsma(S_ENABLE); 00031 * 00032 * 00033 * @endcode 00034 * 00035 * @note The CS status depends of the RSSI threshold set. Please see the Spirit_Qi 00036 * module for details. 00037 * 00038 * @attention 00039 * 00040 * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> 00041 * 00042 * Redistribution and use in source and binary forms, with or without modification, 00043 * are permitted provided that the following conditions are met: 00044 * 1. Redistributions of source code must retain the above copyright notice, 00045 * this list of conditions and the following disclaimer. 00046 * 2. Redistributions in binary form must reproduce the above copyright notice, 00047 * this list of conditions and the following disclaimer in the documentation 00048 * and/or other materials provided with the distribution. 00049 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00050 * may be used to endorse or promote products derived from this software 00051 * without specific prior written permission. 00052 * 00053 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00054 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00055 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00056 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00057 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00058 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00059 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00060 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00061 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00062 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00063 * 00064 ****************************************************************************** 00065 */ 00066 00067 /* Define to prevent recursive inclusion -------------------------------------*/ 00068 #ifndef __SPIRIT_CSMA_H 00069 #define __SPIRIT_CSMA_H 00070 00071 00072 /* Includes ------------------------------------------------------------------*/ 00073 00074 #include "SPIRIT_Types.h" 00075 #include "SPIRIT_Regs.h" 00076 00077 00078 #ifdef __cplusplus 00079 extern "C" { 00080 #endif 00081 00082 00083 /** 00084 * @addtogroup SPIRIT_Libraries 00085 * @{ 00086 */ 00087 00088 00089 /** 00090 * @defgroup SPIRIT_Csma CSMA 00091 * @brief Configuration and management of SPIRIT CSMA. 00092 * @details See the file <i>@ref SPIRIT_Csma.h</i> for more details. 00093 * @{ 00094 */ 00095 00096 /** 00097 * @defgroup Csma_Exported_Types CSMA Exported Types 00098 * @{ 00099 */ 00100 00101 00102 /** 00103 * @brief Multiplier for Tcca time enumeration (Tcca = Multiplier*Tbit). 00104 */ 00105 typedef enum 00106 { 00107 TBIT_TIME_64 = CSMA_CCA_PERIOD_64TBIT, /*!< CSMA/CA: Sets CCA period to 64*TBIT */ 00108 TBIT_TIME_128 = CSMA_CCA_PERIOD_128TBIT, /*!< CSMA/CA: Sets CCA period to 128*TBIT */ 00109 TBIT_TIME_256 = CSMA_CCA_PERIOD_256TBIT, /*!< CSMA/CA: Sets CCA period to 256*TBIT */ 00110 TBIT_TIME_512 = CSMA_CCA_PERIOD_512TBIT, /*!< CSMA/CA: Sets CCA period to 512*TBIT */ 00111 }CcaPeriod; 00112 00113 #define IS_CCA_PERIOD(PERIOD) (PERIOD == TBIT_TIME_64 || \ 00114 PERIOD == TBIT_TIME_128 || \ 00115 PERIOD == TBIT_TIME_256 || \ 00116 PERIOD == TBIT_TIME_512) 00117 00118 00119 /** 00120 * @brief Multiplier of Tcca time enumeration to obtain Tlisten (Tlisten = [1...15]*Tcca). 00121 */ 00122 typedef enum 00123 { 00124 TCCA_TIME_0 = 0x00, /*!< CSMA/CA: Sets CCA length to 0 */ 00125 TCCA_TIME_1 = 0x10, /*!< CSMA/CA: Sets CCA length to 1*TLISTEN */ 00126 TCCA_TIME_2 = 0x20, /*!< CSMA/CA: Sets CCA length to 2*TLISTEN */ 00127 TCCA_TIME_3 = 0x30, /*!< CSMA/CA: Sets CCA length to 3*TLISTEN */ 00128 TCCA_TIME_4 = 0x40, /*!< CSMA/CA: Sets CCA length to 4*TLISTEN */ 00129 TCCA_TIME_5 = 0x50, /*!< CSMA/CA: Sets CCA length to 5*TLISTEN */ 00130 TCCA_TIME_6 = 0x60, /*!< CSMA/CA: Sets CCA length to 6*TLISTEN */ 00131 TCCA_TIME_7 = 0x70, /*!< CSMA/CA: Sets CCA length to 7*TLISTEN */ 00132 TCCA_TIME_8 = 0x80, /*!< CSMA/CA: Sets CCA length to 8*TLISTEN */ 00133 TCCA_TIME_9 = 0x90, /*!< CSMA/CA: Sets CCA length to 9*TLISTEN */ 00134 TCCA_TIME_10 = 0xA0, /*!< CSMA/CA: Sets CCA length to 10*TLISTEN */ 00135 TCCA_TIME_11 = 0xB0, /*!< CSMA/CA: Sets CCA length to 11*TLISTEN */ 00136 TCCA_TIME_12 = 0xC0, /*!< CSMA/CA: Sets CCA length to 12*TLISTEN */ 00137 TCCA_TIME_13 = 0xD0, /*!< CSMA/CA: Sets CCA length to 13*TLISTEN */ 00138 TCCA_TIME_14 = 0xE0, /*!< CSMA/CA: Sets CCA length to 14*TLISTEN */ 00139 TCCA_TIME_15 = 0xF0, /*!< CSMA/CA: Sets CCA length to 15*TLISTEN */ 00140 }CsmaLength; 00141 00142 #define IS_CSMA_LENGTH(LENGTH) (LENGTH == TCCA_TIME_0 || \ 00143 LENGTH == TCCA_TIME_1 || \ 00144 LENGTH == TCCA_TIME_2 || \ 00145 LENGTH == TCCA_TIME_3 || \ 00146 LENGTH == TCCA_TIME_4 || \ 00147 LENGTH == TCCA_TIME_5 || \ 00148 LENGTH == TCCA_TIME_6 || \ 00149 LENGTH == TCCA_TIME_7 || \ 00150 LENGTH == TCCA_TIME_8 || \ 00151 LENGTH == TCCA_TIME_9 || \ 00152 LENGTH == TCCA_TIME_10 || \ 00153 LENGTH == TCCA_TIME_11 || \ 00154 LENGTH == TCCA_TIME_12 || \ 00155 LENGTH == TCCA_TIME_13 || \ 00156 LENGTH == TCCA_TIME_14 || \ 00157 LENGTH == TCCA_TIME_15) 00158 00159 00160 /** 00161 * @brief SPIRIT CSMA Init structure definition 00162 */ 00163 typedef struct 00164 { 00165 SpiritFunctionalState xCsmaPersistentMode; /*!< Specifies if the CSMA persistent mode has to be on or off. 00166 This parameter can be S_ENABLE or S_DISABLE */ 00167 CcaPeriod xMultiplierTbit; /*!< Specifies the Tbit multiplier to obtain the Tcca. 00168 This parameter can be a value of @ref CcaPeriod */ 00169 CsmaLength xCcaLength; /*!< Specifies the Tcca multiplier to determinate the Tlisten. 00170 This parameter can be a value of @ref CsmaLength. */ 00171 uint8_t cMaxNb; /*!< Specifies the max number of backoff cycles. Not used in persistent mode. 00172 This parameter is an uint8_t. */ 00173 uint16_t nBuCounterSeed; /*!< Specifies the BU counter seed. Not used in persistent mode. 00174 This parameter can be a value of 16 bits. */ 00175 uint8_t cBuPrescaler; /*!< Specifies the BU prescaler. Not used in persistent mode. 00176 This parameter can be a value of 6 bits. */ 00177 }CsmaInit; 00178 00179 00180 /** 00181 *@} 00182 */ 00183 00184 00185 /** 00186 * @defgroup Csma_Exported_Constants CSMA Exported Constants 00187 * @{ 00188 */ 00189 00190 /** 00191 * @defgroup Csma_Parameters CSMA Parameters 00192 * @{ 00193 */ 00194 00195 #define IS_BU_COUNTER_SEED(SEED) (SEED!=0) 00196 #define IS_BU_PRESCALER(PRESCALER) (PRESCALER<64) 00197 #define IS_CMAX_NB(NB) (NB<8) 00198 00199 /** 00200 *@} 00201 */ 00202 00203 /** 00204 *@} 00205 */ 00206 00207 00208 /** 00209 * @defgroup Csma_Exported_Macros CSMA Exported Macros 00210 * @{ 00211 */ 00212 00213 00214 /** 00215 *@} 00216 */ 00217 00218 00219 /** 00220 * @defgroup Csma_Exported_Functions CSMA Exported Functions 00221 * @{ 00222 */ 00223 00224 void SpiritCsmaInit(CsmaInit* pxCsmaInit); 00225 void SpiritCsmaGetInfo(CsmaInit* pxCsmaInit); 00226 void SpiritCsma(SpiritFunctionalState xNewState); 00227 SpiritFunctionalState SpiritCsmaGetCsma(void); 00228 void SpiritCsmaPersistentMode(SpiritFunctionalState xNewState); 00229 SpiritFunctionalState SpiritCsmaGetPersistentMode(void); 00230 void SpiritCsmaSeedReloadMode(SpiritFunctionalState xNewState); 00231 SpiritFunctionalState SpiritCsmaGetSeedReloadMode(void); 00232 void SpiritCsmaSetBuCounterSeed(uint16_t nBuCounterSeed); 00233 uint16_t SpiritCsmaGetBuCounterSeed(void); 00234 void SpiritCsmaSetBuPrescaler(uint8_t cBuPrescaler); 00235 uint8_t SpiritCsmaGetBuPrescaler(void); 00236 void SpiritCsmaSetCcaPeriod(CcaPeriod xMultiplierTbit); 00237 CcaPeriod SpiritCsmaGetCcaPeriod(void); 00238 void SpiritCsmaSetCcaLength(CsmaLength xCcaLength); 00239 uint8_t SpiritCsmaGetCcaLength(void); 00240 void SpiritCsmaSetMaxNumberBackoff(uint8_t cMaxNb); 00241 uint8_t SpiritCsmaGetMaxNumberBackoff(void); 00242 00243 00244 /** 00245 *@} 00246 */ 00247 00248 /** 00249 *@} 00250 */ 00251 00252 00253 /** 00254 *@} 00255 */ 00256 00257 #ifdef __cplusplus 00258 } 00259 #endif 00260 00261 #endif 00262 00263 /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/
Generated on Tue Jul 12 2022 17:40:25 by 1.7.2