001

Committer:
ganlikun
Date:
Sun Jun 12 14:02:44 2022 +0000
Revision:
0:13413ea9a877
00

Who changed what in which revision?

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