source: trunk/firmware/Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_lptim.h

Last change on this file was 6, checked in by f.jahn, 8 months ago
File size: 33.9 KB
Line 
1/**
2 ******************************************************************************
3 * @file stm32g0xx_hal_lptim.h
4 * @author MCD Application Team
5 * @brief Header file of LPTIM HAL module.
6 ******************************************************************************
7 * @attention
8 *
9 * <h2><center>&copy; Copyright (c) 2018 STMicroelectronics.
10 * All rights reserved.</center></h2>
11 *
12 * This software component is licensed by ST under BSD 3-Clause license,
13 * the "License"; You may not use this file except in compliance with the
14 * License. You may obtain a copy of the License at:
15 * opensource.org/licenses/BSD-3-Clause
16 *
17 ******************************************************************************
18 */
19
20/* Define to prevent recursive inclusion -------------------------------------*/
21#ifndef STM32G0xx_HAL_LPTIM_H
22#define STM32G0xx_HAL_LPTIM_H
23
24#ifdef __cplusplus
25 extern "C" {
26#endif
27
28/* Includes ------------------------------------------------------------------*/
29#include "stm32g0xx_hal_def.h"
30
31/** @addtogroup STM32G0xx_HAL_Driver
32 * @{
33 */
34
35#if defined (LPTIM1) || defined (LPTIM2)
36
37/** @addtogroup LPTIM
38 * @{
39 */
40
41/* Exported types ------------------------------------------------------------*/
42/** @defgroup LPTIM_Exported_Types LPTIM Exported Types
43 * @{
44 */
45
46/**
47 * @brief LPTIM Clock configuration definition
48 */
49typedef struct
50{
51 uint32_t Source; /*!< Selects the clock source.
52 This parameter can be a value of @ref LPTIM_Clock_Source */
53
54 uint32_t Prescaler; /*!< Specifies the counter clock Prescaler.
55 This parameter can be a value of @ref LPTIM_Clock_Prescaler */
56
57}LPTIM_ClockConfigTypeDef;
58
59/**
60 * @brief LPTIM Clock configuration definition
61 */
62typedef struct
63{
64 uint32_t Polarity; /*!< Selects the polarity of the active edge for the counter unit
65 if the ULPTIM input is selected.
66 Note: This parameter is used only when Ultra low power clock source is used.
67 Note: If the polarity is configured on 'both edges', an auxiliary clock
68 (one of the Low power oscillator) must be active.
69 This parameter can be a value of @ref LPTIM_Clock_Polarity */
70
71 uint32_t SampleTime; /*!< Selects the clock sampling time to configure the clock glitch filter.
72 Note: This parameter is used only when Ultra low power clock source is used.
73 This parameter can be a value of @ref LPTIM_Clock_Sample_Time */
74
75}LPTIM_ULPClockConfigTypeDef;
76
77/**
78 * @brief LPTIM Trigger configuration definition
79 */
80typedef struct
81{
82 uint32_t Source; /*!< Selects the Trigger source.
83 This parameter can be a value of @ref LPTIM_Trigger_Source */
84
85 uint32_t ActiveEdge; /*!< Selects the Trigger active edge.
86 Note: This parameter is used only when an external trigger is used.
87 This parameter can be a value of @ref LPTIM_External_Trigger_Polarity */
88
89 uint32_t SampleTime; /*!< Selects the trigger sampling time to configure the clock glitch filter.
90 Note: This parameter is used only when an external trigger is used.
91 This parameter can be a value of @ref LPTIM_Trigger_Sample_Time */
92}LPTIM_TriggerConfigTypeDef;
93
94/**
95 * @brief LPTIM Initialization Structure definition
96 */
97typedef struct
98{
99 LPTIM_ClockConfigTypeDef Clock; /*!< Specifies the clock parameters */
100
101 LPTIM_ULPClockConfigTypeDef UltraLowPowerClock; /*!< Specifies the Ultra Low Power clock parameters */
102
103 LPTIM_TriggerConfigTypeDef Trigger; /*!< Specifies the Trigger parameters */
104
105 uint32_t OutputPolarity; /*!< Specifies the Output polarity.
106 This parameter can be a value of @ref LPTIM_Output_Polarity */
107
108 uint32_t UpdateMode; /*!< Specifies whether the update of the autoreload and the compare
109 values is done immediately or after the end of current period.
110 This parameter can be a value of @ref LPTIM_Updating_Mode */
111
112 uint32_t CounterSource; /*!< Specifies whether the counter is incremented each internal event
113 or each external event.
114 This parameter can be a value of @ref LPTIM_Counter_Source */
115
116 uint32_t Input1Source; /*!< Specifies source selected for input1 (GPIO or comparator output).
117 This parameter can be a value of @ref LPTIM_Input1_Source */
118
119 uint32_t Input2Source; /*!< Specifies source selected for input2 (GPIO or comparator output).
120 Note: This parameter is used only for encoder feature so is used only
121 for LPTIM1 instance.
122 This parameter can be a value of @ref LPTIM_Input2_Source */
123}LPTIM_InitTypeDef;
124
125/**
126 * @brief HAL LPTIM State structure definition
127 */
128typedef enum
129{
130 HAL_LPTIM_STATE_RESET = 0x00U, /*!< Peripheral not yet initialized or disabled */
131 HAL_LPTIM_STATE_READY = 0x01U, /*!< Peripheral Initialized and ready for use */
132 HAL_LPTIM_STATE_BUSY = 0x02U, /*!< An internal process is ongoing */
133 HAL_LPTIM_STATE_TIMEOUT = 0x03U, /*!< Timeout state */
134 HAL_LPTIM_STATE_ERROR = 0x04U /*!< Internal Process is ongoing */
135}HAL_LPTIM_StateTypeDef;
136
137/**
138 * @brief LPTIM handle Structure definition
139 */
140#if (USE_HAL_LPTIM_REGISTER_CALLBACKS == 1)
141typedef struct __LPTIM_HandleTypeDef
142#else
143typedef struct
144#endif
145{
146 LPTIM_TypeDef *Instance; /*!< Register base address */
147
148 LPTIM_InitTypeDef Init; /*!< LPTIM required parameters */
149
150 HAL_StatusTypeDef Status; /*!< LPTIM peripheral status */
151
152 HAL_LockTypeDef Lock; /*!< LPTIM locking object */
153
154 __IO HAL_LPTIM_StateTypeDef State; /*!< LPTIM peripheral state */
155
156#if (USE_HAL_LPTIM_REGISTER_CALLBACKS == 1)
157 void (* MspInitCallback) (struct __LPTIM_HandleTypeDef *hlptim); /*!< LPTIM Base Msp Init Callback */
158 void (* MspDeInitCallback) (struct __LPTIM_HandleTypeDef *hlptim); /*!< LPTIM Base Msp DeInit Callback */
159 void (* CompareMatchCallback) (struct __LPTIM_HandleTypeDef *hlptim); /*!< Compare match Callback */
160 void (* AutoReloadMatchCallback) (struct __LPTIM_HandleTypeDef *hlptim); /*!< Auto-reload match Callback */
161 void (* TriggerCallback) (struct __LPTIM_HandleTypeDef *hlptim); /*!< External trigger event detection Callback */
162 void (* CompareWriteCallback) (struct __LPTIM_HandleTypeDef *hlptim); /*!< Compare register write complete Callback */
163 void (* AutoReloadWriteCallback) (struct __LPTIM_HandleTypeDef *hlptim); /*!< Auto-reload register write complete Callback */
164 void (* DirectionUpCallback) (struct __LPTIM_HandleTypeDef *hlptim); /*!< Up-counting direction change Callback */
165 void (* DirectionDownCallback) (struct __LPTIM_HandleTypeDef *hlptim); /*!< Down-counting direction change Callback */
166#endif /* USE_HAL_LPTIM_REGISTER_CALLBACKS */
167}LPTIM_HandleTypeDef;
168
169#if (USE_HAL_LPTIM_REGISTER_CALLBACKS == 1)
170/**
171 * @brief HAL LPTIM Callback ID enumeration definition
172 */
173typedef enum
174{
175 HAL_LPTIM_MSPINIT_CB_ID = 0x00U, /*!< LPTIM Base Msp Init Callback ID */
176 HAL_LPTIM_MSPDEINIT_CB_ID = 0x01U, /*!< LPTIM Base Msp DeInit Callback ID */
177 HAL_LPTIM_COMPARE_MATCH_CB_ID = 0x02U, /*!< Compare match Callback ID */
178 HAL_LPTIM_AUTORELOAD_MATCH_CB_ID = 0x03U, /*!< Auto-reload match Callback ID */
179 HAL_LPTIM_TRIGGER_CB_ID = 0x04U, /*!< External trigger event detection Callback ID */
180 HAL_LPTIM_COMPARE_WRITE_CB_ID = 0x05U, /*!< Compare register write complete Callback ID */
181 HAL_LPTIM_AUTORELOAD_WRITE_CB_ID = 0x06U, /*!< Auto-reload register write complete Callback ID */
182 HAL_LPTIM_DIRECTION_UP_CB_ID = 0x07U, /*!< Up-counting direction change Callback ID */
183 HAL_LPTIM_DIRECTION_DOWN_CB_ID = 0x08U, /*!< Down-counting direction change Callback ID */
184}HAL_LPTIM_CallbackIDTypeDef;
185
186/**
187 * @brief HAL TIM Callback pointer definition
188 */
189typedef void (*pLPTIM_CallbackTypeDef)(LPTIM_HandleTypeDef * hlptim); /*!< pointer to the LPTIM callback function */
190
191#endif /* USE_HAL_LPTIM_REGISTER_CALLBACKS */
192/**
193 * @}
194 */
195
196/* Exported constants --------------------------------------------------------*/
197/** @defgroup LPTIM_Exported_Constants LPTIM Exported Constants
198 * @{
199 */
200
201/** @defgroup LPTIM_Clock_Source LPTIM Clock Source
202 * @{
203 */
204#define LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC 0x00000000U
205#define LPTIM_CLOCKSOURCE_ULPTIM LPTIM_CFGR_CKSEL
206/**
207 * @}
208 */
209
210/** @defgroup LPTIM_Clock_Prescaler LPTIM Clock Prescaler
211 * @{
212 */
213#define LPTIM_PRESCALER_DIV1 0x00000000U
214#define LPTIM_PRESCALER_DIV2 LPTIM_CFGR_PRESC_0
215#define LPTIM_PRESCALER_DIV4 LPTIM_CFGR_PRESC_1
216#define LPTIM_PRESCALER_DIV8 (LPTIM_CFGR_PRESC_0 | LPTIM_CFGR_PRESC_1)
217#define LPTIM_PRESCALER_DIV16 LPTIM_CFGR_PRESC_2
218#define LPTIM_PRESCALER_DIV32 (LPTIM_CFGR_PRESC_0 | LPTIM_CFGR_PRESC_2)
219#define LPTIM_PRESCALER_DIV64 (LPTIM_CFGR_PRESC_1 | LPTIM_CFGR_PRESC_2)
220#define LPTIM_PRESCALER_DIV128 LPTIM_CFGR_PRESC
221/**
222 * @}
223 */
224
225/** @defgroup LPTIM_Output_Polarity LPTIM Output Polarity
226 * @{
227 */
228
229#define LPTIM_OUTPUTPOLARITY_HIGH 0x00000000U
230#define LPTIM_OUTPUTPOLARITY_LOW LPTIM_CFGR_WAVPOL
231/**
232 * @}
233 */
234
235/** @defgroup LPTIM_Clock_Sample_Time LPTIM Clock Sample Time
236 * @{
237 */
238#define LPTIM_CLOCKSAMPLETIME_DIRECTTRANSITION 0x00000000U
239#define LPTIM_CLOCKSAMPLETIME_2TRANSITIONS LPTIM_CFGR_CKFLT_0
240#define LPTIM_CLOCKSAMPLETIME_4TRANSITIONS LPTIM_CFGR_CKFLT_1
241#define LPTIM_CLOCKSAMPLETIME_8TRANSITIONS LPTIM_CFGR_CKFLT
242/**
243 * @}
244 */
245
246/** @defgroup LPTIM_Clock_Polarity LPTIM Clock Polarity
247 * @{
248 */
249#define LPTIM_CLOCKPOLARITY_RISING 0x00000000U
250#define LPTIM_CLOCKPOLARITY_FALLING LPTIM_CFGR_CKPOL_0
251#define LPTIM_CLOCKPOLARITY_RISING_FALLING LPTIM_CFGR_CKPOL_1
252/**
253 * @}
254 */
255
256/** @defgroup LPTIM_Trigger_Source LPTIM Trigger Source
257 * @{
258 */
259#define LPTIM_TRIGSOURCE_SOFTWARE 0x0000FFFFU
260#define LPTIM_TRIGSOURCE_0 0x00000000U
261#define LPTIM_TRIGSOURCE_1 LPTIM_CFGR_TRIGSEL_0
262#define LPTIM_TRIGSOURCE_2 LPTIM_CFGR_TRIGSEL_1
263#define LPTIM_TRIGSOURCE_3 (LPTIM_CFGR_TRIGSEL_0 | LPTIM_CFGR_TRIGSEL_1)
264#define LPTIM_TRIGSOURCE_4 LPTIM_CFGR_TRIGSEL_2
265#define LPTIM_TRIGSOURCE_5 (LPTIM_CFGR_TRIGSEL_0 | LPTIM_CFGR_TRIGSEL_2)
266#define LPTIM_TRIGSOURCE_6 (LPTIM_CFGR_TRIGSEL_1 | LPTIM_CFGR_TRIGSEL_2)
267#define LPTIM_TRIGSOURCE_7 LPTIM_CFGR_TRIGSEL
268/**
269 * @}
270 */
271
272/** @defgroup LPTIM_External_Trigger_Polarity LPTIM External Trigger Polarity
273 * @{
274 */
275#define LPTIM_ACTIVEEDGE_RISING LPTIM_CFGR_TRIGEN_0
276#define LPTIM_ACTIVEEDGE_FALLING LPTIM_CFGR_TRIGEN_1
277#define LPTIM_ACTIVEEDGE_RISING_FALLING LPTIM_CFGR_TRIGEN
278/**
279 * @}
280 */
281
282/** @defgroup LPTIM_Trigger_Sample_Time LPTIM Trigger Sample Time
283 * @{
284 */
285#define LPTIM_TRIGSAMPLETIME_DIRECTTRANSITION 0x00000000U
286#define LPTIM_TRIGSAMPLETIME_2TRANSITIONS LPTIM_CFGR_TRGFLT_0
287#define LPTIM_TRIGSAMPLETIME_4TRANSITIONS LPTIM_CFGR_TRGFLT_1
288#define LPTIM_TRIGSAMPLETIME_8TRANSITIONS LPTIM_CFGR_TRGFLT
289/**
290 * @}
291 */
292
293/** @defgroup LPTIM_Updating_Mode LPTIM Updating Mode
294 * @{
295 */
296
297#define LPTIM_UPDATE_IMMEDIATE 0x00000000U
298#define LPTIM_UPDATE_ENDOFPERIOD LPTIM_CFGR_PRELOAD
299/**
300 * @}
301 */
302
303/** @defgroup LPTIM_Counter_Source LPTIM Counter Source
304 * @{
305 */
306
307#define LPTIM_COUNTERSOURCE_INTERNAL 0x00000000U
308#define LPTIM_COUNTERSOURCE_EXTERNAL LPTIM_CFGR_COUNTMODE
309/**
310 * @}
311 */
312
313/** @defgroup LPTIM_Input1_Source LPTIM Input1 Source
314 * @{
315 */
316
317#define LPTIM_INPUT1SOURCE_GPIO 0x00000000U /*!< For LPTIM1 and LPTIM2 */
318#define LPTIM_INPUT1SOURCE_COMP1 LPTIM_CFGR2_IN1SEL_0 /*!< For LPTIM1 and LPTIM2 */
319#define LPTIM_INPUT1SOURCE_COMP2 LPTIM_CFGR2_IN1SEL_1 /*!< For LPTIM2 */
320#define LPTIM_INPUT1SOURCE_COMP1_COMP2 (LPTIM_CFGR2_IN1SEL_1 | LPTIM_CFGR2_IN1SEL_0) /*!< For LPTIM2 */
321/**
322 * @}
323 */
324
325/** @defgroup LPTIM_Input2_Source LPTIM Input2 Source
326 * @{
327 */
328
329#define LPTIM_INPUT2SOURCE_GPIO 0x00000000U /*!< For LPTIM1 */
330#define LPTIM_INPUT2SOURCE_COMP2 LPTIM_CFGR2_IN2SEL_0 /*!< For LPTIM1 */
331/**
332 * @}
333 */
334
335/** @defgroup LPTIM_Flag_Definition LPTIM Flags Definition
336 * @{
337 */
338
339#define LPTIM_FLAG_DOWN LPTIM_ISR_DOWN
340#define LPTIM_FLAG_UP LPTIM_ISR_UP
341#define LPTIM_FLAG_ARROK LPTIM_ISR_ARROK
342#define LPTIM_FLAG_CMPOK LPTIM_ISR_CMPOK
343#define LPTIM_FLAG_EXTTRIG LPTIM_ISR_EXTTRIG
344#define LPTIM_FLAG_ARRM LPTIM_ISR_ARRM
345#define LPTIM_FLAG_CMPM LPTIM_ISR_CMPM
346/**
347 * @}
348 */
349
350/** @defgroup LPTIM_Interrupts_Definition LPTIM Interrupts Definition
351 * @{
352 */
353
354#define LPTIM_IT_DOWN LPTIM_IER_DOWNIE
355#define LPTIM_IT_UP LPTIM_IER_UPIE
356#define LPTIM_IT_ARROK LPTIM_IER_ARROKIE
357#define LPTIM_IT_CMPOK LPTIM_IER_CMPOKIE
358#define LPTIM_IT_EXTTRIG LPTIM_IER_EXTTRIGIE
359#define LPTIM_IT_ARRM LPTIM_IER_ARRMIE
360#define LPTIM_IT_CMPM LPTIM_IER_CMPMIE
361/**
362 * @}
363 */
364
365/**
366 * @}
367 */
368
369/* Exported macros -----------------------------------------------------------*/
370/** @defgroup LPTIM_Exported_Macros LPTIM Exported Macros
371 * @{
372 */
373
374/** @brief Reset LPTIM handle state.
375 * @param __HANDLE__ LPTIM handle
376 * @retval None
377 */
378#if (USE_HAL_LPTIM_REGISTER_CALLBACKS == 1)
379#define __HAL_LPTIM_RESET_HANDLE_STATE(__HANDLE__) do { \
380 (__HANDLE__)->State = HAL_LPTIM_STATE_RESET; \
381 (__HANDLE__)->MspInitCallback = NULL; \
382 (__HANDLE__)->MspDeInitCallback = NULL; \
383 } while(0)
384#else
385#define __HAL_LPTIM_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_LPTIM_STATE_RESET)
386#endif /* USE_HAL_LPTIM_REGISTER_CALLBACKS */
387
388/**
389 * @brief Enable the LPTIM peripheral.
390 * @param __HANDLE__ LPTIM handle
391 * @retval None
392 */
393#define __HAL_LPTIM_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (LPTIM_CR_ENABLE))
394
395/**
396 * @brief Disable the LPTIM peripheral.
397 * @param __HANDLE__ LPTIM handle
398 * @retval None
399 */
400#define __HAL_LPTIM_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(LPTIM_CR_ENABLE))
401
402/**
403 * @brief Start the LPTIM peripheral in Continuous mode.
404 * @param __HANDLE__ LPTIM handle
405 * @retval None
406 */
407#define __HAL_LPTIM_START_CONTINUOUS(__HANDLE__) ((__HANDLE__)->Instance->CR |= LPTIM_CR_CNTSTRT)
408/**
409 * @brief Start the LPTIM peripheral in single mode.
410 * @param __HANDLE__ LPTIM handle
411 * @retval None
412 */
413#define __HAL_LPTIM_START_SINGLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= LPTIM_CR_SNGSTRT)
414
415/**
416 * @brief Reset the LPTIM Counter register in synchronous mode.
417 * @param __HANDLE__ LPTIM handle
418 * @retval None
419 */
420#define __HAL_LPTIM_RESET_COUNTER(__HANDLE__) ((__HANDLE__)->Instance->CR |= LPTIM_CR_COUNTRST)
421
422/**
423 * @brief Reset after read of the LPTIM Counter register in asynchronous mode.
424 * @param __HANDLE__ LPTIM handle
425 * @retval None
426 */
427#define __HAL_LPTIM_RESET_COUNTER_AFTERREAD(__HANDLE__) ((__HANDLE__)->Instance->CR |= LPTIM_CR_RSTARE)
428
429/**
430 * @brief Write the passed parameter in the Autoreload register.
431 * @param __HANDLE__ LPTIM handle
432 * @param __VALUE__ Autoreload value
433 * @retval None
434 */
435#define __HAL_LPTIM_AUTORELOAD_SET(__HANDLE__ , __VALUE__) ((__HANDLE__)->Instance->ARR = (__VALUE__))
436
437/**
438 * @brief Write the passed parameter in the Compare register.
439 * @param __HANDLE__ LPTIM handle
440 * @param __VALUE__ Compare value
441 * @retval None
442 */
443#define __HAL_LPTIM_COMPARE_SET(__HANDLE__ , __VALUE__) ((__HANDLE__)->Instance->CMP = (__VALUE__))
444
445/**
446 * @brief Check whether the specified LPTIM flag is set or not.
447 * @param __HANDLE__ LPTIM handle
448 * @param __FLAG__ LPTIM flag to check
449 * This parameter can be a value of:
450 * @arg LPTIM_FLAG_DOWN : Counter direction change up Flag.
451 * @arg LPTIM_FLAG_UP : Counter direction change down to up Flag.
452 * @arg LPTIM_FLAG_ARROK : Autoreload register update OK Flag.
453 * @arg LPTIM_FLAG_CMPOK : Compare register update OK Flag.
454 * @arg LPTIM_FLAG_EXTTRIG : External trigger edge event Flag.
455 * @arg LPTIM_FLAG_ARRM : Autoreload match Flag.
456 * @arg LPTIM_FLAG_CMPM : Compare match Flag.
457 * @retval The state of the specified flag (SET or RESET).
458 */
459#define __HAL_LPTIM_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR &(__FLAG__)) == (__FLAG__))
460
461/**
462 * @brief Clear the specified LPTIM flag.
463 * @param __HANDLE__ LPTIM handle.
464 * @param __FLAG__ LPTIM flag to clear.
465 * This parameter can be a value of:
466 * @arg LPTIM_FLAG_DOWN : Counter direction change up Flag.
467 * @arg LPTIM_FLAG_UP : Counter direction change down to up Flag.
468 * @arg LPTIM_FLAG_ARROK : Autoreload register update OK Flag.
469 * @arg LPTIM_FLAG_CMPOK : Compare register update OK Flag.
470 * @arg LPTIM_FLAG_EXTTRIG : External trigger edge event Flag.
471 * @arg LPTIM_FLAG_ARRM : Autoreload match Flag.
472 * @arg LPTIM_FLAG_CMPM : Compare match Flag.
473 * @retval None.
474 */
475#define __HAL_LPTIM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__))
476
477/**
478 * @brief Enable the specified LPTIM interrupt.
479 * @param __HANDLE__ LPTIM handle.
480 * @param __INTERRUPT__ LPTIM interrupt to set.
481 * This parameter can be a value of:
482 * @arg LPTIM_IT_DOWN : Counter direction change up Interrupt.
483 * @arg LPTIM_IT_UP : Counter direction change down to up Interrupt.
484 * @arg LPTIM_IT_ARROK : Autoreload register update OK Interrupt.
485 * @arg LPTIM_IT_CMPOK : Compare register update OK Interrupt.
486 * @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt.
487 * @arg LPTIM_IT_ARRM : Autoreload match Interrupt.
488 * @arg LPTIM_IT_CMPM : Compare match Interrupt.
489 * @retval None.
490 */
491#define __HAL_LPTIM_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER |= (__INTERRUPT__))
492
493 /**
494 * @brief Disable the specified LPTIM interrupt.
495 * @param __HANDLE__ LPTIM handle.
496 * @param __INTERRUPT__ LPTIM interrupt to set.
497 * This parameter can be a value of:
498 * @arg LPTIM_IT_DOWN : Counter direction change up Interrupt.
499 * @arg LPTIM_IT_UP : Counter direction change down to up Interrupt.
500 * @arg LPTIM_IT_ARROK : Autoreload register update OK Interrupt.
501 * @arg LPTIM_IT_CMPOK : Compare register update OK Interrupt.
502 * @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt.
503 * @arg LPTIM_IT_ARRM : Autoreload match Interrupt.
504 * @arg LPTIM_IT_CMPM : Compare match Interrupt.
505 * @retval None.
506 */
507#define __HAL_LPTIM_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER &= (~(__INTERRUPT__)))
508
509 /**
510 * @brief Check whether the specified LPTIM interrupt source is enabled or not.
511 * @param __HANDLE__ LPTIM handle.
512 * @param __INTERRUPT__ LPTIM interrupt to check.
513 * This parameter can be a value of:
514 * @arg LPTIM_IT_DOWN : Counter direction change up Interrupt.
515 * @arg LPTIM_IT_UP : Counter direction change down to up Interrupt.
516 * @arg LPTIM_IT_ARROK : Autoreload register update OK Interrupt.
517 * @arg LPTIM_IT_CMPOK : Compare register update OK Interrupt.
518 * @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt.
519 * @arg LPTIM_IT_ARRM : Autoreload match Interrupt.
520 * @arg LPTIM_IT_CMPM : Compare match Interrupt.
521 * @retval Interrupt status.
522 */
523
524#define __HAL_LPTIM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->IER & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
525
526/**
527 * @}
528 */
529
530/* Exported functions --------------------------------------------------------*/
531/** @defgroup LPTIM_Exported_Functions LPTIM Exported Functions
532 * @{
533 */
534
535/* Initialization/de-initialization functions ********************************/
536HAL_StatusTypeDef HAL_LPTIM_Init(LPTIM_HandleTypeDef *hlptim);
537HAL_StatusTypeDef HAL_LPTIM_DeInit(LPTIM_HandleTypeDef *hlptim);
538
539/* MSP functions *************************************************************/
540void HAL_LPTIM_MspInit(LPTIM_HandleTypeDef *hlptim);
541void HAL_LPTIM_MspDeInit(LPTIM_HandleTypeDef *hlptim);
542
543/* Start/Stop operation functions *********************************************/
544/* ################################# PWM Mode ################################*/
545/* Blocking mode: Polling */
546HAL_StatusTypeDef HAL_LPTIM_PWM_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
547HAL_StatusTypeDef HAL_LPTIM_PWM_Stop(LPTIM_HandleTypeDef *hlptim);
548/* Non-Blocking mode: Interrupt */
549HAL_StatusTypeDef HAL_LPTIM_PWM_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
550HAL_StatusTypeDef HAL_LPTIM_PWM_Stop_IT(LPTIM_HandleTypeDef *hlptim);
551
552/* ############################# One Pulse Mode ##############################*/
553/* Blocking mode: Polling */
554HAL_StatusTypeDef HAL_LPTIM_OnePulse_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
555HAL_StatusTypeDef HAL_LPTIM_OnePulse_Stop(LPTIM_HandleTypeDef *hlptim);
556/* Non-Blocking mode: Interrupt */
557HAL_StatusTypeDef HAL_LPTIM_OnePulse_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
558HAL_StatusTypeDef HAL_LPTIM_OnePulse_Stop_IT(LPTIM_HandleTypeDef *hlptim);
559
560/* ############################## Set once Mode ##############################*/
561/* Blocking mode: Polling */
562HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
563HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop(LPTIM_HandleTypeDef *hlptim);
564/* Non-Blocking mode: Interrupt */
565HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
566HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop_IT(LPTIM_HandleTypeDef *hlptim);
567
568/* ############################### Encoder Mode ##############################*/
569/* Blocking mode: Polling */
570HAL_StatusTypeDef HAL_LPTIM_Encoder_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
571HAL_StatusTypeDef HAL_LPTIM_Encoder_Stop(LPTIM_HandleTypeDef *hlptim);
572/* Non-Blocking mode: Interrupt */
573HAL_StatusTypeDef HAL_LPTIM_Encoder_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
574HAL_StatusTypeDef HAL_LPTIM_Encoder_Stop_IT(LPTIM_HandleTypeDef *hlptim);
575
576/* ############################# Time out Mode ##############################*/
577/* Blocking mode: Polling */
578HAL_StatusTypeDef HAL_LPTIM_TimeOut_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Timeout);
579HAL_StatusTypeDef HAL_LPTIM_TimeOut_Stop(LPTIM_HandleTypeDef *hlptim);
580/* Non-Blocking mode: Interrupt */
581HAL_StatusTypeDef HAL_LPTIM_TimeOut_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Timeout);
582HAL_StatusTypeDef HAL_LPTIM_TimeOut_Stop_IT(LPTIM_HandleTypeDef *hlptim);
583
584/* ############################## Counter Mode ###############################*/
585/* Blocking mode: Polling */
586HAL_StatusTypeDef HAL_LPTIM_Counter_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
587HAL_StatusTypeDef HAL_LPTIM_Counter_Stop(LPTIM_HandleTypeDef *hlptim);
588/* Non-Blocking mode: Interrupt */
589HAL_StatusTypeDef HAL_LPTIM_Counter_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
590HAL_StatusTypeDef HAL_LPTIM_Counter_Stop_IT(LPTIM_HandleTypeDef *hlptim);
591
592/* Reading operation functions ************************************************/
593uint32_t HAL_LPTIM_ReadCounter(LPTIM_HandleTypeDef *hlptim);
594uint32_t HAL_LPTIM_ReadAutoReload(LPTIM_HandleTypeDef *hlptim);
595uint32_t HAL_LPTIM_ReadCompare(LPTIM_HandleTypeDef *hlptim);
596
597/* LPTIM IRQ functions *******************************************************/
598void HAL_LPTIM_IRQHandler(LPTIM_HandleTypeDef *hlptim);
599
600/* CallBack functions ********************************************************/
601void HAL_LPTIM_CompareMatchCallback(LPTIM_HandleTypeDef *hlptim);
602void HAL_LPTIM_AutoReloadMatchCallback(LPTIM_HandleTypeDef *hlptim);
603void HAL_LPTIM_TriggerCallback(LPTIM_HandleTypeDef *hlptim);
604void HAL_LPTIM_CompareWriteCallback(LPTIM_HandleTypeDef *hlptim);
605void HAL_LPTIM_AutoReloadWriteCallback(LPTIM_HandleTypeDef *hlptim);
606void HAL_LPTIM_DirectionUpCallback(LPTIM_HandleTypeDef *hlptim);
607void HAL_LPTIM_DirectionDownCallback(LPTIM_HandleTypeDef *hlptim);
608
609/* Callbacks Register/UnRegister functions ***********************************/
610#if (USE_HAL_LPTIM_REGISTER_CALLBACKS == 1)
611HAL_StatusTypeDef HAL_LPTIM_RegisterCallback(LPTIM_HandleTypeDef *lphtim, HAL_LPTIM_CallbackIDTypeDef CallbackID, pLPTIM_CallbackTypeDef pCallback);
612HAL_StatusTypeDef HAL_LPTIM_UnRegisterCallback(LPTIM_HandleTypeDef *lphtim, HAL_LPTIM_CallbackIDTypeDef CallbackID);
613#endif /* USE_HAL_LPTIM_REGISTER_CALLBACKS */
614
615/* Peripheral State functions ************************************************/
616HAL_LPTIM_StateTypeDef HAL_LPTIM_GetState(LPTIM_HandleTypeDef *hlptim);
617
618/**
619 * @}
620 */
621
622/* Private types -------------------------------------------------------------*/
623/** @defgroup LPTIM_Private_Types LPTIM Private Types
624 * @{
625 */
626
627/**
628 * @}
629 */
630
631/* Private variables ---------------------------------------------------------*/
632/** @defgroup LPTIM_Private_Variables LPTIM Private Variables
633 * @{
634 */
635
636/**
637 * @}
638 */
639
640/* Private constants ---------------------------------------------------------*/
641/** @defgroup LPTIM_Private_Constants LPTIM Private Constants
642 * @{
643 */
644
645/**
646 * @}
647 */
648
649/* Private macros ------------------------------------------------------------*/
650/** @defgroup LPTIM_Private_Macros LPTIM Private Macros
651 * @{
652 */
653
654#define IS_LPTIM_CLOCK_SOURCE(__SOURCE__) (((__SOURCE__) == LPTIM_CLOCKSOURCE_ULPTIM) || \
655 ((__SOURCE__) == LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC))
656
657
658#define IS_LPTIM_CLOCK_PRESCALER(__PRESCALER__) (((__PRESCALER__) == LPTIM_PRESCALER_DIV1 ) || \
659 ((__PRESCALER__) == LPTIM_PRESCALER_DIV2 ) || \
660 ((__PRESCALER__) == LPTIM_PRESCALER_DIV4 ) || \
661 ((__PRESCALER__) == LPTIM_PRESCALER_DIV8 ) || \
662 ((__PRESCALER__) == LPTIM_PRESCALER_DIV16 ) || \
663 ((__PRESCALER__) == LPTIM_PRESCALER_DIV32 ) || \
664 ((__PRESCALER__) == LPTIM_PRESCALER_DIV64 ) || \
665 ((__PRESCALER__) == LPTIM_PRESCALER_DIV128))
666
667#define IS_LPTIM_CLOCK_PRESCALERDIV1(__PRESCALER__) ((__PRESCALER__) == LPTIM_PRESCALER_DIV1)
668
669#define IS_LPTIM_OUTPUT_POLARITY(__POLARITY__) (((__POLARITY__) == LPTIM_OUTPUTPOLARITY_LOW ) || \
670 ((__POLARITY__) == LPTIM_OUTPUTPOLARITY_HIGH))
671
672#define IS_LPTIM_CLOCK_SAMPLE_TIME(__SAMPLETIME__) (((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_DIRECTTRANSITION) || \
673 ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_2TRANSITIONS) || \
674 ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_4TRANSITIONS) || \
675 ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_8TRANSITIONS))
676
677#define IS_LPTIM_CLOCK_POLARITY(__POLARITY__) (((__POLARITY__) == LPTIM_CLOCKPOLARITY_RISING) || \
678 ((__POLARITY__) == LPTIM_CLOCKPOLARITY_FALLING) || \
679 ((__POLARITY__) == LPTIM_CLOCKPOLARITY_RISING_FALLING))
680
681#define IS_LPTIM_TRG_SOURCE(__TRIG__) (((__TRIG__) == LPTIM_TRIGSOURCE_SOFTWARE) || \
682 ((__TRIG__) == LPTIM_TRIGSOURCE_0) || \
683 ((__TRIG__) == LPTIM_TRIGSOURCE_1) || \
684 ((__TRIG__) == LPTIM_TRIGSOURCE_2) || \
685 ((__TRIG__) == LPTIM_TRIGSOURCE_3) || \
686 ((__TRIG__) == LPTIM_TRIGSOURCE_4) || \
687 ((__TRIG__) == LPTIM_TRIGSOURCE_5) || \
688 ((__TRIG__) == LPTIM_TRIGSOURCE_6) || \
689 ((__TRIG__) == LPTIM_TRIGSOURCE_7))
690
691#define IS_LPTIM_EXT_TRG_POLARITY(__POLARITY__) (((__POLARITY__) == LPTIM_ACTIVEEDGE_RISING ) || \
692 ((__POLARITY__) == LPTIM_ACTIVEEDGE_FALLING ) || \
693 ((__POLARITY__) == LPTIM_ACTIVEEDGE_RISING_FALLING ))
694
695#define IS_LPTIM_TRIG_SAMPLE_TIME(__SAMPLETIME__) (((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_DIRECTTRANSITION) || \
696 ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_2TRANSITIONS ) || \
697 ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_4TRANSITIONS ) || \
698 ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_8TRANSITIONS ))
699
700#define IS_LPTIM_UPDATE_MODE(__MODE__) (((__MODE__) == LPTIM_UPDATE_IMMEDIATE) || \
701 ((__MODE__) == LPTIM_UPDATE_ENDOFPERIOD))
702
703#define IS_LPTIM_COUNTER_SOURCE(__SOURCE__) (((__SOURCE__) == LPTIM_COUNTERSOURCE_INTERNAL) || \
704 ((__SOURCE__) == LPTIM_COUNTERSOURCE_EXTERNAL))
705
706#define IS_LPTIM_AUTORELOAD(__AUTORELOAD__) ((__AUTORELOAD__) <= 0x0000FFFFUL)
707
708#define IS_LPTIM_COMPARE(__COMPARE__) ((__COMPARE__) <= 0x0000FFFFUL)
709
710#define IS_LPTIM_PERIOD(__PERIOD__) ((__PERIOD__) <= 0x0000FFFFUL)
711
712#define IS_LPTIM_PULSE(__PULSE__) ((__PULSE__) <= 0x0000FFFFUL)
713
714#define IS_LPTIM_INPUT1_SOURCE(__INSTANCE__, __SOURCE__) \
715 ((((__INSTANCE__) == LPTIM1) && \
716 (((__SOURCE__) == LPTIM_INPUT1SOURCE_GPIO) || \
717 ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP1))) \
718 || \
719 (((__INSTANCE__) == LPTIM2) && \
720 (((__SOURCE__) == LPTIM_INPUT1SOURCE_GPIO) || \
721 ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP1) || \
722 ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP2) || \
723 ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP1_COMP2))))
724
725#define IS_LPTIM_INPUT2_SOURCE(__INSTANCE__, __SOURCE__) \
726 (((__INSTANCE__) == LPTIM1) && \
727 (((__SOURCE__) == LPTIM_INPUT2SOURCE_GPIO) || \
728 ((__SOURCE__) == LPTIM_INPUT2SOURCE_COMP2)))
729
730/**
731 * @}
732 */
733
734/* Private functions ---------------------------------------------------------*/
735/** @defgroup LPTIM_Private_Functions LPTIM Private Functions
736 * @{
737 */
738
739/**
740 * @}
741 */
742
743/**
744 * @}
745 */
746
747#endif /* LPTIM1 || LPTIM2 */
748/**
749 * @}
750 */
751
752#ifdef __cplusplus
753}
754#endif
755
756#endif /* STM32G0xx_HAL_LPTIM_H */
757
758/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Note: See TracBrowser for help on using the repository browser.