Updated and Validated
[betaflight.git] / lib / main / STM32F7 / Drivers / STM32F7xx_HAL_Driver / Inc / stm32f7xx_ll_tim.h
blob3da5961b5c182267f69751d27fba30daeced4ba7
1 /**
2 ******************************************************************************
3 * @file stm32f7xx_ll_tim.h
4 * @author MCD Application Team
5 * @brief Header file of TIM LL module.
6 ******************************************************************************
7 * @attention
9 * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
10 * All rights reserved.</center></h2>
12 * This software component is licensed by ST under BSD 3-Clause license,
13 * the "License"; You may not use this file except in compliance with the
14 * License. You may obtain a copy of the License at:
15 * opensource.org/licenses/BSD-3-Clause
17 ******************************************************************************
20 /* Define to prevent recursive inclusion -------------------------------------*/
21 #ifndef __STM32F7xx_LL_TIM_H
22 #define __STM32F7xx_LL_TIM_H
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
28 /* Includes ------------------------------------------------------------------*/
29 #include "stm32f7xx.h"
31 /** @addtogroup STM32F7xx_LL_Driver
32 * @{
35 #if defined (TIM1) || defined (TIM8) || defined (TIM2) || defined (TIM3) || defined (TIM4) || defined (TIM5) || defined (TIM9) || defined (TIM10) || defined (TIM11) || defined (TIM12) || defined (TIM13) || defined (TIM14) || defined (TIM6) || defined (TIM7)
37 /** @defgroup TIM_LL TIM
38 * @{
41 /* Private types -------------------------------------------------------------*/
42 /* Private variables ---------------------------------------------------------*/
43 /** @defgroup TIM_LL_Private_Variables TIM Private Variables
44 * @{
46 static const uint8_t OFFSET_TAB_CCMRx[] =
48 0x00U, /* 0: TIMx_CH1 */
49 0x00U, /* 1: TIMx_CH1N */
50 0x00U, /* 2: TIMx_CH2 */
51 0x00U, /* 3: TIMx_CH2N */
52 0x04U, /* 4: TIMx_CH3 */
53 0x04U, /* 5: TIMx_CH3N */
54 0x04U, /* 6: TIMx_CH4 */
55 0x3CU, /* 7: TIMx_CH5 */
56 0x3CU /* 8: TIMx_CH6 */
59 static const uint8_t SHIFT_TAB_OCxx[] =
61 0U, /* 0: OC1M, OC1FE, OC1PE */
62 0U, /* 1: - NA */
63 8U, /* 2: OC2M, OC2FE, OC2PE */
64 0U, /* 3: - NA */
65 0U, /* 4: OC3M, OC3FE, OC3PE */
66 0U, /* 5: - NA */
67 8U, /* 6: OC4M, OC4FE, OC4PE */
68 0U, /* 7: OC5M, OC5FE, OC5PE */
69 8U /* 8: OC6M, OC6FE, OC6PE */
72 static const uint8_t SHIFT_TAB_ICxx[] =
74 0U, /* 0: CC1S, IC1PSC, IC1F */
75 0U, /* 1: - NA */
76 8U, /* 2: CC2S, IC2PSC, IC2F */
77 0U, /* 3: - NA */
78 0U, /* 4: CC3S, IC3PSC, IC3F */
79 0U, /* 5: - NA */
80 8U, /* 6: CC4S, IC4PSC, IC4F */
81 0U, /* 7: - NA */
82 0U /* 8: - NA */
85 static const uint8_t SHIFT_TAB_CCxP[] =
87 0U, /* 0: CC1P */
88 2U, /* 1: CC1NP */
89 4U, /* 2: CC2P */
90 6U, /* 3: CC2NP */
91 8U, /* 4: CC3P */
92 10U, /* 5: CC3NP */
93 12U, /* 6: CC4P */
94 16U, /* 7: CC5P */
95 20U /* 8: CC6P */
98 static const uint8_t SHIFT_TAB_OISx[] =
100 0U, /* 0: OIS1 */
101 1U, /* 1: OIS1N */
102 2U, /* 2: OIS2 */
103 3U, /* 3: OIS2N */
104 4U, /* 4: OIS3 */
105 5U, /* 5: OIS3N */
106 6U, /* 6: OIS4 */
107 8U, /* 7: OIS5 */
108 10U /* 8: OIS6 */
111 * @}
114 /* Private constants ---------------------------------------------------------*/
115 /** @defgroup TIM_LL_Private_Constants TIM Private Constants
116 * @{
119 #if defined(TIM_BREAK_INPUT_SUPPORT)
120 /* Defines used for the bit position in the register and perform offsets */
121 #define TIM_POSITION_BRK_SOURCE (POSITION_VAL(Source) & 0x1FUL)
123 /* Generic bit definitions for TIMx_AF1 register */
124 #define TIMx_AF1_BKINE TIM1_AF1_BKINE /*!< BRK BKINE input enable */
125 #if defined(DFSDM1_Channel0)
126 #define TIMx_AF1_BKDFBKE TIM1_AF1_BKDFBKE /*!< BRK DFSDM1_BREAK[0] enable */
127 #endif /* DFSDM1_Channel0 */
128 #define TIMx_AF1_BKINP TIM1_AF1_BKINP /*!< BRK BKIN input polarity */
129 /* Generic bit definitions for TIMx_AF2 register */
130 #define TIMx_AF2_BK2INE TIM1_AF2_BK2INE /*!< BRK B2KINE input enable */
131 #if defined(DFSDM1_Channel0)
132 #define TIMx_AF2_BK2DFBKE TIM1_AF2_BK2DFBKE /*!< BRK DFSDM_BREAK[0] enable */
133 #endif /* DFSDM1_Channel0 */
134 #define TIMx_AF2_BK2INP TIM1_AF2_BK2INP /*!< BRK BK2IN input polarity */
135 #endif /* TIM_BREAK_INPUT_SUPPORT */
137 /* Remap mask definitions */
138 #define TIMx_OR_RMP_SHIFT 16U
139 #define TIMx_OR_RMP_MASK 0x0000FFFFU
140 #define TIM2_OR_RMP_MASK (TIM2_OR_ITR1_RMP << TIMx_OR_RMP_SHIFT)
141 #define TIM5_OR_RMP_MASK (TIM5_OR_TI4_RMP << TIMx_OR_RMP_SHIFT)
142 #define TIM11_OR_RMP_MASK (TIM11_OR_TI1_RMP << TIMx_OR_RMP_SHIFT)
144 /* Mask used to set the TDG[x:0] of the DTG bits of the TIMx_BDTR register */
145 #define DT_DELAY_1 ((uint8_t)0x7F)
146 #define DT_DELAY_2 ((uint8_t)0x3F)
147 #define DT_DELAY_3 ((uint8_t)0x1F)
148 #define DT_DELAY_4 ((uint8_t)0x1F)
150 /* Mask used to set the DTG[7:5] bits of the DTG bits of the TIMx_BDTR register */
151 #define DT_RANGE_1 ((uint8_t)0x00)
152 #define DT_RANGE_2 ((uint8_t)0x80)
153 #define DT_RANGE_3 ((uint8_t)0xC0)
154 #define DT_RANGE_4 ((uint8_t)0xE0)
158 * @}
161 /* Private macros ------------------------------------------------------------*/
162 /** @defgroup TIM_LL_Private_Macros TIM Private Macros
163 * @{
165 /** @brief Convert channel id into channel index.
166 * @param __CHANNEL__ This parameter can be one of the following values:
167 * @arg @ref LL_TIM_CHANNEL_CH1
168 * @arg @ref LL_TIM_CHANNEL_CH1N
169 * @arg @ref LL_TIM_CHANNEL_CH2
170 * @arg @ref LL_TIM_CHANNEL_CH2N
171 * @arg @ref LL_TIM_CHANNEL_CH3
172 * @arg @ref LL_TIM_CHANNEL_CH3N
173 * @arg @ref LL_TIM_CHANNEL_CH4
174 * @arg @ref LL_TIM_CHANNEL_CH5
175 * @arg @ref LL_TIM_CHANNEL_CH6
176 * @retval none
178 #define TIM_GET_CHANNEL_INDEX( __CHANNEL__) \
179 (((__CHANNEL__) == LL_TIM_CHANNEL_CH1) ? 0U :\
180 ((__CHANNEL__) == LL_TIM_CHANNEL_CH1N) ? 1U :\
181 ((__CHANNEL__) == LL_TIM_CHANNEL_CH2) ? 2U :\
182 ((__CHANNEL__) == LL_TIM_CHANNEL_CH2N) ? 3U :\
183 ((__CHANNEL__) == LL_TIM_CHANNEL_CH3) ? 4U :\
184 ((__CHANNEL__) == LL_TIM_CHANNEL_CH3N) ? 5U :\
185 ((__CHANNEL__) == LL_TIM_CHANNEL_CH4) ? 6U :\
186 ((__CHANNEL__) == LL_TIM_CHANNEL_CH5) ? 7U : 8U)
188 /** @brief Calculate the deadtime sampling period(in ps).
189 * @param __TIMCLK__ timer input clock frequency (in Hz).
190 * @param __CKD__ This parameter can be one of the following values:
191 * @arg @ref LL_TIM_CLOCKDIVISION_DIV1
192 * @arg @ref LL_TIM_CLOCKDIVISION_DIV2
193 * @arg @ref LL_TIM_CLOCKDIVISION_DIV4
194 * @retval none
196 #define TIM_CALC_DTS(__TIMCLK__, __CKD__) \
197 (((__CKD__) == LL_TIM_CLOCKDIVISION_DIV1) ? ((uint64_t)1000000000000U/(__TIMCLK__)) : \
198 ((__CKD__) == LL_TIM_CLOCKDIVISION_DIV2) ? ((uint64_t)1000000000000U/((__TIMCLK__) >> 1U)) : \
199 ((uint64_t)1000000000000U/((__TIMCLK__) >> 2U)))
201 * @}
205 /* Exported types ------------------------------------------------------------*/
206 #if defined(USE_FULL_LL_DRIVER)
207 /** @defgroup TIM_LL_ES_INIT TIM Exported Init structure
208 * @{
212 * @brief TIM Time Base configuration structure definition.
214 typedef struct
216 uint16_t Prescaler; /*!< Specifies the prescaler value used to divide the TIM clock.
217 This parameter can be a number between Min_Data=0x0000 and Max_Data=0xFFFF.
219 This feature can be modified afterwards using unitary function @ref LL_TIM_SetPrescaler().*/
221 uint32_t CounterMode; /*!< Specifies the counter mode.
222 This parameter can be a value of @ref TIM_LL_EC_COUNTERMODE.
224 This feature can be modified afterwards using unitary function @ref LL_TIM_SetCounterMode().*/
226 uint32_t Autoreload; /*!< Specifies the auto reload value to be loaded into the active
227 Auto-Reload Register at the next update event.
228 This parameter must be a number between Min_Data=0x0000 and Max_Data=0xFFFF.
229 Some timer instances may support 32 bits counters. In that case this parameter must be a number between 0x0000 and 0xFFFFFFFF.
231 This feature can be modified afterwards using unitary function @ref LL_TIM_SetAutoReload().*/
233 uint32_t ClockDivision; /*!< Specifies the clock division.
234 This parameter can be a value of @ref TIM_LL_EC_CLOCKDIVISION.
236 This feature can be modified afterwards using unitary function @ref LL_TIM_SetClockDivision().*/
238 uint8_t RepetitionCounter; /*!< Specifies the repetition counter value. Each time the RCR downcounter
239 reaches zero, an update event is generated and counting restarts
240 from the RCR value (N).
241 This means in PWM mode that (N+1) corresponds to:
242 - the number of PWM periods in edge-aligned mode
243 - the number of half PWM period in center-aligned mode
244 This parameter must be a number between 0x00 and 0xFF.
246 This feature can be modified afterwards using unitary function @ref LL_TIM_SetRepetitionCounter().*/
247 } LL_TIM_InitTypeDef;
250 * @brief TIM Output Compare configuration structure definition.
252 typedef struct
254 uint32_t OCMode; /*!< Specifies the output mode.
255 This parameter can be a value of @ref TIM_LL_EC_OCMODE.
257 This feature can be modified afterwards using unitary function @ref LL_TIM_OC_SetMode().*/
259 uint32_t OCState; /*!< Specifies the TIM Output Compare state.
260 This parameter can be a value of @ref TIM_LL_EC_OCSTATE.
262 This feature can be modified afterwards using unitary functions @ref LL_TIM_CC_EnableChannel() or @ref LL_TIM_CC_DisableChannel().*/
264 uint32_t OCNState; /*!< Specifies the TIM complementary Output Compare state.
265 This parameter can be a value of @ref TIM_LL_EC_OCSTATE.
267 This feature can be modified afterwards using unitary functions @ref LL_TIM_CC_EnableChannel() or @ref LL_TIM_CC_DisableChannel().*/
269 uint32_t CompareValue; /*!< Specifies the Compare value to be loaded into the Capture Compare Register.
270 This parameter can be a number between Min_Data=0x0000 and Max_Data=0xFFFF.
272 This feature can be modified afterwards using unitary function LL_TIM_OC_SetCompareCHx (x=1..6).*/
274 uint32_t OCPolarity; /*!< Specifies the output polarity.
275 This parameter can be a value of @ref TIM_LL_EC_OCPOLARITY.
277 This feature can be modified afterwards using unitary function @ref LL_TIM_OC_SetPolarity().*/
279 uint32_t OCNPolarity; /*!< Specifies the complementary output polarity.
280 This parameter can be a value of @ref TIM_LL_EC_OCPOLARITY.
282 This feature can be modified afterwards using unitary function @ref LL_TIM_OC_SetPolarity().*/
285 uint32_t OCIdleState; /*!< Specifies the TIM Output Compare pin state during Idle state.
286 This parameter can be a value of @ref TIM_LL_EC_OCIDLESTATE.
288 This feature can be modified afterwards using unitary function @ref LL_TIM_OC_SetIdleState().*/
290 uint32_t OCNIdleState; /*!< Specifies the TIM Output Compare pin state during Idle state.
291 This parameter can be a value of @ref TIM_LL_EC_OCIDLESTATE.
293 This feature can be modified afterwards using unitary function @ref LL_TIM_OC_SetIdleState().*/
294 } LL_TIM_OC_InitTypeDef;
297 * @brief TIM Input Capture configuration structure definition.
300 typedef struct
303 uint32_t ICPolarity; /*!< Specifies the active edge of the input signal.
304 This parameter can be a value of @ref TIM_LL_EC_IC_POLARITY.
306 This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPolarity().*/
308 uint32_t ICActiveInput; /*!< Specifies the input.
309 This parameter can be a value of @ref TIM_LL_EC_ACTIVEINPUT.
311 This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetActiveInput().*/
313 uint32_t ICPrescaler; /*!< Specifies the Input Capture Prescaler.
314 This parameter can be a value of @ref TIM_LL_EC_ICPSC.
316 This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPrescaler().*/
318 uint32_t ICFilter; /*!< Specifies the input capture filter.
319 This parameter can be a value of @ref TIM_LL_EC_IC_FILTER.
321 This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetFilter().*/
322 } LL_TIM_IC_InitTypeDef;
326 * @brief TIM Encoder interface configuration structure definition.
328 typedef struct
330 uint32_t EncoderMode; /*!< Specifies the encoder resolution (x2 or x4).
331 This parameter can be a value of @ref TIM_LL_EC_ENCODERMODE.
333 This feature can be modified afterwards using unitary function @ref LL_TIM_SetEncoderMode().*/
335 uint32_t IC1Polarity; /*!< Specifies the active edge of TI1 input.
336 This parameter can be a value of @ref TIM_LL_EC_IC_POLARITY.
338 This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPolarity().*/
340 uint32_t IC1ActiveInput; /*!< Specifies the TI1 input source
341 This parameter can be a value of @ref TIM_LL_EC_ACTIVEINPUT.
343 This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetActiveInput().*/
345 uint32_t IC1Prescaler; /*!< Specifies the TI1 input prescaler value.
346 This parameter can be a value of @ref TIM_LL_EC_ICPSC.
348 This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPrescaler().*/
350 uint32_t IC1Filter; /*!< Specifies the TI1 input filter.
351 This parameter can be a value of @ref TIM_LL_EC_IC_FILTER.
353 This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetFilter().*/
355 uint32_t IC2Polarity; /*!< Specifies the active edge of TI2 input.
356 This parameter can be a value of @ref TIM_LL_EC_IC_POLARITY.
358 This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPolarity().*/
360 uint32_t IC2ActiveInput; /*!< Specifies the TI2 input source
361 This parameter can be a value of @ref TIM_LL_EC_ACTIVEINPUT.
363 This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetActiveInput().*/
365 uint32_t IC2Prescaler; /*!< Specifies the TI2 input prescaler value.
366 This parameter can be a value of @ref TIM_LL_EC_ICPSC.
368 This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPrescaler().*/
370 uint32_t IC2Filter; /*!< Specifies the TI2 input filter.
371 This parameter can be a value of @ref TIM_LL_EC_IC_FILTER.
373 This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetFilter().*/
375 } LL_TIM_ENCODER_InitTypeDef;
378 * @brief TIM Hall sensor interface configuration structure definition.
380 typedef struct
383 uint32_t IC1Polarity; /*!< Specifies the active edge of TI1 input.
384 This parameter can be a value of @ref TIM_LL_EC_IC_POLARITY.
386 This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPolarity().*/
388 uint32_t IC1Prescaler; /*!< Specifies the TI1 input prescaler value.
389 Prescaler must be set to get a maximum counter period longer than the
390 time interval between 2 consecutive changes on the Hall inputs.
391 This parameter can be a value of @ref TIM_LL_EC_ICPSC.
393 This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPrescaler().*/
395 uint32_t IC1Filter; /*!< Specifies the TI1 input filter.
396 This parameter can be a value of @ref TIM_LL_EC_IC_FILTER.
398 This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetFilter().*/
400 uint32_t CommutationDelay; /*!< Specifies the compare value to be loaded into the Capture Compare Register.
401 A positive pulse (TRGO event) is generated with a programmable delay every time
402 a change occurs on the Hall inputs.
403 This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF.
405 This feature can be modified afterwards using unitary function @ref LL_TIM_OC_SetCompareCH2().*/
406 } LL_TIM_HALLSENSOR_InitTypeDef;
409 * @brief BDTR (Break and Dead Time) structure definition
411 typedef struct
413 uint32_t OSSRState; /*!< Specifies the Off-State selection used in Run mode.
414 This parameter can be a value of @ref TIM_LL_EC_OSSR
416 This feature can be modified afterwards using unitary function @ref LL_TIM_SetOffStates()
418 @note This bit-field cannot be modified as long as LOCK level 2 has been programmed. */
420 uint32_t OSSIState; /*!< Specifies the Off-State used in Idle state.
421 This parameter can be a value of @ref TIM_LL_EC_OSSI
423 This feature can be modified afterwards using unitary function @ref LL_TIM_SetOffStates()
425 @note This bit-field cannot be modified as long as LOCK level 2 has been programmed. */
427 uint32_t LockLevel; /*!< Specifies the LOCK level parameters.
428 This parameter can be a value of @ref TIM_LL_EC_LOCKLEVEL
430 @note The LOCK bits can be written only once after the reset. Once the TIMx_BDTR register
431 has been written, their content is frozen until the next reset.*/
433 uint8_t DeadTime; /*!< Specifies the delay time between the switching-off and the
434 switching-on of the outputs.
435 This parameter can be a number between Min_Data = 0x00 and Max_Data = 0xFF.
437 This feature can be modified afterwards using unitary function @ref LL_TIM_OC_SetDeadTime()
439 @note This bit-field can not be modified as long as LOCK level 1, 2 or 3 has been programmed. */
441 uint16_t BreakState; /*!< Specifies whether the TIM Break input is enabled or not.
442 This parameter can be a value of @ref TIM_LL_EC_BREAK_ENABLE
444 This feature can be modified afterwards using unitary functions @ref LL_TIM_EnableBRK() or @ref LL_TIM_DisableBRK()
446 @note This bit-field can not be modified as long as LOCK level 1 has been programmed. */
448 uint32_t BreakPolarity; /*!< Specifies the TIM Break Input pin polarity.
449 This parameter can be a value of @ref TIM_LL_EC_BREAK_POLARITY
451 This feature can be modified afterwards using unitary function @ref LL_TIM_ConfigBRK()
453 @note This bit-field can not be modified as long as LOCK level 1 has been programmed. */
455 uint32_t BreakFilter; /*!< Specifies the TIM Break Filter.
456 This parameter can be a value of @ref TIM_LL_EC_BREAK_FILTER
458 This feature can be modified afterwards using unitary function @ref LL_TIM_ConfigBRK()
460 @note This bit-field can not be modified as long as LOCK level 1 has been programmed. */
462 uint32_t Break2State; /*!< Specifies whether the TIM Break2 input is enabled or not.
463 This parameter can be a value of @ref TIM_LL_EC_BREAK2_ENABLE
465 This feature can be modified afterwards using unitary functions @ref LL_TIM_EnableBRK2() or @ref LL_TIM_DisableBRK2()
467 @note This bit-field can not be modified as long as LOCK level 1 has been programmed. */
469 uint32_t Break2Polarity; /*!< Specifies the TIM Break2 Input pin polarity.
470 This parameter can be a value of @ref TIM_LL_EC_BREAK2_POLARITY
472 This feature can be modified afterwards using unitary function @ref LL_TIM_ConfigBRK2()
474 @note This bit-field can not be modified as long as LOCK level 1 has been programmed. */
476 uint32_t Break2Filter; /*!< Specifies the TIM Break2 Filter.
477 This parameter can be a value of @ref TIM_LL_EC_BREAK2_FILTER
479 This feature can be modified afterwards using unitary function @ref LL_TIM_ConfigBRK2()
481 @note This bit-field can not be modified as long as LOCK level 1 has been programmed. */
483 uint32_t AutomaticOutput; /*!< Specifies whether the TIM Automatic Output feature is enabled or not.
484 This parameter can be a value of @ref TIM_LL_EC_AUTOMATICOUTPUT_ENABLE
486 This feature can be modified afterwards using unitary functions @ref LL_TIM_EnableAutomaticOutput() or @ref LL_TIM_DisableAutomaticOutput()
488 @note This bit-field can not be modified as long as LOCK level 1 has been programmed. */
489 } LL_TIM_BDTR_InitTypeDef;
492 * @}
494 #endif /* USE_FULL_LL_DRIVER */
496 /* Exported constants --------------------------------------------------------*/
497 /** @defgroup TIM_LL_Exported_Constants TIM Exported Constants
498 * @{
501 /** @defgroup TIM_LL_EC_GET_FLAG Get Flags Defines
502 * @brief Flags defines which can be used with LL_TIM_ReadReg function.
503 * @{
505 #define LL_TIM_SR_UIF TIM_SR_UIF /*!< Update interrupt flag */
506 #define LL_TIM_SR_CC1IF TIM_SR_CC1IF /*!< Capture/compare 1 interrupt flag */
507 #define LL_TIM_SR_CC2IF TIM_SR_CC2IF /*!< Capture/compare 2 interrupt flag */
508 #define LL_TIM_SR_CC3IF TIM_SR_CC3IF /*!< Capture/compare 3 interrupt flag */
509 #define LL_TIM_SR_CC4IF TIM_SR_CC4IF /*!< Capture/compare 4 interrupt flag */
510 #define LL_TIM_SR_CC5IF TIM_SR_CC5IF /*!< Capture/compare 5 interrupt flag */
511 #define LL_TIM_SR_CC6IF TIM_SR_CC6IF /*!< Capture/compare 6 interrupt flag */
512 #define LL_TIM_SR_COMIF TIM_SR_COMIF /*!< COM interrupt flag */
513 #define LL_TIM_SR_TIF TIM_SR_TIF /*!< Trigger interrupt flag */
514 #define LL_TIM_SR_BIF TIM_SR_BIF /*!< Break interrupt flag */
515 #define LL_TIM_SR_B2IF TIM_SR_B2IF /*!< Second break interrupt flag */
516 #define LL_TIM_SR_CC1OF TIM_SR_CC1OF /*!< Capture/Compare 1 overcapture flag */
517 #define LL_TIM_SR_CC2OF TIM_SR_CC2OF /*!< Capture/Compare 2 overcapture flag */
518 #define LL_TIM_SR_CC3OF TIM_SR_CC3OF /*!< Capture/Compare 3 overcapture flag */
519 #define LL_TIM_SR_CC4OF TIM_SR_CC4OF /*!< Capture/Compare 4 overcapture flag */
520 #define LL_TIM_SR_SBIF TIM_SR_SBIF /*!< System Break interrupt flag */
522 * @}
525 #if defined(USE_FULL_LL_DRIVER)
526 /** @defgroup TIM_LL_EC_BREAK_ENABLE Break Enable
527 * @{
529 #define LL_TIM_BREAK_DISABLE 0x00000000U /*!< Break function disabled */
530 #define LL_TIM_BREAK_ENABLE TIM_BDTR_BKE /*!< Break function enabled */
532 * @}
535 /** @defgroup TIM_LL_EC_BREAK2_ENABLE Break2 Enable
536 * @{
538 #define LL_TIM_BREAK2_DISABLE 0x00000000U /*!< Break2 function disabled */
539 #define LL_TIM_BREAK2_ENABLE TIM_BDTR_BK2E /*!< Break2 function enabled */
541 * @}
544 /** @defgroup TIM_LL_EC_AUTOMATICOUTPUT_ENABLE Automatic output enable
545 * @{
547 #define LL_TIM_AUTOMATICOUTPUT_DISABLE 0x00000000U /*!< MOE can be set only by software */
548 #define LL_TIM_AUTOMATICOUTPUT_ENABLE TIM_BDTR_AOE /*!< MOE can be set by software or automatically at the next update event */
550 * @}
552 #endif /* USE_FULL_LL_DRIVER */
554 /** @defgroup TIM_LL_EC_IT IT Defines
555 * @brief IT defines which can be used with LL_TIM_ReadReg and LL_TIM_WriteReg functions.
556 * @{
558 #define LL_TIM_DIER_UIE TIM_DIER_UIE /*!< Update interrupt enable */
559 #define LL_TIM_DIER_CC1IE TIM_DIER_CC1IE /*!< Capture/compare 1 interrupt enable */
560 #define LL_TIM_DIER_CC2IE TIM_DIER_CC2IE /*!< Capture/compare 2 interrupt enable */
561 #define LL_TIM_DIER_CC3IE TIM_DIER_CC3IE /*!< Capture/compare 3 interrupt enable */
562 #define LL_TIM_DIER_CC4IE TIM_DIER_CC4IE /*!< Capture/compare 4 interrupt enable */
563 #define LL_TIM_DIER_COMIE TIM_DIER_COMIE /*!< COM interrupt enable */
564 #define LL_TIM_DIER_TIE TIM_DIER_TIE /*!< Trigger interrupt enable */
565 #define LL_TIM_DIER_BIE TIM_DIER_BIE /*!< Break interrupt enable */
567 * @}
570 /** @defgroup TIM_LL_EC_UPDATESOURCE Update Source
571 * @{
573 #define LL_TIM_UPDATESOURCE_REGULAR 0x00000000U /*!< Counter overflow/underflow, Setting the UG bit or Update generation through the slave mode controller generates an update request */
574 #define LL_TIM_UPDATESOURCE_COUNTER TIM_CR1_URS /*!< Only counter overflow/underflow generates an update request */
576 * @}
579 /** @defgroup TIM_LL_EC_ONEPULSEMODE One Pulse Mode
580 * @{
582 #define LL_TIM_ONEPULSEMODE_SINGLE TIM_CR1_OPM /*!< Counter is not stopped at update event */
583 #define LL_TIM_ONEPULSEMODE_REPETITIVE 0x00000000U /*!< Counter stops counting at the next update event */
585 * @}
588 /** @defgroup TIM_LL_EC_COUNTERMODE Counter Mode
589 * @{
591 #define LL_TIM_COUNTERMODE_UP 0x00000000U /*!<Counter used as upcounter */
592 #define LL_TIM_COUNTERMODE_DOWN TIM_CR1_DIR /*!< Counter used as downcounter */
593 #define LL_TIM_COUNTERMODE_CENTER_UP TIM_CR1_CMS_0 /*!< The counter counts up and down alternatively. Output compare interrupt flags of output channels are set only when the counter is counting down. */
594 #define LL_TIM_COUNTERMODE_CENTER_DOWN TIM_CR1_CMS_1 /*!<The counter counts up and down alternatively. Output compare interrupt flags of output channels are set only when the counter is counting up */
595 #define LL_TIM_COUNTERMODE_CENTER_UP_DOWN TIM_CR1_CMS /*!< The counter counts up and down alternatively. Output compare interrupt flags of output channels are set only when the counter is counting up or down. */
597 * @}
600 /** @defgroup TIM_LL_EC_CLOCKDIVISION Clock Division
601 * @{
603 #define LL_TIM_CLOCKDIVISION_DIV1 0x00000000U /*!< tDTS=tCK_INT */
604 #define LL_TIM_CLOCKDIVISION_DIV2 TIM_CR1_CKD_0 /*!< tDTS=2*tCK_INT */
605 #define LL_TIM_CLOCKDIVISION_DIV4 TIM_CR1_CKD_1 /*!< tDTS=4*tCK_INT */
607 * @}
610 /** @defgroup TIM_LL_EC_COUNTERDIRECTION Counter Direction
611 * @{
613 #define LL_TIM_COUNTERDIRECTION_UP 0x00000000U /*!< Timer counter counts up */
614 #define LL_TIM_COUNTERDIRECTION_DOWN TIM_CR1_DIR /*!< Timer counter counts down */
616 * @}
619 /** @defgroup TIM_LL_EC_CCUPDATESOURCE Capture Compare Update Source
620 * @{
622 #define LL_TIM_CCUPDATESOURCE_COMG_ONLY 0x00000000U /*!< Capture/compare control bits are updated by setting the COMG bit only */
623 #define LL_TIM_CCUPDATESOURCE_COMG_AND_TRGI TIM_CR2_CCUS /*!< Capture/compare control bits are updated by setting the COMG bit or when a rising edge occurs on trigger input (TRGI) */
625 * @}
628 /** @defgroup TIM_LL_EC_CCDMAREQUEST Capture Compare DMA Request
629 * @{
631 #define LL_TIM_CCDMAREQUEST_CC 0x00000000U /*!< CCx DMA request sent when CCx event occurs */
632 #define LL_TIM_CCDMAREQUEST_UPDATE TIM_CR2_CCDS /*!< CCx DMA requests sent when update event occurs */
634 * @}
637 /** @defgroup TIM_LL_EC_LOCKLEVEL Lock Level
638 * @{
640 #define LL_TIM_LOCKLEVEL_OFF 0x00000000U /*!< LOCK OFF - No bit is write protected */
641 #define LL_TIM_LOCKLEVEL_1 TIM_BDTR_LOCK_0 /*!< LOCK Level 1 */
642 #define LL_TIM_LOCKLEVEL_2 TIM_BDTR_LOCK_1 /*!< LOCK Level 2 */
643 #define LL_TIM_LOCKLEVEL_3 TIM_BDTR_LOCK /*!< LOCK Level 3 */
645 * @}
648 /** @defgroup TIM_LL_EC_CHANNEL Channel
649 * @{
651 #define LL_TIM_CHANNEL_CH1 TIM_CCER_CC1E /*!< Timer input/output channel 1 */
652 #define LL_TIM_CHANNEL_CH1N TIM_CCER_CC1NE /*!< Timer complementary output channel 1 */
653 #define LL_TIM_CHANNEL_CH2 TIM_CCER_CC2E /*!< Timer input/output channel 2 */
654 #define LL_TIM_CHANNEL_CH2N TIM_CCER_CC2NE /*!< Timer complementary output channel 2 */
655 #define LL_TIM_CHANNEL_CH3 TIM_CCER_CC3E /*!< Timer input/output channel 3 */
656 #define LL_TIM_CHANNEL_CH3N TIM_CCER_CC3NE /*!< Timer complementary output channel 3 */
657 #define LL_TIM_CHANNEL_CH4 TIM_CCER_CC4E /*!< Timer input/output channel 4 */
658 #define LL_TIM_CHANNEL_CH5 TIM_CCER_CC5E /*!< Timer output channel 5 */
659 #define LL_TIM_CHANNEL_CH6 TIM_CCER_CC6E /*!< Timer output channel 6 */
661 * @}
664 #if defined(USE_FULL_LL_DRIVER)
665 /** @defgroup TIM_LL_EC_OCSTATE Output Configuration State
666 * @{
668 #define LL_TIM_OCSTATE_DISABLE 0x00000000U /*!< OCx is not active */
669 #define LL_TIM_OCSTATE_ENABLE TIM_CCER_CC1E /*!< OCx signal is output on the corresponding output pin */
671 * @}
673 #endif /* USE_FULL_LL_DRIVER */
675 /** @defgroup TIM_LL_EC_OCMODE Output Configuration Mode
676 * @{
678 #define LL_TIM_OCMODE_FROZEN 0x00000000U /*!<The comparison between the output compare register TIMx_CCRy and the counter TIMx_CNT has no effect on the output channel level */
679 #define LL_TIM_OCMODE_ACTIVE TIM_CCMR1_OC1M_0 /*!<OCyREF is forced high on compare match*/
680 #define LL_TIM_OCMODE_INACTIVE TIM_CCMR1_OC1M_1 /*!<OCyREF is forced low on compare match*/
681 #define LL_TIM_OCMODE_TOGGLE (TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_0) /*!<OCyREF toggles on compare match*/
682 #define LL_TIM_OCMODE_FORCED_INACTIVE TIM_CCMR1_OC1M_2 /*!<OCyREF is forced low*/
683 #define LL_TIM_OCMODE_FORCED_ACTIVE (TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1M_0) /*!<OCyREF is forced high*/
684 #define LL_TIM_OCMODE_PWM1 (TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1M_1) /*!<In upcounting, channel y is active as long as TIMx_CNT<TIMx_CCRy else inactive. In downcounting, channel y is inactive as long as TIMx_CNT>TIMx_CCRy else active.*/
685 #define LL_TIM_OCMODE_PWM2 (TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_0) /*!<In upcounting, channel y is inactive as long as TIMx_CNT<TIMx_CCRy else active. In downcounting, channel y is active as long as TIMx_CNT>TIMx_CCRy else inactive*/
686 #define LL_TIM_OCMODE_RETRIG_OPM1 TIM_CCMR1_OC1M_3 /*!<Retrigerrable OPM mode 1*/
687 #define LL_TIM_OCMODE_RETRIG_OPM2 (TIM_CCMR1_OC1M_3 | TIM_CCMR1_OC1M_0) /*!<Retrigerrable OPM mode 2*/
688 #define LL_TIM_OCMODE_COMBINED_PWM1 (TIM_CCMR1_OC1M_3 | TIM_CCMR1_OC1M_2) /*!<Combined PWM mode 1*/
689 #define LL_TIM_OCMODE_COMBINED_PWM2 (TIM_CCMR1_OC1M_3 | TIM_CCMR1_OC1M_0 | TIM_CCMR1_OC1M_2) /*!<Combined PWM mode 2*/
690 #define LL_TIM_OCMODE_ASSYMETRIC_PWM1 (TIM_CCMR1_OC1M_3 | TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_2) /*!<Asymmetric PWM mode 1*/
691 #define LL_TIM_OCMODE_ASSYMETRIC_PWM2 (TIM_CCMR1_OC1M_3 | TIM_CCMR1_OC1M) /*!<Asymmetric PWM mode 2*/
693 * @}
696 /** @defgroup TIM_LL_EC_OCPOLARITY Output Configuration Polarity
697 * @{
699 #define LL_TIM_OCPOLARITY_HIGH 0x00000000U /*!< OCxactive high*/
700 #define LL_TIM_OCPOLARITY_LOW TIM_CCER_CC1P /*!< OCxactive low*/
702 * @}
705 /** @defgroup TIM_LL_EC_OCIDLESTATE Output Configuration Idle State
706 * @{
708 #define LL_TIM_OCIDLESTATE_LOW 0x00000000U /*!<OCx=0 (after a dead-time if OC is implemented) when MOE=0*/
709 #define LL_TIM_OCIDLESTATE_HIGH TIM_CR2_OIS1 /*!<OCx=1 (after a dead-time if OC is implemented) when MOE=0*/
711 * @}
714 /** @defgroup TIM_LL_EC_GROUPCH5 GROUPCH5
715 * @{
717 #define LL_TIM_GROUPCH5_NONE 0x00000000U /*!< No effect of OC5REF on OC1REFC, OC2REFC and OC3REFC */
718 #define LL_TIM_GROUPCH5_OC1REFC TIM_CCR5_GC5C1 /*!< OC1REFC is the logical AND of OC1REFC and OC5REF */
719 #define LL_TIM_GROUPCH5_OC2REFC TIM_CCR5_GC5C2 /*!< OC2REFC is the logical AND of OC2REFC and OC5REF */
720 #define LL_TIM_GROUPCH5_OC3REFC TIM_CCR5_GC5C3 /*!< OC3REFC is the logical AND of OC3REFC and OC5REF */
722 * @}
725 /** @defgroup TIM_LL_EC_ACTIVEINPUT Active Input Selection
726 * @{
728 #define LL_TIM_ACTIVEINPUT_DIRECTTI (TIM_CCMR1_CC1S_0 << 16U) /*!< ICx is mapped on TIx */
729 #define LL_TIM_ACTIVEINPUT_INDIRECTTI (TIM_CCMR1_CC1S_1 << 16U) /*!< ICx is mapped on TIy */
730 #define LL_TIM_ACTIVEINPUT_TRC (TIM_CCMR1_CC1S << 16U) /*!< ICx is mapped on TRC */
732 * @}
735 /** @defgroup TIM_LL_EC_ICPSC Input Configuration Prescaler
736 * @{
738 #define LL_TIM_ICPSC_DIV1 0x00000000U /*!< No prescaler, capture is done each time an edge is detected on the capture input */
739 #define LL_TIM_ICPSC_DIV2 (TIM_CCMR1_IC1PSC_0 << 16U) /*!< Capture is done once every 2 events */
740 #define LL_TIM_ICPSC_DIV4 (TIM_CCMR1_IC1PSC_1 << 16U) /*!< Capture is done once every 4 events */
741 #define LL_TIM_ICPSC_DIV8 (TIM_CCMR1_IC1PSC << 16U) /*!< Capture is done once every 8 events */
743 * @}
746 /** @defgroup TIM_LL_EC_IC_FILTER Input Configuration Filter
747 * @{
749 #define LL_TIM_IC_FILTER_FDIV1 0x00000000U /*!< No filter, sampling is done at fDTS */
750 #define LL_TIM_IC_FILTER_FDIV1_N2 (TIM_CCMR1_IC1F_0 << 16U) /*!< fSAMPLING=fCK_INT, N=2 */
751 #define LL_TIM_IC_FILTER_FDIV1_N4 (TIM_CCMR1_IC1F_1 << 16U) /*!< fSAMPLING=fCK_INT, N=4 */
752 #define LL_TIM_IC_FILTER_FDIV1_N8 ((TIM_CCMR1_IC1F_1 | TIM_CCMR1_IC1F_0) << 16U) /*!< fSAMPLING=fCK_INT, N=8 */
753 #define LL_TIM_IC_FILTER_FDIV2_N6 (TIM_CCMR1_IC1F_2 << 16U) /*!< fSAMPLING=fDTS/2, N=6 */
754 #define LL_TIM_IC_FILTER_FDIV2_N8 ((TIM_CCMR1_IC1F_2 | TIM_CCMR1_IC1F_0) << 16U) /*!< fSAMPLING=fDTS/2, N=8 */
755 #define LL_TIM_IC_FILTER_FDIV4_N6 ((TIM_CCMR1_IC1F_2 | TIM_CCMR1_IC1F_1) << 16U) /*!< fSAMPLING=fDTS/4, N=6 */
756 #define LL_TIM_IC_FILTER_FDIV4_N8 ((TIM_CCMR1_IC1F_2 | TIM_CCMR1_IC1F_1 | TIM_CCMR1_IC1F_0) << 16U) /*!< fSAMPLING=fDTS/4, N=8 */
757 #define LL_TIM_IC_FILTER_FDIV8_N6 (TIM_CCMR1_IC1F_3 << 16U) /*!< fSAMPLING=fDTS/8, N=6 */
758 #define LL_TIM_IC_FILTER_FDIV8_N8 ((TIM_CCMR1_IC1F_3 | TIM_CCMR1_IC1F_0) << 16U) /*!< fSAMPLING=fDTS/8, N=8 */
759 #define LL_TIM_IC_FILTER_FDIV16_N5 ((TIM_CCMR1_IC1F_3 | TIM_CCMR1_IC1F_1) << 16U) /*!< fSAMPLING=fDTS/16, N=5 */
760 #define LL_TIM_IC_FILTER_FDIV16_N6 ((TIM_CCMR1_IC1F_3 | TIM_CCMR1_IC1F_1 | TIM_CCMR1_IC1F_0) << 16U) /*!< fSAMPLING=fDTS/16, N=6 */
761 #define LL_TIM_IC_FILTER_FDIV16_N8 ((TIM_CCMR1_IC1F_3 | TIM_CCMR1_IC1F_2) << 16U) /*!< fSAMPLING=fDTS/16, N=8 */
762 #define LL_TIM_IC_FILTER_FDIV32_N5 ((TIM_CCMR1_IC1F_3 | TIM_CCMR1_IC1F_2 | TIM_CCMR1_IC1F_0) << 16U) /*!< fSAMPLING=fDTS/32, N=5 */
763 #define LL_TIM_IC_FILTER_FDIV32_N6 ((TIM_CCMR1_IC1F_3 | TIM_CCMR1_IC1F_2 | TIM_CCMR1_IC1F_1) << 16U) /*!< fSAMPLING=fDTS/32, N=6 */
764 #define LL_TIM_IC_FILTER_FDIV32_N8 (TIM_CCMR1_IC1F << 16U) /*!< fSAMPLING=fDTS/32, N=8 */
766 * @}
769 /** @defgroup TIM_LL_EC_IC_POLARITY Input Configuration Polarity
770 * @{
772 #define LL_TIM_IC_POLARITY_RISING 0x00000000U /*!< The circuit is sensitive to TIxFP1 rising edge, TIxFP1 is not inverted */
773 #define LL_TIM_IC_POLARITY_FALLING TIM_CCER_CC1P /*!< The circuit is sensitive to TIxFP1 falling edge, TIxFP1 is inverted */
774 #define LL_TIM_IC_POLARITY_BOTHEDGE (TIM_CCER_CC1P | TIM_CCER_CC1NP) /*!< The circuit is sensitive to both TIxFP1 rising and falling edges, TIxFP1 is not inverted */
776 * @}
779 /** @defgroup TIM_LL_EC_CLOCKSOURCE Clock Source
780 * @{
782 #define LL_TIM_CLOCKSOURCE_INTERNAL 0x00000000U /*!< The timer is clocked by the internal clock provided from the RCC */
783 #define LL_TIM_CLOCKSOURCE_EXT_MODE1 (TIM_SMCR_SMS_2 | TIM_SMCR_SMS_1 | TIM_SMCR_SMS_0) /*!< Counter counts at each rising or falling edge on a selected input*/
784 #define LL_TIM_CLOCKSOURCE_EXT_MODE2 TIM_SMCR_ECE /*!< Counter counts at each rising or falling edge on the external trigger input ETR */
786 * @}
789 /** @defgroup TIM_LL_EC_ENCODERMODE Encoder Mode
790 * @{
792 #define LL_TIM_ENCODERMODE_X2_TI1 TIM_SMCR_SMS_0 /*!< Quadrature encoder mode 1, x2 mode - Counter counts up/down on TI1FP1 edge depending on TI2FP2 level */
793 #define LL_TIM_ENCODERMODE_X2_TI2 TIM_SMCR_SMS_1 /*!< Quadrature encoder mode 2, x2 mode - Counter counts up/down on TI2FP2 edge depending on TI1FP1 level */
794 #define LL_TIM_ENCODERMODE_X4_TI12 (TIM_SMCR_SMS_1 | TIM_SMCR_SMS_0) /*!< Quadrature encoder mode 3, x4 mode - Counter counts up/down on both TI1FP1 and TI2FP2 edges depending on the level of the other input */
796 * @}
799 /** @defgroup TIM_LL_EC_TRGO Trigger Output
800 * @{
802 #define LL_TIM_TRGO_RESET 0x00000000U /*!< UG bit from the TIMx_EGR register is used as trigger output */
803 #define LL_TIM_TRGO_ENABLE TIM_CR2_MMS_0 /*!< Counter Enable signal (CNT_EN) is used as trigger output */
804 #define LL_TIM_TRGO_UPDATE TIM_CR2_MMS_1 /*!< Update event is used as trigger output */
805 #define LL_TIM_TRGO_CC1IF (TIM_CR2_MMS_1 | TIM_CR2_MMS_0) /*!< CC1 capture or a compare match is used as trigger output */
806 #define LL_TIM_TRGO_OC1REF TIM_CR2_MMS_2 /*!< OC1REF signal is used as trigger output */
807 #define LL_TIM_TRGO_OC2REF (TIM_CR2_MMS_2 | TIM_CR2_MMS_0) /*!< OC2REF signal is used as trigger output */
808 #define LL_TIM_TRGO_OC3REF (TIM_CR2_MMS_2 | TIM_CR2_MMS_1) /*!< OC3REF signal is used as trigger output */
809 #define LL_TIM_TRGO_OC4REF (TIM_CR2_MMS_2 | TIM_CR2_MMS_1 | TIM_CR2_MMS_0) /*!< OC4REF signal is used as trigger output */
811 * @}
814 /** @defgroup TIM_LL_EC_TRGO2 Trigger Output 2
815 * @{
817 #define LL_TIM_TRGO2_RESET 0x00000000U /*!< UG bit from the TIMx_EGR register is used as trigger output 2 */
818 #define LL_TIM_TRGO2_ENABLE TIM_CR2_MMS2_0 /*!< Counter Enable signal (CNT_EN) is used as trigger output 2 */
819 #define LL_TIM_TRGO2_UPDATE TIM_CR2_MMS2_1 /*!< Update event is used as trigger output 2 */
820 #define LL_TIM_TRGO2_CC1F (TIM_CR2_MMS2_1 | TIM_CR2_MMS2_0) /*!< CC1 capture or a compare match is used as trigger output 2 */
821 #define LL_TIM_TRGO2_OC1 TIM_CR2_MMS2_2 /*!< OC1REF signal is used as trigger output 2 */
822 #define LL_TIM_TRGO2_OC2 (TIM_CR2_MMS2_2 | TIM_CR2_MMS2_0) /*!< OC2REF signal is used as trigger output 2 */
823 #define LL_TIM_TRGO2_OC3 (TIM_CR2_MMS2_2 | TIM_CR2_MMS2_1) /*!< OC3REF signal is used as trigger output 2 */
824 #define LL_TIM_TRGO2_OC4 (TIM_CR2_MMS2_2 | TIM_CR2_MMS2_1 | TIM_CR2_MMS2_0) /*!< OC4REF signal is used as trigger output 2 */
825 #define LL_TIM_TRGO2_OC5 TIM_CR2_MMS2_3 /*!< OC5REF signal is used as trigger output 2 */
826 #define LL_TIM_TRGO2_OC6 (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_0) /*!< OC6REF signal is used as trigger output 2 */
827 #define LL_TIM_TRGO2_OC4_RISINGFALLING (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_1) /*!< OC4REF rising or falling edges are used as trigger output 2 */
828 #define LL_TIM_TRGO2_OC6_RISINGFALLING (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_1 | TIM_CR2_MMS2_0) /*!< OC6REF rising or falling edges are used as trigger output 2 */
829 #define LL_TIM_TRGO2_OC4_RISING_OC6_RISING (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_2) /*!< OC4REF or OC6REF rising edges are used as trigger output 2 */
830 #define LL_TIM_TRGO2_OC4_RISING_OC6_FALLING (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_2 | TIM_CR2_MMS2_0) /*!< OC4REF rising or OC6REF falling edges are used as trigger output 2 */
831 #define LL_TIM_TRGO2_OC5_RISING_OC6_RISING (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_2 |TIM_CR2_MMS2_1) /*!< OC5REF or OC6REF rising edges are used as trigger output 2 */
832 #define LL_TIM_TRGO2_OC5_RISING_OC6_FALLING (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_2 | TIM_CR2_MMS2_1 | TIM_CR2_MMS2_0) /*!< OC5REF rising or OC6REF falling edges are used as trigger output 2 */
834 * @}
837 /** @defgroup TIM_LL_EC_SLAVEMODE Slave Mode
838 * @{
840 #define LL_TIM_SLAVEMODE_DISABLED 0x00000000U /*!< Slave mode disabled */
841 #define LL_TIM_SLAVEMODE_RESET TIM_SMCR_SMS_2 /*!< Reset Mode - Rising edge of the selected trigger input (TRGI) reinitializes the counter */
842 #define LL_TIM_SLAVEMODE_GATED (TIM_SMCR_SMS_2 | TIM_SMCR_SMS_0) /*!< Gated Mode - The counter clock is enabled when the trigger input (TRGI) is high */
843 #define LL_TIM_SLAVEMODE_TRIGGER (TIM_SMCR_SMS_2 | TIM_SMCR_SMS_1) /*!< Trigger Mode - The counter starts at a rising edge of the trigger TRGI */
844 #define LL_TIM_SLAVEMODE_COMBINED_RESETTRIGGER TIM_SMCR_SMS_3 /*!< Combined reset + trigger mode - Rising edge of the selected trigger input (TRGI) reinitializes the counter, generates an update of the registers and starts the counter */
846 * @}
849 /** @defgroup TIM_LL_EC_TS Trigger Selection
850 * @{
852 #define LL_TIM_TS_ITR0 0x00000000U /*!< Internal Trigger 0 (ITR0) is used as trigger input */
853 #define LL_TIM_TS_ITR1 TIM_SMCR_TS_0 /*!< Internal Trigger 1 (ITR1) is used as trigger input */
854 #define LL_TIM_TS_ITR2 TIM_SMCR_TS_1 /*!< Internal Trigger 2 (ITR2) is used as trigger input */
855 #define LL_TIM_TS_ITR3 (TIM_SMCR_TS_0 | TIM_SMCR_TS_1) /*!< Internal Trigger 3 (ITR3) is used as trigger input */
856 #define LL_TIM_TS_TI1F_ED TIM_SMCR_TS_2 /*!< TI1 Edge Detector (TI1F_ED) is used as trigger input */
857 #define LL_TIM_TS_TI1FP1 (TIM_SMCR_TS_2 | TIM_SMCR_TS_0) /*!< Filtered Timer Input 1 (TI1FP1) is used as trigger input */
858 #define LL_TIM_TS_TI2FP2 (TIM_SMCR_TS_2 | TIM_SMCR_TS_1) /*!< Filtered Timer Input 2 (TI12P2) is used as trigger input */
859 #define LL_TIM_TS_ETRF (TIM_SMCR_TS_2 | TIM_SMCR_TS_1 | TIM_SMCR_TS_0) /*!< Filtered external Trigger (ETRF) is used as trigger input */
861 * @}
864 /** @defgroup TIM_LL_EC_ETR_POLARITY External Trigger Polarity
865 * @{
867 #define LL_TIM_ETR_POLARITY_NONINVERTED 0x00000000U /*!< ETR is non-inverted, active at high level or rising edge */
868 #define LL_TIM_ETR_POLARITY_INVERTED TIM_SMCR_ETP /*!< ETR is inverted, active at low level or falling edge */
870 * @}
873 /** @defgroup TIM_LL_EC_ETR_PRESCALER External Trigger Prescaler
874 * @{
876 #define LL_TIM_ETR_PRESCALER_DIV1 0x00000000U /*!< ETR prescaler OFF */
877 #define LL_TIM_ETR_PRESCALER_DIV2 TIM_SMCR_ETPS_0 /*!< ETR frequency is divided by 2 */
878 #define LL_TIM_ETR_PRESCALER_DIV4 TIM_SMCR_ETPS_1 /*!< ETR frequency is divided by 4 */
879 #define LL_TIM_ETR_PRESCALER_DIV8 TIM_SMCR_ETPS /*!< ETR frequency is divided by 8 */
881 * @}
884 /** @defgroup TIM_LL_EC_ETR_FILTER External Trigger Filter
885 * @{
887 #define LL_TIM_ETR_FILTER_FDIV1 0x00000000U /*!< No filter, sampling is done at fDTS */
888 #define LL_TIM_ETR_FILTER_FDIV1_N2 TIM_SMCR_ETF_0 /*!< fSAMPLING=fCK_INT, N=2 */
889 #define LL_TIM_ETR_FILTER_FDIV1_N4 TIM_SMCR_ETF_1 /*!< fSAMPLING=fCK_INT, N=4 */
890 #define LL_TIM_ETR_FILTER_FDIV1_N8 (TIM_SMCR_ETF_1 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fCK_INT, N=8 */
891 #define LL_TIM_ETR_FILTER_FDIV2_N6 TIM_SMCR_ETF_2 /*!< fSAMPLING=fDTS/2, N=6 */
892 #define LL_TIM_ETR_FILTER_FDIV2_N8 (TIM_SMCR_ETF_2 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/2, N=8 */
893 #define LL_TIM_ETR_FILTER_FDIV4_N6 (TIM_SMCR_ETF_2 | TIM_SMCR_ETF_1) /*!< fSAMPLING=fDTS/4, N=6 */
894 #define LL_TIM_ETR_FILTER_FDIV4_N8 (TIM_SMCR_ETF_2 | TIM_SMCR_ETF_1 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/4, N=8 */
895 #define LL_TIM_ETR_FILTER_FDIV8_N6 TIM_SMCR_ETF_3 /*!< fSAMPLING=fDTS/8, N=8 */
896 #define LL_TIM_ETR_FILTER_FDIV8_N8 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/16, N=5 */
897 #define LL_TIM_ETR_FILTER_FDIV16_N5 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_1) /*!< fSAMPLING=fDTS/16, N=6 */
898 #define LL_TIM_ETR_FILTER_FDIV16_N6 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_1 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/16, N=8 */
899 #define LL_TIM_ETR_FILTER_FDIV16_N8 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_2) /*!< fSAMPLING=fDTS/16, N=5 */
900 #define LL_TIM_ETR_FILTER_FDIV32_N5 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_2 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/32, N=5 */
901 #define LL_TIM_ETR_FILTER_FDIV32_N6 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_2 | TIM_SMCR_ETF_1) /*!< fSAMPLING=fDTS/32, N=6 */
902 #define LL_TIM_ETR_FILTER_FDIV32_N8 TIM_SMCR_ETF /*!< fSAMPLING=fDTS/32, N=8 */
904 * @}
908 /** @defgroup TIM_LL_EC_BREAK_POLARITY break polarity
909 * @{
911 #define LL_TIM_BREAK_POLARITY_LOW 0x00000000U /*!< Break input BRK is active low */
912 #define LL_TIM_BREAK_POLARITY_HIGH TIM_BDTR_BKP /*!< Break input BRK is active high */
914 * @}
917 /** @defgroup TIM_LL_EC_BREAK_FILTER break filter
918 * @{
920 #define LL_TIM_BREAK_FILTER_FDIV1 0x00000000U /*!< No filter, BRK acts asynchronously */
921 #define LL_TIM_BREAK_FILTER_FDIV1_N2 0x00010000U /*!< fSAMPLING=fCK_INT, N=2 */
922 #define LL_TIM_BREAK_FILTER_FDIV1_N4 0x00020000U /*!< fSAMPLING=fCK_INT, N=4 */
923 #define LL_TIM_BREAK_FILTER_FDIV1_N8 0x00030000U /*!< fSAMPLING=fCK_INT, N=8 */
924 #define LL_TIM_BREAK_FILTER_FDIV2_N6 0x00040000U /*!< fSAMPLING=fDTS/2, N=6 */
925 #define LL_TIM_BREAK_FILTER_FDIV2_N8 0x00050000U /*!< fSAMPLING=fDTS/2, N=8 */
926 #define LL_TIM_BREAK_FILTER_FDIV4_N6 0x00060000U /*!< fSAMPLING=fDTS/4, N=6 */
927 #define LL_TIM_BREAK_FILTER_FDIV4_N8 0x00070000U /*!< fSAMPLING=fDTS/4, N=8 */
928 #define LL_TIM_BREAK_FILTER_FDIV8_N6 0x00080000U /*!< fSAMPLING=fDTS/8, N=6 */
929 #define LL_TIM_BREAK_FILTER_FDIV8_N8 0x00090000U /*!< fSAMPLING=fDTS/8, N=8 */
930 #define LL_TIM_BREAK_FILTER_FDIV16_N5 0x000A0000U /*!< fSAMPLING=fDTS/16, N=5 */
931 #define LL_TIM_BREAK_FILTER_FDIV16_N6 0x000B0000U /*!< fSAMPLING=fDTS/16, N=6 */
932 #define LL_TIM_BREAK_FILTER_FDIV16_N8 0x000C0000U /*!< fSAMPLING=fDTS/16, N=8 */
933 #define LL_TIM_BREAK_FILTER_FDIV32_N5 0x000D0000U /*!< fSAMPLING=fDTS/32, N=5 */
934 #define LL_TIM_BREAK_FILTER_FDIV32_N6 0x000E0000U /*!< fSAMPLING=fDTS/32, N=6 */
935 #define LL_TIM_BREAK_FILTER_FDIV32_N8 0x000F0000U /*!< fSAMPLING=fDTS/32, N=8 */
937 * @}
940 /** @defgroup TIM_LL_EC_BREAK2_POLARITY BREAK2 POLARITY
941 * @{
943 #define LL_TIM_BREAK2_POLARITY_LOW 0x00000000U /*!< Break input BRK2 is active low */
944 #define LL_TIM_BREAK2_POLARITY_HIGH TIM_BDTR_BK2P /*!< Break input BRK2 is active high */
946 * @}
949 /** @defgroup TIM_LL_EC_BREAK2_FILTER BREAK2 FILTER
950 * @{
952 #define LL_TIM_BREAK2_FILTER_FDIV1 0x00000000U /*!< No filter, BRK acts asynchronously */
953 #define LL_TIM_BREAK2_FILTER_FDIV1_N2 0x00100000U /*!< fSAMPLING=fCK_INT, N=2 */
954 #define LL_TIM_BREAK2_FILTER_FDIV1_N4 0x00200000U /*!< fSAMPLING=fCK_INT, N=4 */
955 #define LL_TIM_BREAK2_FILTER_FDIV1_N8 0x00300000U /*!< fSAMPLING=fCK_INT, N=8 */
956 #define LL_TIM_BREAK2_FILTER_FDIV2_N6 0x00400000U /*!< fSAMPLING=fDTS/2, N=6 */
957 #define LL_TIM_BREAK2_FILTER_FDIV2_N8 0x00500000U /*!< fSAMPLING=fDTS/2, N=8 */
958 #define LL_TIM_BREAK2_FILTER_FDIV4_N6 0x00600000U /*!< fSAMPLING=fDTS/4, N=6 */
959 #define LL_TIM_BREAK2_FILTER_FDIV4_N8 0x00700000U /*!< fSAMPLING=fDTS/4, N=8 */
960 #define LL_TIM_BREAK2_FILTER_FDIV8_N6 0x00800000U /*!< fSAMPLING=fDTS/8, N=6 */
961 #define LL_TIM_BREAK2_FILTER_FDIV8_N8 0x00900000U /*!< fSAMPLING=fDTS/8, N=8 */
962 #define LL_TIM_BREAK2_FILTER_FDIV16_N5 0x00A00000U /*!< fSAMPLING=fDTS/16, N=5 */
963 #define LL_TIM_BREAK2_FILTER_FDIV16_N6 0x00B00000U /*!< fSAMPLING=fDTS/16, N=6 */
964 #define LL_TIM_BREAK2_FILTER_FDIV16_N8 0x00C00000U /*!< fSAMPLING=fDTS/16, N=8 */
965 #define LL_TIM_BREAK2_FILTER_FDIV32_N5 0x00D00000U /*!< fSAMPLING=fDTS/32, N=5 */
966 #define LL_TIM_BREAK2_FILTER_FDIV32_N6 0x00E00000U /*!< fSAMPLING=fDTS/32, N=6 */
967 #define LL_TIM_BREAK2_FILTER_FDIV32_N8 0x00F00000U /*!< fSAMPLING=fDTS/32, N=8 */
969 * @}
972 /** @defgroup TIM_LL_EC_OSSI OSSI
973 * @{
975 #define LL_TIM_OSSI_DISABLE 0x00000000U /*!< When inactive, OCx/OCxN outputs are disabled */
976 #define LL_TIM_OSSI_ENABLE TIM_BDTR_OSSI /*!< When inactive, OxC/OCxN outputs are first forced with their inactive level then forced to their idle level after the deadtime */
978 * @}
981 /** @defgroup TIM_LL_EC_OSSR OSSR
982 * @{
984 #define LL_TIM_OSSR_DISABLE 0x00000000U /*!< When inactive, OCx/OCxN outputs are disabled */
985 #define LL_TIM_OSSR_ENABLE TIM_BDTR_OSSR /*!< When inactive, OC/OCN outputs are enabled with their inactive level as soon as CCxE=1 or CCxNE=1 */
987 * @}
990 #if defined(TIM_BREAK_INPUT_SUPPORT)
991 /** @defgroup TIM_LL_EC_BREAK_INPUT BREAK INPUT
992 * @{
994 #define LL_TIM_BREAK_INPUT_BKIN 0x00000000U /*!< TIMx_BKIN input */
995 #define LL_TIM_BREAK_INPUT_BKIN2 0x00000004U /*!< TIMx_BKIN2 input */
997 * @}
1000 /** @defgroup TIM_LL_EC_BKIN_SOURCE BKIN SOURCE
1001 * @{
1003 #define LL_TIM_BKIN_SOURCE_BKIN TIM1_AF1_BKINE /*!< BKIN input from AF controller */
1004 #define LL_TIM_BKIN_SOURCE_DF1BK TIM1_AF1_BKDF1BKE /*!< internal signal: DFSDM1 break output */
1006 * @}
1009 /** @defgroup TIM_LL_EC_BKIN_POLARITY BKIN POLARITY
1010 * @{
1012 #define LL_TIM_BKIN_POLARITY_LOW TIM1_AF1_BKINP /*!< BRK BKIN input is active low */
1013 #define LL_TIM_BKIN_POLARITY_HIGH 0x00000000U /*!< BRK BKIN input is active high */
1015 * @}
1017 #endif /* TIM_BREAK_INPUT_SUPPORT */
1019 /** @defgroup TIM_LL_EC_DMABURST_BASEADDR DMA Burst Base Address
1020 * @{
1022 #define LL_TIM_DMABURST_BASEADDR_CR1 0x00000000U /*!< TIMx_CR1 register is the DMA base address for DMA burst */
1023 #define LL_TIM_DMABURST_BASEADDR_CR2 TIM_DCR_DBA_0 /*!< TIMx_CR2 register is the DMA base address for DMA burst */
1024 #define LL_TIM_DMABURST_BASEADDR_SMCR TIM_DCR_DBA_1 /*!< TIMx_SMCR register is the DMA base address for DMA burst */
1025 #define LL_TIM_DMABURST_BASEADDR_DIER (TIM_DCR_DBA_1 | TIM_DCR_DBA_0) /*!< TIMx_DIER register is the DMA base address for DMA burst */
1026 #define LL_TIM_DMABURST_BASEADDR_SR TIM_DCR_DBA_2 /*!< TIMx_SR register is the DMA base address for DMA burst */
1027 #define LL_TIM_DMABURST_BASEADDR_EGR (TIM_DCR_DBA_2 | TIM_DCR_DBA_0) /*!< TIMx_EGR register is the DMA base address for DMA burst */
1028 #define LL_TIM_DMABURST_BASEADDR_CCMR1 (TIM_DCR_DBA_2 | TIM_DCR_DBA_1) /*!< TIMx_CCMR1 register is the DMA base address for DMA burst */
1029 #define LL_TIM_DMABURST_BASEADDR_CCMR2 (TIM_DCR_DBA_2 | TIM_DCR_DBA_1 | TIM_DCR_DBA_0) /*!< TIMx_CCMR2 register is the DMA base address for DMA burst */
1030 #define LL_TIM_DMABURST_BASEADDR_CCER TIM_DCR_DBA_3 /*!< TIMx_CCER register is the DMA base address for DMA burst */
1031 #define LL_TIM_DMABURST_BASEADDR_CNT (TIM_DCR_DBA_3 | TIM_DCR_DBA_0) /*!< TIMx_CNT register is the DMA base address for DMA burst */
1032 #define LL_TIM_DMABURST_BASEADDR_PSC (TIM_DCR_DBA_3 | TIM_DCR_DBA_1) /*!< TIMx_PSC register is the DMA base address for DMA burst */
1033 #define LL_TIM_DMABURST_BASEADDR_ARR (TIM_DCR_DBA_3 | TIM_DCR_DBA_1 | TIM_DCR_DBA_0) /*!< TIMx_ARR register is the DMA base address for DMA burst */
1034 #define LL_TIM_DMABURST_BASEADDR_RCR (TIM_DCR_DBA_3 | TIM_DCR_DBA_2) /*!< TIMx_RCR register is the DMA base address for DMA burst */
1035 #define LL_TIM_DMABURST_BASEADDR_CCR1 (TIM_DCR_DBA_3 | TIM_DCR_DBA_2 | TIM_DCR_DBA_0) /*!< TIMx_CCR1 register is the DMA base address for DMA burst */
1036 #define LL_TIM_DMABURST_BASEADDR_CCR2 (TIM_DCR_DBA_3 | TIM_DCR_DBA_2 | TIM_DCR_DBA_1) /*!< TIMx_CCR2 register is the DMA base address for DMA burst */
1037 #define LL_TIM_DMABURST_BASEADDR_CCR3 (TIM_DCR_DBA_3 | TIM_DCR_DBA_2 | TIM_DCR_DBA_1 | TIM_DCR_DBA_0) /*!< TIMx_CCR3 register is the DMA base address for DMA burst */
1038 #define LL_TIM_DMABURST_BASEADDR_CCR4 TIM_DCR_DBA_4 /*!< TIMx_CCR4 register is the DMA base address for DMA burst */
1039 #define LL_TIM_DMABURST_BASEADDR_BDTR (TIM_DCR_DBA_4 | TIM_DCR_DBA_0) /*!< TIMx_BDTR register is the DMA base address for DMA burst */
1040 #define LL_TIM_DMABURST_BASEADDR_OR (TIM_DCR_DBA_4 | TIM_DCR_DBA_2) /*!< TIMx_OR register is the DMA base address for DMA burst */
1041 #define LL_TIM_DMABURST_BASEADDR_CCMR3 (TIM_DCR_DBA_4 | TIM_DCR_DBA_2 | TIM_DCR_DBA_0) /*!< TIMx_CCMR3 register is the DMA base address for DMA burst */
1042 #define LL_TIM_DMABURST_BASEADDR_CCR5 (TIM_DCR_DBA_4 | TIM_DCR_DBA_2 | TIM_DCR_DBA_1) /*!< TIMx_CCR5 register is the DMA base address for DMA burst */
1043 #define LL_TIM_DMABURST_BASEADDR_CCR6 (TIM_DCR_DBA_4 | TIM_DCR_DBA_2 | TIM_DCR_DBA_1 | TIM_DCR_DBA_0) /*!< TIMx_CCR6 register is the DMA base address for DMA burst */
1044 #if defined(TIM_AF1_BKINE)&&defined(TIM_AF2_BKINE)
1045 #define LL_TIM_DMABURST_BASEADDR_AF1 (TIM_DCR_DBA_4 | TIM_DCR_DBA_3) /*!< TIMx_AF1 register is the DMA base address for DMA burst */
1046 #define LL_TIM_DMABURST_BASEADDR_AF2 (TIM_DCR_DBA_4 | TIM_DCR_DBA_3 | TIM_DCR_DBA_0) /*!< TIMx_AF2 register is the DMA base address for DMA burst */
1047 #endif /* TIM_AF1_BKINE && TIM_AF2_BKINE */
1049 * @}
1052 /** @defgroup TIM_LL_EC_DMABURST_LENGTH DMA Burst Length
1053 * @{
1055 #define LL_TIM_DMABURST_LENGTH_1TRANSFER 0x00000000U /*!< Transfer is done to 1 register starting from the DMA burst base address */
1056 #define LL_TIM_DMABURST_LENGTH_2TRANSFERS TIM_DCR_DBL_0 /*!< Transfer is done to 2 registers starting from the DMA burst base address */
1057 #define LL_TIM_DMABURST_LENGTH_3TRANSFERS TIM_DCR_DBL_1 /*!< Transfer is done to 3 registers starting from the DMA burst base address */
1058 #define LL_TIM_DMABURST_LENGTH_4TRANSFERS (TIM_DCR_DBL_1 | TIM_DCR_DBL_0) /*!< Transfer is done to 4 registers starting from the DMA burst base address */
1059 #define LL_TIM_DMABURST_LENGTH_5TRANSFERS TIM_DCR_DBL_2 /*!< Transfer is done to 5 registers starting from the DMA burst base address */
1060 #define LL_TIM_DMABURST_LENGTH_6TRANSFERS (TIM_DCR_DBL_2 | TIM_DCR_DBL_0) /*!< Transfer is done to 6 registers starting from the DMA burst base address */
1061 #define LL_TIM_DMABURST_LENGTH_7TRANSFERS (TIM_DCR_DBL_2 | TIM_DCR_DBL_1) /*!< Transfer is done to 7 registers starting from the DMA burst base address */
1062 #define LL_TIM_DMABURST_LENGTH_8TRANSFERS (TIM_DCR_DBL_2 | TIM_DCR_DBL_1 | TIM_DCR_DBL_0) /*!< Transfer is done to 1 registers starting from the DMA burst base address */
1063 #define LL_TIM_DMABURST_LENGTH_9TRANSFERS TIM_DCR_DBL_3 /*!< Transfer is done to 9 registers starting from the DMA burst base address */
1064 #define LL_TIM_DMABURST_LENGTH_10TRANSFERS (TIM_DCR_DBL_3 | TIM_DCR_DBL_0) /*!< Transfer is done to 10 registers starting from the DMA burst base address */
1065 #define LL_TIM_DMABURST_LENGTH_11TRANSFERS (TIM_DCR_DBL_3 | TIM_DCR_DBL_1) /*!< Transfer is done to 11 registers starting from the DMA burst base address */
1066 #define LL_TIM_DMABURST_LENGTH_12TRANSFERS (TIM_DCR_DBL_3 | TIM_DCR_DBL_1 | TIM_DCR_DBL_0) /*!< Transfer is done to 12 registers starting from the DMA burst base address */
1067 #define LL_TIM_DMABURST_LENGTH_13TRANSFERS (TIM_DCR_DBL_3 | TIM_DCR_DBL_2) /*!< Transfer is done to 13 registers starting from the DMA burst base address */
1068 #define LL_TIM_DMABURST_LENGTH_14TRANSFERS (TIM_DCR_DBL_3 | TIM_DCR_DBL_2 | TIM_DCR_DBL_0) /*!< Transfer is done to 14 registers starting from the DMA burst base address */
1069 #define LL_TIM_DMABURST_LENGTH_15TRANSFERS (TIM_DCR_DBL_3 | TIM_DCR_DBL_2 | TIM_DCR_DBL_1) /*!< Transfer is done to 15 registers starting from the DMA burst base address */
1070 #define LL_TIM_DMABURST_LENGTH_16TRANSFERS (TIM_DCR_DBL_3 | TIM_DCR_DBL_2 | TIM_DCR_DBL_1 | TIM_DCR_DBL_0) /*!< Transfer is done to 16 registers starting from the DMA burst base address */
1071 #define LL_TIM_DMABURST_LENGTH_17TRANSFERS TIM_DCR_DBL_4 /*!< Transfer is done to 17 registers starting from the DMA burst base address */
1072 #define LL_TIM_DMABURST_LENGTH_18TRANSFERS (TIM_DCR_DBL_4 | TIM_DCR_DBL_0) /*!< Transfer is done to 18 registers starting from the DMA burst base address */
1074 * @}
1078 /** @defgroup TIM_LL_EC_TIM2_ITR1_RMP_TIM8 TIM2 Internal Trigger1 Remap TIM8
1079 * @{
1081 #define LL_TIM_TIM2_ITR1_RMP_TIM8_TRGO TIM2_OR_RMP_MASK /*!< TIM2_ITR1 is connected to TIM8_TRGO */
1082 #define LL_TIM_TIM2_ITR1_RMP_ETH_PTP (TIM2_OR_ITR1_RMP_0 | TIM2_OR_RMP_MASK) /*!< TIM2_ITR1 is connected to ETH_PTP */
1083 #define LL_TIM_TIM2_ITR1_RMP_OTG_FS_SOF (TIM2_OR_ITR1_RMP_1 | TIM2_OR_RMP_MASK) /*!< TIM2_ITR1 is connected to OTG_FS SOF */
1084 #define LL_TIM_TIM2_ITR1_RMP_OTG_HS_SOF (TIM2_OR_ITR1_RMP | TIM2_OR_RMP_MASK) /*!< TIM2_ITR1 is connected to OTG_HS SOF */
1086 * @}
1089 /** @defgroup TIM_LL_EC_TIM5_TI4_RMP TIM5 External Input Ch4 Remap
1090 * @{
1092 #define LL_TIM_TIM5_TI4_RMP_GPIO TIM5_OR_RMP_MASK /*!< TIM5 channel 4 is connected to GPIO */
1093 #define LL_TIM_TIM5_TI4_RMP_LSI (TIM5_OR_TI4_RMP_0 | TIM5_OR_RMP_MASK) /*!< TIM5 channel 4 is connected to LSI internal clock */
1094 #define LL_TIM_TIM5_TI4_RMP_LSE (TIM5_OR_TI4_RMP_1 | TIM5_OR_RMP_MASK) /*!< TIM5 channel 4 is connected to LSE */
1095 #define LL_TIM_TIM5_TI4_RMP_RTC (TIM5_OR_TI4_RMP | TIM5_OR_RMP_MASK) /*!< TIM5 channel 4 is connected to RTC wakeup interrupt */
1097 * @}
1100 /** @defgroup TIM_LL_EC_TIM11_TI1_RMP TIM11 External Input Capture 1 Remap
1101 * @{
1103 #define LL_TIM_TIM11_TI1_RMP_GPIO TIM11_OR_RMP_MASK /*!< TIM11 channel 1 is connected to GPIO */
1104 #define LL_TIM_TIM11_TI1_RMP_SPDIFRX (TIM11_OR_TI1_RMP_0 | TIM11_OR_RMP_MASK) /*!< TIM11 channel 1 is connected to SPDIFRX */
1105 #define LL_TIM_TIM11_TI1_RMP_HSE (TIM11_OR_TI1_RMP_1 | TIM11_OR_RMP_MASK) /*!< TIM11 channel 1 is connected to HSE */
1106 #define LL_TIM_TIM11_TI1_RMP_MCO1 (TIM11_OR_TI1_RMP | TIM11_OR_RMP_MASK) /*!< TIM11 channel 1 is connected to MCO1 */
1108 * @}
1112 * @}
1116 * @}
1119 /* Exported macro ------------------------------------------------------------*/
1120 /** @defgroup TIM_LL_Exported_Macros TIM Exported Macros
1121 * @{
1124 /** @defgroup TIM_LL_EM_WRITE_READ Common Write and read registers Macros
1125 * @{
1128 * @brief Write a value in TIM register.
1129 * @param __INSTANCE__ TIM Instance
1130 * @param __REG__ Register to be written
1131 * @param __VALUE__ Value to be written in the register
1132 * @retval None
1134 #define LL_TIM_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG((__INSTANCE__)->__REG__, (__VALUE__))
1137 * @brief Read a value in TIM register.
1138 * @param __INSTANCE__ TIM Instance
1139 * @param __REG__ Register to be read
1140 * @retval Register value
1142 #define LL_TIM_ReadReg(__INSTANCE__, __REG__) READ_REG((__INSTANCE__)->__REG__)
1144 * @}
1147 /** @defgroup TIM_LL_EM_Exported_Macros Exported_Macros
1148 * @{
1152 * @brief HELPER macro retrieving the UIFCPY flag from the counter value.
1153 * @note ex: @ref __LL_TIM_GETFLAG_UIFCPY (@ref LL_TIM_GetCounter ());
1154 * @note Relevant only if UIF flag remapping has been enabled (UIF status bit is copied
1155 * to TIMx_CNT register bit 31)
1156 * @param __CNT__ Counter value
1157 * @retval UIF status bit
1159 #define __LL_TIM_GETFLAG_UIFCPY(__CNT__) \
1160 (READ_BIT((__CNT__), TIM_CNT_UIFCPY) >> TIM_CNT_UIFCPY_Pos)
1163 * @brief HELPER macro calculating DTG[0:7] in the TIMx_BDTR register to achieve the requested dead time duration.
1164 * @note ex: @ref __LL_TIM_CALC_DEADTIME (80000000, @ref LL_TIM_GetClockDivision (), 120);
1165 * @param __TIMCLK__ timer input clock frequency (in Hz)
1166 * @param __CKD__ This parameter can be one of the following values:
1167 * @arg @ref LL_TIM_CLOCKDIVISION_DIV1
1168 * @arg @ref LL_TIM_CLOCKDIVISION_DIV2
1169 * @arg @ref LL_TIM_CLOCKDIVISION_DIV4
1170 * @param __DT__ deadtime duration (in ns)
1171 * @retval DTG[0:7]
1173 #define __LL_TIM_CALC_DEADTIME(__TIMCLK__, __CKD__, __DT__) \
1174 ( (((uint64_t)((__DT__)*1000U)) < ((DT_DELAY_1+1U) * TIM_CALC_DTS((__TIMCLK__), (__CKD__)))) ? (uint8_t)(((uint64_t)((__DT__)*1000U) / TIM_CALC_DTS((__TIMCLK__), (__CKD__))) & DT_DELAY_1) : \
1175 (((uint64_t)((__DT__)*1000U)) < ((64U + (DT_DELAY_2+1U)) * 2U * TIM_CALC_DTS((__TIMCLK__), (__CKD__)))) ? (uint8_t)(DT_RANGE_2 | ((uint8_t)((uint8_t)((((uint64_t)((__DT__)*1000U))/ TIM_CALC_DTS((__TIMCLK__), (__CKD__))) >> 1U) - (uint8_t) 64) & DT_DELAY_2)) :\
1176 (((uint64_t)((__DT__)*1000U)) < ((32U + (DT_DELAY_3+1U)) * 8U * TIM_CALC_DTS((__TIMCLK__), (__CKD__)))) ? (uint8_t)(DT_RANGE_3 | ((uint8_t)((uint8_t)(((((uint64_t)(__DT__)*1000U))/ TIM_CALC_DTS((__TIMCLK__), (__CKD__))) >> 3U) - (uint8_t) 32) & DT_DELAY_3)) :\
1177 (((uint64_t)((__DT__)*1000U)) < ((32U + (DT_DELAY_4+1U)) * 16U * TIM_CALC_DTS((__TIMCLK__), (__CKD__)))) ? (uint8_t)(DT_RANGE_4 | ((uint8_t)((uint8_t)(((((uint64_t)(__DT__)*1000U))/ TIM_CALC_DTS((__TIMCLK__), (__CKD__))) >> 4U) - (uint8_t) 32) & DT_DELAY_4)) :\
1181 * @brief HELPER macro calculating the prescaler value to achieve the required counter clock frequency.
1182 * @note ex: @ref __LL_TIM_CALC_PSC (80000000, 1000000);
1183 * @param __TIMCLK__ timer input clock frequency (in Hz)
1184 * @param __CNTCLK__ counter clock frequency (in Hz)
1185 * @retval Prescaler value (between Min_Data=0 and Max_Data=65535)
1187 #define __LL_TIM_CALC_PSC(__TIMCLK__, __CNTCLK__) \
1188 (((__TIMCLK__) >= (__CNTCLK__)) ? (uint32_t)(((__TIMCLK__)/(__CNTCLK__)) - 1U) : 0U)
1191 * @brief HELPER macro calculating the auto-reload value to achieve the required output signal frequency.
1192 * @note ex: @ref __LL_TIM_CALC_ARR (1000000, @ref LL_TIM_GetPrescaler (), 10000);
1193 * @param __TIMCLK__ timer input clock frequency (in Hz)
1194 * @param __PSC__ prescaler
1195 * @param __FREQ__ output signal frequency (in Hz)
1196 * @retval Auto-reload value (between Min_Data=0 and Max_Data=65535)
1198 #define __LL_TIM_CALC_ARR(__TIMCLK__, __PSC__, __FREQ__) \
1199 ((((__TIMCLK__)/((__PSC__) + 1U)) >= (__FREQ__)) ? (((__TIMCLK__)/((__FREQ__) * ((__PSC__) + 1U))) - 1U) : 0U)
1202 * @brief HELPER macro calculating the compare value required to achieve the required timer output compare active/inactive delay.
1203 * @note ex: @ref __LL_TIM_CALC_DELAY (1000000, @ref LL_TIM_GetPrescaler (), 10);
1204 * @param __TIMCLK__ timer input clock frequency (in Hz)
1205 * @param __PSC__ prescaler
1206 * @param __DELAY__ timer output compare active/inactive delay (in us)
1207 * @retval Compare value (between Min_Data=0 and Max_Data=65535)
1209 #define __LL_TIM_CALC_DELAY(__TIMCLK__, __PSC__, __DELAY__) \
1210 ((uint32_t)(((uint64_t)(__TIMCLK__) * (uint64_t)(__DELAY__)) \
1211 / ((uint64_t)1000000U * (uint64_t)((__PSC__) + 1U))))
1214 * @brief HELPER macro calculating the auto-reload value to achieve the required pulse duration (when the timer operates in one pulse mode).
1215 * @note ex: @ref __LL_TIM_CALC_PULSE (1000000, @ref LL_TIM_GetPrescaler (), 10, 20);
1216 * @param __TIMCLK__ timer input clock frequency (in Hz)
1217 * @param __PSC__ prescaler
1218 * @param __DELAY__ timer output compare active/inactive delay (in us)
1219 * @param __PULSE__ pulse duration (in us)
1220 * @retval Auto-reload value (between Min_Data=0 and Max_Data=65535)
1222 #define __LL_TIM_CALC_PULSE(__TIMCLK__, __PSC__, __DELAY__, __PULSE__) \
1223 ((uint32_t)(__LL_TIM_CALC_DELAY((__TIMCLK__), (__PSC__), (__PULSE__)) \
1224 + __LL_TIM_CALC_DELAY((__TIMCLK__), (__PSC__), (__DELAY__))))
1227 * @brief HELPER macro retrieving the ratio of the input capture prescaler
1228 * @note ex: @ref __LL_TIM_GET_ICPSC_RATIO (@ref LL_TIM_IC_GetPrescaler ());
1229 * @param __ICPSC__ This parameter can be one of the following values:
1230 * @arg @ref LL_TIM_ICPSC_DIV1
1231 * @arg @ref LL_TIM_ICPSC_DIV2
1232 * @arg @ref LL_TIM_ICPSC_DIV4
1233 * @arg @ref LL_TIM_ICPSC_DIV8
1234 * @retval Input capture prescaler ratio (1, 2, 4 or 8)
1236 #define __LL_TIM_GET_ICPSC_RATIO(__ICPSC__) \
1237 ((uint32_t)(0x01U << (((__ICPSC__) >> 16U) >> TIM_CCMR1_IC1PSC_Pos)))
1241 * @}
1246 * @}
1249 /* Exported functions --------------------------------------------------------*/
1250 /** @defgroup TIM_LL_Exported_Functions TIM Exported Functions
1251 * @{
1254 /** @defgroup TIM_LL_EF_Time_Base Time Base configuration
1255 * @{
1258 * @brief Enable timer counter.
1259 * @rmtoll CR1 CEN LL_TIM_EnableCounter
1260 * @param TIMx Timer instance
1261 * @retval None
1263 __STATIC_INLINE void LL_TIM_EnableCounter(TIM_TypeDef *TIMx)
1265 SET_BIT(TIMx->CR1, TIM_CR1_CEN);
1269 * @brief Disable timer counter.
1270 * @rmtoll CR1 CEN LL_TIM_DisableCounter
1271 * @param TIMx Timer instance
1272 * @retval None
1274 __STATIC_INLINE void LL_TIM_DisableCounter(TIM_TypeDef *TIMx)
1276 CLEAR_BIT(TIMx->CR1, TIM_CR1_CEN);
1280 * @brief Indicates whether the timer counter is enabled.
1281 * @rmtoll CR1 CEN LL_TIM_IsEnabledCounter
1282 * @param TIMx Timer instance
1283 * @retval State of bit (1 or 0).
1285 __STATIC_INLINE uint32_t LL_TIM_IsEnabledCounter(TIM_TypeDef *TIMx)
1287 return ((READ_BIT(TIMx->CR1, TIM_CR1_CEN) == (TIM_CR1_CEN)) ? 1UL : 0UL);
1291 * @brief Enable update event generation.
1292 * @rmtoll CR1 UDIS LL_TIM_EnableUpdateEvent
1293 * @param TIMx Timer instance
1294 * @retval None
1296 __STATIC_INLINE void LL_TIM_EnableUpdateEvent(TIM_TypeDef *TIMx)
1298 CLEAR_BIT(TIMx->CR1, TIM_CR1_UDIS);
1302 * @brief Disable update event generation.
1303 * @rmtoll CR1 UDIS LL_TIM_DisableUpdateEvent
1304 * @param TIMx Timer instance
1305 * @retval None
1307 __STATIC_INLINE void LL_TIM_DisableUpdateEvent(TIM_TypeDef *TIMx)
1309 SET_BIT(TIMx->CR1, TIM_CR1_UDIS);
1313 * @brief Indicates whether update event generation is enabled.
1314 * @rmtoll CR1 UDIS LL_TIM_IsEnabledUpdateEvent
1315 * @param TIMx Timer instance
1316 * @retval Inverted state of bit (0 or 1).
1318 __STATIC_INLINE uint32_t LL_TIM_IsEnabledUpdateEvent(TIM_TypeDef *TIMx)
1320 return ((READ_BIT(TIMx->CR1, TIM_CR1_UDIS) == (uint32_t)RESET) ? 1UL : 0UL);
1324 * @brief Set update event source
1325 * @note Update event source set to LL_TIM_UPDATESOURCE_REGULAR: any of the following events
1326 * generate an update interrupt or DMA request if enabled:
1327 * - Counter overflow/underflow
1328 * - Setting the UG bit
1329 * - Update generation through the slave mode controller
1330 * @note Update event source set to LL_TIM_UPDATESOURCE_COUNTER: only counter
1331 * overflow/underflow generates an update interrupt or DMA request if enabled.
1332 * @rmtoll CR1 URS LL_TIM_SetUpdateSource
1333 * @param TIMx Timer instance
1334 * @param UpdateSource This parameter can be one of the following values:
1335 * @arg @ref LL_TIM_UPDATESOURCE_REGULAR
1336 * @arg @ref LL_TIM_UPDATESOURCE_COUNTER
1337 * @retval None
1339 __STATIC_INLINE void LL_TIM_SetUpdateSource(TIM_TypeDef *TIMx, uint32_t UpdateSource)
1341 MODIFY_REG(TIMx->CR1, TIM_CR1_URS, UpdateSource);
1345 * @brief Get actual event update source
1346 * @rmtoll CR1 URS LL_TIM_GetUpdateSource
1347 * @param TIMx Timer instance
1348 * @retval Returned value can be one of the following values:
1349 * @arg @ref LL_TIM_UPDATESOURCE_REGULAR
1350 * @arg @ref LL_TIM_UPDATESOURCE_COUNTER
1352 __STATIC_INLINE uint32_t LL_TIM_GetUpdateSource(TIM_TypeDef *TIMx)
1354 return (uint32_t)(READ_BIT(TIMx->CR1, TIM_CR1_URS));
1358 * @brief Set one pulse mode (one shot v.s. repetitive).
1359 * @rmtoll CR1 OPM LL_TIM_SetOnePulseMode
1360 * @param TIMx Timer instance
1361 * @param OnePulseMode This parameter can be one of the following values:
1362 * @arg @ref LL_TIM_ONEPULSEMODE_SINGLE
1363 * @arg @ref LL_TIM_ONEPULSEMODE_REPETITIVE
1364 * @retval None
1366 __STATIC_INLINE void LL_TIM_SetOnePulseMode(TIM_TypeDef *TIMx, uint32_t OnePulseMode)
1368 MODIFY_REG(TIMx->CR1, TIM_CR1_OPM, OnePulseMode);
1372 * @brief Get actual one pulse mode.
1373 * @rmtoll CR1 OPM LL_TIM_GetOnePulseMode
1374 * @param TIMx Timer instance
1375 * @retval Returned value can be one of the following values:
1376 * @arg @ref LL_TIM_ONEPULSEMODE_SINGLE
1377 * @arg @ref LL_TIM_ONEPULSEMODE_REPETITIVE
1379 __STATIC_INLINE uint32_t LL_TIM_GetOnePulseMode(TIM_TypeDef *TIMx)
1381 return (uint32_t)(READ_BIT(TIMx->CR1, TIM_CR1_OPM));
1385 * @brief Set the timer counter counting mode.
1386 * @note Macro @ref IS_TIM_COUNTER_MODE_SELECT_INSTANCE(TIMx) can be used to
1387 * check whether or not the counter mode selection feature is supported
1388 * by a timer instance.
1389 * @note Switching from Center Aligned counter mode to Edge counter mode (or reverse)
1390 * requires a timer reset to avoid unexpected direction
1391 * due to DIR bit readonly in center aligned mode.
1392 * @rmtoll CR1 DIR LL_TIM_SetCounterMode\n
1393 * CR1 CMS LL_TIM_SetCounterMode
1394 * @param TIMx Timer instance
1395 * @param CounterMode This parameter can be one of the following values:
1396 * @arg @ref LL_TIM_COUNTERMODE_UP
1397 * @arg @ref LL_TIM_COUNTERMODE_DOWN
1398 * @arg @ref LL_TIM_COUNTERMODE_CENTER_UP
1399 * @arg @ref LL_TIM_COUNTERMODE_CENTER_DOWN
1400 * @arg @ref LL_TIM_COUNTERMODE_CENTER_UP_DOWN
1401 * @retval None
1403 __STATIC_INLINE void LL_TIM_SetCounterMode(TIM_TypeDef *TIMx, uint32_t CounterMode)
1405 MODIFY_REG(TIMx->CR1, (TIM_CR1_DIR | TIM_CR1_CMS), CounterMode);
1409 * @brief Get actual counter mode.
1410 * @note Macro @ref IS_TIM_COUNTER_MODE_SELECT_INSTANCE(TIMx) can be used to
1411 * check whether or not the counter mode selection feature is supported
1412 * by a timer instance.
1413 * @rmtoll CR1 DIR LL_TIM_GetCounterMode\n
1414 * CR1 CMS LL_TIM_GetCounterMode
1415 * @param TIMx Timer instance
1416 * @retval Returned value can be one of the following values:
1417 * @arg @ref LL_TIM_COUNTERMODE_UP
1418 * @arg @ref LL_TIM_COUNTERMODE_DOWN
1419 * @arg @ref LL_TIM_COUNTERMODE_CENTER_UP
1420 * @arg @ref LL_TIM_COUNTERMODE_CENTER_DOWN
1421 * @arg @ref LL_TIM_COUNTERMODE_CENTER_UP_DOWN
1423 __STATIC_INLINE uint32_t LL_TIM_GetCounterMode(TIM_TypeDef *TIMx)
1425 return (uint32_t)(READ_BIT(TIMx->CR1, TIM_CR1_DIR | TIM_CR1_CMS));
1429 * @brief Enable auto-reload (ARR) preload.
1430 * @rmtoll CR1 ARPE LL_TIM_EnableARRPreload
1431 * @param TIMx Timer instance
1432 * @retval None
1434 __STATIC_INLINE void LL_TIM_EnableARRPreload(TIM_TypeDef *TIMx)
1436 SET_BIT(TIMx->CR1, TIM_CR1_ARPE);
1440 * @brief Disable auto-reload (ARR) preload.
1441 * @rmtoll CR1 ARPE LL_TIM_DisableARRPreload
1442 * @param TIMx Timer instance
1443 * @retval None
1445 __STATIC_INLINE void LL_TIM_DisableARRPreload(TIM_TypeDef *TIMx)
1447 CLEAR_BIT(TIMx->CR1,TIM_CR1_ARPE);
1451 * @brief Indicates whether auto-reload (ARR) preload is enabled.
1452 * @rmtoll CR1 ARPE LL_TIM_IsEnabledARRPreload
1453 * @param TIMx Timer instance
1454 * @retval State of bit (1 or 0).
1456 __STATIC_INLINE uint32_t LL_TIM_IsEnabledARRPreload(TIM_TypeDef *TIMx)
1458 return ((READ_BIT(TIMx->CR1, TIM_CR1_ARPE) == (TIM_CR1_ARPE)) ? 1UL : 0UL);
1462 * @brief Set the division ratio between the timer clock and the sampling clock used by the dead-time generators (when supported) and the digital filters.
1463 * @note Macro @ref IS_TIM_CLOCK_DIVISION_INSTANCE(TIMx) can be used to check
1464 * whether or not the clock division feature is supported by the timer
1465 * instance.
1466 * @rmtoll CR1 CKD LL_TIM_SetClockDivision
1467 * @param TIMx Timer instance
1468 * @param ClockDivision This parameter can be one of the following values:
1469 * @arg @ref LL_TIM_CLOCKDIVISION_DIV1
1470 * @arg @ref LL_TIM_CLOCKDIVISION_DIV2
1471 * @arg @ref LL_TIM_CLOCKDIVISION_DIV4
1472 * @retval None
1474 __STATIC_INLINE void LL_TIM_SetClockDivision(TIM_TypeDef *TIMx, uint32_t ClockDivision)
1476 MODIFY_REG(TIMx->CR1, TIM_CR1_CKD, ClockDivision);
1480 * @brief Get the actual division ratio between the timer clock and the sampling clock used by the dead-time generators (when supported) and the digital filters.
1481 * @note Macro @ref IS_TIM_CLOCK_DIVISION_INSTANCE(TIMx) can be used to check
1482 * whether or not the clock division feature is supported by the timer
1483 * instance.
1484 * @rmtoll CR1 CKD LL_TIM_GetClockDivision
1485 * @param TIMx Timer instance
1486 * @retval Returned value can be one of the following values:
1487 * @arg @ref LL_TIM_CLOCKDIVISION_DIV1
1488 * @arg @ref LL_TIM_CLOCKDIVISION_DIV2
1489 * @arg @ref LL_TIM_CLOCKDIVISION_DIV4
1491 __STATIC_INLINE uint32_t LL_TIM_GetClockDivision(TIM_TypeDef *TIMx)
1493 return (uint32_t)(READ_BIT(TIMx->CR1, TIM_CR1_CKD));
1497 * @brief Set the counter value.
1498 * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
1499 * whether or not a timer instance supports a 32 bits counter.
1500 * @rmtoll CNT CNT LL_TIM_SetCounter
1501 * @param TIMx Timer instance
1502 * @param Counter Counter value (between Min_Data=0 and Max_Data=0xFFFF or 0xFFFFFFFF)
1503 * @retval None
1505 __STATIC_INLINE void LL_TIM_SetCounter(TIM_TypeDef *TIMx, uint32_t Counter)
1507 WRITE_REG(TIMx->CNT, Counter);
1511 * @brief Get the counter value.
1512 * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
1513 * whether or not a timer instance supports a 32 bits counter.
1514 * @rmtoll CNT CNT LL_TIM_GetCounter
1515 * @param TIMx Timer instance
1516 * @retval Counter value (between Min_Data=0 and Max_Data=0xFFFF or 0xFFFFFFFF)
1518 __STATIC_INLINE uint32_t LL_TIM_GetCounter(TIM_TypeDef *TIMx)
1520 return (uint32_t)(READ_REG(TIMx->CNT));
1524 * @brief Get the current direction of the counter
1525 * @rmtoll CR1 DIR LL_TIM_GetDirection
1526 * @param TIMx Timer instance
1527 * @retval Returned value can be one of the following values:
1528 * @arg @ref LL_TIM_COUNTERDIRECTION_UP
1529 * @arg @ref LL_TIM_COUNTERDIRECTION_DOWN
1531 __STATIC_INLINE uint32_t LL_TIM_GetDirection(TIM_TypeDef *TIMx)
1533 return (uint32_t)(READ_BIT(TIMx->CR1, TIM_CR1_DIR));
1537 * @brief Set the prescaler value.
1538 * @note The counter clock frequency CK_CNT is equal to fCK_PSC / (PSC[15:0] + 1).
1539 * @note The prescaler can be changed on the fly as this control register is buffered. The new
1540 * prescaler ratio is taken into account at the next update event.
1541 * @note Helper macro @ref __LL_TIM_CALC_PSC can be used to calculate the Prescaler parameter
1542 * @rmtoll PSC PSC LL_TIM_SetPrescaler
1543 * @param TIMx Timer instance
1544 * @param Prescaler between Min_Data=0 and Max_Data=65535
1545 * @retval None
1547 __STATIC_INLINE void LL_TIM_SetPrescaler(TIM_TypeDef *TIMx, uint32_t Prescaler)
1549 WRITE_REG(TIMx->PSC, Prescaler);
1553 * @brief Get the prescaler value.
1554 * @rmtoll PSC PSC LL_TIM_GetPrescaler
1555 * @param TIMx Timer instance
1556 * @retval Prescaler value between Min_Data=0 and Max_Data=65535
1558 __STATIC_INLINE uint32_t LL_TIM_GetPrescaler(TIM_TypeDef *TIMx)
1560 return (uint32_t)(READ_REG(TIMx->PSC));
1564 * @brief Set the auto-reload value.
1565 * @note The counter is blocked while the auto-reload value is null.
1566 * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
1567 * whether or not a timer instance supports a 32 bits counter.
1568 * @note Helper macro @ref __LL_TIM_CALC_ARR can be used to calculate the AutoReload parameter
1569 * @rmtoll ARR ARR LL_TIM_SetAutoReload
1570 * @param TIMx Timer instance
1571 * @param AutoReload between Min_Data=0 and Max_Data=65535
1572 * @retval None
1574 __STATIC_INLINE void LL_TIM_SetAutoReload(TIM_TypeDef *TIMx, uint32_t AutoReload)
1576 WRITE_REG(TIMx->ARR, AutoReload);
1580 * @brief Get the auto-reload value.
1581 * @rmtoll ARR ARR LL_TIM_GetAutoReload
1582 * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
1583 * whether or not a timer instance supports a 32 bits counter.
1584 * @param TIMx Timer instance
1585 * @retval Auto-reload value
1587 __STATIC_INLINE uint32_t LL_TIM_GetAutoReload(TIM_TypeDef *TIMx)
1589 return (uint32_t)(READ_REG(TIMx->ARR));
1593 * @brief Set the repetition counter value.
1594 * @note For advanced timer instances RepetitionCounter can be up to 65535.
1595 * @note Macro @ref IS_TIM_REPETITION_COUNTER_INSTANCE(TIMx) can be used to check
1596 * whether or not a timer instance supports a repetition counter.
1597 * @rmtoll RCR REP LL_TIM_SetRepetitionCounter
1598 * @param TIMx Timer instance
1599 * @param RepetitionCounter between Min_Data=0 and Max_Data=255
1600 * @retval None
1602 __STATIC_INLINE void LL_TIM_SetRepetitionCounter(TIM_TypeDef *TIMx, uint32_t RepetitionCounter)
1604 WRITE_REG(TIMx->RCR, RepetitionCounter);
1608 * @brief Get the repetition counter value.
1609 * @note Macro @ref IS_TIM_REPETITION_COUNTER_INSTANCE(TIMx) can be used to check
1610 * whether or not a timer instance supports a repetition counter.
1611 * @rmtoll RCR REP LL_TIM_GetRepetitionCounter
1612 * @param TIMx Timer instance
1613 * @retval Repetition counter value
1615 __STATIC_INLINE uint32_t LL_TIM_GetRepetitionCounter(TIM_TypeDef *TIMx)
1617 return (uint32_t)(READ_REG(TIMx->RCR));
1621 * @brief Force a continuous copy of the update interrupt flag (UIF) into the timer counter register (bit 31).
1622 * @note This allows both the counter value and a potential roll-over condition signalled by the UIFCPY flag to be read in an atomic way.
1623 * @rmtoll CR1 UIFREMAP LL_TIM_EnableUIFRemap
1624 * @param TIMx Timer instance
1625 * @retval None
1627 __STATIC_INLINE void LL_TIM_EnableUIFRemap(TIM_TypeDef *TIMx)
1629 SET_BIT(TIMx->CR1, TIM_CR1_UIFREMAP);
1633 * @brief Disable update interrupt flag (UIF) remapping.
1634 * @rmtoll CR1 UIFREMAP LL_TIM_DisableUIFRemap
1635 * @param TIMx Timer instance
1636 * @retval None
1638 __STATIC_INLINE void LL_TIM_DisableUIFRemap(TIM_TypeDef *TIMx)
1640 CLEAR_BIT(TIMx->CR1, TIM_CR1_UIFREMAP);
1644 * @}
1647 /** @defgroup TIM_LL_EF_Capture_Compare Capture Compare configuration
1648 * @{
1651 * @brief Enable the capture/compare control bits (CCxE, CCxNE and OCxM) preload.
1652 * @note CCxE, CCxNE and OCxM bits are preloaded, after having been written,
1653 * they are updated only when a commutation event (COM) occurs.
1654 * @note Only on channels that have a complementary output.
1655 * @note Macro @ref IS_TIM_COMMUTATION_EVENT_INSTANCE(TIMx) can be used to check
1656 * whether or not a timer instance is able to generate a commutation event.
1657 * @rmtoll CR2 CCPC LL_TIM_CC_EnablePreload
1658 * @param TIMx Timer instance
1659 * @retval None
1661 __STATIC_INLINE void LL_TIM_CC_EnablePreload(TIM_TypeDef *TIMx)
1663 SET_BIT(TIMx->CR2, TIM_CR2_CCPC);
1667 * @brief Disable the capture/compare control bits (CCxE, CCxNE and OCxM) preload.
1668 * @note Macro @ref IS_TIM_COMMUTATION_EVENT_INSTANCE(TIMx) can be used to check
1669 * whether or not a timer instance is able to generate a commutation event.
1670 * @rmtoll CR2 CCPC LL_TIM_CC_DisablePreload
1671 * @param TIMx Timer instance
1672 * @retval None
1674 __STATIC_INLINE void LL_TIM_CC_DisablePreload(TIM_TypeDef *TIMx)
1676 CLEAR_BIT(TIMx->CR2, TIM_CR2_CCPC);
1680 * @brief Set the updated source of the capture/compare control bits (CCxE, CCxNE and OCxM).
1681 * @note Macro @ref IS_TIM_COMMUTATION_EVENT_INSTANCE(TIMx) can be used to check
1682 * whether or not a timer instance is able to generate a commutation event.
1683 * @rmtoll CR2 CCUS LL_TIM_CC_SetUpdate
1684 * @param TIMx Timer instance
1685 * @param CCUpdateSource This parameter can be one of the following values:
1686 * @arg @ref LL_TIM_CCUPDATESOURCE_COMG_ONLY
1687 * @arg @ref LL_TIM_CCUPDATESOURCE_COMG_AND_TRGI
1688 * @retval None
1690 __STATIC_INLINE void LL_TIM_CC_SetUpdate(TIM_TypeDef *TIMx, uint32_t CCUpdateSource)
1692 MODIFY_REG(TIMx->CR2, TIM_CR2_CCUS, CCUpdateSource);
1696 * @brief Set the trigger of the capture/compare DMA request.
1697 * @rmtoll CR2 CCDS LL_TIM_CC_SetDMAReqTrigger
1698 * @param TIMx Timer instance
1699 * @param DMAReqTrigger This parameter can be one of the following values:
1700 * @arg @ref LL_TIM_CCDMAREQUEST_CC
1701 * @arg @ref LL_TIM_CCDMAREQUEST_UPDATE
1702 * @retval None
1704 __STATIC_INLINE void LL_TIM_CC_SetDMAReqTrigger(TIM_TypeDef *TIMx, uint32_t DMAReqTrigger)
1706 MODIFY_REG(TIMx->CR2, TIM_CR2_CCDS, DMAReqTrigger);
1710 * @brief Get actual trigger of the capture/compare DMA request.
1711 * @rmtoll CR2 CCDS LL_TIM_CC_GetDMAReqTrigger
1712 * @param TIMx Timer instance
1713 * @retval Returned value can be one of the following values:
1714 * @arg @ref LL_TIM_CCDMAREQUEST_CC
1715 * @arg @ref LL_TIM_CCDMAREQUEST_UPDATE
1717 __STATIC_INLINE uint32_t LL_TIM_CC_GetDMAReqTrigger(TIM_TypeDef *TIMx)
1719 return (uint32_t)(READ_BIT(TIMx->CR2, TIM_CR2_CCDS));
1723 * @brief Set the lock level to freeze the
1724 * configuration of several capture/compare parameters.
1725 * @note Macro @ref IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
1726 * the lock mechanism is supported by a timer instance.
1727 * @rmtoll BDTR LOCK LL_TIM_CC_SetLockLevel
1728 * @param TIMx Timer instance
1729 * @param LockLevel This parameter can be one of the following values:
1730 * @arg @ref LL_TIM_LOCKLEVEL_OFF
1731 * @arg @ref LL_TIM_LOCKLEVEL_1
1732 * @arg @ref LL_TIM_LOCKLEVEL_2
1733 * @arg @ref LL_TIM_LOCKLEVEL_3
1734 * @retval None
1736 __STATIC_INLINE void LL_TIM_CC_SetLockLevel(TIM_TypeDef *TIMx, uint32_t LockLevel)
1738 MODIFY_REG(TIMx->BDTR, TIM_BDTR_LOCK, LockLevel);
1742 * @brief Enable capture/compare channels.
1743 * @rmtoll CCER CC1E LL_TIM_CC_EnableChannel\n
1744 * CCER CC1NE LL_TIM_CC_EnableChannel\n
1745 * CCER CC2E LL_TIM_CC_EnableChannel\n
1746 * CCER CC2NE LL_TIM_CC_EnableChannel\n
1747 * CCER CC3E LL_TIM_CC_EnableChannel\n
1748 * CCER CC3NE LL_TIM_CC_EnableChannel\n
1749 * CCER CC4E LL_TIM_CC_EnableChannel\n
1750 * CCER CC5E LL_TIM_CC_EnableChannel\n
1751 * CCER CC6E LL_TIM_CC_EnableChannel
1752 * @param TIMx Timer instance
1753 * @param Channels This parameter can be a combination of the following values:
1754 * @arg @ref LL_TIM_CHANNEL_CH1
1755 * @arg @ref LL_TIM_CHANNEL_CH1N
1756 * @arg @ref LL_TIM_CHANNEL_CH2
1757 * @arg @ref LL_TIM_CHANNEL_CH2N
1758 * @arg @ref LL_TIM_CHANNEL_CH3
1759 * @arg @ref LL_TIM_CHANNEL_CH3N
1760 * @arg @ref LL_TIM_CHANNEL_CH4
1761 * @arg @ref LL_TIM_CHANNEL_CH5
1762 * @arg @ref LL_TIM_CHANNEL_CH6
1763 * @retval None
1765 __STATIC_INLINE void LL_TIM_CC_EnableChannel(TIM_TypeDef *TIMx, uint32_t Channels)
1767 SET_BIT(TIMx->CCER, Channels);
1771 * @brief Disable capture/compare channels.
1772 * @rmtoll CCER CC1E LL_TIM_CC_DisableChannel\n
1773 * CCER CC1NE LL_TIM_CC_DisableChannel\n
1774 * CCER CC2E LL_TIM_CC_DisableChannel\n
1775 * CCER CC2NE LL_TIM_CC_DisableChannel\n
1776 * CCER CC3E LL_TIM_CC_DisableChannel\n
1777 * CCER CC3NE LL_TIM_CC_DisableChannel\n
1778 * CCER CC4E LL_TIM_CC_DisableChannel\n
1779 * CCER CC5E LL_TIM_CC_DisableChannel\n
1780 * CCER CC6E LL_TIM_CC_DisableChannel
1781 * @param TIMx Timer instance
1782 * @param Channels This parameter can be a combination of the following values:
1783 * @arg @ref LL_TIM_CHANNEL_CH1
1784 * @arg @ref LL_TIM_CHANNEL_CH1N
1785 * @arg @ref LL_TIM_CHANNEL_CH2
1786 * @arg @ref LL_TIM_CHANNEL_CH2N
1787 * @arg @ref LL_TIM_CHANNEL_CH3
1788 * @arg @ref LL_TIM_CHANNEL_CH3N
1789 * @arg @ref LL_TIM_CHANNEL_CH4
1790 * @arg @ref LL_TIM_CHANNEL_CH5
1791 * @arg @ref LL_TIM_CHANNEL_CH6
1792 * @retval None
1794 __STATIC_INLINE void LL_TIM_CC_DisableChannel(TIM_TypeDef *TIMx, uint32_t Channels)
1796 CLEAR_BIT(TIMx->CCER, Channels);
1800 * @brief Indicate whether channel(s) is(are) enabled.
1801 * @rmtoll CCER CC1E LL_TIM_CC_IsEnabledChannel\n
1802 * CCER CC1NE LL_TIM_CC_IsEnabledChannel\n
1803 * CCER CC2E LL_TIM_CC_IsEnabledChannel\n
1804 * CCER CC2NE LL_TIM_CC_IsEnabledChannel\n
1805 * CCER CC3E LL_TIM_CC_IsEnabledChannel\n
1806 * CCER CC3NE LL_TIM_CC_IsEnabledChannel\n
1807 * CCER CC4E LL_TIM_CC_IsEnabledChannel\n
1808 * CCER CC5E LL_TIM_CC_IsEnabledChannel\n
1809 * CCER CC6E LL_TIM_CC_IsEnabledChannel
1810 * @param TIMx Timer instance
1811 * @param Channels This parameter can be a combination of the following values:
1812 * @arg @ref LL_TIM_CHANNEL_CH1
1813 * @arg @ref LL_TIM_CHANNEL_CH1N
1814 * @arg @ref LL_TIM_CHANNEL_CH2
1815 * @arg @ref LL_TIM_CHANNEL_CH2N
1816 * @arg @ref LL_TIM_CHANNEL_CH3
1817 * @arg @ref LL_TIM_CHANNEL_CH3N
1818 * @arg @ref LL_TIM_CHANNEL_CH4
1819 * @arg @ref LL_TIM_CHANNEL_CH5
1820 * @arg @ref LL_TIM_CHANNEL_CH6
1821 * @retval State of bit (1 or 0).
1823 __STATIC_INLINE uint32_t LL_TIM_CC_IsEnabledChannel(TIM_TypeDef *TIMx, uint32_t Channels)
1825 return ((READ_BIT(TIMx->CCER, Channels) == (Channels)) ? 1UL : 0UL);
1829 * @}
1832 /** @defgroup TIM_LL_EF_Output_Channel Output channel configuration
1833 * @{
1836 * @brief Configure an output channel.
1837 * @rmtoll CCMR1 CC1S LL_TIM_OC_ConfigOutput\n
1838 * CCMR1 CC2S LL_TIM_OC_ConfigOutput\n
1839 * CCMR2 CC3S LL_TIM_OC_ConfigOutput\n
1840 * CCMR2 CC4S LL_TIM_OC_ConfigOutput\n
1841 * CCMR3 CC5S LL_TIM_OC_ConfigOutput\n
1842 * CCMR3 CC6S LL_TIM_OC_ConfigOutput\n
1843 * CCER CC1P LL_TIM_OC_ConfigOutput\n
1844 * CCER CC2P LL_TIM_OC_ConfigOutput\n
1845 * CCER CC3P LL_TIM_OC_ConfigOutput\n
1846 * CCER CC4P LL_TIM_OC_ConfigOutput\n
1847 * CCER CC5P LL_TIM_OC_ConfigOutput\n
1848 * CCER CC6P LL_TIM_OC_ConfigOutput\n
1849 * CR2 OIS1 LL_TIM_OC_ConfigOutput\n
1850 * CR2 OIS2 LL_TIM_OC_ConfigOutput\n
1851 * CR2 OIS3 LL_TIM_OC_ConfigOutput\n
1852 * CR2 OIS4 LL_TIM_OC_ConfigOutput\n
1853 * CR2 OIS5 LL_TIM_OC_ConfigOutput\n
1854 * CR2 OIS6 LL_TIM_OC_ConfigOutput
1855 * @param TIMx Timer instance
1856 * @param Channel This parameter can be one of the following values:
1857 * @arg @ref LL_TIM_CHANNEL_CH1
1858 * @arg @ref LL_TIM_CHANNEL_CH2
1859 * @arg @ref LL_TIM_CHANNEL_CH3
1860 * @arg @ref LL_TIM_CHANNEL_CH4
1861 * @arg @ref LL_TIM_CHANNEL_CH5
1862 * @arg @ref LL_TIM_CHANNEL_CH6
1863 * @param Configuration This parameter must be a combination of all the following values:
1864 * @arg @ref LL_TIM_OCPOLARITY_HIGH or @ref LL_TIM_OCPOLARITY_LOW
1865 * @arg @ref LL_TIM_OCIDLESTATE_LOW or @ref LL_TIM_OCIDLESTATE_HIGH
1866 * @retval None
1868 __STATIC_INLINE void LL_TIM_OC_ConfigOutput(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t Configuration)
1870 register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
1871 register __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
1872 CLEAR_BIT(*pReg, (TIM_CCMR1_CC1S << SHIFT_TAB_OCxx[iChannel]));
1873 MODIFY_REG(TIMx->CCER, (TIM_CCER_CC1P << SHIFT_TAB_CCxP[iChannel]),
1874 (Configuration & TIM_CCER_CC1P) << SHIFT_TAB_CCxP[iChannel]);
1875 MODIFY_REG(TIMx->CR2, (TIM_CR2_OIS1 << SHIFT_TAB_OISx[iChannel]),
1876 (Configuration & TIM_CR2_OIS1) << SHIFT_TAB_OISx[iChannel]);
1880 * @brief Define the behavior of the output reference signal OCxREF from which
1881 * OCx and OCxN (when relevant) are derived.
1882 * @rmtoll CCMR1 OC1M LL_TIM_OC_SetMode\n
1883 * CCMR1 OC2M LL_TIM_OC_SetMode\n
1884 * CCMR2 OC3M LL_TIM_OC_SetMode\n
1885 * CCMR2 OC4M LL_TIM_OC_SetMode\n
1886 * CCMR3 OC5M LL_TIM_OC_SetMode\n
1887 * CCMR3 OC6M LL_TIM_OC_SetMode
1888 * @param TIMx Timer instance
1889 * @param Channel This parameter can be one of the following values:
1890 * @arg @ref LL_TIM_CHANNEL_CH1
1891 * @arg @ref LL_TIM_CHANNEL_CH2
1892 * @arg @ref LL_TIM_CHANNEL_CH3
1893 * @arg @ref LL_TIM_CHANNEL_CH4
1894 * @arg @ref LL_TIM_CHANNEL_CH5
1895 * @arg @ref LL_TIM_CHANNEL_CH6
1896 * @param Mode This parameter can be one of the following values:
1897 * @arg @ref LL_TIM_OCMODE_FROZEN
1898 * @arg @ref LL_TIM_OCMODE_ACTIVE
1899 * @arg @ref LL_TIM_OCMODE_INACTIVE
1900 * @arg @ref LL_TIM_OCMODE_TOGGLE
1901 * @arg @ref LL_TIM_OCMODE_FORCED_INACTIVE
1902 * @arg @ref LL_TIM_OCMODE_FORCED_ACTIVE
1903 * @arg @ref LL_TIM_OCMODE_PWM1
1904 * @arg @ref LL_TIM_OCMODE_PWM2
1905 * @arg @ref LL_TIM_OCMODE_RETRIG_OPM1
1906 * @arg @ref LL_TIM_OCMODE_RETRIG_OPM2
1907 * @arg @ref LL_TIM_OCMODE_COMBINED_PWM1
1908 * @arg @ref LL_TIM_OCMODE_COMBINED_PWM2
1909 * @arg @ref LL_TIM_OCMODE_ASSYMETRIC_PWM1
1910 * @arg @ref LL_TIM_OCMODE_ASSYMETRIC_PWM2
1911 * @retval None
1913 __STATIC_INLINE void LL_TIM_OC_SetMode(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t Mode)
1915 register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
1916 register __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
1917 MODIFY_REG(*pReg, ((TIM_CCMR1_OC1M | TIM_CCMR1_CC1S) << SHIFT_TAB_OCxx[iChannel]), Mode << SHIFT_TAB_OCxx[iChannel]);
1921 * @brief Get the output compare mode of an output channel.
1922 * @rmtoll CCMR1 OC1M LL_TIM_OC_GetMode\n
1923 * CCMR1 OC2M LL_TIM_OC_GetMode\n
1924 * CCMR2 OC3M LL_TIM_OC_GetMode\n
1925 * CCMR2 OC4M LL_TIM_OC_GetMode\n
1926 * CCMR3 OC5M LL_TIM_OC_GetMode\n
1927 * CCMR3 OC6M LL_TIM_OC_GetMode
1928 * @param TIMx Timer instance
1929 * @param Channel This parameter can be one of the following values:
1930 * @arg @ref LL_TIM_CHANNEL_CH1
1931 * @arg @ref LL_TIM_CHANNEL_CH2
1932 * @arg @ref LL_TIM_CHANNEL_CH3
1933 * @arg @ref LL_TIM_CHANNEL_CH4
1934 * @arg @ref LL_TIM_CHANNEL_CH5
1935 * @arg @ref LL_TIM_CHANNEL_CH6
1936 * @retval Returned value can be one of the following values:
1937 * @arg @ref LL_TIM_OCMODE_FROZEN
1938 * @arg @ref LL_TIM_OCMODE_ACTIVE
1939 * @arg @ref LL_TIM_OCMODE_INACTIVE
1940 * @arg @ref LL_TIM_OCMODE_TOGGLE
1941 * @arg @ref LL_TIM_OCMODE_FORCED_INACTIVE
1942 * @arg @ref LL_TIM_OCMODE_FORCED_ACTIVE
1943 * @arg @ref LL_TIM_OCMODE_PWM1
1944 * @arg @ref LL_TIM_OCMODE_PWM2
1945 * @arg @ref LL_TIM_OCMODE_RETRIG_OPM1
1946 * @arg @ref LL_TIM_OCMODE_RETRIG_OPM2
1947 * @arg @ref LL_TIM_OCMODE_COMBINED_PWM1
1948 * @arg @ref LL_TIM_OCMODE_COMBINED_PWM2
1949 * @arg @ref LL_TIM_OCMODE_ASSYMETRIC_PWM1
1950 * @arg @ref LL_TIM_OCMODE_ASSYMETRIC_PWM2
1952 __STATIC_INLINE uint32_t LL_TIM_OC_GetMode(TIM_TypeDef *TIMx, uint32_t Channel)
1954 register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
1955 register const __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
1956 return (READ_BIT(*pReg, ((TIM_CCMR1_OC1M | TIM_CCMR1_CC1S) << SHIFT_TAB_OCxx[iChannel])) >> SHIFT_TAB_OCxx[iChannel]);
1960 * @brief Set the polarity of an output channel.
1961 * @rmtoll CCER CC1P LL_TIM_OC_SetPolarity\n
1962 * CCER CC1NP LL_TIM_OC_SetPolarity\n
1963 * CCER CC2P LL_TIM_OC_SetPolarity\n
1964 * CCER CC2NP LL_TIM_OC_SetPolarity\n
1965 * CCER CC3P LL_TIM_OC_SetPolarity\n
1966 * CCER CC3NP LL_TIM_OC_SetPolarity\n
1967 * CCER CC4P LL_TIM_OC_SetPolarity\n
1968 * CCER CC5P LL_TIM_OC_SetPolarity\n
1969 * CCER CC6P LL_TIM_OC_SetPolarity
1970 * @param TIMx Timer instance
1971 * @param Channel This parameter can be one of the following values:
1972 * @arg @ref LL_TIM_CHANNEL_CH1
1973 * @arg @ref LL_TIM_CHANNEL_CH1N
1974 * @arg @ref LL_TIM_CHANNEL_CH2
1975 * @arg @ref LL_TIM_CHANNEL_CH2N
1976 * @arg @ref LL_TIM_CHANNEL_CH3
1977 * @arg @ref LL_TIM_CHANNEL_CH3N
1978 * @arg @ref LL_TIM_CHANNEL_CH4
1979 * @arg @ref LL_TIM_CHANNEL_CH5
1980 * @arg @ref LL_TIM_CHANNEL_CH6
1981 * @param Polarity This parameter can be one of the following values:
1982 * @arg @ref LL_TIM_OCPOLARITY_HIGH
1983 * @arg @ref LL_TIM_OCPOLARITY_LOW
1984 * @retval None
1986 __STATIC_INLINE void LL_TIM_OC_SetPolarity(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t Polarity)
1988 register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
1989 MODIFY_REG(TIMx->CCER, (TIM_CCER_CC1P << SHIFT_TAB_CCxP[iChannel]), Polarity << SHIFT_TAB_CCxP[iChannel]);
1993 * @brief Get the polarity of an output channel.
1994 * @rmtoll CCER CC1P LL_TIM_OC_GetPolarity\n
1995 * CCER CC1NP LL_TIM_OC_GetPolarity\n
1996 * CCER CC2P LL_TIM_OC_GetPolarity\n
1997 * CCER CC2NP LL_TIM_OC_GetPolarity\n
1998 * CCER CC3P LL_TIM_OC_GetPolarity\n
1999 * CCER CC3NP LL_TIM_OC_GetPolarity\n
2000 * CCER CC4P LL_TIM_OC_GetPolarity\n
2001 * CCER CC5P LL_TIM_OC_GetPolarity\n
2002 * CCER CC6P LL_TIM_OC_GetPolarity
2003 * @param TIMx Timer instance
2004 * @param Channel This parameter can be one of the following values:
2005 * @arg @ref LL_TIM_CHANNEL_CH1
2006 * @arg @ref LL_TIM_CHANNEL_CH1N
2007 * @arg @ref LL_TIM_CHANNEL_CH2
2008 * @arg @ref LL_TIM_CHANNEL_CH2N
2009 * @arg @ref LL_TIM_CHANNEL_CH3
2010 * @arg @ref LL_TIM_CHANNEL_CH3N
2011 * @arg @ref LL_TIM_CHANNEL_CH4
2012 * @arg @ref LL_TIM_CHANNEL_CH5
2013 * @arg @ref LL_TIM_CHANNEL_CH6
2014 * @retval Returned value can be one of the following values:
2015 * @arg @ref LL_TIM_OCPOLARITY_HIGH
2016 * @arg @ref LL_TIM_OCPOLARITY_LOW
2018 __STATIC_INLINE uint32_t LL_TIM_OC_GetPolarity(TIM_TypeDef *TIMx, uint32_t Channel)
2020 register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
2021 return (READ_BIT(TIMx->CCER, (TIM_CCER_CC1P << SHIFT_TAB_CCxP[iChannel])) >> SHIFT_TAB_CCxP[iChannel]);
2025 * @brief Set the IDLE state of an output channel
2026 * @note This function is significant only for the timer instances
2027 * supporting the break feature. Macro @ref IS_TIM_BREAK_INSTANCE(TIMx)
2028 * can be used to check whether or not a timer instance provides
2029 * a break input.
2030 * @rmtoll CR2 OIS1 LL_TIM_OC_SetIdleState\n
2031 * CR2 OIS2N LL_TIM_OC_SetIdleState\n
2032 * CR2 OIS2 LL_TIM_OC_SetIdleState\n
2033 * CR2 OIS2N LL_TIM_OC_SetIdleState\n
2034 * CR2 OIS3 LL_TIM_OC_SetIdleState\n
2035 * CR2 OIS3N LL_TIM_OC_SetIdleState\n
2036 * CR2 OIS4 LL_TIM_OC_SetIdleState\n
2037 * CR2 OIS5 LL_TIM_OC_SetIdleState\n
2038 * CR2 OIS6 LL_TIM_OC_SetIdleState
2039 * @param TIMx Timer instance
2040 * @param Channel This parameter can be one of the following values:
2041 * @arg @ref LL_TIM_CHANNEL_CH1
2042 * @arg @ref LL_TIM_CHANNEL_CH1N
2043 * @arg @ref LL_TIM_CHANNEL_CH2
2044 * @arg @ref LL_TIM_CHANNEL_CH2N
2045 * @arg @ref LL_TIM_CHANNEL_CH3
2046 * @arg @ref LL_TIM_CHANNEL_CH3N
2047 * @arg @ref LL_TIM_CHANNEL_CH4
2048 * @arg @ref LL_TIM_CHANNEL_CH5
2049 * @arg @ref LL_TIM_CHANNEL_CH6
2050 * @param IdleState This parameter can be one of the following values:
2051 * @arg @ref LL_TIM_OCIDLESTATE_LOW
2052 * @arg @ref LL_TIM_OCIDLESTATE_HIGH
2053 * @retval None
2055 __STATIC_INLINE void LL_TIM_OC_SetIdleState(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t IdleState)
2057 register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
2058 MODIFY_REG(TIMx->CR2, (TIM_CR2_OIS1 << SHIFT_TAB_OISx[iChannel]), IdleState << SHIFT_TAB_OISx[iChannel]);
2062 * @brief Get the IDLE state of an output channel
2063 * @rmtoll CR2 OIS1 LL_TIM_OC_GetIdleState\n
2064 * CR2 OIS2N LL_TIM_OC_GetIdleState\n
2065 * CR2 OIS2 LL_TIM_OC_GetIdleState\n
2066 * CR2 OIS2N LL_TIM_OC_GetIdleState\n
2067 * CR2 OIS3 LL_TIM_OC_GetIdleState\n
2068 * CR2 OIS3N LL_TIM_OC_GetIdleState\n
2069 * CR2 OIS4 LL_TIM_OC_GetIdleState\n
2070 * CR2 OIS5 LL_TIM_OC_GetIdleState\n
2071 * CR2 OIS6 LL_TIM_OC_GetIdleState
2072 * @param TIMx Timer instance
2073 * @param Channel This parameter can be one of the following values:
2074 * @arg @ref LL_TIM_CHANNEL_CH1
2075 * @arg @ref LL_TIM_CHANNEL_CH1N
2076 * @arg @ref LL_TIM_CHANNEL_CH2
2077 * @arg @ref LL_TIM_CHANNEL_CH2N
2078 * @arg @ref LL_TIM_CHANNEL_CH3
2079 * @arg @ref LL_TIM_CHANNEL_CH3N
2080 * @arg @ref LL_TIM_CHANNEL_CH4
2081 * @arg @ref LL_TIM_CHANNEL_CH5
2082 * @arg @ref LL_TIM_CHANNEL_CH6
2083 * @retval Returned value can be one of the following values:
2084 * @arg @ref LL_TIM_OCIDLESTATE_LOW
2085 * @arg @ref LL_TIM_OCIDLESTATE_HIGH
2087 __STATIC_INLINE uint32_t LL_TIM_OC_GetIdleState(TIM_TypeDef *TIMx, uint32_t Channel)
2089 register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
2090 return (READ_BIT(TIMx->CR2, (TIM_CR2_OIS1 << SHIFT_TAB_OISx[iChannel])) >> SHIFT_TAB_OISx[iChannel]);
2094 * @brief Enable fast mode for the output channel.
2095 * @note Acts only if the channel is configured in PWM1 or PWM2 mode.
2096 * @rmtoll CCMR1 OC1FE LL_TIM_OC_EnableFast\n
2097 * CCMR1 OC2FE LL_TIM_OC_EnableFast\n
2098 * CCMR2 OC3FE LL_TIM_OC_EnableFast\n
2099 * CCMR2 OC4FE LL_TIM_OC_EnableFast\n
2100 * CCMR3 OC5FE LL_TIM_OC_EnableFast\n
2101 * CCMR3 OC6FE LL_TIM_OC_EnableFast
2102 * @param TIMx Timer instance
2103 * @param Channel This parameter can be one of the following values:
2104 * @arg @ref LL_TIM_CHANNEL_CH1
2105 * @arg @ref LL_TIM_CHANNEL_CH2
2106 * @arg @ref LL_TIM_CHANNEL_CH3
2107 * @arg @ref LL_TIM_CHANNEL_CH4
2108 * @arg @ref LL_TIM_CHANNEL_CH5
2109 * @arg @ref LL_TIM_CHANNEL_CH6
2110 * @retval None
2112 __STATIC_INLINE void LL_TIM_OC_EnableFast(TIM_TypeDef *TIMx, uint32_t Channel)
2114 register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
2115 register __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
2116 SET_BIT(*pReg, (TIM_CCMR1_OC1FE << SHIFT_TAB_OCxx[iChannel]));
2121 * @brief Disable fast mode for the output channel.
2122 * @rmtoll CCMR1 OC1FE LL_TIM_OC_DisableFast\n
2123 * CCMR1 OC2FE LL_TIM_OC_DisableFast\n
2124 * CCMR2 OC3FE LL_TIM_OC_DisableFast\n
2125 * CCMR2 OC4FE LL_TIM_OC_DisableFast\n
2126 * CCMR3 OC5FE LL_TIM_OC_DisableFast\n
2127 * CCMR3 OC6FE LL_TIM_OC_DisableFast
2128 * @param TIMx Timer instance
2129 * @param Channel This parameter can be one of the following values:
2130 * @arg @ref LL_TIM_CHANNEL_CH1
2131 * @arg @ref LL_TIM_CHANNEL_CH2
2132 * @arg @ref LL_TIM_CHANNEL_CH3
2133 * @arg @ref LL_TIM_CHANNEL_CH4
2134 * @arg @ref LL_TIM_CHANNEL_CH5
2135 * @arg @ref LL_TIM_CHANNEL_CH6
2136 * @retval None
2138 __STATIC_INLINE void LL_TIM_OC_DisableFast(TIM_TypeDef *TIMx, uint32_t Channel)
2140 register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
2141 register __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
2142 CLEAR_BIT(*pReg, (TIM_CCMR1_OC1FE << SHIFT_TAB_OCxx[iChannel]));
2147 * @brief Indicates whether fast mode is enabled for the output channel.
2148 * @rmtoll CCMR1 OC1FE LL_TIM_OC_IsEnabledFast\n
2149 * CCMR1 OC2FE LL_TIM_OC_IsEnabledFast\n
2150 * CCMR2 OC3FE LL_TIM_OC_IsEnabledFast\n
2151 * CCMR2 OC4FE LL_TIM_OC_IsEnabledFast\n
2152 * CCMR3 OC5FE LL_TIM_OC_IsEnabledFast\n
2153 * CCMR3 OC6FE LL_TIM_OC_IsEnabledFast
2154 * @param TIMx Timer instance
2155 * @param Channel This parameter can be one of the following values:
2156 * @arg @ref LL_TIM_CHANNEL_CH1
2157 * @arg @ref LL_TIM_CHANNEL_CH2
2158 * @arg @ref LL_TIM_CHANNEL_CH3
2159 * @arg @ref LL_TIM_CHANNEL_CH4
2160 * @arg @ref LL_TIM_CHANNEL_CH5
2161 * @arg @ref LL_TIM_CHANNEL_CH6
2162 * @retval State of bit (1 or 0).
2164 __STATIC_INLINE uint32_t LL_TIM_OC_IsEnabledFast(TIM_TypeDef *TIMx, uint32_t Channel)
2166 register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
2167 register const __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
2168 register uint32_t bitfield = TIM_CCMR1_OC1FE << SHIFT_TAB_OCxx[iChannel];
2169 return ((READ_BIT(*pReg, bitfield) == bitfield) ? 1UL : 0UL);
2173 * @brief Enable compare register (TIMx_CCRx) preload for the output channel.
2174 * @rmtoll CCMR1 OC1PE LL_TIM_OC_EnablePreload\n
2175 * CCMR1 OC2PE LL_TIM_OC_EnablePreload\n
2176 * CCMR2 OC3PE LL_TIM_OC_EnablePreload\n
2177 * CCMR2 OC4PE LL_TIM_OC_EnablePreload\n
2178 * CCMR3 OC5PE LL_TIM_OC_EnablePreload\n
2179 * CCMR3 OC6PE LL_TIM_OC_EnablePreload
2180 * @param TIMx Timer instance
2181 * @param Channel This parameter can be one of the following values:
2182 * @arg @ref LL_TIM_CHANNEL_CH1
2183 * @arg @ref LL_TIM_CHANNEL_CH2
2184 * @arg @ref LL_TIM_CHANNEL_CH3
2185 * @arg @ref LL_TIM_CHANNEL_CH4
2186 * @arg @ref LL_TIM_CHANNEL_CH5
2187 * @arg @ref LL_TIM_CHANNEL_CH6
2188 * @retval None
2190 __STATIC_INLINE void LL_TIM_OC_EnablePreload(TIM_TypeDef *TIMx, uint32_t Channel)
2192 register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
2193 register __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
2194 SET_BIT(*pReg, (TIM_CCMR1_OC1PE << SHIFT_TAB_OCxx[iChannel]));
2198 * @brief Disable compare register (TIMx_CCRx) preload for the output channel.
2199 * @rmtoll CCMR1 OC1PE LL_TIM_OC_DisablePreload\n
2200 * CCMR1 OC2PE LL_TIM_OC_DisablePreload\n
2201 * CCMR2 OC3PE LL_TIM_OC_DisablePreload\n
2202 * CCMR2 OC4PE LL_TIM_OC_DisablePreload\n
2203 * CCMR3 OC5PE LL_TIM_OC_DisablePreload\n
2204 * CCMR3 OC6PE LL_TIM_OC_DisablePreload
2205 * @param TIMx Timer instance
2206 * @param Channel This parameter can be one of the following values:
2207 * @arg @ref LL_TIM_CHANNEL_CH1
2208 * @arg @ref LL_TIM_CHANNEL_CH2
2209 * @arg @ref LL_TIM_CHANNEL_CH3
2210 * @arg @ref LL_TIM_CHANNEL_CH4
2211 * @arg @ref LL_TIM_CHANNEL_CH5
2212 * @arg @ref LL_TIM_CHANNEL_CH6
2213 * @retval None
2215 __STATIC_INLINE void LL_TIM_OC_DisablePreload(TIM_TypeDef *TIMx, uint32_t Channel)
2217 register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
2218 register __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
2219 CLEAR_BIT(*pReg, (TIM_CCMR1_OC1PE << SHIFT_TAB_OCxx[iChannel]));
2223 * @brief Indicates whether compare register (TIMx_CCRx) preload is enabled for the output channel.
2224 * @rmtoll CCMR1 OC1PE LL_TIM_OC_IsEnabledPreload\n
2225 * CCMR1 OC2PE LL_TIM_OC_IsEnabledPreload\n
2226 * CCMR2 OC3PE LL_TIM_OC_IsEnabledPreload\n
2227 * CCMR2 OC4PE LL_TIM_OC_IsEnabledPreload\n
2228 * CCMR3 OC5PE LL_TIM_OC_IsEnabledPreload\n
2229 * CCMR3 OC6PE LL_TIM_OC_IsEnabledPreload
2230 * @param TIMx Timer instance
2231 * @param Channel This parameter can be one of the following values:
2232 * @arg @ref LL_TIM_CHANNEL_CH1
2233 * @arg @ref LL_TIM_CHANNEL_CH2
2234 * @arg @ref LL_TIM_CHANNEL_CH3
2235 * @arg @ref LL_TIM_CHANNEL_CH4
2236 * @arg @ref LL_TIM_CHANNEL_CH5
2237 * @arg @ref LL_TIM_CHANNEL_CH6
2238 * @retval State of bit (1 or 0).
2240 __STATIC_INLINE uint32_t LL_TIM_OC_IsEnabledPreload(TIM_TypeDef *TIMx, uint32_t Channel)
2242 register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
2243 register const __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
2244 register uint32_t bitfield = TIM_CCMR1_OC1PE << SHIFT_TAB_OCxx[iChannel];
2245 return ((READ_BIT(*pReg, bitfield) == bitfield) ? 1UL : 0UL);
2249 * @brief Enable clearing the output channel on an external event.
2250 * @note This function can only be used in Output compare and PWM modes. It does not work in Forced mode.
2251 * @note Macro @ref IS_TIM_OCXREF_CLEAR_INSTANCE(TIMx) can be used to check whether
2252 * or not a timer instance can clear the OCxREF signal on an external event.
2253 * @rmtoll CCMR1 OC1CE LL_TIM_OC_EnableClear\n
2254 * CCMR1 OC2CE LL_TIM_OC_EnableClear\n
2255 * CCMR2 OC3CE LL_TIM_OC_EnableClear\n
2256 * CCMR2 OC4CE LL_TIM_OC_EnableClear\n
2257 * CCMR3 OC5CE LL_TIM_OC_EnableClear\n
2258 * CCMR3 OC6CE LL_TIM_OC_EnableClear
2259 * @param TIMx Timer instance
2260 * @param Channel This parameter can be one of the following values:
2261 * @arg @ref LL_TIM_CHANNEL_CH1
2262 * @arg @ref LL_TIM_CHANNEL_CH2
2263 * @arg @ref LL_TIM_CHANNEL_CH3
2264 * @arg @ref LL_TIM_CHANNEL_CH4
2265 * @arg @ref LL_TIM_CHANNEL_CH5
2266 * @arg @ref LL_TIM_CHANNEL_CH6
2267 * @retval None
2269 __STATIC_INLINE void LL_TIM_OC_EnableClear(TIM_TypeDef *TIMx, uint32_t Channel)
2271 register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
2272 register __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
2273 SET_BIT(*pReg, (TIM_CCMR1_OC1CE << SHIFT_TAB_OCxx[iChannel]));
2277 * @brief Disable clearing the output channel on an external event.
2278 * @note Macro @ref IS_TIM_OCXREF_CLEAR_INSTANCE(TIMx) can be used to check whether
2279 * or not a timer instance can clear the OCxREF signal on an external event.
2280 * @rmtoll CCMR1 OC1CE LL_TIM_OC_DisableClear\n
2281 * CCMR1 OC2CE LL_TIM_OC_DisableClear\n
2282 * CCMR2 OC3CE LL_TIM_OC_DisableClear\n
2283 * CCMR2 OC4CE LL_TIM_OC_DisableClear\n
2284 * CCMR3 OC5CE LL_TIM_OC_DisableClear\n
2285 * CCMR3 OC6CE LL_TIM_OC_DisableClear
2286 * @param TIMx Timer instance
2287 * @param Channel This parameter can be one of the following values:
2288 * @arg @ref LL_TIM_CHANNEL_CH1
2289 * @arg @ref LL_TIM_CHANNEL_CH2
2290 * @arg @ref LL_TIM_CHANNEL_CH3
2291 * @arg @ref LL_TIM_CHANNEL_CH4
2292 * @arg @ref LL_TIM_CHANNEL_CH5
2293 * @arg @ref LL_TIM_CHANNEL_CH6
2294 * @retval None
2296 __STATIC_INLINE void LL_TIM_OC_DisableClear(TIM_TypeDef *TIMx, uint32_t Channel)
2298 register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
2299 register __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
2300 CLEAR_BIT(*pReg, (TIM_CCMR1_OC1CE << SHIFT_TAB_OCxx[iChannel]));
2304 * @brief Indicates clearing the output channel on an external event is enabled for the output channel.
2305 * @note This function enables clearing the output channel on an external event.
2306 * @note This function can only be used in Output compare and PWM modes. It does not work in Forced mode.
2307 * @note Macro @ref IS_TIM_OCXREF_CLEAR_INSTANCE(TIMx) can be used to check whether
2308 * or not a timer instance can clear the OCxREF signal on an external event.
2309 * @rmtoll CCMR1 OC1CE LL_TIM_OC_IsEnabledClear\n
2310 * CCMR1 OC2CE LL_TIM_OC_IsEnabledClear\n
2311 * CCMR2 OC3CE LL_TIM_OC_IsEnabledClear\n
2312 * CCMR2 OC4CE LL_TIM_OC_IsEnabledClear\n
2313 * CCMR3 OC5CE LL_TIM_OC_IsEnabledClear\n
2314 * CCMR3 OC6CE LL_TIM_OC_IsEnabledClear
2315 * @param TIMx Timer instance
2316 * @param Channel This parameter can be one of the following values:
2317 * @arg @ref LL_TIM_CHANNEL_CH1
2318 * @arg @ref LL_TIM_CHANNEL_CH2
2319 * @arg @ref LL_TIM_CHANNEL_CH3
2320 * @arg @ref LL_TIM_CHANNEL_CH4
2321 * @arg @ref LL_TIM_CHANNEL_CH5
2322 * @arg @ref LL_TIM_CHANNEL_CH6
2323 * @retval State of bit (1 or 0).
2325 __STATIC_INLINE uint32_t LL_TIM_OC_IsEnabledClear(TIM_TypeDef *TIMx, uint32_t Channel)
2327 register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
2328 register const __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
2329 register uint32_t bitfield = TIM_CCMR1_OC1CE << SHIFT_TAB_OCxx[iChannel];
2330 return ((READ_BIT(*pReg, bitfield) == bitfield) ? 1UL : 0UL);
2334 * @brief Set the dead-time delay (delay inserted between the rising edge of the OCxREF signal and the rising edge of the Ocx and OCxN signals).
2335 * @note Macro @ref IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
2336 * dead-time insertion feature is supported by a timer instance.
2337 * @note Helper macro @ref __LL_TIM_CALC_DEADTIME can be used to calculate the DeadTime parameter
2338 * @rmtoll BDTR DTG LL_TIM_OC_SetDeadTime
2339 * @param TIMx Timer instance
2340 * @param DeadTime between Min_Data=0 and Max_Data=255
2341 * @retval None
2343 __STATIC_INLINE void LL_TIM_OC_SetDeadTime(TIM_TypeDef *TIMx, uint32_t DeadTime)
2345 MODIFY_REG(TIMx->BDTR, TIM_BDTR_DTG, DeadTime);
2349 * @brief Set compare value for output channel 1 (TIMx_CCR1).
2350 * @note In 32-bit timer implementations compare value can be between 0x00000000 and 0xFFFFFFFF.
2351 * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
2352 * whether or not a timer instance supports a 32 bits counter.
2353 * @note Macro @ref IS_TIM_CC1_INSTANCE(TIMx) can be used to check whether or not
2354 * output channel 1 is supported by a timer instance.
2355 * @rmtoll CCR1 CCR1 LL_TIM_OC_SetCompareCH1
2356 * @param TIMx Timer instance
2357 * @param CompareValue between Min_Data=0 and Max_Data=65535
2358 * @retval None
2360 __STATIC_INLINE void LL_TIM_OC_SetCompareCH1(TIM_TypeDef *TIMx, uint32_t CompareValue)
2362 WRITE_REG(TIMx->CCR1, CompareValue);
2366 * @brief Set compare value for output channel 2 (TIMx_CCR2).
2367 * @note In 32-bit timer implementations compare value can be between 0x00000000 and 0xFFFFFFFF.
2368 * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
2369 * whether or not a timer instance supports a 32 bits counter.
2370 * @note Macro @ref IS_TIM_CC2_INSTANCE(TIMx) can be used to check whether or not
2371 * output channel 2 is supported by a timer instance.
2372 * @rmtoll CCR2 CCR2 LL_TIM_OC_SetCompareCH2
2373 * @param TIMx Timer instance
2374 * @param CompareValue between Min_Data=0 and Max_Data=65535
2375 * @retval None
2377 __STATIC_INLINE void LL_TIM_OC_SetCompareCH2(TIM_TypeDef *TIMx, uint32_t CompareValue)
2379 WRITE_REG(TIMx->CCR2, CompareValue);
2383 * @brief Set compare value for output channel 3 (TIMx_CCR3).
2384 * @note In 32-bit timer implementations compare value can be between 0x00000000 and 0xFFFFFFFF.
2385 * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
2386 * whether or not a timer instance supports a 32 bits counter.
2387 * @note Macro @ref IS_TIM_CC3_INSTANCE(TIMx) can be used to check whether or not
2388 * output channel is supported by a timer instance.
2389 * @rmtoll CCR3 CCR3 LL_TIM_OC_SetCompareCH3
2390 * @param TIMx Timer instance
2391 * @param CompareValue between Min_Data=0 and Max_Data=65535
2392 * @retval None
2394 __STATIC_INLINE void LL_TIM_OC_SetCompareCH3(TIM_TypeDef *TIMx, uint32_t CompareValue)
2396 WRITE_REG(TIMx->CCR3, CompareValue);
2400 * @brief Set compare value for output channel 4 (TIMx_CCR4).
2401 * @note In 32-bit timer implementations compare value can be between 0x00000000 and 0xFFFFFFFF.
2402 * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
2403 * whether or not a timer instance supports a 32 bits counter.
2404 * @note Macro @ref IS_TIM_CC4_INSTANCE(TIMx) can be used to check whether or not
2405 * output channel 4 is supported by a timer instance.
2406 * @rmtoll CCR4 CCR4 LL_TIM_OC_SetCompareCH4
2407 * @param TIMx Timer instance
2408 * @param CompareValue between Min_Data=0 and Max_Data=65535
2409 * @retval None
2411 __STATIC_INLINE void LL_TIM_OC_SetCompareCH4(TIM_TypeDef *TIMx, uint32_t CompareValue)
2413 WRITE_REG(TIMx->CCR4, CompareValue);
2417 * @brief Set compare value for output channel 5 (TIMx_CCR5).
2418 * @note Macro @ref IS_TIM_CC5_INSTANCE(TIMx) can be used to check whether or not
2419 * output channel 5 is supported by a timer instance.
2420 * @rmtoll CCR5 CCR5 LL_TIM_OC_SetCompareCH5
2421 * @param TIMx Timer instance
2422 * @param CompareValue between Min_Data=0 and Max_Data=65535
2423 * @retval None
2425 __STATIC_INLINE void LL_TIM_OC_SetCompareCH5(TIM_TypeDef *TIMx, uint32_t CompareValue)
2427 MODIFY_REG(TIMx->CCR5, TIM_CCR5_CCR5, CompareValue);
2431 * @brief Set compare value for output channel 6 (TIMx_CCR6).
2432 * @note Macro @ref IS_TIM_CC6_INSTANCE(TIMx) can be used to check whether or not
2433 * output channel 6 is supported by a timer instance.
2434 * @rmtoll CCR6 CCR6 LL_TIM_OC_SetCompareCH6
2435 * @param TIMx Timer instance
2436 * @param CompareValue between Min_Data=0 and Max_Data=65535
2437 * @retval None
2439 __STATIC_INLINE void LL_TIM_OC_SetCompareCH6(TIM_TypeDef *TIMx, uint32_t CompareValue)
2441 WRITE_REG(TIMx->CCR6, CompareValue);
2445 * @brief Get compare value (TIMx_CCR1) set for output channel 1.
2446 * @note In 32-bit timer implementations returned compare value can be between 0x00000000 and 0xFFFFFFFF.
2447 * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
2448 * whether or not a timer instance supports a 32 bits counter.
2449 * @note Macro @ref IS_TIM_CC1_INSTANCE(TIMx) can be used to check whether or not
2450 * output channel 1 is supported by a timer instance.
2451 * @rmtoll CCR1 CCR1 LL_TIM_OC_GetCompareCH1
2452 * @param TIMx Timer instance
2453 * @retval CompareValue (between Min_Data=0 and Max_Data=65535)
2455 __STATIC_INLINE uint32_t LL_TIM_OC_GetCompareCH1(TIM_TypeDef *TIMx)
2457 return (uint32_t)(READ_REG(TIMx->CCR1));
2461 * @brief Get compare value (TIMx_CCR2) set for output channel 2.
2462 * @note In 32-bit timer implementations returned compare value can be between 0x00000000 and 0xFFFFFFFF.
2463 * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
2464 * whether or not a timer instance supports a 32 bits counter.
2465 * @note Macro @ref IS_TIM_CC2_INSTANCE(TIMx) can be used to check whether or not
2466 * output channel 2 is supported by a timer instance.
2467 * @rmtoll CCR2 CCR2 LL_TIM_OC_GetCompareCH2
2468 * @param TIMx Timer instance
2469 * @retval CompareValue (between Min_Data=0 and Max_Data=65535)
2471 __STATIC_INLINE uint32_t LL_TIM_OC_GetCompareCH2(TIM_TypeDef *TIMx)
2473 return (uint32_t)(READ_REG(TIMx->CCR2));
2477 * @brief Get compare value (TIMx_CCR3) set for output channel 3.
2478 * @note In 32-bit timer implementations returned compare value can be between 0x00000000 and 0xFFFFFFFF.
2479 * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
2480 * whether or not a timer instance supports a 32 bits counter.
2481 * @note Macro @ref IS_TIM_CC3_INSTANCE(TIMx) can be used to check whether or not
2482 * output channel 3 is supported by a timer instance.
2483 * @rmtoll CCR3 CCR3 LL_TIM_OC_GetCompareCH3
2484 * @param TIMx Timer instance
2485 * @retval CompareValue (between Min_Data=0 and Max_Data=65535)
2487 __STATIC_INLINE uint32_t LL_TIM_OC_GetCompareCH3(TIM_TypeDef *TIMx)
2489 return (uint32_t)(READ_REG(TIMx->CCR3));
2493 * @brief Get compare value (TIMx_CCR4) set for output channel 4.
2494 * @note In 32-bit timer implementations returned compare value can be between 0x00000000 and 0xFFFFFFFF.
2495 * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
2496 * whether or not a timer instance supports a 32 bits counter.
2497 * @note Macro @ref IS_TIM_CC4_INSTANCE(TIMx) can be used to check whether or not
2498 * output channel 4 is supported by a timer instance.
2499 * @rmtoll CCR4 CCR4 LL_TIM_OC_GetCompareCH4
2500 * @param TIMx Timer instance
2501 * @retval CompareValue (between Min_Data=0 and Max_Data=65535)
2503 __STATIC_INLINE uint32_t LL_TIM_OC_GetCompareCH4(TIM_TypeDef *TIMx)
2505 return (uint32_t)(READ_REG(TIMx->CCR4));
2509 * @brief Get compare value (TIMx_CCR5) set for output channel 5.
2510 * @note Macro @ref IS_TIM_CC5_INSTANCE(TIMx) can be used to check whether or not
2511 * output channel 5 is supported by a timer instance.
2512 * @rmtoll CCR5 CCR5 LL_TIM_OC_GetCompareCH5
2513 * @param TIMx Timer instance
2514 * @retval CompareValue (between Min_Data=0 and Max_Data=65535)
2516 __STATIC_INLINE uint32_t LL_TIM_OC_GetCompareCH5(TIM_TypeDef *TIMx)
2518 return (uint32_t)(READ_BIT(TIMx->CCR5, TIM_CCR5_CCR5));
2522 * @brief Get compare value (TIMx_CCR6) set for output channel 6.
2523 * @note Macro @ref IS_TIM_CC6_INSTANCE(TIMx) can be used to check whether or not
2524 * output channel 6 is supported by a timer instance.
2525 * @rmtoll CCR6 CCR6 LL_TIM_OC_GetCompareCH6
2526 * @param TIMx Timer instance
2527 * @retval CompareValue (between Min_Data=0 and Max_Data=65535)
2529 __STATIC_INLINE uint32_t LL_TIM_OC_GetCompareCH6(TIM_TypeDef *TIMx)
2531 return (uint32_t)(READ_REG(TIMx->CCR6));
2535 * @brief Select on which reference signal the OC5REF is combined to.
2536 * @note Macro @ref IS_TIM_COMBINED3PHASEPWM_INSTANCE(TIMx) can be used to check
2537 * whether or not a timer instance supports the combined 3-phase PWM mode.
2538 * @rmtoll CCR5 GC5C3 LL_TIM_SetCH5CombinedChannels\n
2539 * CCR5 GC5C2 LL_TIM_SetCH5CombinedChannels\n
2540 * CCR5 GC5C1 LL_TIM_SetCH5CombinedChannels
2541 * @param TIMx Timer instance
2542 * @param GroupCH5 This parameter can be a combination of the following values:
2543 * @arg @ref LL_TIM_GROUPCH5_NONE
2544 * @arg @ref LL_TIM_GROUPCH5_OC1REFC
2545 * @arg @ref LL_TIM_GROUPCH5_OC2REFC
2546 * @arg @ref LL_TIM_GROUPCH5_OC3REFC
2547 * @retval None
2549 __STATIC_INLINE void LL_TIM_SetCH5CombinedChannels(TIM_TypeDef *TIMx, uint32_t GroupCH5)
2551 MODIFY_REG(TIMx->CCR5, (TIM_CCR5_GC5C3 | TIM_CCR5_GC5C2 | TIM_CCR5_GC5C1), GroupCH5);
2555 * @}
2558 /** @defgroup TIM_LL_EF_Input_Channel Input channel configuration
2559 * @{
2562 * @brief Configure input channel.
2563 * @rmtoll CCMR1 CC1S LL_TIM_IC_Config\n
2564 * CCMR1 IC1PSC LL_TIM_IC_Config\n
2565 * CCMR1 IC1F LL_TIM_IC_Config\n
2566 * CCMR1 CC2S LL_TIM_IC_Config\n
2567 * CCMR1 IC2PSC LL_TIM_IC_Config\n
2568 * CCMR1 IC2F LL_TIM_IC_Config\n
2569 * CCMR2 CC3S LL_TIM_IC_Config\n
2570 * CCMR2 IC3PSC LL_TIM_IC_Config\n
2571 * CCMR2 IC3F LL_TIM_IC_Config\n
2572 * CCMR2 CC4S LL_TIM_IC_Config\n
2573 * CCMR2 IC4PSC LL_TIM_IC_Config\n
2574 * CCMR2 IC4F LL_TIM_IC_Config\n
2575 * CCER CC1P LL_TIM_IC_Config\n
2576 * CCER CC1NP LL_TIM_IC_Config\n
2577 * CCER CC2P LL_TIM_IC_Config\n
2578 * CCER CC2NP LL_TIM_IC_Config\n
2579 * CCER CC3P LL_TIM_IC_Config\n
2580 * CCER CC3NP LL_TIM_IC_Config\n
2581 * CCER CC4P LL_TIM_IC_Config\n
2582 * CCER CC4NP LL_TIM_IC_Config
2583 * @param TIMx Timer instance
2584 * @param Channel This parameter can be one of the following values:
2585 * @arg @ref LL_TIM_CHANNEL_CH1
2586 * @arg @ref LL_TIM_CHANNEL_CH2
2587 * @arg @ref LL_TIM_CHANNEL_CH3
2588 * @arg @ref LL_TIM_CHANNEL_CH4
2589 * @param Configuration This parameter must be a combination of all the following values:
2590 * @arg @ref LL_TIM_ACTIVEINPUT_DIRECTTI or @ref LL_TIM_ACTIVEINPUT_INDIRECTTI or @ref LL_TIM_ACTIVEINPUT_TRC
2591 * @arg @ref LL_TIM_ICPSC_DIV1 or ... or @ref LL_TIM_ICPSC_DIV8
2592 * @arg @ref LL_TIM_IC_FILTER_FDIV1 or ... or @ref LL_TIM_IC_FILTER_FDIV32_N8
2593 * @arg @ref LL_TIM_IC_POLARITY_RISING or @ref LL_TIM_IC_POLARITY_FALLING or @ref LL_TIM_IC_POLARITY_BOTHEDGE
2594 * @retval None
2596 __STATIC_INLINE void LL_TIM_IC_Config(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t Configuration)
2598 register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
2599 register __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
2600 MODIFY_REG(*pReg, ((TIM_CCMR1_IC1F | TIM_CCMR1_IC1PSC | TIM_CCMR1_CC1S) << SHIFT_TAB_ICxx[iChannel]),
2601 ((Configuration >> 16U) & (TIM_CCMR1_IC1F | TIM_CCMR1_IC1PSC | TIM_CCMR1_CC1S)) << SHIFT_TAB_ICxx[iChannel]);
2602 MODIFY_REG(TIMx->CCER, ((TIM_CCER_CC1NP | TIM_CCER_CC1P) << SHIFT_TAB_CCxP[iChannel]),
2603 (Configuration & (TIM_CCER_CC1NP | TIM_CCER_CC1P)) << SHIFT_TAB_CCxP[iChannel]);
2607 * @brief Set the active input.
2608 * @rmtoll CCMR1 CC1S LL_TIM_IC_SetActiveInput\n
2609 * CCMR1 CC2S LL_TIM_IC_SetActiveInput\n
2610 * CCMR2 CC3S LL_TIM_IC_SetActiveInput\n
2611 * CCMR2 CC4S LL_TIM_IC_SetActiveInput
2612 * @param TIMx Timer instance
2613 * @param Channel This parameter can be one of the following values:
2614 * @arg @ref LL_TIM_CHANNEL_CH1
2615 * @arg @ref LL_TIM_CHANNEL_CH2
2616 * @arg @ref LL_TIM_CHANNEL_CH3
2617 * @arg @ref LL_TIM_CHANNEL_CH4
2618 * @param ICActiveInput This parameter can be one of the following values:
2619 * @arg @ref LL_TIM_ACTIVEINPUT_DIRECTTI
2620 * @arg @ref LL_TIM_ACTIVEINPUT_INDIRECTTI
2621 * @arg @ref LL_TIM_ACTIVEINPUT_TRC
2622 * @retval None
2624 __STATIC_INLINE void LL_TIM_IC_SetActiveInput(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t ICActiveInput)
2626 register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
2627 register __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
2628 MODIFY_REG(*pReg, ((TIM_CCMR1_CC1S) << SHIFT_TAB_ICxx[iChannel]), (ICActiveInput >> 16U) << SHIFT_TAB_ICxx[iChannel]);
2632 * @brief Get the current active input.
2633 * @rmtoll CCMR1 CC1S LL_TIM_IC_GetActiveInput\n
2634 * CCMR1 CC2S LL_TIM_IC_GetActiveInput\n
2635 * CCMR2 CC3S LL_TIM_IC_GetActiveInput\n
2636 * CCMR2 CC4S LL_TIM_IC_GetActiveInput
2637 * @param TIMx Timer instance
2638 * @param Channel This parameter can be one of the following values:
2639 * @arg @ref LL_TIM_CHANNEL_CH1
2640 * @arg @ref LL_TIM_CHANNEL_CH2
2641 * @arg @ref LL_TIM_CHANNEL_CH3
2642 * @arg @ref LL_TIM_CHANNEL_CH4
2643 * @retval Returned value can be one of the following values:
2644 * @arg @ref LL_TIM_ACTIVEINPUT_DIRECTTI
2645 * @arg @ref LL_TIM_ACTIVEINPUT_INDIRECTTI
2646 * @arg @ref LL_TIM_ACTIVEINPUT_TRC
2648 __STATIC_INLINE uint32_t LL_TIM_IC_GetActiveInput(TIM_TypeDef *TIMx, uint32_t Channel)
2650 register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
2651 register const __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
2652 return ((READ_BIT(*pReg, ((TIM_CCMR1_CC1S) << SHIFT_TAB_ICxx[iChannel])) >> SHIFT_TAB_ICxx[iChannel]) << 16U);
2656 * @brief Set the prescaler of input channel.
2657 * @rmtoll CCMR1 IC1PSC LL_TIM_IC_SetPrescaler\n
2658 * CCMR1 IC2PSC LL_TIM_IC_SetPrescaler\n
2659 * CCMR2 IC3PSC LL_TIM_IC_SetPrescaler\n
2660 * CCMR2 IC4PSC LL_TIM_IC_SetPrescaler
2661 * @param TIMx Timer instance
2662 * @param Channel This parameter can be one of the following values:
2663 * @arg @ref LL_TIM_CHANNEL_CH1
2664 * @arg @ref LL_TIM_CHANNEL_CH2
2665 * @arg @ref LL_TIM_CHANNEL_CH3
2666 * @arg @ref LL_TIM_CHANNEL_CH4
2667 * @param ICPrescaler This parameter can be one of the following values:
2668 * @arg @ref LL_TIM_ICPSC_DIV1
2669 * @arg @ref LL_TIM_ICPSC_DIV2
2670 * @arg @ref LL_TIM_ICPSC_DIV4
2671 * @arg @ref LL_TIM_ICPSC_DIV8
2672 * @retval None
2674 __STATIC_INLINE void LL_TIM_IC_SetPrescaler(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t ICPrescaler)
2676 register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
2677 register __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
2678 MODIFY_REG(*pReg, ((TIM_CCMR1_IC1PSC) << SHIFT_TAB_ICxx[iChannel]), (ICPrescaler >> 16U) << SHIFT_TAB_ICxx[iChannel]);
2682 * @brief Get the current prescaler value acting on an input channel.
2683 * @rmtoll CCMR1 IC1PSC LL_TIM_IC_GetPrescaler\n
2684 * CCMR1 IC2PSC LL_TIM_IC_GetPrescaler\n
2685 * CCMR2 IC3PSC LL_TIM_IC_GetPrescaler\n
2686 * CCMR2 IC4PSC LL_TIM_IC_GetPrescaler
2687 * @param TIMx Timer instance
2688 * @param Channel This parameter can be one of the following values:
2689 * @arg @ref LL_TIM_CHANNEL_CH1
2690 * @arg @ref LL_TIM_CHANNEL_CH2
2691 * @arg @ref LL_TIM_CHANNEL_CH3
2692 * @arg @ref LL_TIM_CHANNEL_CH4
2693 * @retval Returned value can be one of the following values:
2694 * @arg @ref LL_TIM_ICPSC_DIV1
2695 * @arg @ref LL_TIM_ICPSC_DIV2
2696 * @arg @ref LL_TIM_ICPSC_DIV4
2697 * @arg @ref LL_TIM_ICPSC_DIV8
2699 __STATIC_INLINE uint32_t LL_TIM_IC_GetPrescaler(TIM_TypeDef *TIMx, uint32_t Channel)
2701 register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
2702 register const __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
2703 return ((READ_BIT(*pReg, ((TIM_CCMR1_IC1PSC) << SHIFT_TAB_ICxx[iChannel])) >> SHIFT_TAB_ICxx[iChannel]) << 16U);
2707 * @brief Set the input filter duration.
2708 * @rmtoll CCMR1 IC1F LL_TIM_IC_SetFilter\n
2709 * CCMR1 IC2F LL_TIM_IC_SetFilter\n
2710 * CCMR2 IC3F LL_TIM_IC_SetFilter\n
2711 * CCMR2 IC4F LL_TIM_IC_SetFilter
2712 * @param TIMx Timer instance
2713 * @param Channel This parameter can be one of the following values:
2714 * @arg @ref LL_TIM_CHANNEL_CH1
2715 * @arg @ref LL_TIM_CHANNEL_CH2
2716 * @arg @ref LL_TIM_CHANNEL_CH3
2717 * @arg @ref LL_TIM_CHANNEL_CH4
2718 * @param ICFilter This parameter can be one of the following values:
2719 * @arg @ref LL_TIM_IC_FILTER_FDIV1
2720 * @arg @ref LL_TIM_IC_FILTER_FDIV1_N2
2721 * @arg @ref LL_TIM_IC_FILTER_FDIV1_N4
2722 * @arg @ref LL_TIM_IC_FILTER_FDIV1_N8
2723 * @arg @ref LL_TIM_IC_FILTER_FDIV2_N6
2724 * @arg @ref LL_TIM_IC_FILTER_FDIV2_N8
2725 * @arg @ref LL_TIM_IC_FILTER_FDIV4_N6
2726 * @arg @ref LL_TIM_IC_FILTER_FDIV4_N8
2727 * @arg @ref LL_TIM_IC_FILTER_FDIV8_N6
2728 * @arg @ref LL_TIM_IC_FILTER_FDIV8_N8
2729 * @arg @ref LL_TIM_IC_FILTER_FDIV16_N5
2730 * @arg @ref LL_TIM_IC_FILTER_FDIV16_N6
2731 * @arg @ref LL_TIM_IC_FILTER_FDIV16_N8
2732 * @arg @ref LL_TIM_IC_FILTER_FDIV32_N5
2733 * @arg @ref LL_TIM_IC_FILTER_FDIV32_N6
2734 * @arg @ref LL_TIM_IC_FILTER_FDIV32_N8
2735 * @retval None
2737 __STATIC_INLINE void LL_TIM_IC_SetFilter(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t ICFilter)
2739 register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
2740 register __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
2741 MODIFY_REG(*pReg, ((TIM_CCMR1_IC1F) << SHIFT_TAB_ICxx[iChannel]), (ICFilter >> 16U) << SHIFT_TAB_ICxx[iChannel]);
2745 * @brief Get the input filter duration.
2746 * @rmtoll CCMR1 IC1F LL_TIM_IC_GetFilter\n
2747 * CCMR1 IC2F LL_TIM_IC_GetFilter\n
2748 * CCMR2 IC3F LL_TIM_IC_GetFilter\n
2749 * CCMR2 IC4F LL_TIM_IC_GetFilter
2750 * @param TIMx Timer instance
2751 * @param Channel This parameter can be one of the following values:
2752 * @arg @ref LL_TIM_CHANNEL_CH1
2753 * @arg @ref LL_TIM_CHANNEL_CH2
2754 * @arg @ref LL_TIM_CHANNEL_CH3
2755 * @arg @ref LL_TIM_CHANNEL_CH4
2756 * @retval Returned value can be one of the following values:
2757 * @arg @ref LL_TIM_IC_FILTER_FDIV1
2758 * @arg @ref LL_TIM_IC_FILTER_FDIV1_N2
2759 * @arg @ref LL_TIM_IC_FILTER_FDIV1_N4
2760 * @arg @ref LL_TIM_IC_FILTER_FDIV1_N8
2761 * @arg @ref LL_TIM_IC_FILTER_FDIV2_N6
2762 * @arg @ref LL_TIM_IC_FILTER_FDIV2_N8
2763 * @arg @ref LL_TIM_IC_FILTER_FDIV4_N6
2764 * @arg @ref LL_TIM_IC_FILTER_FDIV4_N8
2765 * @arg @ref LL_TIM_IC_FILTER_FDIV8_N6
2766 * @arg @ref LL_TIM_IC_FILTER_FDIV8_N8
2767 * @arg @ref LL_TIM_IC_FILTER_FDIV16_N5
2768 * @arg @ref LL_TIM_IC_FILTER_FDIV16_N6
2769 * @arg @ref LL_TIM_IC_FILTER_FDIV16_N8
2770 * @arg @ref LL_TIM_IC_FILTER_FDIV32_N5
2771 * @arg @ref LL_TIM_IC_FILTER_FDIV32_N6
2772 * @arg @ref LL_TIM_IC_FILTER_FDIV32_N8
2774 __STATIC_INLINE uint32_t LL_TIM_IC_GetFilter(TIM_TypeDef *TIMx, uint32_t Channel)
2776 register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
2777 register const __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
2778 return ((READ_BIT(*pReg, ((TIM_CCMR1_IC1F) << SHIFT_TAB_ICxx[iChannel])) >> SHIFT_TAB_ICxx[iChannel]) << 16U);
2782 * @brief Set the input channel polarity.
2783 * @rmtoll CCER CC1P LL_TIM_IC_SetPolarity\n
2784 * CCER CC1NP LL_TIM_IC_SetPolarity\n
2785 * CCER CC2P LL_TIM_IC_SetPolarity\n
2786 * CCER CC2NP LL_TIM_IC_SetPolarity\n
2787 * CCER CC3P LL_TIM_IC_SetPolarity\n
2788 * CCER CC3NP LL_TIM_IC_SetPolarity\n
2789 * CCER CC4P LL_TIM_IC_SetPolarity\n
2790 * CCER CC4NP LL_TIM_IC_SetPolarity
2791 * @param TIMx Timer instance
2792 * @param Channel This parameter can be one of the following values:
2793 * @arg @ref LL_TIM_CHANNEL_CH1
2794 * @arg @ref LL_TIM_CHANNEL_CH2
2795 * @arg @ref LL_TIM_CHANNEL_CH3
2796 * @arg @ref LL_TIM_CHANNEL_CH4
2797 * @param ICPolarity This parameter can be one of the following values:
2798 * @arg @ref LL_TIM_IC_POLARITY_RISING
2799 * @arg @ref LL_TIM_IC_POLARITY_FALLING
2800 * @arg @ref LL_TIM_IC_POLARITY_BOTHEDGE
2801 * @retval None
2803 __STATIC_INLINE void LL_TIM_IC_SetPolarity(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t ICPolarity)
2805 register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
2806 MODIFY_REG(TIMx->CCER, ((TIM_CCER_CC1NP | TIM_CCER_CC1P) << SHIFT_TAB_CCxP[iChannel]),
2807 ICPolarity << SHIFT_TAB_CCxP[iChannel]);
2811 * @brief Get the current input channel polarity.
2812 * @rmtoll CCER CC1P LL_TIM_IC_GetPolarity\n
2813 * CCER CC1NP LL_TIM_IC_GetPolarity\n
2814 * CCER CC2P LL_TIM_IC_GetPolarity\n
2815 * CCER CC2NP LL_TIM_IC_GetPolarity\n
2816 * CCER CC3P LL_TIM_IC_GetPolarity\n
2817 * CCER CC3NP LL_TIM_IC_GetPolarity\n
2818 * CCER CC4P LL_TIM_IC_GetPolarity\n
2819 * CCER CC4NP LL_TIM_IC_GetPolarity
2820 * @param TIMx Timer instance
2821 * @param Channel This parameter can be one of the following values:
2822 * @arg @ref LL_TIM_CHANNEL_CH1
2823 * @arg @ref LL_TIM_CHANNEL_CH2
2824 * @arg @ref LL_TIM_CHANNEL_CH3
2825 * @arg @ref LL_TIM_CHANNEL_CH4
2826 * @retval Returned value can be one of the following values:
2827 * @arg @ref LL_TIM_IC_POLARITY_RISING
2828 * @arg @ref LL_TIM_IC_POLARITY_FALLING
2829 * @arg @ref LL_TIM_IC_POLARITY_BOTHEDGE
2831 __STATIC_INLINE uint32_t LL_TIM_IC_GetPolarity(TIM_TypeDef *TIMx, uint32_t Channel)
2833 register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
2834 return (READ_BIT(TIMx->CCER, ((TIM_CCER_CC1NP | TIM_CCER_CC1P) << SHIFT_TAB_CCxP[iChannel])) >>
2835 SHIFT_TAB_CCxP[iChannel]);
2839 * @brief Connect the TIMx_CH1, CH2 and CH3 pins to the TI1 input (XOR combination).
2840 * @note Macro @ref IS_TIM_XOR_INSTANCE(TIMx) can be used to check whether or not
2841 * a timer instance provides an XOR input.
2842 * @rmtoll CR2 TI1S LL_TIM_IC_EnableXORCombination
2843 * @param TIMx Timer instance
2844 * @retval None
2846 __STATIC_INLINE void LL_TIM_IC_EnableXORCombination(TIM_TypeDef *TIMx)
2848 SET_BIT(TIMx->CR2, TIM_CR2_TI1S);
2852 * @brief Disconnect the TIMx_CH1, CH2 and CH3 pins from the TI1 input.
2853 * @note Macro @ref IS_TIM_XOR_INSTANCE(TIMx) can be used to check whether or not
2854 * a timer instance provides an XOR input.
2855 * @rmtoll CR2 TI1S LL_TIM_IC_DisableXORCombination
2856 * @param TIMx Timer instance
2857 * @retval None
2859 __STATIC_INLINE void LL_TIM_IC_DisableXORCombination(TIM_TypeDef *TIMx)
2861 CLEAR_BIT(TIMx->CR2, TIM_CR2_TI1S);
2865 * @brief Indicates whether the TIMx_CH1, CH2 and CH3 pins are connectected to the TI1 input.
2866 * @note Macro @ref IS_TIM_XOR_INSTANCE(TIMx) can be used to check whether or not
2867 * a timer instance provides an XOR input.
2868 * @rmtoll CR2 TI1S LL_TIM_IC_IsEnabledXORCombination
2869 * @param TIMx Timer instance
2870 * @retval State of bit (1 or 0).
2872 __STATIC_INLINE uint32_t LL_TIM_IC_IsEnabledXORCombination(TIM_TypeDef *TIMx)
2874 return ((READ_BIT(TIMx->CR2, TIM_CR2_TI1S) == (TIM_CR2_TI1S)) ? 1UL : 0UL);
2878 * @brief Get captured value for input channel 1.
2879 * @note In 32-bit timer implementations returned captured value can be between 0x00000000 and 0xFFFFFFFF.
2880 * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
2881 * whether or not a timer instance supports a 32 bits counter.
2882 * @note Macro @ref IS_TIM_CC1_INSTANCE(TIMx) can be used to check whether or not
2883 * input channel 1 is supported by a timer instance.
2884 * @rmtoll CCR1 CCR1 LL_TIM_IC_GetCaptureCH1
2885 * @param TIMx Timer instance
2886 * @retval CapturedValue (between Min_Data=0 and Max_Data=65535)
2888 __STATIC_INLINE uint32_t LL_TIM_IC_GetCaptureCH1(TIM_TypeDef *TIMx)
2890 return (uint32_t)(READ_REG(TIMx->CCR1));
2894 * @brief Get captured value for input channel 2.
2895 * @note In 32-bit timer implementations returned captured value can be between 0x00000000 and 0xFFFFFFFF.
2896 * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
2897 * whether or not a timer instance supports a 32 bits counter.
2898 * @note Macro @ref IS_TIM_CC2_INSTANCE(TIMx) can be used to check whether or not
2899 * input channel 2 is supported by a timer instance.
2900 * @rmtoll CCR2 CCR2 LL_TIM_IC_GetCaptureCH2
2901 * @param TIMx Timer instance
2902 * @retval CapturedValue (between Min_Data=0 and Max_Data=65535)
2904 __STATIC_INLINE uint32_t LL_TIM_IC_GetCaptureCH2(TIM_TypeDef *TIMx)
2906 return (uint32_t)(READ_REG(TIMx->CCR2));
2910 * @brief Get captured value for input channel 3.
2911 * @note In 32-bit timer implementations returned captured value can be between 0x00000000 and 0xFFFFFFFF.
2912 * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
2913 * whether or not a timer instance supports a 32 bits counter.
2914 * @note Macro @ref IS_TIM_CC3_INSTANCE(TIMx) can be used to check whether or not
2915 * input channel 3 is supported by a timer instance.
2916 * @rmtoll CCR3 CCR3 LL_TIM_IC_GetCaptureCH3
2917 * @param TIMx Timer instance
2918 * @retval CapturedValue (between Min_Data=0 and Max_Data=65535)
2920 __STATIC_INLINE uint32_t LL_TIM_IC_GetCaptureCH3(TIM_TypeDef *TIMx)
2922 return (uint32_t)(READ_REG(TIMx->CCR3));
2926 * @brief Get captured value for input channel 4.
2927 * @note In 32-bit timer implementations returned captured value can be between 0x00000000 and 0xFFFFFFFF.
2928 * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
2929 * whether or not a timer instance supports a 32 bits counter.
2930 * @note Macro @ref IS_TIM_CC4_INSTANCE(TIMx) can be used to check whether or not
2931 * input channel 4 is supported by a timer instance.
2932 * @rmtoll CCR4 CCR4 LL_TIM_IC_GetCaptureCH4
2933 * @param TIMx Timer instance
2934 * @retval CapturedValue (between Min_Data=0 and Max_Data=65535)
2936 __STATIC_INLINE uint32_t LL_TIM_IC_GetCaptureCH4(TIM_TypeDef *TIMx)
2938 return (uint32_t)(READ_REG(TIMx->CCR4));
2942 * @}
2945 /** @defgroup TIM_LL_EF_Clock_Selection Counter clock selection
2946 * @{
2949 * @brief Enable external clock mode 2.
2950 * @note When external clock mode 2 is enabled the counter is clocked by any active edge on the ETRF signal.
2951 * @note Macro @ref IS_TIM_CLOCKSOURCE_ETRMODE2_INSTANCE(TIMx) can be used to check
2952 * whether or not a timer instance supports external clock mode2.
2953 * @rmtoll SMCR ECE LL_TIM_EnableExternalClock
2954 * @param TIMx Timer instance
2955 * @retval None
2957 __STATIC_INLINE void LL_TIM_EnableExternalClock(TIM_TypeDef *TIMx)
2959 SET_BIT(TIMx->SMCR, TIM_SMCR_ECE);
2963 * @brief Disable external clock mode 2.
2964 * @note Macro @ref IS_TIM_CLOCKSOURCE_ETRMODE2_INSTANCE(TIMx) can be used to check
2965 * whether or not a timer instance supports external clock mode2.
2966 * @rmtoll SMCR ECE LL_TIM_DisableExternalClock
2967 * @param TIMx Timer instance
2968 * @retval None
2970 __STATIC_INLINE void LL_TIM_DisableExternalClock(TIM_TypeDef *TIMx)
2972 CLEAR_BIT(TIMx->SMCR, TIM_SMCR_ECE);
2976 * @brief Indicate whether external clock mode 2 is enabled.
2977 * @note Macro @ref IS_TIM_CLOCKSOURCE_ETRMODE2_INSTANCE(TIMx) can be used to check
2978 * whether or not a timer instance supports external clock mode2.
2979 * @rmtoll SMCR ECE LL_TIM_IsEnabledExternalClock
2980 * @param TIMx Timer instance
2981 * @retval State of bit (1 or 0).
2983 __STATIC_INLINE uint32_t LL_TIM_IsEnabledExternalClock(TIM_TypeDef *TIMx)
2985 return ((READ_BIT(TIMx->SMCR, TIM_SMCR_ECE) == (TIM_SMCR_ECE)) ? 1UL : 0UL);
2989 * @brief Set the clock source of the counter clock.
2990 * @note when selected clock source is external clock mode 1, the timer input
2991 * the external clock is applied is selected by calling the @ref LL_TIM_SetTriggerInput()
2992 * function. This timer input must be configured by calling
2993 * the @ref LL_TIM_IC_Config() function.
2994 * @note Macro @ref IS_TIM_CLOCKSOURCE_ETRMODE1_INSTANCE(TIMx) can be used to check
2995 * whether or not a timer instance supports external clock mode1.
2996 * @note Macro @ref IS_TIM_CLOCKSOURCE_ETRMODE2_INSTANCE(TIMx) can be used to check
2997 * whether or not a timer instance supports external clock mode2.
2998 * @rmtoll SMCR SMS LL_TIM_SetClockSource\n
2999 * SMCR ECE LL_TIM_SetClockSource
3000 * @param TIMx Timer instance
3001 * @param ClockSource This parameter can be one of the following values:
3002 * @arg @ref LL_TIM_CLOCKSOURCE_INTERNAL
3003 * @arg @ref LL_TIM_CLOCKSOURCE_EXT_MODE1
3004 * @arg @ref LL_TIM_CLOCKSOURCE_EXT_MODE2
3005 * @retval None
3007 __STATIC_INLINE void LL_TIM_SetClockSource(TIM_TypeDef *TIMx, uint32_t ClockSource)
3009 MODIFY_REG(TIMx->SMCR, TIM_SMCR_SMS | TIM_SMCR_ECE, ClockSource);
3013 * @brief Set the encoder interface mode.
3014 * @note Macro @ref IS_TIM_ENCODER_INTERFACE_INSTANCE(TIMx) can be used to check
3015 * whether or not a timer instance supports the encoder mode.
3016 * @rmtoll SMCR SMS LL_TIM_SetEncoderMode
3017 * @param TIMx Timer instance
3018 * @param EncoderMode This parameter can be one of the following values:
3019 * @arg @ref LL_TIM_ENCODERMODE_X2_TI1
3020 * @arg @ref LL_TIM_ENCODERMODE_X2_TI2
3021 * @arg @ref LL_TIM_ENCODERMODE_X4_TI12
3022 * @retval None
3024 __STATIC_INLINE void LL_TIM_SetEncoderMode(TIM_TypeDef *TIMx, uint32_t EncoderMode)
3026 MODIFY_REG(TIMx->SMCR, TIM_SMCR_SMS, EncoderMode);
3030 * @}
3033 /** @defgroup TIM_LL_EF_Timer_Synchronization Timer synchronisation configuration
3034 * @{
3037 * @brief Set the trigger output (TRGO) used for timer synchronization .
3038 * @note Macro @ref IS_TIM_MASTER_INSTANCE(TIMx) can be used to check
3039 * whether or not a timer instance can operate as a master timer.
3040 * @rmtoll CR2 MMS LL_TIM_SetTriggerOutput
3041 * @param TIMx Timer instance
3042 * @param TimerSynchronization This parameter can be one of the following values:
3043 * @arg @ref LL_TIM_TRGO_RESET
3044 * @arg @ref LL_TIM_TRGO_ENABLE
3045 * @arg @ref LL_TIM_TRGO_UPDATE
3046 * @arg @ref LL_TIM_TRGO_CC1IF
3047 * @arg @ref LL_TIM_TRGO_OC1REF
3048 * @arg @ref LL_TIM_TRGO_OC2REF
3049 * @arg @ref LL_TIM_TRGO_OC3REF
3050 * @arg @ref LL_TIM_TRGO_OC4REF
3051 * @retval None
3053 __STATIC_INLINE void LL_TIM_SetTriggerOutput(TIM_TypeDef *TIMx, uint32_t TimerSynchronization)
3055 MODIFY_REG(TIMx->CR2, TIM_CR2_MMS, TimerSynchronization);
3059 * @brief Set the trigger output 2 (TRGO2) used for ADC synchronization .
3060 * @note Macro @ref IS_TIM_TRGO2_INSTANCE(TIMx) can be used to check
3061 * whether or not a timer instance can be used for ADC synchronization.
3062 * @rmtoll CR2 MMS2 LL_TIM_SetTriggerOutput2
3063 * @param TIMx Timer Instance
3064 * @param ADCSynchronization This parameter can be one of the following values:
3065 * @arg @ref LL_TIM_TRGO2_RESET
3066 * @arg @ref LL_TIM_TRGO2_ENABLE
3067 * @arg @ref LL_TIM_TRGO2_UPDATE
3068 * @arg @ref LL_TIM_TRGO2_CC1F
3069 * @arg @ref LL_TIM_TRGO2_OC1
3070 * @arg @ref LL_TIM_TRGO2_OC2
3071 * @arg @ref LL_TIM_TRGO2_OC3
3072 * @arg @ref LL_TIM_TRGO2_OC4
3073 * @arg @ref LL_TIM_TRGO2_OC5
3074 * @arg @ref LL_TIM_TRGO2_OC6
3075 * @arg @ref LL_TIM_TRGO2_OC4_RISINGFALLING
3076 * @arg @ref LL_TIM_TRGO2_OC6_RISINGFALLING
3077 * @arg @ref LL_TIM_TRGO2_OC4_RISING_OC6_RISING
3078 * @arg @ref LL_TIM_TRGO2_OC4_RISING_OC6_FALLING
3079 * @arg @ref LL_TIM_TRGO2_OC5_RISING_OC6_RISING
3080 * @arg @ref LL_TIM_TRGO2_OC5_RISING_OC6_FALLING
3081 * @retval None
3083 __STATIC_INLINE void LL_TIM_SetTriggerOutput2(TIM_TypeDef *TIMx, uint32_t ADCSynchronization)
3085 MODIFY_REG(TIMx->CR2, TIM_CR2_MMS2, ADCSynchronization);
3089 * @brief Set the synchronization mode of a slave timer.
3090 * @note Macro @ref IS_TIM_SLAVE_INSTANCE(TIMx) can be used to check whether or not
3091 * a timer instance can operate as a slave timer.
3092 * @rmtoll SMCR SMS LL_TIM_SetSlaveMode
3093 * @param TIMx Timer instance
3094 * @param SlaveMode This parameter can be one of the following values:
3095 * @arg @ref LL_TIM_SLAVEMODE_DISABLED
3096 * @arg @ref LL_TIM_SLAVEMODE_RESET
3097 * @arg @ref LL_TIM_SLAVEMODE_GATED
3098 * @arg @ref LL_TIM_SLAVEMODE_TRIGGER
3099 * @arg @ref LL_TIM_SLAVEMODE_COMBINED_RESETTRIGGER
3100 * @retval None
3102 __STATIC_INLINE void LL_TIM_SetSlaveMode(TIM_TypeDef *TIMx, uint32_t SlaveMode)
3104 MODIFY_REG(TIMx->SMCR, TIM_SMCR_SMS, SlaveMode);
3108 * @brief Set the selects the trigger input to be used to synchronize the counter.
3109 * @note Macro @ref IS_TIM_SLAVE_INSTANCE(TIMx) can be used to check whether or not
3110 * a timer instance can operate as a slave timer.
3111 * @rmtoll SMCR TS LL_TIM_SetTriggerInput
3112 * @param TIMx Timer instance
3113 * @param TriggerInput This parameter can be one of the following values:
3114 * @arg @ref LL_TIM_TS_ITR0
3115 * @arg @ref LL_TIM_TS_ITR1
3116 * @arg @ref LL_TIM_TS_ITR2
3117 * @arg @ref LL_TIM_TS_ITR3
3118 * @arg @ref LL_TIM_TS_TI1F_ED
3119 * @arg @ref LL_TIM_TS_TI1FP1
3120 * @arg @ref LL_TIM_TS_TI2FP2
3121 * @arg @ref LL_TIM_TS_ETRF
3122 * @retval None
3124 __STATIC_INLINE void LL_TIM_SetTriggerInput(TIM_TypeDef *TIMx, uint32_t TriggerInput)
3126 MODIFY_REG(TIMx->SMCR, TIM_SMCR_TS, TriggerInput);
3130 * @brief Enable the Master/Slave mode.
3131 * @note Macro @ref IS_TIM_SLAVE_INSTANCE(TIMx) can be used to check whether or not
3132 * a timer instance can operate as a slave timer.
3133 * @rmtoll SMCR MSM LL_TIM_EnableMasterSlaveMode
3134 * @param TIMx Timer instance
3135 * @retval None
3137 __STATIC_INLINE void LL_TIM_EnableMasterSlaveMode(TIM_TypeDef *TIMx)
3139 SET_BIT(TIMx->SMCR, TIM_SMCR_MSM);
3143 * @brief Disable the Master/Slave mode.
3144 * @note Macro @ref IS_TIM_SLAVE_INSTANCE(TIMx) can be used to check whether or not
3145 * a timer instance can operate as a slave timer.
3146 * @rmtoll SMCR MSM LL_TIM_DisableMasterSlaveMode
3147 * @param TIMx Timer instance
3148 * @retval None
3150 __STATIC_INLINE void LL_TIM_DisableMasterSlaveMode(TIM_TypeDef *TIMx)
3152 CLEAR_BIT(TIMx->SMCR, TIM_SMCR_MSM);
3156 * @brief Indicates whether the Master/Slave mode is enabled.
3157 * @note Macro @ref IS_TIM_SLAVE_INSTANCE(TIMx) can be used to check whether or not
3158 * a timer instance can operate as a slave timer.
3159 * @rmtoll SMCR MSM LL_TIM_IsEnabledMasterSlaveMode
3160 * @param TIMx Timer instance
3161 * @retval State of bit (1 or 0).
3163 __STATIC_INLINE uint32_t LL_TIM_IsEnabledMasterSlaveMode(TIM_TypeDef *TIMx)
3165 return ((READ_BIT(TIMx->SMCR, TIM_SMCR_MSM) == (TIM_SMCR_MSM)) ? 1UL : 0UL);
3169 * @brief Configure the external trigger (ETR) input.
3170 * @note Macro @ref IS_TIM_ETR_INSTANCE(TIMx) can be used to check whether or not
3171 * a timer instance provides an external trigger input.
3172 * @rmtoll SMCR ETP LL_TIM_ConfigETR\n
3173 * SMCR ETPS LL_TIM_ConfigETR\n
3174 * SMCR ETF LL_TIM_ConfigETR
3175 * @param TIMx Timer instance
3176 * @param ETRPolarity This parameter can be one of the following values:
3177 * @arg @ref LL_TIM_ETR_POLARITY_NONINVERTED
3178 * @arg @ref LL_TIM_ETR_POLARITY_INVERTED
3179 * @param ETRPrescaler This parameter can be one of the following values:
3180 * @arg @ref LL_TIM_ETR_PRESCALER_DIV1
3181 * @arg @ref LL_TIM_ETR_PRESCALER_DIV2
3182 * @arg @ref LL_TIM_ETR_PRESCALER_DIV4
3183 * @arg @ref LL_TIM_ETR_PRESCALER_DIV8
3184 * @param ETRFilter This parameter can be one of the following values:
3185 * @arg @ref LL_TIM_ETR_FILTER_FDIV1
3186 * @arg @ref LL_TIM_ETR_FILTER_FDIV1_N2
3187 * @arg @ref LL_TIM_ETR_FILTER_FDIV1_N4
3188 * @arg @ref LL_TIM_ETR_FILTER_FDIV1_N8
3189 * @arg @ref LL_TIM_ETR_FILTER_FDIV2_N6
3190 * @arg @ref LL_TIM_ETR_FILTER_FDIV2_N8
3191 * @arg @ref LL_TIM_ETR_FILTER_FDIV4_N6
3192 * @arg @ref LL_TIM_ETR_FILTER_FDIV4_N8
3193 * @arg @ref LL_TIM_ETR_FILTER_FDIV8_N6
3194 * @arg @ref LL_TIM_ETR_FILTER_FDIV8_N8
3195 * @arg @ref LL_TIM_ETR_FILTER_FDIV16_N5
3196 * @arg @ref LL_TIM_ETR_FILTER_FDIV16_N6
3197 * @arg @ref LL_TIM_ETR_FILTER_FDIV16_N8
3198 * @arg @ref LL_TIM_ETR_FILTER_FDIV32_N5
3199 * @arg @ref LL_TIM_ETR_FILTER_FDIV32_N6
3200 * @arg @ref LL_TIM_ETR_FILTER_FDIV32_N8
3201 * @retval None
3203 __STATIC_INLINE void LL_TIM_ConfigETR(TIM_TypeDef *TIMx, uint32_t ETRPolarity, uint32_t ETRPrescaler,
3204 uint32_t ETRFilter)
3206 MODIFY_REG(TIMx->SMCR, TIM_SMCR_ETP | TIM_SMCR_ETPS | TIM_SMCR_ETF, ETRPolarity | ETRPrescaler | ETRFilter);
3210 * @}
3213 /** @defgroup TIM_LL_EF_Break_Function Break function configuration
3214 * @{
3217 * @brief Enable the break function.
3218 * @note Macro @ref IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
3219 * a timer instance provides a break input.
3220 * @rmtoll BDTR BKE LL_TIM_EnableBRK
3221 * @param TIMx Timer instance
3222 * @retval None
3224 __STATIC_INLINE void LL_TIM_EnableBRK(TIM_TypeDef *TIMx)
3226 SET_BIT(TIMx->BDTR, TIM_BDTR_BKE);
3230 * @brief Disable the break function.
3231 * @rmtoll BDTR BKE LL_TIM_DisableBRK
3232 * @param TIMx Timer instance
3233 * @note Macro @ref IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
3234 * a timer instance provides a break input.
3235 * @retval None
3237 __STATIC_INLINE void LL_TIM_DisableBRK(TIM_TypeDef *TIMx)
3239 CLEAR_BIT(TIMx->BDTR, TIM_BDTR_BKE);
3243 * @brief Configure the break input.
3244 * @note Macro @ref IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
3245 * a timer instance provides a break input.
3246 * @rmtoll BDTR BKP LL_TIM_ConfigBRK\n
3247 * BDTR BKF LL_TIM_ConfigBRK
3248 * @param TIMx Timer instance
3249 * @param BreakPolarity This parameter can be one of the following values:
3250 * @arg @ref LL_TIM_BREAK_POLARITY_LOW
3251 * @arg @ref LL_TIM_BREAK_POLARITY_HIGH
3252 * @param BreakFilter This parameter can be one of the following values:
3253 * @arg @ref LL_TIM_BREAK_FILTER_FDIV1
3254 * @arg @ref LL_TIM_BREAK_FILTER_FDIV1_N2
3255 * @arg @ref LL_TIM_BREAK_FILTER_FDIV1_N4
3256 * @arg @ref LL_TIM_BREAK_FILTER_FDIV1_N8
3257 * @arg @ref LL_TIM_BREAK_FILTER_FDIV2_N6
3258 * @arg @ref LL_TIM_BREAK_FILTER_FDIV2_N8
3259 * @arg @ref LL_TIM_BREAK_FILTER_FDIV4_N6
3260 * @arg @ref LL_TIM_BREAK_FILTER_FDIV4_N8
3261 * @arg @ref LL_TIM_BREAK_FILTER_FDIV8_N6
3262 * @arg @ref LL_TIM_BREAK_FILTER_FDIV8_N8
3263 * @arg @ref LL_TIM_BREAK_FILTER_FDIV16_N5
3264 * @arg @ref LL_TIM_BREAK_FILTER_FDIV16_N6
3265 * @arg @ref LL_TIM_BREAK_FILTER_FDIV16_N8
3266 * @arg @ref LL_TIM_BREAK_FILTER_FDIV32_N5
3267 * @arg @ref LL_TIM_BREAK_FILTER_FDIV32_N6
3268 * @arg @ref LL_TIM_BREAK_FILTER_FDIV32_N8
3269 * @retval None
3271 __STATIC_INLINE void LL_TIM_ConfigBRK(TIM_TypeDef *TIMx, uint32_t BreakPolarity, uint32_t BreakFilter)
3273 MODIFY_REG(TIMx->BDTR, TIM_BDTR_BKP | TIM_BDTR_BKF, BreakPolarity | BreakFilter);
3277 * @brief Enable the break 2 function.
3278 * @note Macro @ref IS_TIM_BKIN2_INSTANCE(TIMx) can be used to check whether or not
3279 * a timer instance provides a second break input.
3280 * @rmtoll BDTR BK2E LL_TIM_EnableBRK2
3281 * @param TIMx Timer instance
3282 * @retval None
3284 __STATIC_INLINE void LL_TIM_EnableBRK2(TIM_TypeDef *TIMx)
3286 SET_BIT(TIMx->BDTR, TIM_BDTR_BK2E);
3290 * @brief Disable the break 2 function.
3291 * @note Macro @ref IS_TIM_BKIN2_INSTANCE(TIMx) can be used to check whether or not
3292 * a timer instance provides a second break input.
3293 * @rmtoll BDTR BK2E LL_TIM_DisableBRK2
3294 * @param TIMx Timer instance
3295 * @retval None
3297 __STATIC_INLINE void LL_TIM_DisableBRK2(TIM_TypeDef *TIMx)
3299 CLEAR_BIT(TIMx->BDTR, TIM_BDTR_BK2E);
3303 * @brief Configure the break 2 input.
3304 * @note Macro @ref IS_TIM_BKIN2_INSTANCE(TIMx) can be used to check whether or not
3305 * a timer instance provides a second break input.
3306 * @rmtoll BDTR BK2P LL_TIM_ConfigBRK2\n
3307 * BDTR BK2F LL_TIM_ConfigBRK2
3308 * @param TIMx Timer instance
3309 * @param Break2Polarity This parameter can be one of the following values:
3310 * @arg @ref LL_TIM_BREAK2_POLARITY_LOW
3311 * @arg @ref LL_TIM_BREAK2_POLARITY_HIGH
3312 * @param Break2Filter This parameter can be one of the following values:
3313 * @arg @ref LL_TIM_BREAK2_FILTER_FDIV1
3314 * @arg @ref LL_TIM_BREAK2_FILTER_FDIV1_N2
3315 * @arg @ref LL_TIM_BREAK2_FILTER_FDIV1_N4
3316 * @arg @ref LL_TIM_BREAK2_FILTER_FDIV1_N8
3317 * @arg @ref LL_TIM_BREAK2_FILTER_FDIV2_N6
3318 * @arg @ref LL_TIM_BREAK2_FILTER_FDIV2_N8
3319 * @arg @ref LL_TIM_BREAK2_FILTER_FDIV4_N6
3320 * @arg @ref LL_TIM_BREAK2_FILTER_FDIV4_N8
3321 * @arg @ref LL_TIM_BREAK2_FILTER_FDIV8_N6
3322 * @arg @ref LL_TIM_BREAK2_FILTER_FDIV8_N8
3323 * @arg @ref LL_TIM_BREAK2_FILTER_FDIV16_N5
3324 * @arg @ref LL_TIM_BREAK2_FILTER_FDIV16_N6
3325 * @arg @ref LL_TIM_BREAK2_FILTER_FDIV16_N8
3326 * @arg @ref LL_TIM_BREAK2_FILTER_FDIV32_N5
3327 * @arg @ref LL_TIM_BREAK2_FILTER_FDIV32_N6
3328 * @arg @ref LL_TIM_BREAK2_FILTER_FDIV32_N8
3329 * @retval None
3331 __STATIC_INLINE void LL_TIM_ConfigBRK2(TIM_TypeDef *TIMx, uint32_t Break2Polarity, uint32_t Break2Filter)
3333 MODIFY_REG(TIMx->BDTR, TIM_BDTR_BK2P | TIM_BDTR_BK2F, Break2Polarity | Break2Filter);
3337 * @brief Select the outputs off state (enabled v.s. disabled) in Idle and Run modes.
3338 * @note Macro @ref IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
3339 * a timer instance provides a break input.
3340 * @rmtoll BDTR OSSI LL_TIM_SetOffStates\n
3341 * BDTR OSSR LL_TIM_SetOffStates
3342 * @param TIMx Timer instance
3343 * @param OffStateIdle This parameter can be one of the following values:
3344 * @arg @ref LL_TIM_OSSI_DISABLE
3345 * @arg @ref LL_TIM_OSSI_ENABLE
3346 * @param OffStateRun This parameter can be one of the following values:
3347 * @arg @ref LL_TIM_OSSR_DISABLE
3348 * @arg @ref LL_TIM_OSSR_ENABLE
3349 * @retval None
3351 __STATIC_INLINE void LL_TIM_SetOffStates(TIM_TypeDef *TIMx, uint32_t OffStateIdle, uint32_t OffStateRun)
3353 MODIFY_REG(TIMx->BDTR, TIM_BDTR_OSSI | TIM_BDTR_OSSR, OffStateIdle | OffStateRun);
3357 * @brief Enable automatic output (MOE can be set by software or automatically when a break input is active).
3358 * @note Macro @ref IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
3359 * a timer instance provides a break input.
3360 * @rmtoll BDTR AOE LL_TIM_EnableAutomaticOutput
3361 * @param TIMx Timer instance
3362 * @retval None
3364 __STATIC_INLINE void LL_TIM_EnableAutomaticOutput(TIM_TypeDef *TIMx)
3366 SET_BIT(TIMx->BDTR, TIM_BDTR_AOE);
3370 * @brief Disable automatic output (MOE can be set only by software).
3371 * @note Macro @ref IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
3372 * a timer instance provides a break input.
3373 * @rmtoll BDTR AOE LL_TIM_DisableAutomaticOutput
3374 * @param TIMx Timer instance
3375 * @retval None
3377 __STATIC_INLINE void LL_TIM_DisableAutomaticOutput(TIM_TypeDef *TIMx)
3379 CLEAR_BIT(TIMx->BDTR, TIM_BDTR_AOE);
3383 * @brief Indicate whether automatic output is enabled.
3384 * @note Macro @ref IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
3385 * a timer instance provides a break input.
3386 * @rmtoll BDTR AOE LL_TIM_IsEnabledAutomaticOutput
3387 * @param TIMx Timer instance
3388 * @retval State of bit (1 or 0).
3390 __STATIC_INLINE uint32_t LL_TIM_IsEnabledAutomaticOutput(TIM_TypeDef *TIMx)
3392 return ((READ_BIT(TIMx->BDTR, TIM_BDTR_AOE) == (TIM_BDTR_AOE)) ? 1UL : 0UL);
3396 * @brief Enable the outputs (set the MOE bit in TIMx_BDTR register).
3397 * @note The MOE bit in TIMx_BDTR register allows to enable /disable the outputs by
3398 * software and is reset in case of break or break2 event
3399 * @note Macro @ref IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
3400 * a timer instance provides a break input.
3401 * @rmtoll BDTR MOE LL_TIM_EnableAllOutputs
3402 * @param TIMx Timer instance
3403 * @retval None
3405 __STATIC_INLINE void LL_TIM_EnableAllOutputs(TIM_TypeDef *TIMx)
3407 SET_BIT(TIMx->BDTR, TIM_BDTR_MOE);
3411 * @brief Disable the outputs (reset the MOE bit in TIMx_BDTR register).
3412 * @note The MOE bit in TIMx_BDTR register allows to enable /disable the outputs by
3413 * software and is reset in case of break or break2 event.
3414 * @note Macro @ref IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
3415 * a timer instance provides a break input.
3416 * @rmtoll BDTR MOE LL_TIM_DisableAllOutputs
3417 * @param TIMx Timer instance
3418 * @retval None
3420 __STATIC_INLINE void LL_TIM_DisableAllOutputs(TIM_TypeDef *TIMx)
3422 CLEAR_BIT(TIMx->BDTR, TIM_BDTR_MOE);
3426 * @brief Indicates whether outputs are enabled.
3427 * @note Macro @ref IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
3428 * a timer instance provides a break input.
3429 * @rmtoll BDTR MOE LL_TIM_IsEnabledAllOutputs
3430 * @param TIMx Timer instance
3431 * @retval State of bit (1 or 0).
3433 __STATIC_INLINE uint32_t LL_TIM_IsEnabledAllOutputs(TIM_TypeDef *TIMx)
3435 return ((READ_BIT(TIMx->BDTR, TIM_BDTR_MOE) == (TIM_BDTR_MOE)) ? 1UL : 0UL);
3438 #if defined(TIM_BREAK_INPUT_SUPPORT)
3440 * @brief Enable the signals connected to the designated timer break input.
3441 * @note Macro @ref IS_TIM_BREAKSOURCE_INSTANCE(TIMx) can be used to check whether
3442 * or not a timer instance allows for break input selection.
3443 * @rmtoll AF1 BKINE LL_TIM_EnableBreakInputSource\n
3444 * AF1 BKDFBKE LL_TIM_EnableBreakInputSource\n
3445 * AF2 BK2INE LL_TIM_EnableBreakInputSource\n
3446 * AF2 BK2DFBKE LL_TIM_EnableBreakInputSource
3447 * @param TIMx Timer instance
3448 * @param BreakInput This parameter can be one of the following values:
3449 * @arg @ref LL_TIM_BREAK_INPUT_BKIN
3450 * @arg @ref LL_TIM_BREAK_INPUT_BKIN2
3451 * @param Source This parameter can be one of the following values:
3452 * @arg @ref LL_TIM_BKIN_SOURCE_BKIN
3453 * @arg @ref LL_TIM_BKIN_SOURCE_DF1BK
3454 * @retval None
3456 __STATIC_INLINE void LL_TIM_EnableBreakInputSource(TIM_TypeDef *TIMx, uint32_t BreakInput, uint32_t Source)
3458 register __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->AF1) + BreakInput));
3459 SET_BIT(*pReg, Source);
3463 * @brief Disable the signals connected to the designated timer break input.
3464 * @note Macro @ref IS_TIM_BREAKSOURCE_INSTANCE(TIMx) can be used to check whether
3465 * or not a timer instance allows for break input selection.
3466 * @rmtoll AF1 BKINE LL_TIM_DisableBreakInputSource\n
3467 * AF1 BKDFBKE LL_TIM_DisableBreakInputSource\n
3468 * AF2 BK2INE LL_TIM_DisableBreakInputSource\n
3469 * AF2 BK2DFBKE LL_TIM_DisableBreakInputSource
3470 * @param TIMx Timer instance
3471 * @param BreakInput This parameter can be one of the following values:
3472 * @arg @ref LL_TIM_BREAK_INPUT_BKIN
3473 * @arg @ref LL_TIM_BREAK_INPUT_BKIN2
3474 * @param Source This parameter can be one of the following values:
3475 * @arg @ref LL_TIM_BKIN_SOURCE_BKIN
3476 * @arg @ref LL_TIM_BKIN_SOURCE_DF1BK
3477 * @retval None
3479 __STATIC_INLINE void LL_TIM_DisableBreakInputSource(TIM_TypeDef *TIMx, uint32_t BreakInput, uint32_t Source)
3481 register __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->AF1) + BreakInput));
3482 CLEAR_BIT(*pReg, Source);
3486 * @brief Set the polarity of the break signal for the timer break input.
3487 * @note Macro @ref IS_TIM_BREAKSOURCE_INSTANCE(TIMx) can be used to check whether
3488 * or not a timer instance allows for break input selection.
3489 * @rmtoll AF1 BKINE LL_TIM_SetBreakInputSourcePolarity\n
3490 * AF1 BKDFBKE LL_TIM_SetBreakInputSourcePolarity\n
3491 * AF2 BK2INE LL_TIM_SetBreakInputSourcePolarity\n
3492 * AF2 BK2DFBKE LL_TIM_SetBreakInputSourcePolarity
3493 * @param TIMx Timer instance
3494 * @param BreakInput This parameter can be one of the following values:
3495 * @arg @ref LL_TIM_BREAK_INPUT_BKIN
3496 * @arg @ref LL_TIM_BREAK_INPUT_BKIN2
3497 * @param Source This parameter can be one of the following values:
3498 * @arg @ref LL_TIM_BKIN_SOURCE_BKIN
3499 * @arg @ref LL_TIM_BKIN_SOURCE_DF1BK
3500 * @param Polarity This parameter can be one of the following values:
3501 * @arg @ref LL_TIM_BKIN_POLARITY_LOW
3502 * @arg @ref LL_TIM_BKIN_POLARITY_HIGH
3503 * @retval None
3505 __STATIC_INLINE void LL_TIM_SetBreakInputSourcePolarity(TIM_TypeDef *TIMx, uint32_t BreakInput, uint32_t Source,
3506 uint32_t Polarity)
3508 register __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->AF1) + BreakInput));
3509 MODIFY_REG(*pReg, (TIMx_AF1_BKINP << TIM_POSITION_BRK_SOURCE), (Polarity << TIM_POSITION_BRK_SOURCE));
3511 #endif /* TIM_BREAK_INPUT_SUPPORT */
3513 * @}
3516 /** @defgroup TIM_LL_EF_DMA_Burst_Mode DMA burst mode configuration
3517 * @{
3520 * @brief Configures the timer DMA burst feature.
3521 * @note Macro @ref IS_TIM_DMABURST_INSTANCE(TIMx) can be used to check whether or
3522 * not a timer instance supports the DMA burst mode.
3523 * @rmtoll DCR DBL LL_TIM_ConfigDMABurst\n
3524 * DCR DBA LL_TIM_ConfigDMABurst
3525 * @param TIMx Timer instance
3526 * @param DMABurstBaseAddress This parameter can be one of the following values:
3527 * @arg @ref LL_TIM_DMABURST_BASEADDR_CR1
3528 * @arg @ref LL_TIM_DMABURST_BASEADDR_CR2
3529 * @arg @ref LL_TIM_DMABURST_BASEADDR_SMCR
3530 * @arg @ref LL_TIM_DMABURST_BASEADDR_DIER
3531 * @arg @ref LL_TIM_DMABURST_BASEADDR_SR
3532 * @arg @ref LL_TIM_DMABURST_BASEADDR_EGR
3533 * @arg @ref LL_TIM_DMABURST_BASEADDR_CCMR1
3534 * @arg @ref LL_TIM_DMABURST_BASEADDR_CCMR2
3535 * @arg @ref LL_TIM_DMABURST_BASEADDR_CCER
3536 * @arg @ref LL_TIM_DMABURST_BASEADDR_CNT
3537 * @arg @ref LL_TIM_DMABURST_BASEADDR_PSC
3538 * @arg @ref LL_TIM_DMABURST_BASEADDR_ARR
3539 * @arg @ref LL_TIM_DMABURST_BASEADDR_RCR
3540 * @arg @ref LL_TIM_DMABURST_BASEADDR_CCR1
3541 * @arg @ref LL_TIM_DMABURST_BASEADDR_CCR2
3542 * @arg @ref LL_TIM_DMABURST_BASEADDR_CCR3
3543 * @arg @ref LL_TIM_DMABURST_BASEADDR_CCR4
3544 * @arg @ref LL_TIM_DMABURST_BASEADDR_BDTR
3545 * @arg @ref LL_TIM_DMABURST_BASEADDR_OR
3546 * @arg @ref LL_TIM_DMABURST_BASEADDR_CCMR3
3547 * @arg @ref LL_TIM_DMABURST_BASEADDR_CCR5
3548 * @arg @ref LL_TIM_DMABURST_BASEADDR_CCR6
3549 * @arg @ref LL_TIM_DMABURST_BASEADDR_AF1 (*)
3550 * @arg @ref LL_TIM_DMABURST_BASEADDR_AF2 (*)
3551 * (*) value not defined in all devices
3552 * @param DMABurstLength This parameter can be one of the following values:
3553 * @arg @ref LL_TIM_DMABURST_LENGTH_1TRANSFER
3554 * @arg @ref LL_TIM_DMABURST_LENGTH_2TRANSFERS
3555 * @arg @ref LL_TIM_DMABURST_LENGTH_3TRANSFERS
3556 * @arg @ref LL_TIM_DMABURST_LENGTH_4TRANSFERS
3557 * @arg @ref LL_TIM_DMABURST_LENGTH_5TRANSFERS
3558 * @arg @ref LL_TIM_DMABURST_LENGTH_6TRANSFERS
3559 * @arg @ref LL_TIM_DMABURST_LENGTH_7TRANSFERS
3560 * @arg @ref LL_TIM_DMABURST_LENGTH_8TRANSFERS
3561 * @arg @ref LL_TIM_DMABURST_LENGTH_9TRANSFERS
3562 * @arg @ref LL_TIM_DMABURST_LENGTH_10TRANSFERS
3563 * @arg @ref LL_TIM_DMABURST_LENGTH_11TRANSFERS
3564 * @arg @ref LL_TIM_DMABURST_LENGTH_12TRANSFERS
3565 * @arg @ref LL_TIM_DMABURST_LENGTH_13TRANSFERS
3566 * @arg @ref LL_TIM_DMABURST_LENGTH_14TRANSFERS
3567 * @arg @ref LL_TIM_DMABURST_LENGTH_15TRANSFERS
3568 * @arg @ref LL_TIM_DMABURST_LENGTH_16TRANSFERS
3569 * @arg @ref LL_TIM_DMABURST_LENGTH_17TRANSFERS
3570 * @arg @ref LL_TIM_DMABURST_LENGTH_18TRANSFERS
3571 * @retval None
3573 __STATIC_INLINE void LL_TIM_ConfigDMABurst(TIM_TypeDef *TIMx, uint32_t DMABurstBaseAddress, uint32_t DMABurstLength)
3575 MODIFY_REG(TIMx->DCR, (TIM_DCR_DBL | TIM_DCR_DBA), (DMABurstBaseAddress | DMABurstLength));
3579 * @}
3582 /** @defgroup TIM_LL_EF_Timer_Inputs_Remapping Timer input remapping
3583 * @{
3586 * @brief Remap TIM inputs (input channel, internal/external triggers).
3587 * @note Macro @ref IS_TIM_REMAP_INSTANCE(TIMx) can be used to check whether or not
3588 * a some timer inputs can be remapped.
3589 * @rmtoll TIM2_OR ITR1_RMP LL_TIM_SetRemap\n
3590 * TIM5_OR TI4_RMP LL_TIM_SetRemap\n
3591 * TIM11_OR TI1_RMP LL_TIM_SetRemap
3592 * @param TIMx Timer instance
3593 * @param Remap Remap param depends on the TIMx. Description available only
3594 * in CHM version of the User Manual (not in .pdf).
3595 * Otherwise see Reference Manual description of OR registers.
3597 * Below description summarizes "Timer Instance" and "Remap" param combinations:
3599 * TIM2: one of the following values
3601 * ITR1_RMP can be one of the following values
3602 * @arg @ref LL_TIM_TIM2_ITR1_RMP_TIM8_TRGO
3603 * @arg @ref LL_TIM_TIM2_ITR1_RMP_ETH_PTP
3604 * @arg @ref LL_TIM_TIM2_ITR1_RMP_OTG_FS_SOF
3605 * @arg @ref LL_TIM_TIM2_ITR1_RMP_OTG_HS_SOF
3607 * TIM5: one of the following values
3609 * @arg @ref LL_TIM_TIM5_TI4_RMP_GPIO
3610 * @arg @ref LL_TIM_TIM5_TI4_RMP_LSI
3611 * @arg @ref LL_TIM_TIM5_TI4_RMP_LSE
3612 * @arg @ref LL_TIM_TIM5_TI4_RMP_RTC
3614 * TIM11: one of the following values
3616 * @arg @ref LL_TIM_TIM11_TI1_RMP_GPIO
3617 * @arg @ref LL_TIM_TIM11_TI1_RMP_SPDIFRX
3618 * @arg @ref LL_TIM_TIM11_TI1_RMP_HSE
3619 * @arg @ref LL_TIM_TIM11_TI1_RMP_MCO1
3621 * @retval None
3623 __STATIC_INLINE void LL_TIM_SetRemap(TIM_TypeDef *TIMx, uint32_t Remap)
3625 MODIFY_REG(TIMx->OR, (Remap >> TIMx_OR_RMP_SHIFT), (Remap & TIMx_OR_RMP_MASK));
3629 * @}
3632 /** @defgroup TIM_LL_EF_FLAG_Management FLAG-Management
3633 * @{
3636 * @brief Clear the update interrupt flag (UIF).
3637 * @rmtoll SR UIF LL_TIM_ClearFlag_UPDATE
3638 * @param TIMx Timer instance
3639 * @retval None
3641 __STATIC_INLINE void LL_TIM_ClearFlag_UPDATE(TIM_TypeDef *TIMx)
3643 WRITE_REG(TIMx->SR, ~(TIM_SR_UIF));
3647 * @brief Indicate whether update interrupt flag (UIF) is set (update interrupt is pending).
3648 * @rmtoll SR UIF LL_TIM_IsActiveFlag_UPDATE
3649 * @param TIMx Timer instance
3650 * @retval State of bit (1 or 0).
3652 __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_UPDATE(TIM_TypeDef *TIMx)
3654 return ((READ_BIT(TIMx->SR, TIM_SR_UIF) == (TIM_SR_UIF)) ? 1UL : 0UL);
3658 * @brief Clear the Capture/Compare 1 interrupt flag (CC1F).
3659 * @rmtoll SR CC1IF LL_TIM_ClearFlag_CC1
3660 * @param TIMx Timer instance
3661 * @retval None
3663 __STATIC_INLINE void LL_TIM_ClearFlag_CC1(TIM_TypeDef *TIMx)
3665 WRITE_REG(TIMx->SR, ~(TIM_SR_CC1IF));
3669 * @brief Indicate whether Capture/Compare 1 interrupt flag (CC1F) is set (Capture/Compare 1 interrupt is pending).
3670 * @rmtoll SR CC1IF LL_TIM_IsActiveFlag_CC1
3671 * @param TIMx Timer instance
3672 * @retval State of bit (1 or 0).
3674 __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC1(TIM_TypeDef *TIMx)
3676 return ((READ_BIT(TIMx->SR, TIM_SR_CC1IF) == (TIM_SR_CC1IF)) ? 1UL : 0UL);
3680 * @brief Clear the Capture/Compare 2 interrupt flag (CC2F).
3681 * @rmtoll SR CC2IF LL_TIM_ClearFlag_CC2
3682 * @param TIMx Timer instance
3683 * @retval None
3685 __STATIC_INLINE void LL_TIM_ClearFlag_CC2(TIM_TypeDef *TIMx)
3687 WRITE_REG(TIMx->SR, ~(TIM_SR_CC2IF));
3691 * @brief Indicate whether Capture/Compare 2 interrupt flag (CC2F) is set (Capture/Compare 2 interrupt is pending).
3692 * @rmtoll SR CC2IF LL_TIM_IsActiveFlag_CC2
3693 * @param TIMx Timer instance
3694 * @retval State of bit (1 or 0).
3696 __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC2(TIM_TypeDef *TIMx)
3698 return ((READ_BIT(TIMx->SR, TIM_SR_CC2IF) == (TIM_SR_CC2IF)) ? 1UL : 0UL);
3702 * @brief Clear the Capture/Compare 3 interrupt flag (CC3F).
3703 * @rmtoll SR CC3IF LL_TIM_ClearFlag_CC3
3704 * @param TIMx Timer instance
3705 * @retval None
3707 __STATIC_INLINE void LL_TIM_ClearFlag_CC3(TIM_TypeDef *TIMx)
3709 WRITE_REG(TIMx->SR, ~(TIM_SR_CC3IF));
3713 * @brief Indicate whether Capture/Compare 3 interrupt flag (CC3F) is set (Capture/Compare 3 interrupt is pending).
3714 * @rmtoll SR CC3IF LL_TIM_IsActiveFlag_CC3
3715 * @param TIMx Timer instance
3716 * @retval State of bit (1 or 0).
3718 __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC3(TIM_TypeDef *TIMx)
3720 return ((READ_BIT(TIMx->SR, TIM_SR_CC3IF) == (TIM_SR_CC3IF)) ? 1UL : 0UL);
3724 * @brief Clear the Capture/Compare 4 interrupt flag (CC4F).
3725 * @rmtoll SR CC4IF LL_TIM_ClearFlag_CC4
3726 * @param TIMx Timer instance
3727 * @retval None
3729 __STATIC_INLINE void LL_TIM_ClearFlag_CC4(TIM_TypeDef *TIMx)
3731 WRITE_REG(TIMx->SR, ~(TIM_SR_CC4IF));
3735 * @brief Indicate whether Capture/Compare 4 interrupt flag (CC4F) is set (Capture/Compare 4 interrupt is pending).
3736 * @rmtoll SR CC4IF LL_TIM_IsActiveFlag_CC4
3737 * @param TIMx Timer instance
3738 * @retval State of bit (1 or 0).
3740 __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC4(TIM_TypeDef *TIMx)
3742 return ((READ_BIT(TIMx->SR, TIM_SR_CC4IF) == (TIM_SR_CC4IF)) ? 1UL : 0UL);
3746 * @brief Clear the Capture/Compare 5 interrupt flag (CC5F).
3747 * @rmtoll SR CC5IF LL_TIM_ClearFlag_CC5
3748 * @param TIMx Timer instance
3749 * @retval None
3751 __STATIC_INLINE void LL_TIM_ClearFlag_CC5(TIM_TypeDef *TIMx)
3753 WRITE_REG(TIMx->SR, ~(TIM_SR_CC5IF));
3757 * @brief Indicate whether Capture/Compare 5 interrupt flag (CC5F) is set (Capture/Compare 5 interrupt is pending).
3758 * @rmtoll SR CC5IF LL_TIM_IsActiveFlag_CC5
3759 * @param TIMx Timer instance
3760 * @retval State of bit (1 or 0).
3762 __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC5(TIM_TypeDef *TIMx)
3764 return ((READ_BIT(TIMx->SR, TIM_SR_CC5IF) == (TIM_SR_CC5IF)) ? 1UL : 0UL);
3768 * @brief Clear the Capture/Compare 6 interrupt flag (CC6F).
3769 * @rmtoll SR CC6IF LL_TIM_ClearFlag_CC6
3770 * @param TIMx Timer instance
3771 * @retval None
3773 __STATIC_INLINE void LL_TIM_ClearFlag_CC6(TIM_TypeDef *TIMx)
3775 WRITE_REG(TIMx->SR, ~(TIM_SR_CC6IF));
3779 * @brief Indicate whether Capture/Compare 6 interrupt flag (CC6F) is set (Capture/Compare 6 interrupt is pending).
3780 * @rmtoll SR CC6IF LL_TIM_IsActiveFlag_CC6
3781 * @param TIMx Timer instance
3782 * @retval State of bit (1 or 0).
3784 __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC6(TIM_TypeDef *TIMx)
3786 return ((READ_BIT(TIMx->SR, TIM_SR_CC6IF) == (TIM_SR_CC6IF)) ? 1UL : 0UL);
3790 * @brief Clear the commutation interrupt flag (COMIF).
3791 * @rmtoll SR COMIF LL_TIM_ClearFlag_COM
3792 * @param TIMx Timer instance
3793 * @retval None
3795 __STATIC_INLINE void LL_TIM_ClearFlag_COM(TIM_TypeDef *TIMx)
3797 WRITE_REG(TIMx->SR, ~(TIM_SR_COMIF));
3801 * @brief Indicate whether commutation interrupt flag (COMIF) is set (commutation interrupt is pending).
3802 * @rmtoll SR COMIF LL_TIM_IsActiveFlag_COM
3803 * @param TIMx Timer instance
3804 * @retval State of bit (1 or 0).
3806 __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_COM(TIM_TypeDef *TIMx)
3808 return ((READ_BIT(TIMx->SR, TIM_SR_COMIF) == (TIM_SR_COMIF)) ? 1UL : 0UL);
3812 * @brief Clear the trigger interrupt flag (TIF).
3813 * @rmtoll SR TIF LL_TIM_ClearFlag_TRIG
3814 * @param TIMx Timer instance
3815 * @retval None
3817 __STATIC_INLINE void LL_TIM_ClearFlag_TRIG(TIM_TypeDef *TIMx)
3819 WRITE_REG(TIMx->SR, ~(TIM_SR_TIF));
3823 * @brief Indicate whether trigger interrupt flag (TIF) is set (trigger interrupt is pending).
3824 * @rmtoll SR TIF LL_TIM_IsActiveFlag_TRIG
3825 * @param TIMx Timer instance
3826 * @retval State of bit (1 or 0).
3828 __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_TRIG(TIM_TypeDef *TIMx)
3830 return ((READ_BIT(TIMx->SR, TIM_SR_TIF) == (TIM_SR_TIF)) ? 1UL : 0UL);
3834 * @brief Clear the break interrupt flag (BIF).
3835 * @rmtoll SR BIF LL_TIM_ClearFlag_BRK
3836 * @param TIMx Timer instance
3837 * @retval None
3839 __STATIC_INLINE void LL_TIM_ClearFlag_BRK(TIM_TypeDef *TIMx)
3841 WRITE_REG(TIMx->SR, ~(TIM_SR_BIF));
3845 * @brief Indicate whether break interrupt flag (BIF) is set (break interrupt is pending).
3846 * @rmtoll SR BIF LL_TIM_IsActiveFlag_BRK
3847 * @param TIMx Timer instance
3848 * @retval State of bit (1 or 0).
3850 __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_BRK(TIM_TypeDef *TIMx)
3852 return ((READ_BIT(TIMx->SR, TIM_SR_BIF) == (TIM_SR_BIF)) ? 1UL : 0UL);
3856 * @brief Clear the break 2 interrupt flag (B2IF).
3857 * @rmtoll SR B2IF LL_TIM_ClearFlag_BRK2
3858 * @param TIMx Timer instance
3859 * @retval None
3861 __STATIC_INLINE void LL_TIM_ClearFlag_BRK2(TIM_TypeDef *TIMx)
3863 WRITE_REG(TIMx->SR, ~(TIM_SR_B2IF));
3867 * @brief Indicate whether break 2 interrupt flag (B2IF) is set (break 2 interrupt is pending).
3868 * @rmtoll SR B2IF LL_TIM_IsActiveFlag_BRK2
3869 * @param TIMx Timer instance
3870 * @retval State of bit (1 or 0).
3872 __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_BRK2(TIM_TypeDef *TIMx)
3874 return ((READ_BIT(TIMx->SR, TIM_SR_B2IF) == (TIM_SR_B2IF)) ? 1UL : 0UL);
3878 * @brief Clear the Capture/Compare 1 over-capture interrupt flag (CC1OF).
3879 * @rmtoll SR CC1OF LL_TIM_ClearFlag_CC1OVR
3880 * @param TIMx Timer instance
3881 * @retval None
3883 __STATIC_INLINE void LL_TIM_ClearFlag_CC1OVR(TIM_TypeDef *TIMx)
3885 WRITE_REG(TIMx->SR, ~(TIM_SR_CC1OF));
3889 * @brief Indicate whether Capture/Compare 1 over-capture interrupt flag (CC1OF) is set (Capture/Compare 1 interrupt is pending).
3890 * @rmtoll SR CC1OF LL_TIM_IsActiveFlag_CC1OVR
3891 * @param TIMx Timer instance
3892 * @retval State of bit (1 or 0).
3894 __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC1OVR(TIM_TypeDef *TIMx)
3896 return ((READ_BIT(TIMx->SR, TIM_SR_CC1OF) == (TIM_SR_CC1OF)) ? 1UL : 0UL);
3900 * @brief Clear the Capture/Compare 2 over-capture interrupt flag (CC2OF).
3901 * @rmtoll SR CC2OF LL_TIM_ClearFlag_CC2OVR
3902 * @param TIMx Timer instance
3903 * @retval None
3905 __STATIC_INLINE void LL_TIM_ClearFlag_CC2OVR(TIM_TypeDef *TIMx)
3907 WRITE_REG(TIMx->SR, ~(TIM_SR_CC2OF));
3911 * @brief Indicate whether Capture/Compare 2 over-capture interrupt flag (CC2OF) is set (Capture/Compare 2 over-capture interrupt is pending).
3912 * @rmtoll SR CC2OF LL_TIM_IsActiveFlag_CC2OVR
3913 * @param TIMx Timer instance
3914 * @retval State of bit (1 or 0).
3916 __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC2OVR(TIM_TypeDef *TIMx)
3918 return ((READ_BIT(TIMx->SR, TIM_SR_CC2OF) == (TIM_SR_CC2OF)) ? 1UL : 0UL);
3922 * @brief Clear the Capture/Compare 3 over-capture interrupt flag (CC3OF).
3923 * @rmtoll SR CC3OF LL_TIM_ClearFlag_CC3OVR
3924 * @param TIMx Timer instance
3925 * @retval None
3927 __STATIC_INLINE void LL_TIM_ClearFlag_CC3OVR(TIM_TypeDef *TIMx)
3929 WRITE_REG(TIMx->SR, ~(TIM_SR_CC3OF));
3933 * @brief Indicate whether Capture/Compare 3 over-capture interrupt flag (CC3OF) is set (Capture/Compare 3 over-capture interrupt is pending).
3934 * @rmtoll SR CC3OF LL_TIM_IsActiveFlag_CC3OVR
3935 * @param TIMx Timer instance
3936 * @retval State of bit (1 or 0).
3938 __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC3OVR(TIM_TypeDef *TIMx)
3940 return ((READ_BIT(TIMx->SR, TIM_SR_CC3OF) == (TIM_SR_CC3OF)) ? 1UL : 0UL);
3944 * @brief Clear the Capture/Compare 4 over-capture interrupt flag (CC4OF).
3945 * @rmtoll SR CC4OF LL_TIM_ClearFlag_CC4OVR
3946 * @param TIMx Timer instance
3947 * @retval None
3949 __STATIC_INLINE void LL_TIM_ClearFlag_CC4OVR(TIM_TypeDef *TIMx)
3951 WRITE_REG(TIMx->SR, ~(TIM_SR_CC4OF));
3955 * @brief Indicate whether Capture/Compare 4 over-capture interrupt flag (CC4OF) is set (Capture/Compare 4 over-capture interrupt is pending).
3956 * @rmtoll SR CC4OF LL_TIM_IsActiveFlag_CC4OVR
3957 * @param TIMx Timer instance
3958 * @retval State of bit (1 or 0).
3960 __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC4OVR(TIM_TypeDef *TIMx)
3962 return ((READ_BIT(TIMx->SR, TIM_SR_CC4OF) == (TIM_SR_CC4OF)) ? 1UL : 0UL);
3966 * @brief Clear the system break interrupt flag (SBIF).
3967 * @rmtoll SR SBIF LL_TIM_ClearFlag_SYSBRK
3968 * @param TIMx Timer instance
3969 * @retval None
3971 __STATIC_INLINE void LL_TIM_ClearFlag_SYSBRK(TIM_TypeDef *TIMx)
3973 WRITE_REG(TIMx->SR, ~(TIM_SR_SBIF));
3977 * @brief Indicate whether system break interrupt flag (SBIF) is set (system break interrupt is pending).
3978 * @rmtoll SR SBIF LL_TIM_IsActiveFlag_SYSBRK
3979 * @param TIMx Timer instance
3980 * @retval State of bit (1 or 0).
3982 __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_SYSBRK(TIM_TypeDef *TIMx)
3984 return ((READ_BIT(TIMx->SR, TIM_SR_SBIF) == (TIM_SR_SBIF)) ? 1UL : 0UL);
3988 * @}
3991 /** @defgroup TIM_LL_EF_IT_Management IT-Management
3992 * @{
3995 * @brief Enable update interrupt (UIE).
3996 * @rmtoll DIER UIE LL_TIM_EnableIT_UPDATE
3997 * @param TIMx Timer instance
3998 * @retval None
4000 __STATIC_INLINE void LL_TIM_EnableIT_UPDATE(TIM_TypeDef *TIMx)
4002 SET_BIT(TIMx->DIER, TIM_DIER_UIE);
4006 * @brief Disable update interrupt (UIE).
4007 * @rmtoll DIER UIE LL_TIM_DisableIT_UPDATE
4008 * @param TIMx Timer instance
4009 * @retval None
4011 __STATIC_INLINE void LL_TIM_DisableIT_UPDATE(TIM_TypeDef *TIMx)
4013 CLEAR_BIT(TIMx->DIER, TIM_DIER_UIE);
4017 * @brief Indicates whether the update interrupt (UIE) is enabled.
4018 * @rmtoll DIER UIE LL_TIM_IsEnabledIT_UPDATE
4019 * @param TIMx Timer instance
4020 * @retval State of bit (1 or 0).
4022 __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_UPDATE(TIM_TypeDef *TIMx)
4024 return ((READ_BIT(TIMx->DIER, TIM_DIER_UIE) == (TIM_DIER_UIE)) ? 1UL : 0UL);
4028 * @brief Enable capture/compare 1 interrupt (CC1IE).
4029 * @rmtoll DIER CC1IE LL_TIM_EnableIT_CC1
4030 * @param TIMx Timer instance
4031 * @retval None
4033 __STATIC_INLINE void LL_TIM_EnableIT_CC1(TIM_TypeDef *TIMx)
4035 SET_BIT(TIMx->DIER, TIM_DIER_CC1IE);
4039 * @brief Disable capture/compare 1 interrupt (CC1IE).
4040 * @rmtoll DIER CC1IE LL_TIM_DisableIT_CC1
4041 * @param TIMx Timer instance
4042 * @retval None
4044 __STATIC_INLINE void LL_TIM_DisableIT_CC1(TIM_TypeDef *TIMx)
4046 CLEAR_BIT(TIMx->DIER, TIM_DIER_CC1IE);
4050 * @brief Indicates whether the capture/compare 1 interrupt (CC1IE) is enabled.
4051 * @rmtoll DIER CC1IE LL_TIM_IsEnabledIT_CC1
4052 * @param TIMx Timer instance
4053 * @retval State of bit (1 or 0).
4055 __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_CC1(TIM_TypeDef *TIMx)
4057 return ((READ_BIT(TIMx->DIER, TIM_DIER_CC1IE) == (TIM_DIER_CC1IE)) ? 1UL : 0UL);
4061 * @brief Enable capture/compare 2 interrupt (CC2IE).
4062 * @rmtoll DIER CC2IE LL_TIM_EnableIT_CC2
4063 * @param TIMx Timer instance
4064 * @retval None
4066 __STATIC_INLINE void LL_TIM_EnableIT_CC2(TIM_TypeDef *TIMx)
4068 SET_BIT(TIMx->DIER, TIM_DIER_CC2IE);
4072 * @brief Disable capture/compare 2 interrupt (CC2IE).
4073 * @rmtoll DIER CC2IE LL_TIM_DisableIT_CC2
4074 * @param TIMx Timer instance
4075 * @retval None
4077 __STATIC_INLINE void LL_TIM_DisableIT_CC2(TIM_TypeDef *TIMx)
4079 CLEAR_BIT(TIMx->DIER, TIM_DIER_CC2IE);
4083 * @brief Indicates whether the capture/compare 2 interrupt (CC2IE) is enabled.
4084 * @rmtoll DIER CC2IE LL_TIM_IsEnabledIT_CC2
4085 * @param TIMx Timer instance
4086 * @retval State of bit (1 or 0).
4088 __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_CC2(TIM_TypeDef *TIMx)
4090 return ((READ_BIT(TIMx->DIER, TIM_DIER_CC2IE) == (TIM_DIER_CC2IE)) ? 1UL : 0UL);
4094 * @brief Enable capture/compare 3 interrupt (CC3IE).
4095 * @rmtoll DIER CC3IE LL_TIM_EnableIT_CC3
4096 * @param TIMx Timer instance
4097 * @retval None
4099 __STATIC_INLINE void LL_TIM_EnableIT_CC3(TIM_TypeDef *TIMx)
4101 SET_BIT(TIMx->DIER, TIM_DIER_CC3IE);
4105 * @brief Disable capture/compare 3 interrupt (CC3IE).
4106 * @rmtoll DIER CC3IE LL_TIM_DisableIT_CC3
4107 * @param TIMx Timer instance
4108 * @retval None
4110 __STATIC_INLINE void LL_TIM_DisableIT_CC3(TIM_TypeDef *TIMx)
4112 CLEAR_BIT(TIMx->DIER, TIM_DIER_CC3IE);
4116 * @brief Indicates whether the capture/compare 3 interrupt (CC3IE) is enabled.
4117 * @rmtoll DIER CC3IE LL_TIM_IsEnabledIT_CC3
4118 * @param TIMx Timer instance
4119 * @retval State of bit (1 or 0).
4121 __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_CC3(TIM_TypeDef *TIMx)
4123 return ((READ_BIT(TIMx->DIER, TIM_DIER_CC3IE) == (TIM_DIER_CC3IE)) ? 1UL : 0UL);
4127 * @brief Enable capture/compare 4 interrupt (CC4IE).
4128 * @rmtoll DIER CC4IE LL_TIM_EnableIT_CC4
4129 * @param TIMx Timer instance
4130 * @retval None
4132 __STATIC_INLINE void LL_TIM_EnableIT_CC4(TIM_TypeDef *TIMx)
4134 SET_BIT(TIMx->DIER, TIM_DIER_CC4IE);
4138 * @brief Disable capture/compare 4 interrupt (CC4IE).
4139 * @rmtoll DIER CC4IE LL_TIM_DisableIT_CC4
4140 * @param TIMx Timer instance
4141 * @retval None
4143 __STATIC_INLINE void LL_TIM_DisableIT_CC4(TIM_TypeDef *TIMx)
4145 CLEAR_BIT(TIMx->DIER, TIM_DIER_CC4IE);
4149 * @brief Indicates whether the capture/compare 4 interrupt (CC4IE) is enabled.
4150 * @rmtoll DIER CC4IE LL_TIM_IsEnabledIT_CC4
4151 * @param TIMx Timer instance
4152 * @retval State of bit (1 or 0).
4154 __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_CC4(TIM_TypeDef *TIMx)
4156 return ((READ_BIT(TIMx->DIER, TIM_DIER_CC4IE) == (TIM_DIER_CC4IE)) ? 1UL : 0UL);
4160 * @brief Enable commutation interrupt (COMIE).
4161 * @rmtoll DIER COMIE LL_TIM_EnableIT_COM
4162 * @param TIMx Timer instance
4163 * @retval None
4165 __STATIC_INLINE void LL_TIM_EnableIT_COM(TIM_TypeDef *TIMx)
4167 SET_BIT(TIMx->DIER, TIM_DIER_COMIE);
4171 * @brief Disable commutation interrupt (COMIE).
4172 * @rmtoll DIER COMIE LL_TIM_DisableIT_COM
4173 * @param TIMx Timer instance
4174 * @retval None
4176 __STATIC_INLINE void LL_TIM_DisableIT_COM(TIM_TypeDef *TIMx)
4178 CLEAR_BIT(TIMx->DIER, TIM_DIER_COMIE);
4182 * @brief Indicates whether the commutation interrupt (COMIE) is enabled.
4183 * @rmtoll DIER COMIE LL_TIM_IsEnabledIT_COM
4184 * @param TIMx Timer instance
4185 * @retval State of bit (1 or 0).
4187 __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_COM(TIM_TypeDef *TIMx)
4189 return ((READ_BIT(TIMx->DIER, TIM_DIER_COMIE) == (TIM_DIER_COMIE)) ? 1UL : 0UL);
4193 * @brief Enable trigger interrupt (TIE).
4194 * @rmtoll DIER TIE LL_TIM_EnableIT_TRIG
4195 * @param TIMx Timer instance
4196 * @retval None
4198 __STATIC_INLINE void LL_TIM_EnableIT_TRIG(TIM_TypeDef *TIMx)
4200 SET_BIT(TIMx->DIER, TIM_DIER_TIE);
4204 * @brief Disable trigger interrupt (TIE).
4205 * @rmtoll DIER TIE LL_TIM_DisableIT_TRIG
4206 * @param TIMx Timer instance
4207 * @retval None
4209 __STATIC_INLINE void LL_TIM_DisableIT_TRIG(TIM_TypeDef *TIMx)
4211 CLEAR_BIT(TIMx->DIER, TIM_DIER_TIE);
4215 * @brief Indicates whether the trigger interrupt (TIE) is enabled.
4216 * @rmtoll DIER TIE LL_TIM_IsEnabledIT_TRIG
4217 * @param TIMx Timer instance
4218 * @retval State of bit (1 or 0).
4220 __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_TRIG(TIM_TypeDef *TIMx)
4222 return ((READ_BIT(TIMx->DIER, TIM_DIER_TIE) == (TIM_DIER_TIE)) ? 1UL : 0UL);
4226 * @brief Enable break interrupt (BIE).
4227 * @rmtoll DIER BIE LL_TIM_EnableIT_BRK
4228 * @param TIMx Timer instance
4229 * @retval None
4231 __STATIC_INLINE void LL_TIM_EnableIT_BRK(TIM_TypeDef *TIMx)
4233 SET_BIT(TIMx->DIER, TIM_DIER_BIE);
4237 * @brief Disable break interrupt (BIE).
4238 * @rmtoll DIER BIE LL_TIM_DisableIT_BRK
4239 * @param TIMx Timer instance
4240 * @retval None
4242 __STATIC_INLINE void LL_TIM_DisableIT_BRK(TIM_TypeDef *TIMx)
4244 CLEAR_BIT(TIMx->DIER, TIM_DIER_BIE);
4248 * @brief Indicates whether the break interrupt (BIE) is enabled.
4249 * @rmtoll DIER BIE LL_TIM_IsEnabledIT_BRK
4250 * @param TIMx Timer instance
4251 * @retval State of bit (1 or 0).
4253 __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_BRK(TIM_TypeDef *TIMx)
4255 return ((READ_BIT(TIMx->DIER, TIM_DIER_BIE) == (TIM_DIER_BIE)) ? 1UL : 0UL);
4259 * @}
4262 /** @defgroup TIM_LL_EF_DMA_Management DMA-Management
4263 * @{
4266 * @brief Enable update DMA request (UDE).
4267 * @rmtoll DIER UDE LL_TIM_EnableDMAReq_UPDATE
4268 * @param TIMx Timer instance
4269 * @retval None
4271 __STATIC_INLINE void LL_TIM_EnableDMAReq_UPDATE(TIM_TypeDef *TIMx)
4273 SET_BIT(TIMx->DIER, TIM_DIER_UDE);
4277 * @brief Disable update DMA request (UDE).
4278 * @rmtoll DIER UDE LL_TIM_DisableDMAReq_UPDATE
4279 * @param TIMx Timer instance
4280 * @retval None
4282 __STATIC_INLINE void LL_TIM_DisableDMAReq_UPDATE(TIM_TypeDef *TIMx)
4284 CLEAR_BIT(TIMx->DIER, TIM_DIER_UDE);
4288 * @brief Indicates whether the update DMA request (UDE) is enabled.
4289 * @rmtoll DIER UDE LL_TIM_IsEnabledDMAReq_UPDATE
4290 * @param TIMx Timer instance
4291 * @retval State of bit (1 or 0).
4293 __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_UPDATE(TIM_TypeDef *TIMx)
4295 return ((READ_BIT(TIMx->DIER, TIM_DIER_UDE) == (TIM_DIER_UDE)) ? 1UL : 0UL);
4299 * @brief Enable capture/compare 1 DMA request (CC1DE).
4300 * @rmtoll DIER CC1DE LL_TIM_EnableDMAReq_CC1
4301 * @param TIMx Timer instance
4302 * @retval None
4304 __STATIC_INLINE void LL_TIM_EnableDMAReq_CC1(TIM_TypeDef *TIMx)
4306 SET_BIT(TIMx->DIER, TIM_DIER_CC1DE);
4310 * @brief Disable capture/compare 1 DMA request (CC1DE).
4311 * @rmtoll DIER CC1DE LL_TIM_DisableDMAReq_CC1
4312 * @param TIMx Timer instance
4313 * @retval None
4315 __STATIC_INLINE void LL_TIM_DisableDMAReq_CC1(TIM_TypeDef *TIMx)
4317 CLEAR_BIT(TIMx->DIER, TIM_DIER_CC1DE);
4321 * @brief Indicates whether the capture/compare 1 DMA request (CC1DE) is enabled.
4322 * @rmtoll DIER CC1DE LL_TIM_IsEnabledDMAReq_CC1
4323 * @param TIMx Timer instance
4324 * @retval State of bit (1 or 0).
4326 __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_CC1(TIM_TypeDef *TIMx)
4328 return ((READ_BIT(TIMx->DIER, TIM_DIER_CC1DE) == (TIM_DIER_CC1DE)) ? 1UL : 0UL);
4332 * @brief Enable capture/compare 2 DMA request (CC2DE).
4333 * @rmtoll DIER CC2DE LL_TIM_EnableDMAReq_CC2
4334 * @param TIMx Timer instance
4335 * @retval None
4337 __STATIC_INLINE void LL_TIM_EnableDMAReq_CC2(TIM_TypeDef *TIMx)
4339 SET_BIT(TIMx->DIER, TIM_DIER_CC2DE);
4343 * @brief Disable capture/compare 2 DMA request (CC2DE).
4344 * @rmtoll DIER CC2DE LL_TIM_DisableDMAReq_CC2
4345 * @param TIMx Timer instance
4346 * @retval None
4348 __STATIC_INLINE void LL_TIM_DisableDMAReq_CC2(TIM_TypeDef *TIMx)
4350 CLEAR_BIT(TIMx->DIER, TIM_DIER_CC2DE);
4354 * @brief Indicates whether the capture/compare 2 DMA request (CC2DE) is enabled.
4355 * @rmtoll DIER CC2DE LL_TIM_IsEnabledDMAReq_CC2
4356 * @param TIMx Timer instance
4357 * @retval State of bit (1 or 0).
4359 __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_CC2(TIM_TypeDef *TIMx)
4361 return ((READ_BIT(TIMx->DIER, TIM_DIER_CC2DE) == (TIM_DIER_CC2DE)) ? 1UL : 0UL);
4365 * @brief Enable capture/compare 3 DMA request (CC3DE).
4366 * @rmtoll DIER CC3DE LL_TIM_EnableDMAReq_CC3
4367 * @param TIMx Timer instance
4368 * @retval None
4370 __STATIC_INLINE void LL_TIM_EnableDMAReq_CC3(TIM_TypeDef *TIMx)
4372 SET_BIT(TIMx->DIER, TIM_DIER_CC3DE);
4376 * @brief Disable capture/compare 3 DMA request (CC3DE).
4377 * @rmtoll DIER CC3DE LL_TIM_DisableDMAReq_CC3
4378 * @param TIMx Timer instance
4379 * @retval None
4381 __STATIC_INLINE void LL_TIM_DisableDMAReq_CC3(TIM_TypeDef *TIMx)
4383 CLEAR_BIT(TIMx->DIER, TIM_DIER_CC3DE);
4387 * @brief Indicates whether the capture/compare 3 DMA request (CC3DE) is enabled.
4388 * @rmtoll DIER CC3DE LL_TIM_IsEnabledDMAReq_CC3
4389 * @param TIMx Timer instance
4390 * @retval State of bit (1 or 0).
4392 __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_CC3(TIM_TypeDef *TIMx)
4394 return ((READ_BIT(TIMx->DIER, TIM_DIER_CC3DE) == (TIM_DIER_CC3DE)) ? 1UL : 0UL);
4398 * @brief Enable capture/compare 4 DMA request (CC4DE).
4399 * @rmtoll DIER CC4DE LL_TIM_EnableDMAReq_CC4
4400 * @param TIMx Timer instance
4401 * @retval None
4403 __STATIC_INLINE void LL_TIM_EnableDMAReq_CC4(TIM_TypeDef *TIMx)
4405 SET_BIT(TIMx->DIER, TIM_DIER_CC4DE);
4409 * @brief Disable capture/compare 4 DMA request (CC4DE).
4410 * @rmtoll DIER CC4DE LL_TIM_DisableDMAReq_CC4
4411 * @param TIMx Timer instance
4412 * @retval None
4414 __STATIC_INLINE void LL_TIM_DisableDMAReq_CC4(TIM_TypeDef *TIMx)
4416 CLEAR_BIT(TIMx->DIER, TIM_DIER_CC4DE);
4420 * @brief Indicates whether the capture/compare 4 DMA request (CC4DE) is enabled.
4421 * @rmtoll DIER CC4DE LL_TIM_IsEnabledDMAReq_CC4
4422 * @param TIMx Timer instance
4423 * @retval State of bit (1 or 0).
4425 __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_CC4(TIM_TypeDef *TIMx)
4427 return ((READ_BIT(TIMx->DIER, TIM_DIER_CC4DE) == (TIM_DIER_CC4DE)) ? 1UL : 0UL);
4431 * @brief Enable commutation DMA request (COMDE).
4432 * @rmtoll DIER COMDE LL_TIM_EnableDMAReq_COM
4433 * @param TIMx Timer instance
4434 * @retval None
4436 __STATIC_INLINE void LL_TIM_EnableDMAReq_COM(TIM_TypeDef *TIMx)
4438 SET_BIT(TIMx->DIER, TIM_DIER_COMDE);
4442 * @brief Disable commutation DMA request (COMDE).
4443 * @rmtoll DIER COMDE LL_TIM_DisableDMAReq_COM
4444 * @param TIMx Timer instance
4445 * @retval None
4447 __STATIC_INLINE void LL_TIM_DisableDMAReq_COM(TIM_TypeDef *TIMx)
4449 CLEAR_BIT(TIMx->DIER, TIM_DIER_COMDE);
4453 * @brief Indicates whether the commutation DMA request (COMDE) is enabled.
4454 * @rmtoll DIER COMDE LL_TIM_IsEnabledDMAReq_COM
4455 * @param TIMx Timer instance
4456 * @retval State of bit (1 or 0).
4458 __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_COM(TIM_TypeDef *TIMx)
4460 return ((READ_BIT(TIMx->DIER, TIM_DIER_COMDE) == (TIM_DIER_COMDE)) ? 1UL : 0UL);
4464 * @brief Enable trigger interrupt (TDE).
4465 * @rmtoll DIER TDE LL_TIM_EnableDMAReq_TRIG
4466 * @param TIMx Timer instance
4467 * @retval None
4469 __STATIC_INLINE void LL_TIM_EnableDMAReq_TRIG(TIM_TypeDef *TIMx)
4471 SET_BIT(TIMx->DIER, TIM_DIER_TDE);
4475 * @brief Disable trigger interrupt (TDE).
4476 * @rmtoll DIER TDE LL_TIM_DisableDMAReq_TRIG
4477 * @param TIMx Timer instance
4478 * @retval None
4480 __STATIC_INLINE void LL_TIM_DisableDMAReq_TRIG(TIM_TypeDef *TIMx)
4482 CLEAR_BIT(TIMx->DIER, TIM_DIER_TDE);
4486 * @brief Indicates whether the trigger interrupt (TDE) is enabled.
4487 * @rmtoll DIER TDE LL_TIM_IsEnabledDMAReq_TRIG
4488 * @param TIMx Timer instance
4489 * @retval State of bit (1 or 0).
4491 __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_TRIG(TIM_TypeDef *TIMx)
4493 return ((READ_BIT(TIMx->DIER, TIM_DIER_TDE) == (TIM_DIER_TDE)) ? 1UL : 0UL);
4497 * @}
4500 /** @defgroup TIM_LL_EF_EVENT_Management EVENT-Management
4501 * @{
4504 * @brief Generate an update event.
4505 * @rmtoll EGR UG LL_TIM_GenerateEvent_UPDATE
4506 * @param TIMx Timer instance
4507 * @retval None
4509 __STATIC_INLINE void LL_TIM_GenerateEvent_UPDATE(TIM_TypeDef *TIMx)
4511 SET_BIT(TIMx->EGR, TIM_EGR_UG);
4515 * @brief Generate Capture/Compare 1 event.
4516 * @rmtoll EGR CC1G LL_TIM_GenerateEvent_CC1
4517 * @param TIMx Timer instance
4518 * @retval None
4520 __STATIC_INLINE void LL_TIM_GenerateEvent_CC1(TIM_TypeDef *TIMx)
4522 SET_BIT(TIMx->EGR, TIM_EGR_CC1G);
4526 * @brief Generate Capture/Compare 2 event.
4527 * @rmtoll EGR CC2G LL_TIM_GenerateEvent_CC2
4528 * @param TIMx Timer instance
4529 * @retval None
4531 __STATIC_INLINE void LL_TIM_GenerateEvent_CC2(TIM_TypeDef *TIMx)
4533 SET_BIT(TIMx->EGR, TIM_EGR_CC2G);
4537 * @brief Generate Capture/Compare 3 event.
4538 * @rmtoll EGR CC3G LL_TIM_GenerateEvent_CC3
4539 * @param TIMx Timer instance
4540 * @retval None
4542 __STATIC_INLINE void LL_TIM_GenerateEvent_CC3(TIM_TypeDef *TIMx)
4544 SET_BIT(TIMx->EGR, TIM_EGR_CC3G);
4548 * @brief Generate Capture/Compare 4 event.
4549 * @rmtoll EGR CC4G LL_TIM_GenerateEvent_CC4
4550 * @param TIMx Timer instance
4551 * @retval None
4553 __STATIC_INLINE void LL_TIM_GenerateEvent_CC4(TIM_TypeDef *TIMx)
4555 SET_BIT(TIMx->EGR, TIM_EGR_CC4G);
4559 * @brief Generate commutation event.
4560 * @rmtoll EGR COMG LL_TIM_GenerateEvent_COM
4561 * @param TIMx Timer instance
4562 * @retval None
4564 __STATIC_INLINE void LL_TIM_GenerateEvent_COM(TIM_TypeDef *TIMx)
4566 SET_BIT(TIMx->EGR, TIM_EGR_COMG);
4570 * @brief Generate trigger event.
4571 * @rmtoll EGR TG LL_TIM_GenerateEvent_TRIG
4572 * @param TIMx Timer instance
4573 * @retval None
4575 __STATIC_INLINE void LL_TIM_GenerateEvent_TRIG(TIM_TypeDef *TIMx)
4577 SET_BIT(TIMx->EGR, TIM_EGR_TG);
4581 * @brief Generate break event.
4582 * @rmtoll EGR BG LL_TIM_GenerateEvent_BRK
4583 * @param TIMx Timer instance
4584 * @retval None
4586 __STATIC_INLINE void LL_TIM_GenerateEvent_BRK(TIM_TypeDef *TIMx)
4588 SET_BIT(TIMx->EGR, TIM_EGR_BG);
4592 * @brief Generate break 2 event.
4593 * @rmtoll EGR B2G LL_TIM_GenerateEvent_BRK2
4594 * @param TIMx Timer instance
4595 * @retval None
4597 __STATIC_INLINE void LL_TIM_GenerateEvent_BRK2(TIM_TypeDef *TIMx)
4599 SET_BIT(TIMx->EGR, TIM_EGR_B2G);
4603 * @}
4606 #if defined(USE_FULL_LL_DRIVER)
4607 /** @defgroup TIM_LL_EF_Init Initialisation and deinitialisation functions
4608 * @{
4611 ErrorStatus LL_TIM_DeInit(TIM_TypeDef *TIMx);
4612 void LL_TIM_StructInit(LL_TIM_InitTypeDef *TIM_InitStruct);
4613 ErrorStatus LL_TIM_Init(TIM_TypeDef *TIMx, LL_TIM_InitTypeDef *TIM_InitStruct);
4614 void LL_TIM_OC_StructInit(LL_TIM_OC_InitTypeDef *TIM_OC_InitStruct);
4615 ErrorStatus LL_TIM_OC_Init(TIM_TypeDef *TIMx, uint32_t Channel, LL_TIM_OC_InitTypeDef *TIM_OC_InitStruct);
4616 void LL_TIM_IC_StructInit(LL_TIM_IC_InitTypeDef *TIM_ICInitStruct);
4617 ErrorStatus LL_TIM_IC_Init(TIM_TypeDef *TIMx, uint32_t Channel, LL_TIM_IC_InitTypeDef *TIM_IC_InitStruct);
4618 void LL_TIM_ENCODER_StructInit(LL_TIM_ENCODER_InitTypeDef *TIM_EncoderInitStruct);
4619 ErrorStatus LL_TIM_ENCODER_Init(TIM_TypeDef *TIMx, LL_TIM_ENCODER_InitTypeDef *TIM_EncoderInitStruct);
4620 void LL_TIM_HALLSENSOR_StructInit(LL_TIM_HALLSENSOR_InitTypeDef *TIM_HallSensorInitStruct);
4621 ErrorStatus LL_TIM_HALLSENSOR_Init(TIM_TypeDef *TIMx, LL_TIM_HALLSENSOR_InitTypeDef *TIM_HallSensorInitStruct);
4622 void LL_TIM_BDTR_StructInit(LL_TIM_BDTR_InitTypeDef *TIM_BDTRInitStruct);
4623 ErrorStatus LL_TIM_BDTR_Init(TIM_TypeDef *TIMx, LL_TIM_BDTR_InitTypeDef *TIM_BDTRInitStruct);
4625 * @}
4627 #endif /* USE_FULL_LL_DRIVER */
4630 * @}
4634 * @}
4637 #endif /* TIM1 || TIM8 || TIM2 || TIM3 || TIM4 || TIM5 ||TIM9 || TIM10 || TIM11 || TIM12 || TIM13 || TIM14 || TIM6 || TIM7 */
4640 * @}
4643 #ifdef __cplusplus
4645 #endif
4647 #endif /* __STM32F7xx_LL_TIM_H */
4648 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/