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