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