2 ******************************************************************************
3 * @file stm32f4xx_lptim.h
4 * @author MCD Application Team
7 * @brief This file contains all the functions prototypes for the LPTIM
9 ******************************************************************************
12 * <h2><center>© COPYRIGHT 2016 STMicroelectronics</center></h2>
14 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
15 * You may not use this file except in compliance with the License.
16 * You may obtain a copy of the License at:
18 * http://www.st.com/software_license_agreement_liberty_v2
20 * Unless required by applicable law or agreed to in writing, software
21 * distributed under the License is distributed on an "AS IS" BASIS,
22 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 * See the License for the specific language governing permissions and
24 * limitations under the License.
26 ******************************************************************************
29 /* Define to prevent recursive inclusion -------------------------------------*/
30 #ifndef __STM32F4XX_LPTIM_H
31 #define __STM32F4XX_LPTIM_H
37 /* Includes ------------------------------------------------------------------*/
38 #include "stm32f4xx.h"
40 /** @addtogroup STM32F4xx_StdPeriph_Driver
47 #if defined(STM32F410xx)
48 /* Exported types ------------------------------------------------------------*/
50 * @brief LPTIM Init structure definition
55 uint32_t LPTIM_ClockSource
; /*!< Selects the clock source.
56 This parameter can be a value of @ref LPTIM_Clock_Source */
58 uint32_t LPTIM_Prescaler
; /*!< Specifies the timer clock Prescaler.
59 This parameter can be a value of @ref LPTIM_Clock_Prescaler */
61 uint32_t LPTIM_Waveform
; /*!< Selects the output shape.
62 This parameter can be a value of @ref LPTIM_Waveform_Shape */
64 uint32_t LPTIM_OutputPolarity
; /*!< Specifies the LPTIM Output pin polarity.
65 This parameter can be a value of @ref LPTIM_Output_Polarity */
68 /* Exported constants --------------------------------------------------------*/
69 /** @defgroup LPTIM_Exported_Constants
73 #define IS_LPTIM_ALL_PERIPH(PERIPH) ((PERIPH) == LPTIM1)
75 /** @defgroup LPTIM_Clock_Source LPTIM Clock Source
79 #define LPTIM_ClockSource_APBClock_LPosc ((uint32_t)0x00000000)
80 #define LPTIM_ClockSource_ULPTIM ((uint32_t)0x00000001)
81 #define IS_LPTIM_CLOCK_SOURCE(SOURCE) (((SOURCE) == LPTIM_ClockSource_ULPTIM) || \
82 ((SOURCE) == LPTIM_ClockSource_APBClock_LPosc))
87 /** @defgroup LPTIM_Clock_Prescaler LPTIM Clock Prescaler
90 #define LPTIM_Prescaler_DIV1 ((uint32_t)0x00000000)
91 #define LPTIM_Prescaler_DIV2 ((uint32_t)0x00000200)
92 #define LPTIM_Prescaler_DIV4 ((uint32_t)0x00000400)
93 #define LPTIM_Prescaler_DIV8 ((uint32_t)0x00000600)
94 #define LPTIM_Prescaler_DIV16 ((uint32_t)0x00000800)
95 #define LPTIM_Prescaler_DIV32 ((uint32_t)0x00000A00)
96 #define LPTIM_Prescaler_DIV64 ((uint32_t)0x00000C00)
97 #define LPTIM_Prescaler_DIV128 ((uint32_t)0x00000E00)
98 #define IS_LPTIM_CLOCK_PRESCALER(PRESCALER) (((PRESCALER) == LPTIM_Prescaler_DIV1) || \
99 ((PRESCALER) == LPTIM_Prescaler_DIV2) || \
100 ((PRESCALER) == LPTIM_Prescaler_DIV4) || \
101 ((PRESCALER) == LPTIM_Prescaler_DIV8) || \
102 ((PRESCALER) == LPTIM_Prescaler_DIV16) || \
103 ((PRESCALER) == LPTIM_Prescaler_DIV32) || \
104 ((PRESCALER) == LPTIM_Prescaler_DIV64) || \
105 ((PRESCALER) == LPTIM_Prescaler_DIV128))
110 /** @defgroup LPTIM_Waveform_Shape LPTIM Waveform Shape
113 #define LPTIM_Waveform_PWM_OnePulse ((uint32_t)0x00000000)
114 #define LPTIM_Waveform_SetOnce ((uint32_t)0x00100000)
115 #define IS_LPTIM_WAVEFORM(WAVE) (((WAVE) == LPTIM_Waveform_SetOnce) || \
116 ((WAVE) == LPTIM_Waveform_PWM_OnePulse))
121 /** @defgroup LPTIM_Output_Polarity LPTIM Output Polarity
124 #define LPTIM_OutputPolarity_High ((uint32_t)0x00000000)
125 #define LPTIM_OutputPolarity_Low ((uint32_t)0x00200000)
126 #define IS_LPTIM_OUTPUT_POLARITY(POLARITY) (((POLARITY) == LPTIM_OutputPolarity_Low ) || \
127 ((POLARITY) == LPTIM_OutputPolarity_High))
132 /** @defgroup LPTIM_Clock_Polarity LPTIM Clock Polarity
135 #define LPTIM_ClockPolarity_RisingEdge ((uint32_t)0x00000000)
136 #define LPTIM_ClockPolarity_FallingEdge ((uint32_t)0x00000002)
137 #define LPTIM_ClockPolarity_BothEdges ((uint32_t)0x00000004)
138 #define IS_LPTIM_CLOCK_POLARITY(POLARITY) (((POLARITY) == LPTIM_ClockPolarity_RisingEdge ) || \
139 ((POLARITY) == LPTIM_ClockPolarity_FallingEdge ) || \
140 ((POLARITY) == LPTIM_ClockPolarity_BothEdges))
145 /** @defgroup LPTIM_External_Trigger_Source LPTIM External Trigger Source
148 #define LPTIM_ExtTRGSource_0 ((uint32_t)0x00000000)
149 #define LPTIM_ExtTRGSource_1 ((uint32_t)0x00002000)
150 #define LPTIM_ExtTRGSource_2 ((uint32_t)0x00004000)
151 #define LPTIM_ExtTRGSource_3 ((uint32_t)0x00006000)
152 #define LPTIM_ExtTRGSource_4 ((uint32_t)0x00008000)
153 #define LPTIM_ExtTRGSource_5 ((uint32_t)0x0000A000)
154 #define LPTIM_ExtTRGSource_6 ((uint32_t)0x0000C000)
155 #define LPTIM_ExtTRGSource_7 ((uint32_t)0x0000E000)
156 #define IS_LPTIM_EXT_TRG_SOURCE(TRIG) (((TRIG) == LPTIM_ExtTRGSource_0) || \
157 ((TRIG) == LPTIM_ExtTRGSource_1) || \
158 ((TRIG) == LPTIM_ExtTRGSource_2) || \
159 ((TRIG) == LPTIM_ExtTRGSource_3) || \
160 ((TRIG) == LPTIM_ExtTRGSource_4) || \
161 ((TRIG) == LPTIM_ExtTRGSource_5) || \
162 ((TRIG) == LPTIM_ExtTRGSource_6) || \
163 ((TRIG) == LPTIM_ExtTRGSource_7))
168 /** @defgroup LPTIM_External_Trigger_Polarity LPTIM External Trigger Polarity
171 #define LPTIM_ExtTRGPolarity_RisingEdge ((uint32_t)0x00020000)
172 #define LPTIM_ExtTRGPolarity_FallingEdge ((uint32_t)0x00040000)
173 #define LPTIM_ExtTRGPolarity_BothEdges ((uint32_t)0x00060000)
174 #define IS_LPTIM_EXT_TRG_POLARITY(POLAR) (((POLAR) == LPTIM_ExtTRGPolarity_RisingEdge) || \
175 ((POLAR) == LPTIM_ExtTRGPolarity_FallingEdge) || \
176 ((POLAR) == LPTIM_ExtTRGPolarity_BothEdges))
181 /** @defgroup LPTIM_Clock_Sample_Time LPTIM Clock Sample Time
184 #define LPTIM_ClockSampleTime_DirectTransistion ((uint32_t)0x00000000)
185 #define LPTIM_ClockSampleTime_2Transistions ((uint32_t)0x00000008)
186 #define LPTIM_ClockSampleTime_4Transistions ((uint32_t)0x00000010)
187 #define LPTIM_ClockSampleTime_8Transistions ((uint32_t)0x00000018)
188 #define IS_LPTIM_CLOCK_SAMPLE_TIME(SAMPLETIME) (((SAMPLETIME) == LPTIM_ClockSampleTime_DirectTransistion) || \
189 ((SAMPLETIME) == LPTIM_ClockSampleTime_2Transistions) || \
190 ((SAMPLETIME) == LPTIM_ClockSampleTime_4Transistions) || \
191 ((SAMPLETIME) == LPTIM_ClockSampleTime_8Transistions))
196 /** @defgroup LPTIM_Trigger_Sample_Time LPTIM Trigger Sample Time
199 #define LPTIM_TrigSampleTime_DirectTransistion ((uint32_t)0x00000000)
200 #define LPTIM_TrigSampleTime_2Transistions ((uint32_t)0x00000040)
201 #define LPTIM_TrigSampleTime_4Transistions ((uint32_t)0x00000080)
202 #define LPTIM_TrigSampleTime_8Transistions ((uint32_t)0x000000C0)
203 #define IS_LPTIM_TRIG_SAMPLE_TIME(SAMPLETIME) (((SAMPLETIME) == LPTIM_TrigSampleTime_DirectTransistion) || \
204 ((SAMPLETIME) == LPTIM_TrigSampleTime_2Transistions) || \
205 ((SAMPLETIME) == LPTIM_TrigSampleTime_4Transistions) || \
206 ((SAMPLETIME) == LPTIM_TrigSampleTime_8Transistions))
211 /** @defgroup LPTIM_Operating_Mode LPTIM Operating Mode
214 #define LPTIM_Mode_Continuous ((uint32_t)0x00000004)
215 #define LPTIM_Mode_Single ((uint32_t)0x00000002)
216 #define IS_LPTIM_MODE(MODE) (((MODE) == LPTIM_Mode_Continuous) || \
217 ((MODE) == LPTIM_Mode_Single))
222 /** @defgroup LPTIM_Updating_Register LPTIM Updating Register
225 #define LPTIM_Update_Immediate ((uint32_t)0x00000000)
226 #define LPTIM_Update_EndOfPeriod ((uint32_t)0x00400000)
227 #define IS_LPTIM_UPDATE(UPDATE) (((UPDATE) == LPTIM_Update_Immediate) || \
228 ((UPDATE) == LPTIM_Update_EndOfPeriod))
233 /** @defgroup LPTIM_Interrupts_Definition LPTIM Interrupts Definition
236 #define LPTIM_IT_DOWN LPTIM_IER_DOWNIE
237 #define LPTIM_IT_UP LPTIM_IER_UPIE
238 #define LPTIM_IT_ARROK LPTIM_IER_ARROKIE
239 #define LPTIM_IT_CMPOK LPTIM_IER_CMPOKIE
240 #define LPTIM_IT_EXTTRIG LPTIM_IER_EXTTRIGIE
241 #define LPTIM_IT_ARRM LPTIM_IER_ARRMIE
242 #define LPTIM_IT_CMPM LPTIM_IER_CMPMIE
243 #define IS_LPTIM_IT(IT) (((IT) == LPTIM_IT_DOWN) || \
244 ((IT) == LPTIM_IT_UP) || \
245 ((IT) == LPTIM_IT_ARROK) || \
246 ((IT) == LPTIM_IT_CMPOK) || \
247 ((IT) == LPTIM_IT_EXTTRIG) || \
248 ((IT) == LPTIM_IT_ARRM) || \
249 ((IT) == LPTIM_IT_CMPM))
251 #define IS_LPTIM_GET_IT(IT) (((IT) == LPTIM_IT_DOWN) || \
252 ((IT) == LPTIM_IT_UP) || \
253 ((IT) == LPTIM_IT_ARROK) || \
254 ((IT) == LPTIM_IT_CMPOK) || \
255 ((IT) == LPTIM_IT_EXTTRIG) || \
256 ((IT) == LPTIM_IT_ARRM) || \
257 ((IT) == LPTIM_IT_CMPM))
262 /** @defgroup LPTIM_Flag_Definition LPTIM Flag Definition
265 #define LPTIM_FLAG_DOWN LPTIM_ISR_DOWN
266 #define LPTIM_FLAG_UP LPTIM_ISR_UP
267 #define LPTIM_FLAG_ARROK LPTIM_ISR_ARROK
268 #define LPTIM_FLAG_CMPOK LPTIM_ISR_CMPOK
269 #define LPTIM_FLAG_EXTTRIG LPTIM_ISR_EXTTRIG
270 #define LPTIM_FLAG_ARRM LPTIM_ISR_ARRM
271 #define LPTIM_FLAG_CMPM LPTIM_ISR_CMPM
272 #define IS_LPTIM_GET_FLAG(FLAG) (((FLAG) == LPTIM_FLAG_DOWN) || \
273 ((FLAG) == LPTIM_FLAG_UP) || \
274 ((FLAG) == LPTIM_FLAG_ARROK) || \
275 ((FLAG) == LPTIM_FLAG_CMPOK) || \
276 ((FLAG) == LPTIM_FLAG_EXTTRIG) || \
277 ((FLAG) == LPTIM_FLAG_ARRM) || \
278 ((FLAG) == LPTIM_FLAG_CMPM))
283 /** @defgroup LPTIM_Clear_Flag_Definition LPTIM Clear Flag Definition
286 #define LPTIM_CLEAR_DOWN LPTIM_ICR_DOWNCF
287 #define LPTIM_CLEAR_UP LPTIM_ICR_UPCF
288 #define LPTIM_CLEAR_ARROK LPTIM_ICR_ARROKCF
289 #define LPTIM_CLEAR_CMPOK LPTIM_ICR_CMPOKCF
290 #define LPTIM_CLEAR_EXTTRIG LPTIM_ICR_EXTTRIGCF
291 #define LPTIM_CLEAR_ARRM LPTIM_ICR_ARRMCF
292 #define LPTIM_CLEAR_CMPM LPTIM_ICR_CMPMCF
293 #define IS_LPTIM_CLEAR_FLAG(CLEARF) (((CLEARF) == LPTIM_CLEAR_DOWN) || \
294 ((CLEARF) == LPTIM_CLEAR_UP) || \
295 ((CLEARF) == LPTIM_CLEAR_ARROK) || \
296 ((CLEARF) == LPTIM_CLEAR_CMPOK) || \
297 ((CLEARF) == LPTIM_CLEAR_EXTTRIG) || \
298 ((CLEARF) == LPTIM_CLEAR_ARRM ) || \
299 ((CLEARF) == LPTIM_CLEAR_CMPM))
304 /** @defgroup LPTIM_Autorelaod_Value LPTIM Autorelaod Value
307 #define IS_LPTIM_AUTORELOAD(AUTORELOAD) ((AUTORELOAD) <= 0x0000FFFF)
312 /** @defgroup LPTIM_Compare_Value LPTIM Compare Value
315 #define IS_LPTIM_COMPARE(COMPARE) ((COMPARE) <= 0x0000FFFF)
320 /** @defgroup LPTIM_Option_Register_Definition LPTIM Option Register Definition
323 #define LPTIM_OP_PAD_AF ((uint32_t)0x00000000)
324 #define LPTIM_OP_PAD_PA4 LPTIM_OR_OR_0
325 #define LPTIM_OP_PAD_PB9 LPTIM_OR_OR_1
326 #define LPTIM_OP_TIM_DAC LPTIM_OR_OR
335 /* Exported macro ------------------------------------------------------------*/
336 /* Exported functions ------------------------------------------------------- */
338 /* Initialization functions ***************************************************/
339 void LPTIM_DeInit(LPTIM_TypeDef
* LPTIMx
);
340 void LPTIM_Init(LPTIM_TypeDef
* LPTIMx
, LPTIM_InitTypeDef
* LPTIM_InitStruct
);
341 void LPTIM_StructInit(LPTIM_InitTypeDef
* LPTIM_InitStruct
);
343 /* Configuration functions ****************************************************/
344 void LPTIM_Cmd(LPTIM_TypeDef
* LPTIMx
, FunctionalState NewState
);
345 void LPTIM_SelectClockSource(LPTIM_TypeDef
* LPTIMx
, uint32_t LPTIM_ClockSource
);
346 void LPTIM_SelectULPTIMClockPolarity(LPTIM_TypeDef
* LPTIMx
, uint32_t LPTIM_ClockPolarity
);
347 void LPTIM_ConfigPrescaler(LPTIM_TypeDef
* LPTIMx
, uint32_t LPTIM_Prescaler
);
348 void LPTIM_ConfigExternalTrigger(LPTIM_TypeDef
* LPTIMx
, uint32_t LPTIM_ExtTRGSource
, uint32_t LPTIM_ExtTRGPolarity
);
349 void LPTIM_SelectSoftwareStart(LPTIM_TypeDef
* LPTIMx
);
350 void LPTIM_ConfigTriggerGlitchFilter(LPTIM_TypeDef
* LPTIMx
, uint32_t LPTIM_TrigSampleTime
);
351 void LPTIM_ConfigClockGlitchFilter(LPTIM_TypeDef
* LPTIMx
, uint32_t LPTIM_ClockSampleTime
);
352 void LPTIM_SelectOperatingMode(LPTIM_TypeDef
* LPTIMx
, uint32_t LPTIM_Mode
);
353 void LPTIM_TimoutCmd(LPTIM_TypeDef
* LPTIMx
, FunctionalState NewState
);
354 void LPTIM_ConfigWaveform(LPTIM_TypeDef
* LPTIMx
, uint32_t LPTIM_Waveform
);
355 void LPTIM_ConfigUpdate(LPTIM_TypeDef
* LPTIMx
, uint32_t LPTIM_Update
);
356 void LPTIM_SetAutoreloadValue(LPTIM_TypeDef
* LPTIMx
, uint32_t LPTIM_Autoreload
);
357 void LPTIM_SetCompareValue(LPTIM_TypeDef
* LPTIMx
, uint32_t LPTIM_Compare
);
358 void LPTIM_SelectCounterMode(LPTIM_TypeDef
* LPTIMx
, FunctionalState NewState
);
359 void LPTIM_SelectEncoderMode(LPTIM_TypeDef
* LPTIMx
, FunctionalState NewState
);
360 void LPTIM_RemapConfig(LPTIM_TypeDef
* LPTIMx
,uint32_t LPTIM_OPTR
);
361 uint32_t LPTIM_GetCounterValue(LPTIM_TypeDef
* LPTIMx
);
362 uint32_t LPTIM_GetAutoreloadValue(LPTIM_TypeDef
* LPTIMx
);
363 uint32_t LPTIM_GetCompareValue(LPTIM_TypeDef
* LPTIMx
);
365 /* Interrupts and flags management functions **********************************/
366 void LPTIM_ITConfig(LPTIM_TypeDef
* LPTIMx
, uint32_t LPTIM_IT
, FunctionalState NewState
);
367 FlagStatus
LPTIM_GetFlagStatus(LPTIM_TypeDef
* LPTIMx
, uint32_t LPTIM_FLAG
);
368 void LPTIM_ClearFlag(LPTIM_TypeDef
* LPTIMx
, uint32_t LPTIM_CLEARF
);
369 ITStatus
LPTIM_GetITStatus(LPTIM_TypeDef
* LPTIMx
, uint32_t LPTIM_IT
);
371 #endif /* STM32F410xx */
384 #endif /*__STM32F4xx_LPTIM_H */
386 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/