1 /** 2 ****************************************************************************** 3 * @file stm32l0xx_hal_lptim.h 4 * @author MCD Application Team 5 * @brief Header file of LPTIM HAL module. 6 ****************************************************************************** 7 * @attention 8 * 9 * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> 10 * 11 * Redistribution and use in source and binary forms, with or without modification, 12 * are permitted provided that the following conditions are met: 13 * 1. Redistributions of source code must retain the above copyright notice, 14 * this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright notice, 16 * this list of conditions and the following disclaimer in the documentation 17 * and/or other materials provided with the distribution. 18 * 3. Neither the name of STMicroelectronics nor the names of its contributors 19 * may be used to endorse or promote products derived from this software 20 * without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 * 33 ****************************************************************************** 34 */ 35 36 /* Define to prevent recursive inclusion -------------------------------------*/ 37 #ifndef __STM32L0xx_HAL_LPTIM_H 38 #define __STM32L0xx_HAL_LPTIM_H 39 40 #ifdef __cplusplus 41 extern "C" { 42 #endif 43 44 /* Includes ------------------------------------------------------------------*/ 45 #include "stm32l0xx_hal_def.h" 46 47 /** @addtogroup STM32L0xx_HAL_Driver 48 * @{ 49 */ 50 51 /** @defgroup LPTIM LPTIM (Low power timer) 52 * @{ 53 */ 54 55 /* Exported types ------------------------------------------------------------*/ 56 /** @defgroup LPTIM_Exported_Types LPTIM Exported Types 57 * @{ 58 */ 59 60 /** @defgroup LPTIM_Clock_Configuration LPTIM Clock configuration structure 61 * @{ 62 */ 63 #define LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT ((uint32_t)EXTI_IMR_IM29) /*!< External interrupt line 29 Connected to the LPTIM EXTI Line */ 64 65 /** 66 * @brief LPTIM Clock configuration definition 67 */ 68 typedef struct 69 { 70 uint32_t Source; /*!< Selects the clock source. 71 This parameter can be a value of @ref LPTIM_Clock_Source */ 72 73 uint32_t Prescaler; /*!< Specifies the counter clock Prescaler. 74 This parameter can be a value of @ref LPTIM_Clock_Prescaler */ 75 76 }LPTIM_ClockConfigTypeDef; 77 /** 78 * @} 79 */ 80 81 /** @defgroup LPTIM_ULPClock_Configuration LPTIM ULP Clock configuration structure 82 * @{ 83 */ 84 /** 85 * @brief LPTIM ULP Clock configuration definition 86 */ 87 typedef struct 88 { 89 uint32_t Polarity; /*!< Selects the polarity of the active edge for the counter unit 90 if the ULPTIM input is selected. 91 Note: This parameter is used only when Ultra low power clock source is used. 92 Note: If the polarity is configured on 'both edges', an auxiliary clock 93 (one of the Low power oscillator) must be active. 94 This parameter can be a value of @ref LPTIM_Clock_Polarity */ 95 96 uint32_t SampleTime; /*!< Selects the clock sampling time to configure the clock glitch filter. 97 Note: This parameter is used only when Ultra low power clock source is used. 98 This parameter can be a value of @ref LPTIM_Clock_Sample_Time */ 99 100 }LPTIM_ULPClockConfigTypeDef; 101 /** 102 * @} 103 */ 104 105 /** @defgroup LPTIM_Trigger_Configuration LPTIM Trigger configuration structure 106 * @{ 107 */ 108 /** 109 * @brief LPTIM Trigger configuration structure 110 */ 111 typedef struct 112 { 113 uint32_t Source; /*!< Selects the Trigger source. 114 This parameter can be a value of @ref LPTIM_Trigger_Source */ 115 116 uint32_t ActiveEdge; /*!< Selects the Trigger active edge. 117 Note: This parameter is used only when an external trigger is used. 118 This parameter can be a value of @ref LPTIM_External_Trigger_Polarity */ 119 120 uint32_t SampleTime; /*!< Selects the trigger sampling time to configure the clock glitch filter. 121 Note: This parameter is used only when an external trigger is used. 122 This parameter can be a value of @ref LPTIM_Trigger_Sample_Time */ 123 }LPTIM_TriggerConfigTypeDef; 124 /** 125 * @} 126 */ 127 128 /** @defgroup LPTIM_Init_Configuration LPTIM Initialization configuration structure 129 * @{ 130 */ 131 /** 132 * @brief LPTIM Initialization Structure definition 133 */ 134 typedef struct 135 { 136 LPTIM_ClockConfigTypeDef Clock; /*!< Specifies the clock parameters */ 137 138 LPTIM_ULPClockConfigTypeDef UltraLowPowerClock; /*!< Specifies the Ultra Low Power clock parameters */ 139 140 LPTIM_TriggerConfigTypeDef Trigger; /*!< Specifies the Trigger parameters */ 141 142 uint32_t OutputPolarity; /*!< Specifies the Output polarity. 143 This parameter can be a value of @ref LPTIM_Output_Polarity */ 144 145 uint32_t UpdateMode; /*!< Specifies whether the update of the autorelaod and the compare 146 values is done immediately or after the end of current period. 147 This parameter can be a value of @ref LPTIM_Updating_Mode */ 148 149 uint32_t CounterSource; /*!< Specifies whether the counter is incremented each internal event 150 or each external event. 151 This parameter can be a value of @ref LPTIM_Counter_Source */ 152 153 }LPTIM_InitTypeDef; 154 /** 155 * @} 156 */ 157 /** @defgroup LPTIM_State_structure LPTIM state definition 158 * @{ 159 */ 160 /** 161 * @brief HAL LPTIM State structure definition 162 */ 163 typedef enum __HAL_LPTIM_StateTypeDef 164 { 165 HAL_LPTIM_STATE_RESET = 0x00U, /*!< Peripheral not yet initialized or disabled */ 166 HAL_LPTIM_STATE_READY = 0x01U, /*!< Peripheral Initialized and ready for use */ 167 HAL_LPTIM_STATE_BUSY = 0x02U, /*!< An internal process is ongoing */ 168 HAL_LPTIM_STATE_TIMEOUT = 0x03U, /*!< Timeout state */ 169 HAL_LPTIM_STATE_ERROR = 0x04U /*!< Internal Process is ongoing */ 170 }HAL_LPTIM_StateTypeDef; 171 /** 172 * @} 173 */ 174 175 /** @defgroup LPTIM_Handle LPTIM handler 176 * @{ 177 */ 178 /** 179 * @brief LPTIM handle Structure definition 180 */ 181 typedef struct 182 { 183 LPTIM_TypeDef *Instance; /*!< Register base address */ 184 185 LPTIM_InitTypeDef Init; /*!< LPTIM required parameters */ 186 187 HAL_StatusTypeDef Status; /*!< LPTIM peripheral status */ 188 189 HAL_LockTypeDef Lock; /*!< LPTIM locking object */ 190 191 __IO HAL_LPTIM_StateTypeDef State; /*!< LPTIM peripheral state */ 192 193 }LPTIM_HandleTypeDef; 194 195 /** 196 * @} 197 */ 198 /** 199 * @} 200 */ 201 202 /* Exported constants --------------------------------------------------------*/ 203 204 /** @defgroup LPTIM_Exported_Constants LPTIM Exported constants 205 * @{ 206 */ 207 208 /* Check autoreload value */ 209 #define IS_LPTIM_AUTORELOAD(__AUTORELOAD__) ((__AUTORELOAD__) <= 0x0000FFFFU) 210 211 /* Check compare value */ 212 #define IS_LPTIM_COMPARE(__COMPARE__) ((__COMPARE__) <= 0x0000FFFFU) 213 214 /** @defgroup LPTIM_Clock_Source Clock source 215 * @{ 216 */ 217 #define LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC ((uint32_t)0x00U) 218 #define LPTIM_CLOCKSOURCE_ULPTIM LPTIM_CFGR_CKSEL 219 /** 220 * @} 221 */ 222 #define IS_LPTIM_CLOCK_SOURCE(__SOURCE__) (((__SOURCE__) == LPTIM_CLOCKSOURCE_ULPTIM) || \ 223 ((__SOURCE__) == LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC)) 224 225 226 /** @defgroup LPTIM_Clock_Prescaler Prescaler 227 * @{ 228 */ 229 #define LPTIM_PRESCALER_DIV1 ((uint32_t)0x000000U) 230 #define LPTIM_PRESCALER_DIV2 LPTIM_CFGR_PRESC_0 231 #define LPTIM_PRESCALER_DIV4 LPTIM_CFGR_PRESC_1 232 #define LPTIM_PRESCALER_DIV8 ((uint32_t)(LPTIM_CFGR_PRESC_0 | LPTIM_CFGR_PRESC_1)) 233 #define LPTIM_PRESCALER_DIV16 LPTIM_CFGR_PRESC_2 234 #define LPTIM_PRESCALER_DIV32 ((uint32_t)(LPTIM_CFGR_PRESC_0 | LPTIM_CFGR_PRESC_2)) 235 #define LPTIM_PRESCALER_DIV64 ((uint32_t)(LPTIM_CFGR_PRESC_1 | LPTIM_CFGR_PRESC_2)) 236 #define LPTIM_PRESCALER_DIV128 ((uint32_t)LPTIM_CFGR_PRESC) 237 /** 238 * @} 239 */ 240 241 #define IS_LPTIM_CLOCK_PRESCALER(__PRESCALER__) (((__PRESCALER__) == LPTIM_PRESCALER_DIV1 ) || \ 242 ((__PRESCALER__) == LPTIM_PRESCALER_DIV2 ) || \ 243 ((__PRESCALER__) == LPTIM_PRESCALER_DIV4 ) || \ 244 ((__PRESCALER__) == LPTIM_PRESCALER_DIV8 ) || \ 245 ((__PRESCALER__) == LPTIM_PRESCALER_DIV16 ) || \ 246 ((__PRESCALER__) == LPTIM_PRESCALER_DIV32 ) || \ 247 ((__PRESCALER__) == LPTIM_PRESCALER_DIV64 ) || \ 248 ((__PRESCALER__) == LPTIM_PRESCALER_DIV128)) 249 250 #define IS_LPTIM_CLOCK_PRESCALERDIV1(__PRESCALER__) ((__PRESCALER__) == LPTIM_PRESCALER_DIV1) 251 252 253 /** @defgroup LPTIM_Output_Polarity Output polarity 254 * @{ 255 */ 256 #define LPTIM_OUTPUTPOLARITY_HIGH ((uint32_t)0x00000000U) 257 #define LPTIM_OUTPUTPOLARITY_LOW (LPTIM_CFGR_WAVPOL) 258 /** 259 * @} 260 */ 261 #define IS_LPTIM_OUTPUT_POLARITY(__POLARITY__) (((__POLARITY__) == LPTIM_OUTPUTPOLARITY_LOW ) || \ 262 ((__POLARITY__) == LPTIM_OUTPUTPOLARITY_HIGH)) 263 264 /** @defgroup LPTIM_Clock_Sample_Time Clock sample time 265 * @{ 266 */ 267 #define LPTIM_CLOCKSAMPLETIME_DIRECTTRANSITION ((uint32_t)0x00000000U) 268 #define LPTIM_CLOCKSAMPLETIME_2TRANSITIONS LPTIM_CFGR_CKFLT_0 269 #define LPTIM_CLOCKSAMPLETIME_4TRANSITIONS LPTIM_CFGR_CKFLT_1 270 #define LPTIM_CLOCKSAMPLETIME_8TRANSITIONS LPTIM_CFGR_CKFLT 271 /** 272 * @} 273 */ 274 #define IS_LPTIM_CLOCK_SAMPLE_TIME(__SAMPLETIME__) (((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_DIRECTTRANSITION) || \ 275 ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_2TRANSITIONS) || \ 276 ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_4TRANSITIONS) || \ 277 ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_8TRANSITIONS)) 278 279 /** @defgroup LPTIM_Clock_Polarity Clock polarity 280 * @{ 281 */ 282 #define LPTIM_CLOCKPOLARITY_RISING ((uint32_t)0x00000000U) 283 #define LPTIM_CLOCKPOLARITY_FALLING LPTIM_CFGR_CKPOL_0 284 #define LPTIM_CLOCKPOLARITY_RISING_FALLING LPTIM_CFGR_CKPOL_1 285 /** 286 * @} 287 */ 288 289 #define IS_LPTIM_CLOCK_POLARITY(__POLARITY__) (((__POLARITY__) == LPTIM_CLOCKPOLARITY_RISING) || \ 290 ((__POLARITY__) == LPTIM_CLOCKPOLARITY_FALLING) || \ 291 ((__POLARITY__) == LPTIM_CLOCKPOLARITY_RISING_FALLING)) 292 293 /** @defgroup LPTIM_External_Trigger_Polarity Trigger polarity 294 * @{ 295 */ 296 #define LPTIM_ACTIVEEDGE_RISING LPTIM_CFGR_TRIGEN_0 297 #define LPTIM_ACTIVEEDGE_FALLING LPTIM_CFGR_TRIGEN_1 298 #define LPTIM_ACTIVEEDGE_RISING_FALLING LPTIM_CFGR_TRIGEN 299 /** 300 * @} 301 */ 302 #define IS_LPTIM_EXT_TRG_POLARITY(__POLAR__) (((__POLAR__) == LPTIM_ACTIVEEDGE_RISING ) || \ 303 ((__POLAR__) == LPTIM_ACTIVEEDGE_FALLING ) || \ 304 ((__POLAR__) == LPTIM_ACTIVEEDGE_RISING_FALLING )) 305 306 /** @defgroup LPTIM_Trigger_Sample_Time Trigger sample time 307 * @{ 308 */ 309 #define LPTIM_TRIGSAMPLETIME_DIRECTTRANSITION ((uint32_t)0x00000000U) 310 #define LPTIM_TRIGSAMPLETIME_2TRANSITIONS LPTIM_CFGR_TRGFLT_0 311 #define LPTIM_TRIGSAMPLETIME_4TRANSITIONS LPTIM_CFGR_TRGFLT_1 312 #define LPTIM_TRIGSAMPLETIME_8TRANSITIONS LPTIM_CFGR_TRGFLT 313 /** 314 * @} 315 */ 316 #define IS_LPTIM_TRIG_SAMPLE_TIME(__SAMPLETIME__) (((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_DIRECTTRANSITION ) || \ 317 ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_2TRANSITIONS ) || \ 318 ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_4TRANSITIONS ) || \ 319 ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_8TRANSITIONS )) 320 321 322 /** @defgroup LPTIM_Updating_Mode Updating mode 323 * @{ 324 */ 325 326 #define LPTIM_UPDATE_IMMEDIATE ((uint32_t)0x00000000U) 327 #define LPTIM_UPDATE_ENDOFPERIOD LPTIM_CFGR_PRELOAD 328 /** 329 * @} 330 */ 331 #define IS_LPTIM_UPDATE_MODE(__MODE__) (((__MODE__) == LPTIM_UPDATE_IMMEDIATE) || \ 332 ((__MODE__) == LPTIM_UPDATE_ENDOFPERIOD)) 333 334 335 336 /** @defgroup LPTIM_Counter_Source Counter source 337 * @{ 338 */ 339 #define LPTIM_COUNTERSOURCE_INTERNAL ((uint32_t)0x00000000U) 340 #define LPTIM_COUNTERSOURCE_EXTERNAL LPTIM_CFGR_COUNTMODE 341 /** 342 * @} 343 */ 344 #define IS_LPTIM_COUNTER_SOURCE(__SOURCE__) (((__SOURCE__) == LPTIM_COUNTERSOURCE_INTERNAL) || \ 345 ((__SOURCE__) == LPTIM_COUNTERSOURCE_EXTERNAL)) 346 347 348 349 /* Check for period value */ 350 #define IS_LPTIM_PERIOD(__PERIOD__) ((__PERIOD__) <= 0x0000FFFFU) 351 352 /* Check for pulse value */ 353 #define IS_LPTIM_PULSE(__PULSE__) ((__PULSE__) <= 0x0000FFFFU) 354 355 /** @defgroup LPTIM_Flag_Definition Flag definition 356 * @{ 357 */ 358 #define LPTIM_FLAG_DOWN LPTIM_ISR_DOWN 359 #define LPTIM_FLAG_UP LPTIM_ISR_UP 360 #define LPTIM_FLAG_ARROK LPTIM_ISR_ARROK 361 #define LPTIM_FLAG_CMPOK LPTIM_ISR_CMPOK 362 #define LPTIM_FLAG_EXTTRIG LPTIM_ISR_EXTTRIG 363 #define LPTIM_FLAG_ARRM LPTIM_ISR_ARRM 364 #define LPTIM_FLAG_CMPM LPTIM_ISR_CMPM 365 /** 366 * @} 367 */ 368 369 /** @defgroup LPTIM_Interrupts_Definition Interrupts definition 370 * @{ 371 */ 372 #define LPTIM_IT_DOWN LPTIM_IER_DOWNIE 373 #define LPTIM_IT_UP LPTIM_IER_UPIE 374 #define LPTIM_IT_ARROK LPTIM_IER_ARROKIE 375 #define LPTIM_IT_CMPOK LPTIM_IER_CMPOKIE 376 #define LPTIM_IT_EXTTRIG LPTIM_IER_EXTTRIGIE 377 #define LPTIM_IT_ARRM LPTIM_IER_ARRMIE 378 #define LPTIM_IT_CMPM LPTIM_IER_CMPMIE 379 /** 380 * @} 381 */ 382 383 /** 384 * @} 385 */ 386 387 /* Exported macro ------------------------------------------------------------*/ 388 389 /** @defgroup LPTIM_Exported_Macros LPTIM Exported Macros 390 * @{ 391 */ 392 393 /** @brief Reset LPTIM handle state 394 * @param __HANDLE__: LPTIM handle 395 * @retval None 396 */ 397 #define __HAL_LPTIM_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_LPTIM_STATE_RESET) 398 399 /** 400 * @brief Enable/Disable the LPTIM peripheral. 401 * @param __HANDLE__: LPTIM handle 402 * @retval None 403 */ 404 #define __HAL_LPTIM_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (LPTIM_CR_ENABLE)) 405 #define __HAL_LPTIM_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(LPTIM_CR_ENABLE)) 406 407 /** 408 * @brief Starts the LPTIM peripheral in Continuous or in single mode. 409 * @param __HANDLE__: DMA handle 410 * @retval None 411 */ 412 #define __HAL_LPTIM_START_CONTINUOUS(__HANDLE__) ((__HANDLE__)->Instance->CR |= LPTIM_CR_CNTSTRT) 413 #define __HAL_LPTIM_START_SINGLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= LPTIM_CR_SNGSTRT) 414 415 416 /** 417 * @brief Writes the passed parameter in the Autoreload register. 418 * @param __HANDLE__: LPTIM handle 419 * @param __VALUE__ : Autoreload value 420 * @retval None 421 */ 422 #define __HAL_LPTIM_AUTORELOAD_SET(__HANDLE__ , __VALUE__) ((__HANDLE__)->Instance->ARR = (__VALUE__)) 423 424 /** 425 * @brief Writes the passed parameter in the Compare register. 426 * @param __HANDLE__: LPTIM handle 427 * @param __VALUE__ : Compare value 428 * @retval None 429 */ 430 #define __HAL_LPTIM_COMPARE_SET(__HANDLE__ , __VALUE__) ((__HANDLE__)->Instance->CMP = (__VALUE__)) 431 432 /** 433 * @brief Checks whether the specified LPTIM flag is set or not. 434 * @param __HANDLE__: LPTIM handle 435 * @param __FLAG__ : LPTIM flag to check 436 * This parameter can be a value of: 437 * @arg LPTIM_FLAG_DOWN : Counter direction change up Flag. 438 * @arg LPTIM_FLAG_UP : Counter direction change down to up Flag. 439 * @arg LPTIM_FLAG_ARROK : Autoreload register update OK Flag. 440 * @arg LPTIM_FLAG_CMPOK : Compare register update OK Flag. 441 * @arg LPTIM_FLAG_EXTTRIG : External trigger edge event Flag. 442 * @arg LPTIM_FLAG_ARRM : Autoreload match Flag. 443 * @arg LPTIM_FLAG_CMPM : Compare match Flag. 444 * @retval The state of the specified flag (SET or RESET). 445 */ 446 #define __HAL_LPTIM_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR &(__FLAG__)) == (__FLAG__)) 447 448 /** 449 * @brief Clears the specified LPTIM flag. 450 * @param __HANDLE__: LPTIM handle. 451 * @param __FLAG__ : LPTIM flag to clear. 452 * This parameter can be a value of: 453 * @arg LPTIM_FLAG_DOWN : Counter direction change up Flag. 454 * @arg LPTIM_FLAG_UP : Counter direction change down to up Flag. 455 * @arg LPTIM_FLAG_ARROK : Autoreload register update OK Flag. 456 * @arg LPTIM_FLAG_CMPOK : Compare register update OK Flag. 457 * @arg LPTIM_FLAG_EXTTRIG : External trigger edge event Flag. 458 * @arg LPTIM_FLAG_ARRM : Autoreload match Flag. 459 * @arg LPTIM_FLAG_CMPM : Compare match Flag. 460 * @retval None. 461 */ 462 #define __HAL_LPTIM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__)) 463 464 /** 465 * @brief Enable the specified LPTIM interrupt. 466 * @param __HANDLE__ : LPTIM handle. 467 * @param __INTERRUPT__ : LPTIM interrupt to set. 468 * This parameter can be a value of: 469 * @arg LPTIM_IT_DOWN : Counter direction change up Interrupt. 470 * @arg LPTIM_IT_UP : Counter direction change down to up Interrupt. 471 * @arg LPTIM_IT_ARROK : Autoreload register update OK Interrupt. 472 * @arg LPTIM_IT_CMPOK : Compare register update OK Interrupt. 473 * @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt. 474 * @arg LPTIM_IT_ARRM : Autoreload match Interrupt. 475 * @arg LPTIM_IT_CMPM : Compare match Interrupt. 476 * @retval None. 477 */ 478 #define __HAL_LPTIM_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER |= (__INTERRUPT__)) 479 480 /** 481 * @brief Disable the specified LPTIM interrupt. 482 * @param __HANDLE__ : LPTIM handle. 483 * @param __INTERRUPT__ : LPTIM interrupt to set. 484 * This parameter can be a value of: 485 * @arg LPTIM_IT_DOWN : Counter direction change up Interrupt. 486 * @arg LPTIM_IT_UP : Counter direction change down to up Interrupt. 487 * @arg LPTIM_IT_ARROK : Autoreload register update OK Interrupt. 488 * @arg LPTIM_IT_CMPOK : Compare register update OK Interrupt. 489 * @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt. 490 * @arg LPTIM_IT_ARRM : Autoreload match Interrupt. 491 * @arg LPTIM_IT_CMPM : Compare match Interrupt. 492 * @retval None. 493 */ 494 #define __HAL_LPTIM_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER &= (~(__INTERRUPT__))) 495 496 /** 497 * @brief Checks whether the specified LPTIM interrupt is set or not. 498 * @param __HANDLE__ : LPTIM handle. 499 * @param __INTERRUPT__ : LPTIM interrupt to check. 500 * This parameter can be a value of: 501 * @arg LPTIM_IT_DOWN : Counter direction change up Interrupt. 502 * @arg LPTIM_IT_UP : Counter direction change down to up Interrupt. 503 * @arg LPTIM_IT_ARROK : Autoreload register update OK Interrupt. 504 * @arg LPTIM_IT_CMPOK : Compare register update OK Interrupt. 505 * @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt. 506 * @arg LPTIM_IT_ARRM : Autoreload match Interrupt. 507 * @arg LPTIM_IT_CMPM : Compare match Interrupt. 508 * @retval Interrupt status. 509 */ 510 511 #define __HAL_LPTIM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->IER & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) 512 513 /** 514 * @brief Enable interrupt on the LPTIM Wake-up Timer associated Exti line. 515 * @retval None 516 */ 517 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_IT() (EXTI->IMR |= LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT) 518 519 /** 520 * @brief Disable interrupt on the LPTIM Wake-up Timer associated Exti line. 521 * @retval None 522 */ 523 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_IT() (EXTI->IMR &= ~(LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT)) 524 525 /** 526 * @brief Enable event on the LPTIM Wake-up Timer associated Exti line. 527 * @retval None. 528 */ 529 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_EVENT() (EXTI->EMR |= LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT) 530 531 /** 532 * @brief Disable event on the LPTIM Wake-up Timer associated Exti line. 533 * @retval None. 534 */ 535 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_EVENT() (EXTI->EMR &= ~(LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT)) 536 537 /** 538 * @brief Enable falling edge trigger on the LPTIM Wake-up Timer associated Exti line. 539 * @retval None. 540 */ 541 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR |= LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT) 542 543 /** 544 * @brief Disable falling edge trigger on the LPTIM Wake-up Timer associated Exti line. 545 * @retval None. 546 */ 547 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR &= ~(LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT)) 548 549 /** 550 * @brief Enable rising edge trigger on the LPTIM Wake-up Timer associated Exti line. 551 * @retval None. 552 */ 553 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR |= LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT) 554 555 /** 556 * @brief Disable rising edge trigger on the LPTIM Wake-up Timer associated Exti line. 557 * @retval None. 558 */ 559 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR &= ~(LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT)) 560 561 /** 562 * @brief Enable rising & falling edge trigger on the LPTIM Wake-up Timer associated Exti line. 563 * @retval None. 564 */ 565 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_RISING_FALLING_EDGE() do{__HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE();\ 566 __HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_FALLING_EDGE();\ 567 }while(0) 568 569 /** 570 * @brief Disable rising & falling edge trigger on the LPTIM Wake-up Timer associated Exti line. 571 * @retval None. 572 */ 573 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_RISING_FALLING_EDGE() do{__HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_RISING_EDGE();\ 574 __HAL_LPTIM_WAKEUPTIMER_EXTI_DISABLE_FALLING_EDGE();\ 575 }while(0) 576 577 /** 578 * @brief Check whether the LPTIM Wake-up Timer associated Exti line interrupt flag is set or not. 579 * @retval Line Status. 580 */ 581 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_GET_FLAG() (EXTI->PR & LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT) 582 583 /** 584 * @brief Clear the LPTIM Wake-up Timer associated Exti line flag. 585 * @retval None. 586 */ 587 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_CLEAR_FLAG() (EXTI->PR = LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT) 588 589 /** 590 * @brief Generate a Software interrupt on the LPTIM Wake-up Timer associated Exti line. 591 * @retval None. 592 */ 593 #define __HAL_LPTIM_WAKEUPTIMER_EXTI_GENERATE_SWIT() (EXTI->SWIER |= LPTIM_EXTI_LINE_WAKEUPTIMER_EVENT) 594 595 /** 596 * @} 597 */ 598 599 600 /* Include LPTIM HAL Extension module */ 601 #include "stm32l0xx_hal_lptim_ex.h" 602 603 /* Exported functions --------------------------------------------------------*/ 604 605 /** @defgroup LPTIM_Exported_Functions LPTIM Exported Functions 606 * @{ 607 */ 608 /* Initialization/de-initialization functions ********************************/ 609 610 /** @defgroup LPTIM_Exported_Functions_Group1 Initialization/de-initialization functions 611 * @{ 612 */ 613 HAL_StatusTypeDef HAL_LPTIM_Init(LPTIM_HandleTypeDef *hlptim); 614 HAL_StatusTypeDef HAL_LPTIM_DeInit(LPTIM_HandleTypeDef *hlptim); 615 616 617 /* MSP functions *************************************************************/ 618 619 void HAL_LPTIM_MspInit(LPTIM_HandleTypeDef *hlptim); 620 void HAL_LPTIM_MspDeInit(LPTIM_HandleTypeDef *hlptim); 621 622 /** 623 * @} 624 */ 625 626 /* Start/Stop operation functions *********************************************/ 627 628 /** @defgroup LPTIM_Exported_Functions_Group2 LPTIM Start-Stop operation functions 629 * @{ 630 */ 631 632 /* ################################# PWM Mode ################################*/ 633 /* Blocking mode: Polling */ 634 HAL_StatusTypeDef HAL_LPTIM_PWM_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse); 635 HAL_StatusTypeDef HAL_LPTIM_PWM_Stop(LPTIM_HandleTypeDef *hlptim); 636 /* Non-Blocking mode: Interrupt */ 637 HAL_StatusTypeDef HAL_LPTIM_PWM_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse); 638 HAL_StatusTypeDef HAL_LPTIM_PWM_Stop_IT(LPTIM_HandleTypeDef *hlptim); 639 640 /* ############################# One Pulse Mode ##############################*/ 641 /* Blocking mode: Polling */ 642 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse); 643 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Stop(LPTIM_HandleTypeDef *hlptim); 644 /* Non-Blocking mode: Interrupt */ 645 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse); 646 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Stop_IT(LPTIM_HandleTypeDef *hlptim); 647 648 /* ############################## Set once Mode ##############################*/ 649 /* Blocking mode: Polling */ 650 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse); 651 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop(LPTIM_HandleTypeDef *hlptim); 652 /* Non-Blocking mode: Interrupt */ 653 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse); 654 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop_IT(LPTIM_HandleTypeDef *hlptim); 655 656 /* ############################### Encoder Mode ##############################*/ 657 /* Blocking mode: Polling */ 658 HAL_StatusTypeDef HAL_LPTIM_Encoder_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period); 659 HAL_StatusTypeDef HAL_LPTIM_Encoder_Stop(LPTIM_HandleTypeDef *hlptim); 660 /* Non-Blocking mode: Interrupt */ 661 HAL_StatusTypeDef HAL_LPTIM_Encoder_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period); 662 HAL_StatusTypeDef HAL_LPTIM_Encoder_Stop_IT(LPTIM_HandleTypeDef *hlptim); 663 664 /* ############################# Time out Mode ##############################*/ 665 /* Blocking mode: Polling */ 666 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Timeout); 667 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Stop(LPTIM_HandleTypeDef *hlptim); 668 /* Non-Blocking mode: Interrupt */ 669 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Timeout); 670 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Stop_IT(LPTIM_HandleTypeDef *hlptim); 671 672 /* ############################## Counter Mode ###############################*/ 673 /* Blocking mode: Polling */ 674 HAL_StatusTypeDef HAL_LPTIM_Counter_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period); 675 HAL_StatusTypeDef HAL_LPTIM_Counter_Stop(LPTIM_HandleTypeDef *hlptim); 676 /* Non-Blocking mode: Interrupt */ 677 HAL_StatusTypeDef HAL_LPTIM_Counter_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period); 678 HAL_StatusTypeDef HAL_LPTIM_Counter_Stop_IT(LPTIM_HandleTypeDef *hlptim); 679 680 /** 681 * @} 682 */ 683 684 /* Reading operation functions ************************************************/ 685 686 /** @defgroup LPTIM_Exported_Functions_Group3 LPTIM Read operation functions 687 * @{ 688 */ 689 uint32_t HAL_LPTIM_ReadCounter(LPTIM_HandleTypeDef *hlptim); 690 uint32_t HAL_LPTIM_ReadAutoReload(LPTIM_HandleTypeDef *hlptim); 691 uint32_t HAL_LPTIM_ReadCompare(LPTIM_HandleTypeDef *hlptim); 692 /** 693 * @} 694 */ 695 696 /* LPTIM IRQ functions *******************************************************/ 697 /** @defgroup LPTIM_Exported_Functions_Group4 LPTIM IRQ handler 698 * @{ 699 */ 700 void HAL_LPTIM_IRQHandler(LPTIM_HandleTypeDef *hlptim); 701 702 /* CallBack functions ********************************************************/ 703 void HAL_LPTIM_CompareMatchCallback(LPTIM_HandleTypeDef *hlptim); 704 void HAL_LPTIM_AutoReloadMatchCallback(LPTIM_HandleTypeDef *hlptim); 705 void HAL_LPTIM_TriggerCallback(LPTIM_HandleTypeDef *hlptim); 706 void HAL_LPTIM_CompareWriteCallback(LPTIM_HandleTypeDef *hlptim); 707 void HAL_LPTIM_AutoReloadWriteCallback(LPTIM_HandleTypeDef *hlptim); 708 void HAL_LPTIM_DirectionUpCallback(LPTIM_HandleTypeDef *hlptim); 709 void HAL_LPTIM_DirectionDownCallback(LPTIM_HandleTypeDef *hlptim); 710 /** 711 * @} 712 */ 713 /* Peripheral State functions ************************************************/ 714 /** @defgroup LPTIM_Exported_Functions_Group5 Peripheral State functions 715 * @{ 716 */ 717 718 HAL_LPTIM_StateTypeDef HAL_LPTIM_GetState(LPTIM_HandleTypeDef *hlptim); 719 720 /** 721 * @} 722 */ 723 724 /** 725 * @} 726 */ 727 728 /** 729 * @} 730 */ 731 732 /** 733 * @} 734 */ 735 736 #ifdef __cplusplus 737 } 738 #endif 739 740 #endif /* __STM32L0xx_HAL_LPTIM_H */ 741 742 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 743 744