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