Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of stm-spirit1-rf-driver by
SPIRIT_Timer.h
00001 /** 00002 ****************************************************************************** 00003 * @file SPIRIT_Timer.h 00004 * @author VMA division - AMS 00005 * @version 3.2.2 00006 * @date 08-July-2015 00007 * @brief Configuration and management of SPIRIT timers. 00008 * @details 00009 * 00010 * This module provides API to configure the Spirit timing mechanisms. 00011 * They allow the user to set the timer registers using raw values or 00012 * compute them since the desired timer value is expressed in ms. 00013 * Moreover the management of the Spirit LDCR mode can be done using 00014 * these API. 00015 * 00016 * <b>Example:</b> 00017 * @code 00018 * ... 00019 * 00020 * SpiritTimerSetRxTimeoutMs(50.0); 00021 * SpiritTimerSetWakeUpTimerMs(150.0); 00022 * 00023 * // IRQ configuration for RX_TIMEOUT and WAKEUP_TIMEOUT 00024 * ... 00025 * 00026 * SpiritTimerLdcrMode(S_ENABLE); 00027 * 00028 * ... 00029 * 00030 * @endcode 00031 * 00032 * 00033 * @attention 00034 * 00035 * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> 00036 * 00037 * Redistribution and use in source and binary forms, with or without modification, 00038 * are permitted provided that the following conditions are met: 00039 * 1. Redistributions of source code must retain the above copyright notice, 00040 * this list of conditions and the following disclaimer. 00041 * 2. Redistributions in binary form must reproduce the above copyright notice, 00042 * this list of conditions and the following disclaimer in the documentation 00043 * and/or other materials provided with the distribution. 00044 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00045 * may be used to endorse or promote products derived from this software 00046 * without specific prior written permission. 00047 * 00048 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00049 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00050 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00051 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00052 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00053 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00054 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00055 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00056 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00057 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00058 * 00059 ****************************************************************************** 00060 */ 00061 00062 /* Define to prevent recursive inclusion -------------------------------------*/ 00063 #ifndef __SPIRIT1_TIMER_H 00064 #define __SPIRIT1_TIMER_H 00065 00066 00067 /* Includes ------------------------------------------------------------------*/ 00068 00069 #include "SPIRIT_Regs.h" 00070 #include "SPIRIT_Types.h" 00071 00072 00073 #ifdef __cplusplus 00074 extern "C" { 00075 #endif 00076 00077 00078 /** 00079 * @addtogroup SPIRIT_Libraries 00080 * @{ 00081 */ 00082 00083 00084 /** 00085 * @defgroup SPIRIT_Timer Timer 00086 * @brief Configuration and management of SPIRIT Timers. 00087 * @details See the file <i>@ref SPIRIT_Timer.h</i> for more details. 00088 * @{ 00089 */ 00090 00091 00092 /** 00093 * @defgroup Timer_Exported_Types Timer Exported Types 00094 * @{ 00095 */ 00096 00097 /** 00098 * @brief All the possible RX timeout stop conditions enumeration. 00099 */ 00100 typedef enum{ 00101 00102 NO_TIMEOUT_STOP = 0x00, /*!< Timeout never stopped */ 00103 TIMEOUT_ALWAYS_STOPPED = 0x08, /*!< Timeout always stopped (default) */ 00104 RSSI_ABOVE_THRESHOLD = 0x04, /*!< Timeout stopped on RSSI above threshold */ 00105 SQI_ABOVE_THRESHOLD = 0x02, /*!< Timeout stopped on SQI above threshold */ 00106 PQI_ABOVE_THRESHOLD = 0x01, /*!< Timeout stopped on PQI above threshold */ 00107 RSSI_AND_SQI_ABOVE_THRESHOLD = 0x06, /*!< Timeout stopped on both RSSI and SQI above threshold */ 00108 RSSI_AND_PQI_ABOVE_THRESHOLD = 0x05, /*!< Timeout stopped on both RSSI and PQI above threshold */ 00109 SQI_AND_PQI_ABOVE_THRESHOLD = 0x03, /*!< Timeout stopped on both SQI and PQI above threshold */ 00110 ALL_ABOVE_THRESHOLD = 0x07, /*!< Timeout stopped only if RSSI, SQI and PQI are above threshold */ 00111 RSSI_OR_SQI_ABOVE_THRESHOLD = 0x0E, /*!< Timeout stopped if one between RSSI or SQI are above threshold */ 00112 RSSI_OR_PQI_ABOVE_THRESHOLD = 0x0D, /*!< Timeout stopped if one between RSSI or PQI are above threshold */ 00113 SQI_OR_PQI_ABOVE_THRESHOLD = 0x0B, /*!< Timeout stopped if one between SQI or PQI are above threshold */ 00114 ANY_ABOVE_THRESHOLD = 0x0F /*!< Timeout stopped if one among RSSI, SQI or SQI are above threshold */ 00115 00116 } RxTimeoutStopCondition; 00117 00118 00119 #define IS_RX_TIMEOUT_STOP_CONDITION(COND) ( COND == NO_TIMEOUT_STOP || \ 00120 COND == TIMEOUT_ALWAYS_STOPPED || \ 00121 COND == RSSI_ABOVE_THRESHOLD || \ 00122 COND == SQI_ABOVE_THRESHOLD || \ 00123 COND == PQI_ABOVE_THRESHOLD || \ 00124 COND == RSSI_AND_SQI_ABOVE_THRESHOLD || \ 00125 COND == RSSI_AND_PQI_ABOVE_THRESHOLD || \ 00126 COND == SQI_AND_PQI_ABOVE_THRESHOLD || \ 00127 COND == ALL_ABOVE_THRESHOLD || \ 00128 COND == RSSI_OR_SQI_ABOVE_THRESHOLD || \ 00129 COND == RSSI_OR_PQI_ABOVE_THRESHOLD || \ 00130 COND == SQI_OR_PQI_ABOVE_THRESHOLD || \ 00131 COND == ANY_ABOVE_THRESHOLD ) 00132 00133 00134 00135 /** 00136 * @} 00137 */ 00138 00139 00140 /** 00141 * @defgroup Timer_Exported_Constants Timer Exported Constants 00142 * @{ 00143 */ 00144 00145 /** 00146 * @brief It represents the Time Step for RX_Timeout timer in case of 24 MHz Crystal, expressed in us. 00147 * It is equal to 1210/(24*10^6). With this time step it is possible to fix the RX_Timeout to 00148 * a minimum value of 50.417us to a maximum value of about 3.278 s. 00149 * Remember that it is possible to have infinite RX_Timeout writing 0 in the RX_Timeout_Counter and/or RX_Timeout_Prescaler registers. 00150 */ 00151 #define RX_TCLK_24MHz 50.417f 00152 #define IS_RX_TIMEOUT_24MHz(TIMEOUT) (TIMEOUT*1000)>=RX_TCLK_24MHz 00153 00154 /** 00155 * @brief It represents the Time Step for RX_Timeout timer in case of 26 MHz Crystal, expressed in us. 00156 * It is equal to 1210/(26*10^6). With this time step it is possible to fix the RX_Timeout to 00157 * a minimum value of 46.538us to a maximum value of about 3.026 s. 00158 * Remember that it is possible to have infinite RX_Timeout writing 0 in the RX_Timeout_Counter register. 00159 */ 00160 #define RX_TCLK_26MHz 46.538f 00161 #define IS_RX_TIMEOUT_26MHz(TIMEOUT) (TIMEOUT*1000)>=RX_TCLK_26MHz 00162 00163 /** 00164 * @brief It represents the Time Step for RX_Wakeup timer expressed in us. This timer is based on RCO (about 34.7 kHZ). 00165 * With this time step it is possible to fix the Wakeup_Timeout to a minimum value of 28.818us to a maximum 00166 * value of about 1.888 s. 00167 */ 00168 #define WAKEUP_TCLK 28.818f 00169 #define IS_WKUP_TIMEOUT(TIMEOUT) (TIMEOUT*1000)>=WAKEUP_TCLK 00170 00171 00172 00173 /** 00174 * @} 00175 */ 00176 00177 00178 /** 00179 * @defgroup Timer_Exported_Macros Timer Exported Macros 00180 * @{ 00181 */ 00182 00183 #define SET_INFINITE_RX_TIMEOUT() SpiritTimerSetRxTimeoutCounter(0) 00184 00185 /** 00186 * @} 00187 */ 00188 00189 00190 /** 00191 * @defgroup Timer_Exported_Functions Timer Exported Functions 00192 * @{ 00193 */ 00194 00195 void SpiritTimerLdcrMode(SpiritFunctionalState xNewState); 00196 void SpiritTimerLdcrAutoReload(SpiritFunctionalState xNewState); 00197 SpiritFunctionalState SpiritTimerLdcrGetAutoReload(void); 00198 void SpiritTimerSetRxTimeout(uint8_t cCounter , uint8_t cPrescaler); 00199 void SpiritTimerSetRxTimeoutMs(float fDesiredMsec); 00200 void SpiritTimerSetRxTimeoutCounter(uint8_t cCounter); 00201 void SpiritTimerSetRxTimeoutPrescaler(uint8_t cPrescaler); 00202 void SpiritTimerGetRxTimeout(float* pfTimeoutMsec, uint8_t* pcCounter , uint8_t* pcPrescaler); 00203 void SpiritTimerSetWakeUpTimer(uint8_t cCounter , uint8_t cPrescaler); 00204 void SpiritTimerSetWakeUpTimerMs(float fDesiredMsec); 00205 void SpiritTimerSetWakeUpTimerCounter(uint8_t cCounter); 00206 void SpiritTimerSetWakeUpTimerPrescaler(uint8_t cPrescaler); 00207 void SpiritTimerSetWakeUpTimerReloadMs(float fDesiredMsec); 00208 void SpiritTimerGetWakeUpTimer(float* pfWakeUpMsec, uint8_t* pcCounter , uint8_t* pcPrescaler); 00209 void SpiritTimerSetWakeUpTimerReload(uint8_t cCounter , uint8_t cPrescaler); 00210 void SpiritTimerSetWakeUpTimerReloadCounter(uint8_t cCounter); 00211 void SpiritTimerSetWakeUpTimerReloadPrescaler(uint8_t cPrescaler); 00212 void SpiritTimerGetWakeUpTimerReload(float* pfWakeUpReloadMsec, uint8_t* pcCounter , uint8_t* pcPrescaler); 00213 void SpiritTimerComputeWakeUpValues(float fDesiredMsec , uint8_t* pcCounter , uint8_t* pcPrescaler); 00214 void SpiritTimerComputeRxTimeoutValues(float fDesiredMsec , uint8_t* pcCounter , uint8_t* pcPrescaler); 00215 void SpiritTimerSetRxTimeoutStopCondition(RxTimeoutStopCondition xStopCondition); 00216 void SpiritTimerReloadStrobe(void); 00217 uint16_t SpiritTimerGetRcoFrequency(void); 00218 00219 /** 00220 * @} 00221 */ 00222 00223 /** 00224 * @} 00225 */ 00226 00227 00228 /** 00229 * @} 00230 */ 00231 00232 #ifdef __cplusplus 00233 } 00234 #endif 00235 00236 #endif 00237 00238 /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/ 00239
Generated on Wed Jul 13 2022 00:11:57 by
1.7.2
