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