Hal Drivers for L4
Dependents: BSP OneHopeOnePrayer FINAL_AUDIO_RECORD AudioDemo
Fork of STM32L4xx_HAL_Driver by
stm32l4xx_hal_lptim.h
00001 /** 00002 ****************************************************************************** 00003 * @file stm32l4xx_hal_lptim.h 00004 * @author MCD Application Team 00005 * @version V1.1.0 00006 * @date 16-September-2015 00007 * @brief Header file of LPTIM HAL module. 00008 ****************************************************************************** 00009 * @attention 00010 * 00011 * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> 00012 * 00013 * Redistribution and use in source and binary forms, with or without modification, 00014 * are permitted provided that the following conditions are met: 00015 * 1. Redistributions of source code must retain the above copyright notice, 00016 * this list of conditions and the following disclaimer. 00017 * 2. Redistributions in binary form must reproduce the above copyright notice, 00018 * this list of conditions and the following disclaimer in the documentation 00019 * and/or other materials provided with the distribution. 00020 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00021 * may be used to endorse or promote products derived from this software 00022 * without specific prior written permission. 00023 * 00024 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00025 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00026 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00027 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00028 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00029 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00030 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00031 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00032 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00033 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00034 * 00035 ****************************************************************************** 00036 */ 00037 00038 /* Define to prevent recursive inclusion -------------------------------------*/ 00039 #ifndef __STM32L4xx_HAL_LPTIM_H 00040 #define __STM32L4xx_HAL_LPTIM_H 00041 00042 #ifdef __cplusplus 00043 extern "C" { 00044 #endif 00045 00046 /* Includes ------------------------------------------------------------------*/ 00047 #include "stm32l4xx_hal_def.h" 00048 00049 /** @addtogroup STM32L4xx_HAL_Driver 00050 * @{ 00051 */ 00052 00053 /** @addtogroup LPTIM 00054 * @{ 00055 */ 00056 00057 /* Exported types ------------------------------------------------------------*/ 00058 /** @defgroup LPTIM_Exported_Types LPTIM Exported Types 00059 * @{ 00060 */ 00061 00062 /** 00063 * @brief LPTIM Clock configuration definition 00064 */ 00065 typedef struct 00066 { 00067 uint32_t Source; /*!< Selects the clock source. 00068 This parameter can be a value of @ref LPTIM_Clock_Source */ 00069 00070 uint32_t Prescaler; /*!< Specifies the counter clock Prescaler. 00071 This parameter can be a value of @ref LPTIM_Clock_Prescaler */ 00072 00073 }LPTIM_ClockConfigTypeDef; 00074 00075 /** 00076 * @brief LPTIM Clock configuration definition 00077 */ 00078 typedef struct 00079 { 00080 uint32_t Polarity; /*!< Selects the polarity of the active edge for the counter unit 00081 if the ULPTIM input is selected. 00082 Note: This parameter is used only when Ultra low power clock source is used. 00083 Note: If the polarity is configured on 'both edges', an auxiliary clock 00084 (one of the Low power oscillator) must be active. 00085 This parameter can be a value of @ref LPTIM_Clock_Polarity */ 00086 00087 uint32_t SampleTime; /*!< Selects the clock sampling time to configure the clock glitch filter. 00088 Note: This parameter is used only when Ultra low power clock source is used. 00089 This parameter can be a value of @ref LPTIM_Clock_Sample_Time */ 00090 00091 }LPTIM_ULPClockConfigTypeDef; 00092 00093 /** 00094 * @brief LPTIM Trigger configuration definition 00095 */ 00096 typedef struct 00097 { 00098 uint32_t Source; /*!< Selects the Trigger source. 00099 This parameter can be a value of @ref LPTIM_Trigger_Source */ 00100 00101 uint32_t ActiveEdge; /*!< Selects the Trigger active edge. 00102 Note: This parameter is used only when an external trigger is used. 00103 This parameter can be a value of @ref LPTIM_External_Trigger_Polarity */ 00104 00105 uint32_t SampleTime; /*!< Selects the trigger sampling time to configure the clock glitch filter. 00106 Note: This parameter is used only when an external trigger is used. 00107 This parameter can be a value of @ref LPTIM_Trigger_Sample_Time */ 00108 }LPTIM_TriggerConfigTypeDef; 00109 00110 /** 00111 * @brief LPTIM Initialization Structure definition 00112 */ 00113 typedef struct 00114 { 00115 LPTIM_ClockConfigTypeDef Clock; /*!< Specifies the clock parameters */ 00116 00117 LPTIM_ULPClockConfigTypeDef UltraLowPowerClock; /*!< Specifies the Ultra Low Power clock parameters */ 00118 00119 LPTIM_TriggerConfigTypeDef Trigger; /*!< Specifies the Trigger parameters */ 00120 00121 uint32_t OutputPolarity; /*!< Specifies the Output polarity. 00122 This parameter can be a value of @ref LPTIM_Output_Polarity */ 00123 00124 uint32_t UpdateMode; /*!< Specifies whether the update of the autoreload and the compare 00125 values is done immediately or after the end of current period. 00126 This parameter can be a value of @ref LPTIM_Updating_Mode */ 00127 00128 uint32_t CounterSource; /*!< Specifies whether the counter is incremented each internal event 00129 or each external event. 00130 This parameter can be a value of @ref LPTIM_Counter_Source */ 00131 00132 uint32_t Input1Source; /*!< Specifies source selected for input1 (GPIO or comparator output). 00133 This parameter can be a value of @ref LPTIM_Input1_Source */ 00134 00135 uint32_t Input2Source; /*!< Specifies source selected for input2 (GPIO or comparator output). 00136 Note: This parameter is used only for encoder feature so is used only 00137 for LPTIM1 instance. 00138 This parameter can be a value of @ref LPTIM_Input2_Source */ 00139 00140 }LPTIM_InitTypeDef; 00141 00142 /** 00143 * @brief HAL LPTIM State structure definition 00144 */ 00145 typedef enum __HAL_LPTIM_StateTypeDef 00146 { 00147 HAL_LPTIM_STATE_RESET = 0x00, /*!< Peripheral not yet initialized or disabled */ 00148 HAL_LPTIM_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */ 00149 HAL_LPTIM_STATE_BUSY = 0x02, /*!< An internal process is ongoing */ 00150 HAL_LPTIM_STATE_TIMEOUT = 0x03, /*!< Timeout state */ 00151 HAL_LPTIM_STATE_ERROR = 0x04 /*!< Internal Process is ongoing */ 00152 }HAL_LPTIM_StateTypeDef; 00153 00154 /** 00155 * @brief LPTIM handle Structure definition 00156 */ 00157 typedef struct 00158 { 00159 LPTIM_TypeDef *Instance; /*!< Register base address */ 00160 00161 LPTIM_InitTypeDef Init; /*!< LPTIM required parameters */ 00162 00163 HAL_StatusTypeDef Status; /*!< LPTIM peripheral status */ 00164 00165 HAL_LockTypeDef Lock; /*!< LPTIM locking object */ 00166 00167 __IO HAL_LPTIM_StateTypeDef State; /*!< LPTIM peripheral state */ 00168 00169 }LPTIM_HandleTypeDef; 00170 00171 /** 00172 * @} 00173 */ 00174 00175 /* Exported constants --------------------------------------------------------*/ 00176 /** @defgroup LPTIM_Exported_Constants LPTIM Exported Constants 00177 * @{ 00178 */ 00179 00180 /** @defgroup LPTIM_Clock_Source LPTIM Clock Source 00181 * @{ 00182 */ 00183 #define LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC ((uint32_t)0x00) 00184 #define LPTIM_CLOCKSOURCE_ULPTIM LPTIM_CFGR_CKSEL 00185 /** 00186 * @} 00187 */ 00188 00189 /** @defgroup LPTIM_Clock_Prescaler LPTIM Clock Prescaler 00190 * @{ 00191 */ 00192 #define LPTIM_PRESCALER_DIV1 ((uint32_t)0x000000) 00193 #define LPTIM_PRESCALER_DIV2 LPTIM_CFGR_PRESC_0 00194 #define LPTIM_PRESCALER_DIV4 LPTIM_CFGR_PRESC_1 00195 #define LPTIM_PRESCALER_DIV8 ((uint32_t)(LPTIM_CFGR_PRESC_0 | LPTIM_CFGR_PRESC_1)) 00196 #define LPTIM_PRESCALER_DIV16 LPTIM_CFGR_PRESC_2 00197 #define LPTIM_PRESCALER_DIV32 ((uint32_t)(LPTIM_CFGR_PRESC_0 | LPTIM_CFGR_PRESC_2)) 00198 #define LPTIM_PRESCALER_DIV64 ((uint32_t)(LPTIM_CFGR_PRESC_1 | LPTIM_CFGR_PRESC_2)) 00199 #define LPTIM_PRESCALER_DIV128 ((uint32_t)LPTIM_CFGR_PRESC) 00200 /** 00201 * @} 00202 */ 00203 00204 /** @defgroup LPTIM_Output_Polarity LPTIM Output Polarity 00205 * @{ 00206 */ 00207 00208 #define LPTIM_OUTPUTPOLARITY_HIGH ((uint32_t)0x00000000) 00209 #define LPTIM_OUTPUTPOLARITY_LOW (LPTIM_CFGR_WAVPOL) 00210 /** 00211 * @} 00212 */ 00213 00214 /** @defgroup LPTIM_Clock_Sample_Time LPTIM Clock Sample Time 00215 * @{ 00216 */ 00217 #define LPTIM_CLOCKSAMPLETIME_DIRECTTRANSITION ((uint32_t)0x00000000) 00218 #define LPTIM_CLOCKSAMPLETIME_2TRANSITIONS LPTIM_CFGR_CKFLT_0 00219 #define LPTIM_CLOCKSAMPLETIME_4TRANSITIONS LPTIM_CFGR_CKFLT_1 00220 #define LPTIM_CLOCKSAMPLETIME_8TRANSITIONS LPTIM_CFGR_CKFLT 00221 /** 00222 * @} 00223 */ 00224 00225 /** @defgroup LPTIM_Clock_Polarity LPTIM Clock Polarity 00226 * @{ 00227 */ 00228 #define LPTIM_CLOCKPOLARITY_RISING ((uint32_t)0x00000000) 00229 #define LPTIM_CLOCKPOLARITY_FALLING LPTIM_CFGR_CKPOL_0 00230 #define LPTIM_CLOCKPOLARITY_RISING_FALLING LPTIM_CFGR_CKPOL_1 00231 /** 00232 * @} 00233 */ 00234 00235 /** @defgroup LPTIM_Trigger_Source LPTIM Trigger Source 00236 * @{ 00237 */ 00238 #define LPTIM_TRIGSOURCE_SOFTWARE ((uint32_t)0x0000FFFF) 00239 #define LPTIM_TRIGSOURCE_0 ((uint32_t)0x00000000) 00240 #define LPTIM_TRIGSOURCE_1 ((uint32_t)LPTIM_CFGR_TRIGSEL_0) 00241 #define LPTIM_TRIGSOURCE_2 LPTIM_CFGR_TRIGSEL_1 00242 #define LPTIM_TRIGSOURCE_3 ((uint32_t)LPTIM_CFGR_TRIGSEL_0 | LPTIM_CFGR_TRIGSEL_1) 00243 #define LPTIM_TRIGSOURCE_4 LPTIM_CFGR_TRIGSEL_2 00244 #define LPTIM_TRIGSOURCE_5 ((uint32_t)LPTIM_CFGR_TRIGSEL_0 | LPTIM_CFGR_TRIGSEL_2) 00245 #define LPTIM_TRIGSOURCE_6 ((uint32_t)LPTIM_CFGR_TRIGSEL_1 | LPTIM_CFGR_TRIGSEL_2) 00246 #define LPTIM_TRIGSOURCE_7 LPTIM_CFGR_TRIGSEL 00247 /** 00248 * @} 00249 */ 00250 00251 /** @defgroup LPTIM_External_Trigger_Polarity LPTIM External Trigger Polarity 00252 * @{ 00253 */ 00254 #define LPTIM_ACTIVEEDGE_RISING LPTIM_CFGR_TRIGEN_0 00255 #define LPTIM_ACTIVEEDGE_FALLING LPTIM_CFGR_TRIGEN_1 00256 #define LPTIM_ACTIVEEDGE_RISING_FALLING LPTIM_CFGR_TRIGEN 00257 /** 00258 * @} 00259 */ 00260 00261 /** @defgroup LPTIM_Trigger_Sample_Time LPTIM Trigger Sample Time 00262 * @{ 00263 */ 00264 #define LPTIM_TRIGSAMPLETIME_DIRECTTRANSITION ((uint32_t)0x00000000) 00265 #define LPTIM_TRIGSAMPLETIME_2TRANSITIONS LPTIM_CFGR_TRGFLT_0 00266 #define LPTIM_TRIGSAMPLETIME_4TRANSITIONS LPTIM_CFGR_TRGFLT_1 00267 #define LPTIM_TRIGSAMPLETIME_8TRANSITIONS LPTIM_CFGR_TRGFLT 00268 /** 00269 * @} 00270 */ 00271 00272 /** @defgroup LPTIM_Updating_Mode LPTIM Updating Mode 00273 * @{ 00274 */ 00275 00276 #define LPTIM_UPDATE_IMMEDIATE ((uint32_t)0x00000000) 00277 #define LPTIM_UPDATE_ENDOFPERIOD LPTIM_CFGR_PRELOAD 00278 /** 00279 * @} 00280 */ 00281 00282 /** @defgroup LPTIM_Counter_Source LPTIM Counter Source 00283 * @{ 00284 */ 00285 00286 #define LPTIM_COUNTERSOURCE_INTERNAL ((uint32_t)0x00000000) 00287 #define LPTIM_COUNTERSOURCE_EXTERNAL LPTIM_CFGR_COUNTMODE 00288 /** 00289 * @} 00290 */ 00291 00292 /** @defgroup LPTIM_Input1_Source LPTIM Input1 Source 00293 * @{ 00294 */ 00295 00296 #define LPTIM_INPUT1SOURCE_GPIO ((uint32_t)0x00000000) /*!< For LPTIM1 and LPTIM2 */ 00297 #define LPTIM_INPUT1SOURCE_COMP1 LPTIM_OR_OR_0 /*!< For LPTIM1 and LPTIM2 */ 00298 #define LPTIM_INPUT1SOURCE_COMP2 LPTIM_OR_OR_1 /*!< For LPTIM2 */ 00299 #define LPTIM_INPUT1SOURCE_COMP1_COMP2 LPTIM_OR_OR /*!< For LPTIM2 */ 00300 /** 00301 * @} 00302 */ 00303 00304 /** @defgroup LPTIM_Input2_Source LPTIM Input2 Source 00305 * @{ 00306 */ 00307 00308 #define LPTIM_INPUT2SOURCE_GPIO ((uint32_t)0x00000000) /*!< For LPTIM1 */ 00309 #define LPTIM_INPUT2SOURCE_COMP2 LPTIM_OR_OR_1 /*!< For LPTIM1 */ 00310 /** 00311 * @} 00312 */ 00313 00314 /** @defgroup LPTIM_Flag_Definition LPTIM Flags Definition 00315 * @{ 00316 */ 00317 00318 #define LPTIM_FLAG_DOWN LPTIM_ISR_DOWN 00319 #define LPTIM_FLAG_UP LPTIM_ISR_UP 00320 #define LPTIM_FLAG_ARROK LPTIM_ISR_ARROK 00321 #define LPTIM_FLAG_CMPOK LPTIM_ISR_CMPOK 00322 #define LPTIM_FLAG_EXTTRIG LPTIM_ISR_EXTTRIG 00323 #define LPTIM_FLAG_ARRM LPTIM_ISR_ARRM 00324 #define LPTIM_FLAG_CMPM LPTIM_ISR_CMPM 00325 /** 00326 * @} 00327 */ 00328 00329 /** @defgroup LPTIM_Interrupts_Definition LPTIM Interrupts Definition 00330 * @{ 00331 */ 00332 00333 #define LPTIM_IT_DOWN LPTIM_IER_DOWNIE 00334 #define LPTIM_IT_UP LPTIM_IER_UPIE 00335 #define LPTIM_IT_ARROK LPTIM_IER_ARROKIE 00336 #define LPTIM_IT_CMPOK LPTIM_IER_CMPOKIE 00337 #define LPTIM_IT_EXTTRIG LPTIM_IER_EXTTRIGIE 00338 #define LPTIM_IT_ARRM LPTIM_IER_ARRMIE 00339 #define LPTIM_IT_CMPM LPTIM_IER_CMPMIE 00340 /** 00341 * @} 00342 */ 00343 00344 /** 00345 * @} 00346 */ 00347 00348 /* Exported macros -----------------------------------------------------------*/ 00349 /** @defgroup LPTIM_Exported_Macros LPTIM Exported Macros 00350 * @{ 00351 */ 00352 00353 /** @brief Reset LPTIM handle state. 00354 * @param __HANDLE__: LPTIM handle 00355 * @retval None 00356 */ 00357 #define __HAL_LPTIM_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_LPTIM_STATE_RESET) 00358 00359 /** 00360 * @brief Enable the LPTIM peripheral. 00361 * @param __HANDLE__: LPTIM handle 00362 * @retval None 00363 */ 00364 #define __HAL_LPTIM_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (LPTIM_CR_ENABLE)) 00365 00366 /** 00367 * @brief Disable the LPTIM peripheral. 00368 * @param __HANDLE__: LPTIM handle 00369 * @retval None 00370 */ 00371 #define __HAL_LPTIM_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(LPTIM_CR_ENABLE)) 00372 00373 /** 00374 * @brief Start the LPTIM peripheral in Continuous or in single mode. 00375 * @param __HANDLE__: DMA handle 00376 * @retval None 00377 */ 00378 #define __HAL_LPTIM_START_CONTINUOUS(__HANDLE__) ((__HANDLE__)->Instance->CR |= LPTIM_CR_CNTSTRT) 00379 #define __HAL_LPTIM_START_SINGLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= LPTIM_CR_SNGSTRT) 00380 00381 00382 /** 00383 * @brief Write the passed parameter in the Autoreload register. 00384 * @param __HANDLE__: LPTIM handle 00385 * @param __VALUE__: Autoreload value 00386 * @retval None 00387 */ 00388 #define __HAL_LPTIM_AUTORELOAD_SET(__HANDLE__ , __VALUE__) ((__HANDLE__)->Instance->ARR = (__VALUE__)) 00389 00390 /** 00391 * @brief Write the passed parameter in the Compare register. 00392 * @param __HANDLE__: LPTIM handle 00393 * @param __VALUE__: Compare value 00394 * @retval None 00395 */ 00396 #define __HAL_LPTIM_COMPARE_SET(__HANDLE__ , __VALUE__) ((__HANDLE__)->Instance->CMP = (__VALUE__)) 00397 00398 /** 00399 * @brief Check whether the specified LPTIM flag is set or not. 00400 * @param __HANDLE__: LPTIM handle 00401 * @param __FLAG__: LPTIM flag to check 00402 * This parameter can be a value of: 00403 * @arg LPTIM_FLAG_DOWN : Counter direction change up Flag. 00404 * @arg LPTIM_FLAG_UP : Counter direction change down to up Flag. 00405 * @arg LPTIM_FLAG_ARROK : Autoreload register update OK Flag. 00406 * @arg LPTIM_FLAG_CMPOK : Compare register update OK Flag. 00407 * @arg LPTIM_FLAG_EXTTRIG : External trigger edge event Flag. 00408 * @arg LPTIM_FLAG_ARRM : Autoreload match Flag. 00409 * @arg LPTIM_FLAG_CMPM : Compare match Flag. 00410 * @retval The state of the specified flag (SET or RESET). 00411 */ 00412 #define __HAL_LPTIM_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR &(__FLAG__)) == (__FLAG__)) 00413 00414 /** 00415 * @brief Clear the specified LPTIM flag. 00416 * @param __HANDLE__: LPTIM handle. 00417 * @param __FLAG__: LPTIM flag to clear. 00418 * This parameter can be a value of: 00419 * @arg LPTIM_FLAG_DOWN : Counter direction change up Flag. 00420 * @arg LPTIM_FLAG_UP : Counter direction change down to up Flag. 00421 * @arg LPTIM_FLAG_ARROK : Autoreload register update OK Flag. 00422 * @arg LPTIM_FLAG_CMPOK : Compare register update OK Flag. 00423 * @arg LPTIM_FLAG_EXTTRIG : External trigger edge event Flag. 00424 * @arg LPTIM_FLAG_ARRM : Autoreload match Flag. 00425 * @arg LPTIM_FLAG_CMPM : Compare match Flag. 00426 * @retval None 00427 */ 00428 #define __HAL_LPTIM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__)) 00429 00430 /** 00431 * @brief Enable the specified LPTIM interrupt. 00432 * @param __HANDLE__: LPTIM handle. 00433 * @param __INTERRUPT__: LPTIM interrupt to set. 00434 * This parameter can be a value of: 00435 * @arg LPTIM_IT_DOWN : Counter direction change up Interrupt. 00436 * @arg LPTIM_IT_UP : Counter direction change down to up Interrupt. 00437 * @arg LPTIM_IT_ARROK : Autoreload register update OK Interrupt. 00438 * @arg LPTIM_IT_CMPOK : Compare register update OK Interrupt. 00439 * @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt. 00440 * @arg LPTIM_IT_ARRM : Autoreload match Interrupt. 00441 * @arg LPTIM_IT_CMPM : Compare match Interrupt. 00442 * @retval None 00443 */ 00444 #define __HAL_LPTIM_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER |= (__INTERRUPT__)) 00445 00446 /** 00447 * @brief Disable the specified LPTIM interrupt. 00448 * @param __HANDLE__: LPTIM handle. 00449 * @param __INTERRUPT__: LPTIM interrupt to set. 00450 * This parameter can be a value of: 00451 * @arg LPTIM_IT_DOWN : Counter direction change up Interrupt. 00452 * @arg LPTIM_IT_UP : Counter direction change down to up Interrupt. 00453 * @arg LPTIM_IT_ARROK : Autoreload register update OK Interrupt. 00454 * @arg LPTIM_IT_CMPOK : Compare register update OK Interrupt. 00455 * @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt. 00456 * @arg LPTIM_IT_ARRM : Autoreload match Interrupt. 00457 * @arg LPTIM_IT_CMPM : Compare match Interrupt. 00458 * @retval None 00459 */ 00460 #define __HAL_LPTIM_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER &= (~(__INTERRUPT__))) 00461 00462 /** 00463 * @brief Check whether the specified LPTIM interrupt source is enabled or not. 00464 * @param __HANDLE__: LPTIM handle. 00465 * @param __INTERRUPT__: LPTIM interrupt to check. 00466 * This parameter can be a value of: 00467 * @arg LPTIM_IT_DOWN : Counter direction change up Interrupt. 00468 * @arg LPTIM_IT_UP : Counter direction change down to up Interrupt. 00469 * @arg LPTIM_IT_ARROK : Autoreload register update OK Interrupt. 00470 * @arg LPTIM_IT_CMPOK : Compare register update OK Interrupt. 00471 * @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt. 00472 * @arg LPTIM_IT_ARRM : Autoreload match Interrupt. 00473 * @arg LPTIM_IT_CMPM : Compare match Interrupt. 00474 * @retval Interrupt status. 00475 */ 00476 00477 #define __HAL_LPTIM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->IER & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) 00478 00479 /** 00480 * @} 00481 */ 00482 00483 /* Exported functions --------------------------------------------------------*/ 00484 /** @defgroup LPTIM_Exported_Functions LPTIM Exported Functions 00485 * @{ 00486 */ 00487 00488 /* Initialization/de-initialization functions ********************************/ 00489 HAL_StatusTypeDef HAL_LPTIM_Init(LPTIM_HandleTypeDef *hlptim); 00490 HAL_StatusTypeDef HAL_LPTIM_DeInit(LPTIM_HandleTypeDef *hlptim); 00491 00492 /* MSP functions *************************************************************/ 00493 void HAL_LPTIM_MspInit(LPTIM_HandleTypeDef *hlptim); 00494 void HAL_LPTIM_MspDeInit(LPTIM_HandleTypeDef *hlptim); 00495 00496 /* Start/Stop operation functions *********************************************/ 00497 /* ################################# PWM Mode ################################*/ 00498 /* Blocking mode: Polling */ 00499 HAL_StatusTypeDef HAL_LPTIM_PWM_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse); 00500 HAL_StatusTypeDef HAL_LPTIM_PWM_Stop(LPTIM_HandleTypeDef *hlptim); 00501 /* Non-Blocking mode: Interrupt */ 00502 HAL_StatusTypeDef HAL_LPTIM_PWM_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse); 00503 HAL_StatusTypeDef HAL_LPTIM_PWM_Stop_IT(LPTIM_HandleTypeDef *hlptim); 00504 00505 /* ############################# One Pulse Mode ##############################*/ 00506 /* Blocking mode: Polling */ 00507 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse); 00508 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Stop(LPTIM_HandleTypeDef *hlptim); 00509 /* Non-Blocking mode: Interrupt */ 00510 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse); 00511 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Stop_IT(LPTIM_HandleTypeDef *hlptim); 00512 00513 /* ############################## Set once Mode ##############################*/ 00514 /* Blocking mode: Polling */ 00515 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse); 00516 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop(LPTIM_HandleTypeDef *hlptim); 00517 /* Non-Blocking mode: Interrupt */ 00518 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse); 00519 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop_IT(LPTIM_HandleTypeDef *hlptim); 00520 00521 /* ############################### Encoder Mode ##############################*/ 00522 /* Blocking mode: Polling */ 00523 HAL_StatusTypeDef HAL_LPTIM_Encoder_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period); 00524 HAL_StatusTypeDef HAL_LPTIM_Encoder_Stop(LPTIM_HandleTypeDef *hlptim); 00525 /* Non-Blocking mode: Interrupt */ 00526 HAL_StatusTypeDef HAL_LPTIM_Encoder_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period); 00527 HAL_StatusTypeDef HAL_LPTIM_Encoder_Stop_IT(LPTIM_HandleTypeDef *hlptim); 00528 00529 /* ############################# Time out Mode ##############################*/ 00530 /* Blocking mode: Polling */ 00531 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Timeout); 00532 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Stop(LPTIM_HandleTypeDef *hlptim); 00533 /* Non-Blocking mode: Interrupt */ 00534 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Timeout); 00535 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Stop_IT(LPTIM_HandleTypeDef *hlptim); 00536 00537 /* ############################## Counter Mode ###############################*/ 00538 /* Blocking mode: Polling */ 00539 HAL_StatusTypeDef HAL_LPTIM_Counter_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period); 00540 HAL_StatusTypeDef HAL_LPTIM_Counter_Stop(LPTIM_HandleTypeDef *hlptim); 00541 /* Non-Blocking mode: Interrupt */ 00542 HAL_StatusTypeDef HAL_LPTIM_Counter_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period); 00543 HAL_StatusTypeDef HAL_LPTIM_Counter_Stop_IT(LPTIM_HandleTypeDef *hlptim); 00544 00545 /* Reading operation functions ************************************************/ 00546 uint32_t HAL_LPTIM_ReadCounter(LPTIM_HandleTypeDef *hlptim); 00547 uint32_t HAL_LPTIM_ReadAutoReload(LPTIM_HandleTypeDef *hlptim); 00548 uint32_t HAL_LPTIM_ReadCompare(LPTIM_HandleTypeDef *hlptim); 00549 00550 /* LPTIM IRQ functions *******************************************************/ 00551 void HAL_LPTIM_IRQHandler(LPTIM_HandleTypeDef *hlptim); 00552 00553 /* CallBack functions ********************************************************/ 00554 void HAL_LPTIM_CompareMatchCallback(LPTIM_HandleTypeDef *hlptim); 00555 void HAL_LPTIM_AutoReloadMatchCallback(LPTIM_HandleTypeDef *hlptim); 00556 void HAL_LPTIM_TriggerCallback(LPTIM_HandleTypeDef *hlptim); 00557 void HAL_LPTIM_CompareWriteCallback(LPTIM_HandleTypeDef *hlptim); 00558 void HAL_LPTIM_AutoReloadWriteCallback(LPTIM_HandleTypeDef *hlptim); 00559 void HAL_LPTIM_DirectionUpCallback(LPTIM_HandleTypeDef *hlptim); 00560 void HAL_LPTIM_DirectionDownCallback(LPTIM_HandleTypeDef *hlptim); 00561 00562 /* Peripheral State functions ************************************************/ 00563 HAL_LPTIM_StateTypeDef HAL_LPTIM_GetState(LPTIM_HandleTypeDef *hlptim); 00564 00565 /** 00566 * @} 00567 */ 00568 00569 /* Private types -------------------------------------------------------------*/ 00570 /** @defgroup LPTIM_Private_Types LPTIM Private Types 00571 * @{ 00572 */ 00573 00574 /** 00575 * @} 00576 */ 00577 00578 /* Private variables ---------------------------------------------------------*/ 00579 /** @defgroup LPTIM_Private_Variables LPTIM Private Variables 00580 * @{ 00581 */ 00582 00583 /** 00584 * @} 00585 */ 00586 00587 /* Private constants ---------------------------------------------------------*/ 00588 /** @defgroup LPTIM_Private_Constants LPTIM Private Constants 00589 * @{ 00590 */ 00591 00592 /** 00593 * @} 00594 */ 00595 00596 /* Private macros ------------------------------------------------------------*/ 00597 /** @defgroup LPTIM_Private_Macros LPTIM Private Macros 00598 * @{ 00599 */ 00600 00601 #define IS_LPTIM_CLOCK_SOURCE(__SOURCE__) (((__SOURCE__) == LPTIM_CLOCKSOURCE_ULPTIM) || \ 00602 ((__SOURCE__) == LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC)) 00603 00604 00605 #define IS_LPTIM_CLOCK_PRESCALER(__PRESCALER__) (((__PRESCALER__) == LPTIM_PRESCALER_DIV1 ) || \ 00606 ((__PRESCALER__) == LPTIM_PRESCALER_DIV2 ) || \ 00607 ((__PRESCALER__) == LPTIM_PRESCALER_DIV4 ) || \ 00608 ((__PRESCALER__) == LPTIM_PRESCALER_DIV8 ) || \ 00609 ((__PRESCALER__) == LPTIM_PRESCALER_DIV16 ) || \ 00610 ((__PRESCALER__) == LPTIM_PRESCALER_DIV32 ) || \ 00611 ((__PRESCALER__) == LPTIM_PRESCALER_DIV64 ) || \ 00612 ((__PRESCALER__) == LPTIM_PRESCALER_DIV128)) 00613 00614 #define IS_LPTIM_CLOCK_PRESCALERDIV1(__PRESCALER__) ((__PRESCALER__) == LPTIM_PRESCALER_DIV1) 00615 00616 #define IS_LPTIM_OUTPUT_POLARITY(__POLARITY__) (((__POLARITY__) == LPTIM_OUTPUTPOLARITY_LOW ) || \ 00617 ((__POLARITY__) == LPTIM_OUTPUTPOLARITY_HIGH)) 00618 00619 #define IS_LPTIM_CLOCK_SAMPLE_TIME(__SAMPLETIME__) (((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_DIRECTTRANSITION) || \ 00620 ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_2TRANSITIONS) || \ 00621 ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_4TRANSITIONS) || \ 00622 ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_8TRANSITIONS)) 00623 00624 #define IS_LPTIM_CLOCK_POLARITY(__POLARITY__) (((__POLARITY__) == LPTIM_CLOCKPOLARITY_RISING) || \ 00625 ((__POLARITY__) == LPTIM_CLOCKPOLARITY_FALLING) || \ 00626 ((__POLARITY__) == LPTIM_CLOCKPOLARITY_RISING_FALLING)) 00627 00628 #define IS_LPTIM_TRG_SOURCE(__TRIG__) (((__TRIG__) == LPTIM_TRIGSOURCE_SOFTWARE) || \ 00629 ((__TRIG__) == LPTIM_TRIGSOURCE_0) || \ 00630 ((__TRIG__) == LPTIM_TRIGSOURCE_1) || \ 00631 ((__TRIG__) == LPTIM_TRIGSOURCE_2) || \ 00632 ((__TRIG__) == LPTIM_TRIGSOURCE_3) || \ 00633 ((__TRIG__) == LPTIM_TRIGSOURCE_4) || \ 00634 ((__TRIG__) == LPTIM_TRIGSOURCE_5) || \ 00635 ((__TRIG__) == LPTIM_TRIGSOURCE_6) || \ 00636 ((__TRIG__) == LPTIM_TRIGSOURCE_7)) 00637 00638 #define IS_LPTIM_EXT_TRG_POLARITY(__POLARITY__) (((__POLARITY__) == LPTIM_ACTIVEEDGE_RISING ) || \ 00639 ((__POLARITY__) == LPTIM_ACTIVEEDGE_FALLING ) || \ 00640 ((__POLARITY__) == LPTIM_ACTIVEEDGE_RISING_FALLING )) 00641 00642 #define IS_LPTIM_TRIG_SAMPLE_TIME(__SAMPLETIME__) (((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_DIRECTTRANSITION) || \ 00643 ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_2TRANSITIONS ) || \ 00644 ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_4TRANSITIONS ) || \ 00645 ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_8TRANSITIONS )) 00646 00647 #define IS_LPTIM_UPDATE_MODE(__MODE__) (((__MODE__) == LPTIM_UPDATE_IMMEDIATE) || \ 00648 ((__MODE__) == LPTIM_UPDATE_ENDOFPERIOD)) 00649 00650 #define IS_LPTIM_COUNTER_SOURCE(__SOURCE__) (((__SOURCE__) == LPTIM_COUNTERSOURCE_INTERNAL) || \ 00651 ((__SOURCE__) == LPTIM_COUNTERSOURCE_EXTERNAL)) 00652 00653 #define IS_LPTIM_AUTORELOAD(__AUTORELOAD__) ((__AUTORELOAD__) <= 0x0000FFFF) 00654 00655 #define IS_LPTIM_COMPARE(__COMPARE__) ((__COMPARE__) <= 0x0000FFFF) 00656 00657 #define IS_LPTIM_PERIOD(__PERIOD__) ((__PERIOD__) <= 0x0000FFFF) 00658 00659 #define IS_LPTIM_PULSE(__PULSE__) ((__PULSE__) <= 0x0000FFFF) 00660 00661 #define IS_LPTIM_INPUT1_SOURCE(__INSTANCE__, __SOURCE__) \ 00662 ((((__INSTANCE__) == LPTIM1) && \ 00663 (((__SOURCE__) == LPTIM_INPUT1SOURCE_GPIO) || \ 00664 ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP1))) \ 00665 || \ 00666 (((__INSTANCE__) == LPTIM2) && \ 00667 (((__SOURCE__) == LPTIM_INPUT1SOURCE_GPIO) || \ 00668 ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP1) || \ 00669 ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP2) || \ 00670 ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP1_COMP2)))) 00671 00672 #define IS_LPTIM_INPUT2_SOURCE(__INSTANCE__, __SOURCE__) \ 00673 (((__INSTANCE__) == LPTIM1) && \ 00674 (((__SOURCE__) == LPTIM_INPUT2SOURCE_GPIO) || \ 00675 ((__SOURCE__) == LPTIM_INPUT2SOURCE_COMP2))) 00676 00677 /** 00678 * @} 00679 */ 00680 00681 /* Private functions ---------------------------------------------------------*/ 00682 /** @defgroup LPTIM_Private_Functions LPTIM Private Functions 00683 * @{ 00684 */ 00685 00686 /** 00687 * @} 00688 */ 00689 00690 /** 00691 * @} 00692 */ 00693 00694 /** 00695 * @} 00696 */ 00697 00698 #ifdef __cplusplus 00699 } 00700 #endif 00701 00702 #endif /* __STM32L4xx_HAL_LPTIM_H */ 00703 00704 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 00705
Generated on Tue Jul 12 2022 11:35:14 by 1.7.2