1 /**
2   ******************************************************************************
3   * @file    stm32wbxx_hal_tim.h
4   * @author  MCD Application Team
5   * @brief   Header file of TIM HAL module.
6   ******************************************************************************
7   * @attention
8   *
9   * Copyright (c) 2019 STMicroelectronics.
10   * All rights reserved.
11   *
12   * This software is licensed under terms that can be found in the LICENSE file
13   * in the root directory of this software component.
14   * If no LICENSE file comes with this software, it is provided AS-IS.
15   *
16   ******************************************************************************
17   */
18 
19 /* Define to prevent recursive inclusion -------------------------------------*/
20 #ifndef STM32WBxx_HAL_TIM_H
21 #define STM32WBxx_HAL_TIM_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32wbxx_hal_def.h"
29 
30 /** @addtogroup STM32WBxx_HAL_Driver
31   * @{
32   */
33 
34 /** @addtogroup TIM
35   * @{
36   */
37 
38 /* Exported types ------------------------------------------------------------*/
39 /** @defgroup TIM_Exported_Types TIM Exported Types
40   * @{
41   */
42 
43 /**
44   * @brief  TIM Time base Configuration Structure definition
45   */
46 typedef struct
47 {
48   uint32_t Prescaler;         /*!< Specifies the prescaler value used to divide the TIM clock.
49                                    This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */
50 
51   uint32_t CounterMode;       /*!< Specifies the counter mode.
52                                    This parameter can be a value of @ref TIM_Counter_Mode */
53 
54   uint32_t Period;            /*!< Specifies the period value to be loaded into the active
55                                    Auto-Reload Register at the next update event.
56                                    This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF.  */
57 
58   uint32_t ClockDivision;     /*!< Specifies the clock division.
59                                    This parameter can be a value of @ref TIM_ClockDivision */
60 
61   uint32_t RepetitionCounter;  /*!< Specifies the repetition counter value. Each time the RCR downcounter
62                                     reaches zero, an update event is generated and counting restarts
63                                     from the RCR value (N).
64                                     This means in PWM mode that (N+1) corresponds to:
65                                         - the number of PWM periods in edge-aligned mode
66                                         - the number of half PWM period in center-aligned mode
67                                      GP timers: this parameter must be a number between Min_Data = 0x00 and
68                                      Max_Data = 0xFF.
69                                      Advanced timers: this parameter must be a number between Min_Data = 0x0000 and
70                                      Max_Data = 0xFFFF. */
71 
72   uint32_t AutoReloadPreload;  /*!< Specifies the auto-reload preload.
73                                    This parameter can be a value of @ref TIM_AutoReloadPreload */
74 } TIM_Base_InitTypeDef;
75 
76 /**
77   * @brief  TIM Output Compare Configuration Structure definition
78   */
79 typedef struct
80 {
81   uint32_t OCMode;        /*!< Specifies the TIM mode.
82                                This parameter can be a value of @ref TIM_Output_Compare_and_PWM_modes */
83 
84   uint32_t Pulse;         /*!< Specifies the pulse value to be loaded into the Capture Compare Register.
85                                This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */
86 
87   uint32_t OCPolarity;    /*!< Specifies the output polarity.
88                                This parameter can be a value of @ref TIM_Output_Compare_Polarity */
89 
90   uint32_t OCNPolarity;   /*!< Specifies the complementary output polarity.
91                                This parameter can be a value of @ref TIM_Output_Compare_N_Polarity
92                                @note This parameter is valid only for timer instances supporting break feature. */
93 
94   uint32_t OCFastMode;    /*!< Specifies the Fast mode state.
95                                This parameter can be a value of @ref TIM_Output_Fast_State
96                                @note This parameter is valid only in PWM1 and PWM2 mode. */
97 
98 
99   uint32_t OCIdleState;   /*!< Specifies the TIM Output Compare pin state during Idle state.
100                                This parameter can be a value of @ref TIM_Output_Compare_Idle_State
101                                @note This parameter is valid only for timer instances supporting break feature. */
102 
103   uint32_t OCNIdleState;  /*!< Specifies the TIM Output Compare pin state during Idle state.
104                                This parameter can be a value of @ref TIM_Output_Compare_N_Idle_State
105                                @note This parameter is valid only for timer instances supporting break feature. */
106 } TIM_OC_InitTypeDef;
107 
108 /**
109   * @brief  TIM One Pulse Mode Configuration Structure definition
110   */
111 typedef struct
112 {
113   uint32_t OCMode;        /*!< Specifies the TIM mode.
114                                This parameter can be a value of @ref TIM_Output_Compare_and_PWM_modes */
115 
116   uint32_t Pulse;         /*!< Specifies the pulse value to be loaded into the Capture Compare Register.
117                                This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */
118 
119   uint32_t OCPolarity;    /*!< Specifies the output polarity.
120                                This parameter can be a value of @ref TIM_Output_Compare_Polarity */
121 
122   uint32_t OCNPolarity;   /*!< Specifies the complementary output polarity.
123                                This parameter can be a value of @ref TIM_Output_Compare_N_Polarity
124                                @note This parameter is valid only for timer instances supporting break feature. */
125 
126   uint32_t OCIdleState;   /*!< Specifies the TIM Output Compare pin state during Idle state.
127                                This parameter can be a value of @ref TIM_Output_Compare_Idle_State
128                                @note This parameter is valid only for timer instances supporting break feature. */
129 
130   uint32_t OCNIdleState;  /*!< Specifies the TIM Output Compare pin state during Idle state.
131                                This parameter can be a value of @ref TIM_Output_Compare_N_Idle_State
132                                @note This parameter is valid only for timer instances supporting break feature. */
133 
134   uint32_t ICPolarity;    /*!< Specifies the active edge of the input signal.
135                                This parameter can be a value of @ref TIM_Input_Capture_Polarity */
136 
137   uint32_t ICSelection;   /*!< Specifies the input.
138                               This parameter can be a value of @ref TIM_Input_Capture_Selection */
139 
140   uint32_t ICFilter;      /*!< Specifies the input capture filter.
141                               This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
142 } TIM_OnePulse_InitTypeDef;
143 
144 /**
145   * @brief  TIM Input Capture Configuration Structure definition
146   */
147 typedef struct
148 {
149   uint32_t  ICPolarity;  /*!< Specifies the active edge of the input signal.
150                               This parameter can be a value of @ref TIM_Input_Capture_Polarity */
151 
152   uint32_t ICSelection;  /*!< Specifies the input.
153                               This parameter can be a value of @ref TIM_Input_Capture_Selection */
154 
155   uint32_t ICPrescaler;  /*!< Specifies the Input Capture Prescaler.
156                               This parameter can be a value of @ref TIM_Input_Capture_Prescaler */
157 
158   uint32_t ICFilter;     /*!< Specifies the input capture filter.
159                               This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
160 } TIM_IC_InitTypeDef;
161 
162 /**
163   * @brief  TIM Encoder Configuration Structure definition
164   */
165 typedef struct
166 {
167   uint32_t EncoderMode;   /*!< Specifies the active edge of the input signal.
168                                This parameter can be a value of @ref TIM_Encoder_Mode */
169 
170   uint32_t IC1Polarity;   /*!< Specifies the active edge of the input signal.
171                                This parameter can be a value of @ref TIM_Encoder_Input_Polarity */
172 
173   uint32_t IC1Selection;  /*!< Specifies the input.
174                                This parameter can be a value of @ref TIM_Input_Capture_Selection */
175 
176   uint32_t IC1Prescaler;  /*!< Specifies the Input Capture Prescaler.
177                                This parameter can be a value of @ref TIM_Input_Capture_Prescaler */
178 
179   uint32_t IC1Filter;     /*!< Specifies the input capture filter.
180                                This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
181 
182   uint32_t IC2Polarity;   /*!< Specifies the active edge of the input signal.
183                                This parameter can be a value of @ref TIM_Encoder_Input_Polarity */
184 
185   uint32_t IC2Selection;  /*!< Specifies the input.
186                               This parameter can be a value of @ref TIM_Input_Capture_Selection */
187 
188   uint32_t IC2Prescaler;  /*!< Specifies the Input Capture Prescaler.
189                                This parameter can be a value of @ref TIM_Input_Capture_Prescaler */
190 
191   uint32_t IC2Filter;     /*!< Specifies the input capture filter.
192                                This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
193 } TIM_Encoder_InitTypeDef;
194 
195 /**
196   * @brief  Clock Configuration Handle Structure definition
197   */
198 typedef struct
199 {
200   uint32_t ClockSource;     /*!< TIM clock sources
201                                  This parameter can be a value of @ref TIM_Clock_Source */
202   uint32_t ClockPolarity;   /*!< TIM clock polarity
203                                  This parameter can be a value of @ref TIM_Clock_Polarity */
204   uint32_t ClockPrescaler;  /*!< TIM clock prescaler
205                                  This parameter can be a value of @ref TIM_Clock_Prescaler */
206   uint32_t ClockFilter;     /*!< TIM clock filter
207                                  This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
208 } TIM_ClockConfigTypeDef;
209 
210 /**
211   * @brief  TIM Clear Input Configuration Handle Structure definition
212   */
213 typedef struct
214 {
215   uint32_t ClearInputState;      /*!< TIM clear Input state
216                                       This parameter can be ENABLE or DISABLE */
217   uint32_t ClearInputSource;     /*!< TIM clear Input sources
218                                       This parameter can be a value of @ref TIM_ClearInput_Source */
219   uint32_t ClearInputPolarity;   /*!< TIM Clear Input polarity
220                                       This parameter can be a value of @ref TIM_ClearInput_Polarity */
221   uint32_t ClearInputPrescaler;  /*!< TIM Clear Input prescaler
222                                       This parameter must be 0: When OCRef clear feature is used with ETR source,
223                                       ETR prescaler must be off */
224   uint32_t ClearInputFilter;     /*!< TIM Clear Input filter
225                                       This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
226 } TIM_ClearInputConfigTypeDef;
227 
228 /**
229   * @brief  TIM Master configuration Structure definition
230   * @note   Advanced timers provide TRGO2 internal line which is redirected
231   *         to the ADC
232   */
233 typedef struct
234 {
235   uint32_t  MasterOutputTrigger;   /*!< Trigger output (TRGO) selection
236                                         This parameter can be a value of @ref TIM_Master_Mode_Selection */
237   uint32_t  MasterOutputTrigger2;  /*!< Trigger output2 (TRGO2) selection
238                                         This parameter can be a value of @ref TIM_Master_Mode_Selection_2 */
239   uint32_t  MasterSlaveMode;       /*!< Master/slave mode selection
240                                         This parameter can be a value of @ref TIM_Master_Slave_Mode
241                                         @note When the Master/slave mode is enabled, the effect of
242                                         an event on the trigger input (TRGI) is delayed to allow a
243                                         perfect synchronization between the current timer and its
244                                         slaves (through TRGO). It is not mandatory in case of timer
245                                         synchronization mode. */
246 } TIM_MasterConfigTypeDef;
247 
248 /**
249   * @brief  TIM Slave configuration Structure definition
250   */
251 typedef struct
252 {
253   uint32_t  SlaveMode;         /*!< Slave mode selection
254                                     This parameter can be a value of @ref TIM_Slave_Mode */
255   uint32_t  InputTrigger;      /*!< Input Trigger source
256                                     This parameter can be a value of @ref TIM_Trigger_Selection */
257   uint32_t  TriggerPolarity;   /*!< Input Trigger polarity
258                                     This parameter can be a value of @ref TIM_Trigger_Polarity */
259   uint32_t  TriggerPrescaler;  /*!< Input trigger prescaler
260                                     This parameter can be a value of @ref TIM_Trigger_Prescaler */
261   uint32_t  TriggerFilter;     /*!< Input trigger filter
262                                     This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF  */
263 
264 } TIM_SlaveConfigTypeDef;
265 
266 /**
267   * @brief  TIM Break input(s) and Dead time configuration Structure definition
268   * @note   2 break inputs can be configured (BKIN and BKIN2) with configurable
269   *        filter and polarity.
270   */
271 typedef struct
272 {
273   uint32_t OffStateRunMode;      /*!< TIM off state in run mode, This parameter can be a value of @ref TIM_OSSR_Off_State_Selection_for_Run_mode_state */
274 
275   uint32_t OffStateIDLEMode;     /*!< TIM off state in IDLE mode, This parameter can be a value of @ref TIM_OSSI_Off_State_Selection_for_Idle_mode_state */
276 
277   uint32_t LockLevel;            /*!< TIM Lock level, This parameter can be a value of @ref TIM_Lock_level */
278 
279   uint32_t DeadTime;             /*!< TIM dead Time, This parameter can be a number between Min_Data = 0x00 and Max_Data = 0xFF */
280 
281   uint32_t BreakState;           /*!< TIM Break State, This parameter can be a value of @ref TIM_Break_Input_enable_disable */
282 
283   uint32_t BreakPolarity;        /*!< TIM Break input polarity, This parameter can be a value of @ref TIM_Break_Polarity */
284 
285   uint32_t BreakFilter;          /*!< Specifies the break input filter.This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
286 
287   uint32_t BreakAFMode;          /*!< Specifies the alternate function mode of the break input.This parameter can be a value of @ref TIM_Break_Input_AF_Mode */
288 
289   uint32_t Break2State;          /*!< TIM Break2 State, This parameter can be a value of @ref TIM_Break2_Input_enable_disable */
290 
291   uint32_t Break2Polarity;       /*!< TIM Break2 input polarity, This parameter can be a value of @ref TIM_Break2_Polarity */
292 
293   uint32_t Break2Filter;         /*!< TIM break2 input filter.This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
294 
295   uint32_t Break2AFMode;         /*!< Specifies the alternate function mode of the break2 input.This parameter can be a value of @ref TIM_Break2_Input_AF_Mode */
296 
297   uint32_t AutomaticOutput;      /*!< TIM Automatic Output Enable state, This parameter can be a value of @ref TIM_AOE_Bit_Set_Reset */
298 
299 } TIM_BreakDeadTimeConfigTypeDef;
300 
301 /**
302   * @brief  HAL State structures definition
303   */
304 typedef enum
305 {
306   HAL_TIM_STATE_RESET             = 0x00U,    /*!< Peripheral not yet initialized or disabled  */
307   HAL_TIM_STATE_READY             = 0x01U,    /*!< Peripheral Initialized and ready for use    */
308   HAL_TIM_STATE_BUSY              = 0x02U,    /*!< An internal process is ongoing              */
309   HAL_TIM_STATE_TIMEOUT           = 0x03U,    /*!< Timeout state                               */
310   HAL_TIM_STATE_ERROR             = 0x04U     /*!< Reception process is ongoing                */
311 } HAL_TIM_StateTypeDef;
312 
313 /**
314   * @brief  TIM Channel States definition
315   */
316 typedef enum
317 {
318   HAL_TIM_CHANNEL_STATE_RESET             = 0x00U,    /*!< TIM Channel initial state                         */
319   HAL_TIM_CHANNEL_STATE_READY             = 0x01U,    /*!< TIM Channel ready for use                         */
320   HAL_TIM_CHANNEL_STATE_BUSY              = 0x02U,    /*!< An internal process is ongoing on the TIM channel */
321 } HAL_TIM_ChannelStateTypeDef;
322 
323 /**
324   * @brief  DMA Burst States definition
325   */
326 typedef enum
327 {
328   HAL_DMA_BURST_STATE_RESET             = 0x00U,    /*!< DMA Burst initial state */
329   HAL_DMA_BURST_STATE_READY             = 0x01U,    /*!< DMA Burst ready for use */
330   HAL_DMA_BURST_STATE_BUSY              = 0x02U,    /*!< Ongoing DMA Burst       */
331 } HAL_TIM_DMABurstStateTypeDef;
332 
333 /**
334   * @brief  HAL Active channel structures definition
335   */
336 typedef enum
337 {
338   HAL_TIM_ACTIVE_CHANNEL_1        = 0x01U,    /*!< The active channel is 1     */
339   HAL_TIM_ACTIVE_CHANNEL_2        = 0x02U,    /*!< The active channel is 2     */
340   HAL_TIM_ACTIVE_CHANNEL_3        = 0x04U,    /*!< The active channel is 3     */
341   HAL_TIM_ACTIVE_CHANNEL_4        = 0x08U,    /*!< The active channel is 4     */
342   HAL_TIM_ACTIVE_CHANNEL_5        = 0x10U,    /*!< The active channel is 5     */
343   HAL_TIM_ACTIVE_CHANNEL_6        = 0x20U,    /*!< The active channel is 6     */
344   HAL_TIM_ACTIVE_CHANNEL_CLEARED  = 0x00U     /*!< All active channels cleared */
345 } HAL_TIM_ActiveChannel;
346 
347 /**
348   * @brief  TIM Time Base Handle Structure definition
349   */
350 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
351 typedef struct __TIM_HandleTypeDef
352 #else
353 typedef struct
354 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
355 {
356   TIM_TypeDef                        *Instance;         /*!< Register base address                             */
357   TIM_Base_InitTypeDef               Init;              /*!< TIM Time Base required parameters                 */
358   HAL_TIM_ActiveChannel              Channel;           /*!< Active channel                                    */
359   DMA_HandleTypeDef                  *hdma[7];          /*!< DMA Handlers array
360                                                              This array is accessed by a @ref DMA_Handle_index */
361   HAL_LockTypeDef                    Lock;              /*!< Locking object                                    */
362   __IO HAL_TIM_StateTypeDef          State;             /*!< TIM operation state                               */
363   __IO HAL_TIM_ChannelStateTypeDef   ChannelState[6];   /*!< TIM channel operation state                       */
364   __IO HAL_TIM_ChannelStateTypeDef   ChannelNState[4];  /*!< TIM complementary channel operation state         */
365   __IO HAL_TIM_DMABurstStateTypeDef  DMABurstState;     /*!< DMA burst operation state                         */
366 
367 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
368   void (* Base_MspInitCallback)(struct __TIM_HandleTypeDef *htim);              /*!< TIM Base Msp Init Callback                              */
369   void (* Base_MspDeInitCallback)(struct __TIM_HandleTypeDef *htim);            /*!< TIM Base Msp DeInit Callback                            */
370   void (* IC_MspInitCallback)(struct __TIM_HandleTypeDef *htim);                /*!< TIM IC Msp Init Callback                                */
371   void (* IC_MspDeInitCallback)(struct __TIM_HandleTypeDef *htim);              /*!< TIM IC Msp DeInit Callback                              */
372   void (* OC_MspInitCallback)(struct __TIM_HandleTypeDef *htim);                /*!< TIM OC Msp Init Callback                                */
373   void (* OC_MspDeInitCallback)(struct __TIM_HandleTypeDef *htim);              /*!< TIM OC Msp DeInit Callback                              */
374   void (* PWM_MspInitCallback)(struct __TIM_HandleTypeDef *htim);               /*!< TIM PWM Msp Init Callback                               */
375   void (* PWM_MspDeInitCallback)(struct __TIM_HandleTypeDef *htim);             /*!< TIM PWM Msp DeInit Callback                             */
376   void (* OnePulse_MspInitCallback)(struct __TIM_HandleTypeDef *htim);          /*!< TIM One Pulse Msp Init Callback                         */
377   void (* OnePulse_MspDeInitCallback)(struct __TIM_HandleTypeDef *htim);        /*!< TIM One Pulse Msp DeInit Callback                       */
378   void (* Encoder_MspInitCallback)(struct __TIM_HandleTypeDef *htim);           /*!< TIM Encoder Msp Init Callback                           */
379   void (* Encoder_MspDeInitCallback)(struct __TIM_HandleTypeDef *htim);         /*!< TIM Encoder Msp DeInit Callback                         */
380   void (* HallSensor_MspInitCallback)(struct __TIM_HandleTypeDef *htim);        /*!< TIM Hall Sensor Msp Init Callback                       */
381   void (* HallSensor_MspDeInitCallback)(struct __TIM_HandleTypeDef *htim);      /*!< TIM Hall Sensor Msp DeInit Callback                     */
382   void (* PeriodElapsedCallback)(struct __TIM_HandleTypeDef *htim);             /*!< TIM Period Elapsed Callback                             */
383   void (* PeriodElapsedHalfCpltCallback)(struct __TIM_HandleTypeDef *htim);     /*!< TIM Period Elapsed half complete Callback               */
384   void (* TriggerCallback)(struct __TIM_HandleTypeDef *htim);                   /*!< TIM Trigger Callback                                    */
385   void (* TriggerHalfCpltCallback)(struct __TIM_HandleTypeDef *htim);           /*!< TIM Trigger half complete Callback                      */
386   void (* IC_CaptureCallback)(struct __TIM_HandleTypeDef *htim);                /*!< TIM Input Capture Callback                              */
387   void (* IC_CaptureHalfCpltCallback)(struct __TIM_HandleTypeDef *htim);        /*!< TIM Input Capture half complete Callback                */
388   void (* OC_DelayElapsedCallback)(struct __TIM_HandleTypeDef *htim);           /*!< TIM Output Compare Delay Elapsed Callback               */
389   void (* PWM_PulseFinishedCallback)(struct __TIM_HandleTypeDef *htim);         /*!< TIM PWM Pulse Finished Callback                         */
390   void (* PWM_PulseFinishedHalfCpltCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM PWM Pulse Finished half complete Callback           */
391   void (* ErrorCallback)(struct __TIM_HandleTypeDef *htim);                     /*!< TIM Error Callback                                      */
392   void (* CommutationCallback)(struct __TIM_HandleTypeDef *htim);               /*!< TIM Commutation Callback                                */
393   void (* CommutationHalfCpltCallback)(struct __TIM_HandleTypeDef *htim);       /*!< TIM Commutation half complete Callback                  */
394   void (* BreakCallback)(struct __TIM_HandleTypeDef *htim);                     /*!< TIM Break Callback                                      */
395   void (* Break2Callback)(struct __TIM_HandleTypeDef *htim);                    /*!< TIM Break2 Callback                                     */
396 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
397 } TIM_HandleTypeDef;
398 
399 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
400 /**
401   * @brief  HAL TIM Callback ID enumeration definition
402   */
403 typedef enum
404 {
405   HAL_TIM_BASE_MSPINIT_CB_ID              = 0x00U   /*!< TIM Base MspInit Callback ID                               */
406   , HAL_TIM_BASE_MSPDEINIT_CB_ID          = 0x01U   /*!< TIM Base MspDeInit Callback ID                             */
407   , HAL_TIM_IC_MSPINIT_CB_ID              = 0x02U   /*!< TIM IC MspInit Callback ID                                 */
408   , HAL_TIM_IC_MSPDEINIT_CB_ID            = 0x03U   /*!< TIM IC MspDeInit Callback ID                               */
409   , HAL_TIM_OC_MSPINIT_CB_ID              = 0x04U   /*!< TIM OC MspInit Callback ID                                 */
410   , HAL_TIM_OC_MSPDEINIT_CB_ID            = 0x05U   /*!< TIM OC MspDeInit Callback ID                               */
411   , HAL_TIM_PWM_MSPINIT_CB_ID             = 0x06U   /*!< TIM PWM MspInit Callback ID                                */
412   , HAL_TIM_PWM_MSPDEINIT_CB_ID           = 0x07U   /*!< TIM PWM MspDeInit Callback ID                              */
413   , HAL_TIM_ONE_PULSE_MSPINIT_CB_ID       = 0x08U   /*!< TIM One Pulse MspInit Callback ID                          */
414   , HAL_TIM_ONE_PULSE_MSPDEINIT_CB_ID     = 0x09U   /*!< TIM One Pulse MspDeInit Callback ID                        */
415   , HAL_TIM_ENCODER_MSPINIT_CB_ID         = 0x0AU   /*!< TIM Encoder MspInit Callback ID                            */
416   , HAL_TIM_ENCODER_MSPDEINIT_CB_ID       = 0x0BU   /*!< TIM Encoder MspDeInit Callback ID                          */
417   , HAL_TIM_HALL_SENSOR_MSPINIT_CB_ID     = 0x0CU   /*!< TIM Hall Sensor MspDeInit Callback ID                      */
418   , HAL_TIM_HALL_SENSOR_MSPDEINIT_CB_ID   = 0x0DU   /*!< TIM Hall Sensor MspDeInit Callback ID                      */
419   , HAL_TIM_PERIOD_ELAPSED_CB_ID          = 0x0EU   /*!< TIM Period Elapsed Callback ID                             */
420   , HAL_TIM_PERIOD_ELAPSED_HALF_CB_ID     = 0x0FU   /*!< TIM Period Elapsed half complete Callback ID               */
421   , HAL_TIM_TRIGGER_CB_ID                 = 0x10U   /*!< TIM Trigger Callback ID                                    */
422   , HAL_TIM_TRIGGER_HALF_CB_ID            = 0x11U   /*!< TIM Trigger half complete Callback ID                      */
423   , HAL_TIM_IC_CAPTURE_CB_ID              = 0x12U   /*!< TIM Input Capture Callback ID                              */
424   , HAL_TIM_IC_CAPTURE_HALF_CB_ID         = 0x13U   /*!< TIM Input Capture half complete Callback ID                */
425   , HAL_TIM_OC_DELAY_ELAPSED_CB_ID        = 0x14U   /*!< TIM Output Compare Delay Elapsed Callback ID               */
426   , HAL_TIM_PWM_PULSE_FINISHED_CB_ID      = 0x15U   /*!< TIM PWM Pulse Finished Callback ID                         */
427   , HAL_TIM_PWM_PULSE_FINISHED_HALF_CB_ID = 0x16U   /*!< TIM PWM Pulse Finished half complete Callback ID           */
428   , HAL_TIM_ERROR_CB_ID                   = 0x17U   /*!< TIM Error Callback ID                                      */
429   , HAL_TIM_COMMUTATION_CB_ID             = 0x18U   /*!< TIM Commutation Callback ID                                */
430   , HAL_TIM_COMMUTATION_HALF_CB_ID        = 0x19U   /*!< TIM Commutation half complete Callback ID                  */
431   , HAL_TIM_BREAK_CB_ID                   = 0x1AU   /*!< TIM Break Callback ID                                      */
432   , HAL_TIM_BREAK2_CB_ID                  = 0x1BU   /*!< TIM Break2 Callback ID                                     */
433 } HAL_TIM_CallbackIDTypeDef;
434 
435 /**
436   * @brief  HAL TIM Callback pointer definition
437   */
438 typedef  void (*pTIM_CallbackTypeDef)(TIM_HandleTypeDef *htim);  /*!< pointer to the TIM callback function */
439 
440 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
441 
442 /**
443   * @}
444   */
445 /* End of exported types -----------------------------------------------------*/
446 
447 /* Exported constants --------------------------------------------------------*/
448 /** @defgroup TIM_Exported_Constants TIM Exported Constants
449   * @{
450   */
451 
452 /** @defgroup TIM_ClearInput_Source TIM Clear Input Source
453   * @{
454   */
455 #define TIM_CLEARINPUTSOURCE_NONE           0x00000000U         /*!< OCREF_CLR is disabled */
456 #define TIM_CLEARINPUTSOURCE_ETR            0x00000001U         /*!< OCREF_CLR is connected to ETRF input */
457 #define TIM_CLEARINPUTSOURCE_COMP1          TIM1_AF1_ETRSEL_0   /*!< OCREF_CLR_INT is connected to COMP1 output */
458 #define TIM_CLEARINPUTSOURCE_COMP2          TIM1_AF1_ETRSEL_1   /*!< OCREF_CLR_INT is connected to COMP2 output */
459 /**
460   * @}
461   */
462 
463 /** @defgroup TIM_DMA_Base_address TIM DMA Base Address
464   * @{
465   */
466 #define TIM_DMABASE_CR1                    0x00000000U
467 #define TIM_DMABASE_CR2                    0x00000001U
468 #define TIM_DMABASE_SMCR                   0x00000002U
469 #define TIM_DMABASE_DIER                   0x00000003U
470 #define TIM_DMABASE_SR                     0x00000004U
471 #define TIM_DMABASE_EGR                    0x00000005U
472 #define TIM_DMABASE_CCMR1                  0x00000006U
473 #define TIM_DMABASE_CCMR2                  0x00000007U
474 #define TIM_DMABASE_CCER                   0x00000008U
475 #define TIM_DMABASE_CNT                    0x00000009U
476 #define TIM_DMABASE_PSC                    0x0000000AU
477 #define TIM_DMABASE_ARR                    0x0000000BU
478 #define TIM_DMABASE_RCR                    0x0000000CU
479 #define TIM_DMABASE_CCR1                   0x0000000DU
480 #define TIM_DMABASE_CCR2                   0x0000000EU
481 #define TIM_DMABASE_CCR3                   0x0000000FU
482 #define TIM_DMABASE_CCR4                   0x00000010U
483 #define TIM_DMABASE_BDTR                   0x00000011U
484 #define TIM_DMABASE_DCR                    0x00000012U
485 #define TIM_DMABASE_DMAR                   0x00000013U
486 #define TIM_DMABASE_OR                     0x00000014U
487 #define TIM_DMABASE_CCMR3                  0x00000015U
488 #define TIM_DMABASE_CCR5                   0x00000016U
489 #define TIM_DMABASE_CCR6                   0x00000017U
490 #define TIM_DMABASE_AF1                    0x00000018U
491 #define TIM_DMABASE_AF2                    0x00000019U
492 /**
493   * @}
494   */
495 
496 /** @defgroup TIM_Event_Source TIM Event Source
497   * @{
498   */
499 #define TIM_EVENTSOURCE_UPDATE              TIM_EGR_UG     /*!< Reinitialize the counter and generates an update of the registers */
500 #define TIM_EVENTSOURCE_CC1                 TIM_EGR_CC1G   /*!< A capture/compare event is generated on channel 1 */
501 #define TIM_EVENTSOURCE_CC2                 TIM_EGR_CC2G   /*!< A capture/compare event is generated on channel 2 */
502 #define TIM_EVENTSOURCE_CC3                 TIM_EGR_CC3G   /*!< A capture/compare event is generated on channel 3 */
503 #define TIM_EVENTSOURCE_CC4                 TIM_EGR_CC4G   /*!< A capture/compare event is generated on channel 4 */
504 #define TIM_EVENTSOURCE_COM                 TIM_EGR_COMG   /*!< A commutation event is generated */
505 #define TIM_EVENTSOURCE_TRIGGER             TIM_EGR_TG     /*!< A trigger event is generated */
506 #define TIM_EVENTSOURCE_BREAK               TIM_EGR_BG     /*!< A break event is generated */
507 #define TIM_EVENTSOURCE_BREAK2              TIM_EGR_B2G    /*!< A break 2 event is generated */
508 /**
509   * @}
510   */
511 
512 /** @defgroup TIM_Input_Channel_Polarity TIM Input Channel polarity
513   * @{
514   */
515 #define  TIM_INPUTCHANNELPOLARITY_RISING      0x00000000U                       /*!< Polarity for TIx source */
516 #define  TIM_INPUTCHANNELPOLARITY_FALLING     TIM_CCER_CC1P                     /*!< Polarity for TIx source */
517 #define  TIM_INPUTCHANNELPOLARITY_BOTHEDGE    (TIM_CCER_CC1P | TIM_CCER_CC1NP)  /*!< Polarity for TIx source */
518 /**
519   * @}
520   */
521 
522 /** @defgroup TIM_ETR_Polarity TIM ETR Polarity
523   * @{
524   */
525 #define TIM_ETRPOLARITY_INVERTED              TIM_SMCR_ETP                      /*!< Polarity for ETR source */
526 #define TIM_ETRPOLARITY_NONINVERTED           0x00000000U                       /*!< Polarity for ETR source */
527 /**
528   * @}
529   */
530 
531 /** @defgroup TIM_ETR_Prescaler TIM ETR Prescaler
532   * @{
533   */
534 #define TIM_ETRPRESCALER_DIV1                 0x00000000U                       /*!< No prescaler is used */
535 #define TIM_ETRPRESCALER_DIV2                 TIM_SMCR_ETPS_0                   /*!< ETR input source is divided by 2 */
536 #define TIM_ETRPRESCALER_DIV4                 TIM_SMCR_ETPS_1                   /*!< ETR input source is divided by 4 */
537 #define TIM_ETRPRESCALER_DIV8                 TIM_SMCR_ETPS                     /*!< ETR input source is divided by 8 */
538 /**
539   * @}
540   */
541 
542 /** @defgroup TIM_Counter_Mode TIM Counter Mode
543   * @{
544   */
545 #define TIM_COUNTERMODE_UP                 0x00000000U                          /*!< Counter used as up-counter   */
546 #define TIM_COUNTERMODE_DOWN               TIM_CR1_DIR                          /*!< Counter used as down-counter */
547 #define TIM_COUNTERMODE_CENTERALIGNED1     TIM_CR1_CMS_0                        /*!< Center-aligned mode 1        */
548 #define TIM_COUNTERMODE_CENTERALIGNED2     TIM_CR1_CMS_1                        /*!< Center-aligned mode 2        */
549 #define TIM_COUNTERMODE_CENTERALIGNED3     TIM_CR1_CMS                          /*!< Center-aligned mode 3        */
550 /**
551   * @}
552   */
553 
554 /** @defgroup TIM_Update_Interrupt_Flag_Remap TIM Update Interrupt Flag Remap
555   * @{
556   */
557 #define TIM_UIFREMAP_DISABLE               0x00000000U                          /*!< Update interrupt flag remap disabled */
558 #define TIM_UIFREMAP_ENABLE                TIM_CR1_UIFREMAP                     /*!< Update interrupt flag remap enabled */
559 /**
560   * @}
561   */
562 
563 /** @defgroup TIM_ClockDivision TIM Clock Division
564   * @{
565   */
566 #define TIM_CLOCKDIVISION_DIV1             0x00000000U                          /*!< Clock division: tDTS=tCK_INT   */
567 #define TIM_CLOCKDIVISION_DIV2             TIM_CR1_CKD_0                        /*!< Clock division: tDTS=2*tCK_INT */
568 #define TIM_CLOCKDIVISION_DIV4             TIM_CR1_CKD_1                        /*!< Clock division: tDTS=4*tCK_INT */
569 /**
570   * @}
571   */
572 
573 /** @defgroup TIM_Output_Compare_State TIM Output Compare State
574   * @{
575   */
576 #define TIM_OUTPUTSTATE_DISABLE            0x00000000U                          /*!< Capture/Compare 1 output disabled */
577 #define TIM_OUTPUTSTATE_ENABLE             TIM_CCER_CC1E                        /*!< Capture/Compare 1 output enabled */
578 /**
579   * @}
580   */
581 
582 /** @defgroup TIM_AutoReloadPreload TIM Auto-Reload Preload
583   * @{
584   */
585 #define TIM_AUTORELOAD_PRELOAD_DISABLE                0x00000000U               /*!< TIMx_ARR register is not buffered */
586 #define TIM_AUTORELOAD_PRELOAD_ENABLE                 TIM_CR1_ARPE              /*!< TIMx_ARR register is buffered */
587 
588 /**
589   * @}
590   */
591 
592 /** @defgroup TIM_Output_Fast_State TIM Output Fast State
593   * @{
594   */
595 #define TIM_OCFAST_DISABLE                 0x00000000U                          /*!< Output Compare fast disable */
596 #define TIM_OCFAST_ENABLE                  TIM_CCMR1_OC1FE                      /*!< Output Compare fast enable  */
597 /**
598   * @}
599   */
600 
601 /** @defgroup TIM_Output_Compare_N_State TIM Complementary Output Compare State
602   * @{
603   */
604 #define TIM_OUTPUTNSTATE_DISABLE           0x00000000U                          /*!< OCxN is disabled  */
605 #define TIM_OUTPUTNSTATE_ENABLE            TIM_CCER_CC1NE                       /*!< OCxN is enabled   */
606 /**
607   * @}
608   */
609 
610 /** @defgroup TIM_Output_Compare_Polarity TIM Output Compare Polarity
611   * @{
612   */
613 #define TIM_OCPOLARITY_HIGH                0x00000000U                          /*!< Capture/Compare output polarity  */
614 #define TIM_OCPOLARITY_LOW                 TIM_CCER_CC1P                        /*!< Capture/Compare output polarity  */
615 /**
616   * @}
617   */
618 
619 /** @defgroup TIM_Output_Compare_N_Polarity TIM Complementary Output Compare Polarity
620   * @{
621   */
622 #define TIM_OCNPOLARITY_HIGH               0x00000000U                          /*!< Capture/Compare complementary output polarity */
623 #define TIM_OCNPOLARITY_LOW                TIM_CCER_CC1NP                       /*!< Capture/Compare complementary output polarity */
624 /**
625   * @}
626   */
627 
628 /** @defgroup TIM_Output_Compare_Idle_State TIM Output Compare Idle State
629   * @{
630   */
631 #define TIM_OCIDLESTATE_SET                TIM_CR2_OIS1                         /*!< Output Idle state: OCx=1 when MOE=0 */
632 #define TIM_OCIDLESTATE_RESET              0x00000000U                          /*!< Output Idle state: OCx=0 when MOE=0 */
633 /**
634   * @}
635   */
636 
637 /** @defgroup TIM_Output_Compare_N_Idle_State TIM Complementary Output Compare Idle State
638   * @{
639   */
640 #define TIM_OCNIDLESTATE_SET               TIM_CR2_OIS1N                        /*!< Complementary output Idle state: OCxN=1 when MOE=0 */
641 #define TIM_OCNIDLESTATE_RESET             0x00000000U                          /*!< Complementary output Idle state: OCxN=0 when MOE=0 */
642 /**
643   * @}
644   */
645 
646 /** @defgroup TIM_Input_Capture_Polarity TIM Input Capture Polarity
647   * @{
648   */
649 #define  TIM_ICPOLARITY_RISING             TIM_INPUTCHANNELPOLARITY_RISING      /*!< Capture triggered by rising edge on timer input                  */
650 #define  TIM_ICPOLARITY_FALLING            TIM_INPUTCHANNELPOLARITY_FALLING     /*!< Capture triggered by falling edge on timer input                 */
651 #define  TIM_ICPOLARITY_BOTHEDGE           TIM_INPUTCHANNELPOLARITY_BOTHEDGE    /*!< Capture triggered by both rising and falling edges on timer input*/
652 /**
653   * @}
654   */
655 
656 /** @defgroup TIM_Encoder_Input_Polarity TIM Encoder Input Polarity
657   * @{
658   */
659 #define  TIM_ENCODERINPUTPOLARITY_RISING   TIM_INPUTCHANNELPOLARITY_RISING      /*!< Encoder input with rising edge polarity  */
660 #define  TIM_ENCODERINPUTPOLARITY_FALLING  TIM_INPUTCHANNELPOLARITY_FALLING     /*!< Encoder input with falling edge polarity */
661 /**
662   * @}
663   */
664 
665 /** @defgroup TIM_Input_Capture_Selection TIM Input Capture Selection
666   * @{
667   */
668 #define TIM_ICSELECTION_DIRECTTI           TIM_CCMR1_CC1S_0                     /*!< TIM Input 1, 2, 3 or 4 is selected to be connected to IC1, IC2, IC3 or IC4, respectively */
669 #define TIM_ICSELECTION_INDIRECTTI         TIM_CCMR1_CC1S_1                     /*!< TIM Input 1, 2, 3 or 4 is selected to be connected to IC2, IC1, IC4 or IC3, respectively */
670 #define TIM_ICSELECTION_TRC                TIM_CCMR1_CC1S                       /*!< TIM Input 1, 2, 3 or 4 is selected to be connected to TRC */
671 /**
672   * @}
673   */
674 
675 /** @defgroup TIM_Input_Capture_Prescaler TIM Input Capture Prescaler
676   * @{
677   */
678 #define TIM_ICPSC_DIV1                     0x00000000U                          /*!< Capture performed each time an edge is detected on the capture input */
679 #define TIM_ICPSC_DIV2                     TIM_CCMR1_IC1PSC_0                   /*!< Capture performed once every 2 events                                */
680 #define TIM_ICPSC_DIV4                     TIM_CCMR1_IC1PSC_1                   /*!< Capture performed once every 4 events                                */
681 #define TIM_ICPSC_DIV8                     TIM_CCMR1_IC1PSC                     /*!< Capture performed once every 8 events                                */
682 /**
683   * @}
684   */
685 
686 /** @defgroup TIM_One_Pulse_Mode TIM One Pulse Mode
687   * @{
688   */
689 #define TIM_OPMODE_SINGLE                  TIM_CR1_OPM                          /*!< Counter stops counting at the next update event */
690 #define TIM_OPMODE_REPETITIVE              0x00000000U                          /*!< Counter is not stopped at update event          */
691 /**
692   * @}
693   */
694 
695 /** @defgroup TIM_Encoder_Mode TIM Encoder Mode
696   * @{
697   */
698 #define TIM_ENCODERMODE_TI1                      TIM_SMCR_SMS_0                                                      /*!< Quadrature encoder mode 1, x2 mode, counts up/down on TI1FP1 edge depending on TI2FP2 level  */
699 #define TIM_ENCODERMODE_TI2                      TIM_SMCR_SMS_1                                                      /*!< Quadrature encoder mode 2, x2 mode, counts up/down on TI2FP2 edge depending on TI1FP1 level. */
700 #define TIM_ENCODERMODE_TI12                     (TIM_SMCR_SMS_1 | TIM_SMCR_SMS_0)                                   /*!< Quadrature encoder mode 3, x4 mode, counts up/down on both TI1FP1 and TI2FP2 edges depending on the level of the other input. */
701 /**
702   * @}
703   */
704 
705 /** @defgroup TIM_Interrupt_definition TIM interrupt Definition
706   * @{
707   */
708 #define TIM_IT_UPDATE                      TIM_DIER_UIE                         /*!< Update interrupt            */
709 #define TIM_IT_CC1                         TIM_DIER_CC1IE                       /*!< Capture/Compare 1 interrupt */
710 #define TIM_IT_CC2                         TIM_DIER_CC2IE                       /*!< Capture/Compare 2 interrupt */
711 #define TIM_IT_CC3                         TIM_DIER_CC3IE                       /*!< Capture/Compare 3 interrupt */
712 #define TIM_IT_CC4                         TIM_DIER_CC4IE                       /*!< Capture/Compare 4 interrupt */
713 #define TIM_IT_COM                         TIM_DIER_COMIE                       /*!< Commutation interrupt       */
714 #define TIM_IT_TRIGGER                     TIM_DIER_TIE                         /*!< Trigger interrupt           */
715 #define TIM_IT_BREAK                       TIM_DIER_BIE                         /*!< Break interrupt             */
716 /**
717   * @}
718   */
719 
720 /** @defgroup TIM_Commutation_Source  TIM Commutation Source
721   * @{
722   */
723 #define TIM_COMMUTATION_TRGI              TIM_CR2_CCUS                          /*!< When Capture/compare control bits are preloaded, they are updated by setting the COMG bit or when an rising edge occurs on trigger input */
724 #define TIM_COMMUTATION_SOFTWARE          0x00000000U                           /*!< When Capture/compare control bits are preloaded, they are updated by setting the COMG bit */
725 /**
726   * @}
727   */
728 
729 /** @defgroup TIM_DMA_sources TIM DMA Sources
730   * @{
731   */
732 #define TIM_DMA_UPDATE                     TIM_DIER_UDE                         /*!< DMA request is triggered by the update event */
733 #define TIM_DMA_CC1                        TIM_DIER_CC1DE                       /*!< DMA request is triggered by the capture/compare macth 1 event */
734 #define TIM_DMA_CC2                        TIM_DIER_CC2DE                       /*!< DMA request is triggered by the capture/compare macth 2 event event */
735 #define TIM_DMA_CC3                        TIM_DIER_CC3DE                       /*!< DMA request is triggered by the capture/compare macth 3 event event */
736 #define TIM_DMA_CC4                        TIM_DIER_CC4DE                       /*!< DMA request is triggered by the capture/compare macth 4 event event */
737 #define TIM_DMA_COM                        TIM_DIER_COMDE                       /*!< DMA request is triggered by the commutation event */
738 #define TIM_DMA_TRIGGER                    TIM_DIER_TDE                         /*!< DMA request is triggered by the trigger event */
739 /**
740   * @}
741   */
742 
743 /** @defgroup TIM_CC_DMA_Request CCx DMA request selection
744   * @{
745   */
746 #define TIM_CCDMAREQUEST_CC                 0x00000000U                         /*!< CCx DMA request sent when capture or compare match event occurs */
747 #define TIM_CCDMAREQUEST_UPDATE             TIM_CR2_CCDS                        /*!< CCx DMA requests sent when update event occurs */
748 /**
749   * @}
750   */
751 
752 /** @defgroup TIM_Flag_definition TIM Flag Definition
753   * @{
754   */
755 #define TIM_FLAG_UPDATE                    TIM_SR_UIF                           /*!< Update interrupt flag         */
756 #define TIM_FLAG_CC1                       TIM_SR_CC1IF                         /*!< Capture/Compare 1 interrupt flag */
757 #define TIM_FLAG_CC2                       TIM_SR_CC2IF                         /*!< Capture/Compare 2 interrupt flag */
758 #define TIM_FLAG_CC3                       TIM_SR_CC3IF                         /*!< Capture/Compare 3 interrupt flag */
759 #define TIM_FLAG_CC4                       TIM_SR_CC4IF                         /*!< Capture/Compare 4 interrupt flag */
760 #define TIM_FLAG_CC5                       TIM_SR_CC5IF                         /*!< Capture/Compare 5 interrupt flag */
761 #define TIM_FLAG_CC6                       TIM_SR_CC6IF                         /*!< Capture/Compare 6 interrupt flag */
762 #define TIM_FLAG_COM                       TIM_SR_COMIF                         /*!< Commutation interrupt flag    */
763 #define TIM_FLAG_TRIGGER                   TIM_SR_TIF                           /*!< Trigger interrupt flag        */
764 #define TIM_FLAG_BREAK                     TIM_SR_BIF                           /*!< Break interrupt flag          */
765 #define TIM_FLAG_BREAK2                    TIM_SR_B2IF                          /*!< Break 2 interrupt flag        */
766 #define TIM_FLAG_SYSTEM_BREAK              TIM_SR_SBIF                          /*!< System Break interrupt flag   */
767 #define TIM_FLAG_CC1OF                     TIM_SR_CC1OF                         /*!< Capture 1 overcapture flag    */
768 #define TIM_FLAG_CC2OF                     TIM_SR_CC2OF                         /*!< Capture 2 overcapture flag    */
769 #define TIM_FLAG_CC3OF                     TIM_SR_CC3OF                         /*!< Capture 3 overcapture flag    */
770 #define TIM_FLAG_CC4OF                     TIM_SR_CC4OF                         /*!< Capture 4 overcapture flag    */
771 /**
772   * @}
773   */
774 
775 /** @defgroup TIM_Channel TIM Channel
776   * @{
777   */
778 #define TIM_CHANNEL_1                      0x00000000U                          /*!< Capture/compare channel 1 identifier      */
779 #define TIM_CHANNEL_2                      0x00000004U                          /*!< Capture/compare channel 2 identifier      */
780 #define TIM_CHANNEL_3                      0x00000008U                          /*!< Capture/compare channel 3 identifier      */
781 #define TIM_CHANNEL_4                      0x0000000CU                          /*!< Capture/compare channel 4 identifier      */
782 #define TIM_CHANNEL_5                      0x00000010U                          /*!< Compare channel 5 identifier              */
783 #define TIM_CHANNEL_6                      0x00000014U                          /*!< Compare channel 6 identifier              */
784 #define TIM_CHANNEL_ALL                    0x0000003CU                          /*!< Global Capture/compare channel identifier  */
785 /**
786   * @}
787   */
788 
789 /** @defgroup TIM_Clock_Source TIM Clock Source
790   * @{
791   */
792 #define TIM_CLOCKSOURCE_INTERNAL    TIM_SMCR_ETPS_0      /*!< Internal clock source                                 */
793 #define TIM_CLOCKSOURCE_ETRMODE1    TIM_TS_ETRF          /*!< External clock source mode 1 (ETRF)                   */
794 #define TIM_CLOCKSOURCE_ETRMODE2    TIM_SMCR_ETPS_1      /*!< External clock source mode 2                          */
795 #define TIM_CLOCKSOURCE_TI1ED       TIM_TS_TI1F_ED       /*!< External clock source mode 1 (TTI1FP1 + edge detect.) */
796 #define TIM_CLOCKSOURCE_TI1         TIM_TS_TI1FP1        /*!< External clock source mode 1 (TTI1FP1)                */
797 #define TIM_CLOCKSOURCE_TI2         TIM_TS_TI2FP2        /*!< External clock source mode 1 (TTI2FP2)                */
798 #define TIM_CLOCKSOURCE_ITR0        TIM_TS_ITR0          /*!< External clock source mode 1 (ITR0)                   */
799 #define TIM_CLOCKSOURCE_ITR1        TIM_TS_ITR1          /*!< External clock source mode 1 (ITR1)                   */
800 #define TIM_CLOCKSOURCE_ITR2        TIM_TS_ITR2          /*!< External clock source mode 1 (ITR2)                   */
801 #define TIM_CLOCKSOURCE_ITR3        TIM_TS_ITR3          /*!< External clock source mode 1 (ITR3)                   */
802 /**
803   * @}
804   */
805 
806 /** @defgroup TIM_Clock_Polarity TIM Clock Polarity
807   * @{
808   */
809 #define TIM_CLOCKPOLARITY_INVERTED           TIM_ETRPOLARITY_INVERTED           /*!< Polarity for ETRx clock sources */
810 #define TIM_CLOCKPOLARITY_NONINVERTED        TIM_ETRPOLARITY_NONINVERTED        /*!< Polarity for ETRx clock sources */
811 #define TIM_CLOCKPOLARITY_RISING             TIM_INPUTCHANNELPOLARITY_RISING    /*!< Polarity for TIx clock sources */
812 #define TIM_CLOCKPOLARITY_FALLING            TIM_INPUTCHANNELPOLARITY_FALLING   /*!< Polarity for TIx clock sources */
813 #define TIM_CLOCKPOLARITY_BOTHEDGE           TIM_INPUTCHANNELPOLARITY_BOTHEDGE  /*!< Polarity for TIx clock sources */
814 /**
815   * @}
816   */
817 
818 /** @defgroup TIM_Clock_Prescaler TIM Clock Prescaler
819   * @{
820   */
821 #define TIM_CLOCKPRESCALER_DIV1                 TIM_ETRPRESCALER_DIV1           /*!< No prescaler is used                                                     */
822 #define TIM_CLOCKPRESCALER_DIV2                 TIM_ETRPRESCALER_DIV2           /*!< Prescaler for External ETR Clock: Capture performed once every 2 events. */
823 #define TIM_CLOCKPRESCALER_DIV4                 TIM_ETRPRESCALER_DIV4           /*!< Prescaler for External ETR Clock: Capture performed once every 4 events. */
824 #define TIM_CLOCKPRESCALER_DIV8                 TIM_ETRPRESCALER_DIV8           /*!< Prescaler for External ETR Clock: Capture performed once every 8 events. */
825 /**
826   * @}
827   */
828 
829 /** @defgroup TIM_ClearInput_Polarity TIM Clear Input Polarity
830   * @{
831   */
832 #define TIM_CLEARINPUTPOLARITY_INVERTED           TIM_ETRPOLARITY_INVERTED      /*!< Polarity for ETRx pin */
833 #define TIM_CLEARINPUTPOLARITY_NONINVERTED        TIM_ETRPOLARITY_NONINVERTED   /*!< Polarity for ETRx pin */
834 /**
835   * @}
836   */
837 
838 /** @defgroup TIM_ClearInput_Prescaler TIM Clear Input Prescaler
839   * @{
840   */
841 #define TIM_CLEARINPUTPRESCALER_DIV1              TIM_ETRPRESCALER_DIV1         /*!< No prescaler is used                                                   */
842 #define TIM_CLEARINPUTPRESCALER_DIV2              TIM_ETRPRESCALER_DIV2         /*!< Prescaler for External ETR pin: Capture performed once every 2 events. */
843 #define TIM_CLEARINPUTPRESCALER_DIV4              TIM_ETRPRESCALER_DIV4         /*!< Prescaler for External ETR pin: Capture performed once every 4 events. */
844 #define TIM_CLEARINPUTPRESCALER_DIV8              TIM_ETRPRESCALER_DIV8         /*!< Prescaler for External ETR pin: Capture performed once every 8 events. */
845 /**
846   * @}
847   */
848 
849 /** @defgroup TIM_OSSR_Off_State_Selection_for_Run_mode_state TIM OSSR OffState Selection for Run mode state
850   * @{
851   */
852 #define TIM_OSSR_ENABLE                          TIM_BDTR_OSSR                  /*!< When inactive, OC/OCN outputs are enabled (still controlled by the timer)           */
853 #define TIM_OSSR_DISABLE                         0x00000000U                    /*!< When inactive, OC/OCN outputs are disabled (not controlled any longer by the timer) */
854 /**
855   * @}
856   */
857 
858 /** @defgroup TIM_OSSI_Off_State_Selection_for_Idle_mode_state TIM OSSI OffState Selection for Idle mode state
859   * @{
860   */
861 #define TIM_OSSI_ENABLE                          TIM_BDTR_OSSI                  /*!< When inactive, OC/OCN outputs are enabled (still controlled by the timer)           */
862 #define TIM_OSSI_DISABLE                         0x00000000U                    /*!< When inactive, OC/OCN outputs are disabled (not controlled any longer by the timer) */
863 /**
864   * @}
865   */
866 /** @defgroup TIM_Lock_level  TIM Lock level
867   * @{
868   */
869 #define TIM_LOCKLEVEL_OFF                  0x00000000U                          /*!< LOCK OFF     */
870 #define TIM_LOCKLEVEL_1                    TIM_BDTR_LOCK_0                      /*!< LOCK Level 1 */
871 #define TIM_LOCKLEVEL_2                    TIM_BDTR_LOCK_1                      /*!< LOCK Level 2 */
872 #define TIM_LOCKLEVEL_3                    TIM_BDTR_LOCK                        /*!< LOCK Level 3 */
873 /**
874   * @}
875   */
876 
877 /** @defgroup TIM_Break_Input_enable_disable TIM Break Input Enable
878   * @{
879   */
880 #define TIM_BREAK_ENABLE                   TIM_BDTR_BKE                         /*!< Break input BRK is enabled  */
881 #define TIM_BREAK_DISABLE                  0x00000000U                          /*!< Break input BRK is disabled */
882 /**
883   * @}
884   */
885 
886 /** @defgroup TIM_Break_Polarity TIM Break Input Polarity
887   * @{
888   */
889 #define TIM_BREAKPOLARITY_LOW              0x00000000U                          /*!< Break input BRK is active low  */
890 #define TIM_BREAKPOLARITY_HIGH             TIM_BDTR_BKP                         /*!< Break input BRK is active high */
891 /**
892   * @}
893   */
894 
895 /** @defgroup TIM_Break_Input_AF_Mode TIM Break Input Alternate Function Mode
896   * @{
897   */
898 #define TIM_BREAK_AFMODE_INPUT             0x00000000U                          /*!< Break input BRK in input mode */
899 #define TIM_BREAK_AFMODE_BIDIRECTIONAL     TIM_BDTR_BKBID                       /*!< Break input BRK in bidirectional mode */
900 /**
901   * @}
902   */
903 
904 /** @defgroup TIM_Break2_Input_enable_disable TIM Break input 2 Enable
905   * @{
906   */
907 #define TIM_BREAK2_DISABLE                 0x00000000U                          /*!< Break input BRK2 is disabled  */
908 #define TIM_BREAK2_ENABLE                  TIM_BDTR_BK2E                        /*!< Break input BRK2 is enabled  */
909 /**
910   * @}
911   */
912 
913 /** @defgroup TIM_Break2_Polarity TIM Break Input 2 Polarity
914   * @{
915   */
916 #define TIM_BREAK2POLARITY_LOW             0x00000000U                          /*!< Break input BRK2 is active low   */
917 #define TIM_BREAK2POLARITY_HIGH            TIM_BDTR_BK2P                        /*!< Break input BRK2 is active high  */
918 /**
919   * @}
920   */
921 
922 /** @defgroup TIM_Break2_Input_AF_Mode TIM Break2 Input Alternate Function Mode
923   * @{
924   */
925 #define TIM_BREAK2_AFMODE_INPUT            0x00000000U                          /*!< Break2 input BRK2 in input mode */
926 #define TIM_BREAK2_AFMODE_BIDIRECTIONAL    TIM_BDTR_BK2BID                      /*!< Break2 input BRK2 in bidirectional mode */
927 /**
928   * @}
929   */
930 
931 /** @defgroup TIM_AOE_Bit_Set_Reset TIM Automatic Output Enable
932   * @{
933   */
934 #define TIM_AUTOMATICOUTPUT_DISABLE        0x00000000U                          /*!< MOE can be set only by software */
935 #define TIM_AUTOMATICOUTPUT_ENABLE         TIM_BDTR_AOE                         /*!< MOE can be set by software or automatically at the next update event (if none of the break inputs BRK and BRK2 is active) */
936 /**
937   * @}
938   */
939 
940 /** @defgroup TIM_Group_Channel5 TIM Group Channel 5 and Channel 1, 2 or 3
941   * @{
942   */
943 #define TIM_GROUPCH5_NONE                  0x00000000U                          /*!< No effect of OC5REF on OC1REFC, OC2REFC and OC3REFC */
944 #define TIM_GROUPCH5_OC1REFC               TIM_CCR5_GC5C1                       /*!< OC1REFC is the logical AND of OC1REFC and OC5REF    */
945 #define TIM_GROUPCH5_OC2REFC               TIM_CCR5_GC5C2                       /*!< OC2REFC is the logical AND of OC2REFC and OC5REF    */
946 #define TIM_GROUPCH5_OC3REFC               TIM_CCR5_GC5C3                       /*!< OC3REFC is the logical AND of OC3REFC and OC5REF    */
947 /**
948   * @}
949   */
950 
951 /** @defgroup TIM_Master_Mode_Selection TIM Master Mode Selection
952   * @{
953   */
954 #define TIM_TRGO_RESET            0x00000000U                                      /*!< TIMx_EGR.UG bit is used as trigger output (TRGO)              */
955 #define TIM_TRGO_ENABLE           TIM_CR2_MMS_0                                    /*!< TIMx_CR1.CEN bit is used as trigger output (TRGO)             */
956 #define TIM_TRGO_UPDATE           TIM_CR2_MMS_1                                    /*!< Update event is used as trigger output (TRGO)                 */
957 #define TIM_TRGO_OC1              (TIM_CR2_MMS_1 | TIM_CR2_MMS_0)                  /*!< Capture or a compare match 1 is used as trigger output (TRGO) */
958 #define TIM_TRGO_OC1REF           TIM_CR2_MMS_2                                    /*!< OC1REF signal is used as trigger output (TRGO)                */
959 #define TIM_TRGO_OC2REF           (TIM_CR2_MMS_2 | TIM_CR2_MMS_0)                  /*!< OC2REF signal is used as trigger output(TRGO)                 */
960 #define TIM_TRGO_OC3REF           (TIM_CR2_MMS_2 | TIM_CR2_MMS_1)                  /*!< OC3REF signal is used as trigger output(TRGO)                 */
961 #define TIM_TRGO_OC4REF           (TIM_CR2_MMS_2 | TIM_CR2_MMS_1 | TIM_CR2_MMS_0)  /*!< OC4REF signal is used as trigger output(TRGO)                 */
962 /**
963   * @}
964   */
965 
966 /** @defgroup TIM_Master_Mode_Selection_2 TIM Master Mode Selection 2 (TRGO2)
967   * @{
968   */
969 #define TIM_TRGO2_RESET                          0x00000000U                                                         /*!< TIMx_EGR.UG bit is used as trigger output (TRGO2)              */
970 #define TIM_TRGO2_ENABLE                         TIM_CR2_MMS2_0                                                      /*!< TIMx_CR1.CEN bit is used as trigger output (TRGO2)             */
971 #define TIM_TRGO2_UPDATE                         TIM_CR2_MMS2_1                                                      /*!< Update event is used as trigger output (TRGO2)                 */
972 #define TIM_TRGO2_OC1                            (TIM_CR2_MMS2_1 | TIM_CR2_MMS2_0)                                   /*!< Capture or a compare match 1 is used as trigger output (TRGO2) */
973 #define TIM_TRGO2_OC1REF                         TIM_CR2_MMS2_2                                                      /*!< OC1REF signal is used as trigger output (TRGO2)                */
974 #define TIM_TRGO2_OC2REF                         (TIM_CR2_MMS2_2 | TIM_CR2_MMS2_0)                                   /*!< OC2REF signal is used as trigger output (TRGO2)                */
975 #define TIM_TRGO2_OC3REF                         (TIM_CR2_MMS2_2 | TIM_CR2_MMS2_1)                                   /*!< OC3REF signal is used as trigger output (TRGO2)                */
976 #define TIM_TRGO2_OC4REF                         (TIM_CR2_MMS2_2 | TIM_CR2_MMS2_1 | TIM_CR2_MMS2_0)                  /*!< OC4REF signal is used as trigger output (TRGO2)                */
977 #define TIM_TRGO2_OC5REF                         TIM_CR2_MMS2_3                                                      /*!< OC5REF signal is used as trigger output (TRGO2)                */
978 #define TIM_TRGO2_OC6REF                         (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_0)                                   /*!< OC6REF signal is used as trigger output (TRGO2)                */
979 #define TIM_TRGO2_OC4REF_RISINGFALLING           (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_1)                                   /*!< OC4REF rising or falling edges generate pulses on TRGO2        */
980 #define TIM_TRGO2_OC6REF_RISINGFALLING           (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_1 | TIM_CR2_MMS2_0)                  /*!< OC6REF rising or falling edges generate pulses on TRGO2        */
981 #define TIM_TRGO2_OC4REF_RISING_OC6REF_RISING    (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_2)                                   /*!< OC4REF or OC6REF rising edges generate pulses on TRGO2         */
982 #define TIM_TRGO2_OC4REF_RISING_OC6REF_FALLING   (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_2 | TIM_CR2_MMS2_0)                  /*!< OC4REF rising or OC6REF falling edges generate pulses on TRGO2 */
983 #define TIM_TRGO2_OC5REF_RISING_OC6REF_RISING    (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_2 |TIM_CR2_MMS2_1)                   /*!< OC5REF or OC6REF rising edges generate pulses on TRGO2         */
984 #define TIM_TRGO2_OC5REF_RISING_OC6REF_FALLING   (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_2 | TIM_CR2_MMS2_1 | TIM_CR2_MMS2_0) /*!< OC5REF or OC6REF rising edges generate pulses on TRGO2         */
985 /**
986   * @}
987   */
988 
989 /** @defgroup TIM_Master_Slave_Mode TIM Master/Slave Mode
990   * @{
991   */
992 #define TIM_MASTERSLAVEMODE_ENABLE         TIM_SMCR_MSM                         /*!< No action */
993 #define TIM_MASTERSLAVEMODE_DISABLE        0x00000000U                          /*!< Master/slave mode is selected */
994 /**
995   * @}
996   */
997 
998 /** @defgroup TIM_Slave_Mode TIM Slave mode
999   * @{
1000   */
1001 #define TIM_SLAVEMODE_DISABLE                0x00000000U                                        /*!< Slave mode disabled           */
1002 #define TIM_SLAVEMODE_RESET                  TIM_SMCR_SMS_2                                     /*!< Reset Mode                    */
1003 #define TIM_SLAVEMODE_GATED                  (TIM_SMCR_SMS_2 | TIM_SMCR_SMS_0)                  /*!< Gated Mode                    */
1004 #define TIM_SLAVEMODE_TRIGGER                (TIM_SMCR_SMS_2 | TIM_SMCR_SMS_1)                  /*!< Trigger Mode                  */
1005 #define TIM_SLAVEMODE_EXTERNAL1              (TIM_SMCR_SMS_2 | TIM_SMCR_SMS_1 | TIM_SMCR_SMS_0) /*!< External Clock Mode 1         */
1006 #define TIM_SLAVEMODE_COMBINED_RESETTRIGGER  TIM_SMCR_SMS_3                                     /*!< Combined reset + trigger mode */
1007 /**
1008   * @}
1009   */
1010 
1011 /** @defgroup TIM_Output_Compare_and_PWM_modes TIM Output Compare and PWM Modes
1012   * @{
1013   */
1014 #define TIM_OCMODE_TIMING                   0x00000000U                                              /*!< Frozen                                 */
1015 #define TIM_OCMODE_ACTIVE                   TIM_CCMR1_OC1M_0                                         /*!< Set channel to active level on match   */
1016 #define TIM_OCMODE_INACTIVE                 TIM_CCMR1_OC1M_1                                         /*!< Set channel to inactive level on match */
1017 #define TIM_OCMODE_TOGGLE                   (TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_0)                    /*!< Toggle                                 */
1018 #define TIM_OCMODE_PWM1                     (TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1M_1)                    /*!< PWM mode 1                             */
1019 #define TIM_OCMODE_PWM2                     (TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_0) /*!< PWM mode 2                             */
1020 #define TIM_OCMODE_FORCED_ACTIVE            (TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1M_0)                    /*!< Force active level                     */
1021 #define TIM_OCMODE_FORCED_INACTIVE          TIM_CCMR1_OC1M_2                                         /*!< Force inactive level                   */
1022 #define TIM_OCMODE_RETRIGERRABLE_OPM1      TIM_CCMR1_OC1M_3                                          /*!< Retrigerrable OPM mode 1               */
1023 #define TIM_OCMODE_RETRIGERRABLE_OPM2      (TIM_CCMR1_OC1M_3 | TIM_CCMR1_OC1M_0)                     /*!< Retrigerrable OPM mode 2               */
1024 #define TIM_OCMODE_COMBINED_PWM1           (TIM_CCMR1_OC1M_3 | TIM_CCMR1_OC1M_2)                     /*!< Combined PWM mode 1                    */
1025 #define TIM_OCMODE_COMBINED_PWM2           (TIM_CCMR1_OC1M_3 | TIM_CCMR1_OC1M_0 | TIM_CCMR1_OC1M_2)  /*!< Combined PWM mode 2                    */
1026 #define TIM_OCMODE_ASYMMETRIC_PWM1         (TIM_CCMR1_OC1M_3 | TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_2)  /*!< Asymmetric PWM mode 1                  */
1027 #define TIM_OCMODE_ASYMMETRIC_PWM2         TIM_CCMR1_OC1M                                            /*!< Asymmetric PWM mode 2                  */
1028 /**
1029   * @}
1030   */
1031 
1032 /** @defgroup TIM_Trigger_Selection TIM Trigger Selection
1033   * @{
1034   */
1035 #define TIM_TS_ITR0          0x00000000U                                                       /*!< Internal Trigger 0 (ITR0)              */
1036 #define TIM_TS_ITR1          TIM_SMCR_TS_0                                                     /*!< Internal Trigger 1 (ITR1)              */
1037 #define TIM_TS_ITR2          TIM_SMCR_TS_1                                                     /*!< Internal Trigger 2 (ITR2)              */
1038 #define TIM_TS_ITR3          (TIM_SMCR_TS_0 | TIM_SMCR_TS_1)                                   /*!< Internal Trigger 3 (ITR3)              */
1039 #define TIM_TS_TI1F_ED       TIM_SMCR_TS_2                                                     /*!< TI1 Edge Detector (TI1F_ED)            */
1040 #define TIM_TS_TI1FP1        (TIM_SMCR_TS_0 | TIM_SMCR_TS_2)                                   /*!< Filtered Timer Input 1 (TI1FP1)        */
1041 #define TIM_TS_TI2FP2        (TIM_SMCR_TS_1 | TIM_SMCR_TS_2)                                   /*!< Filtered Timer Input 2 (TI2FP2)        */
1042 #define TIM_TS_ETRF          (TIM_SMCR_TS_0 | TIM_SMCR_TS_1 | TIM_SMCR_TS_2)                   /*!< Filtered External Trigger input (ETRF) */
1043 #define TIM_TS_NONE          0x0000FFFFU                                                       /*!< No trigger selected                    */
1044 /**
1045   * @}
1046   */
1047 
1048 /** @defgroup TIM_Trigger_Polarity TIM Trigger Polarity
1049   * @{
1050   */
1051 #define TIM_TRIGGERPOLARITY_INVERTED           TIM_ETRPOLARITY_INVERTED               /*!< Polarity for ETRx trigger sources             */
1052 #define TIM_TRIGGERPOLARITY_NONINVERTED        TIM_ETRPOLARITY_NONINVERTED            /*!< Polarity for ETRx trigger sources             */
1053 #define TIM_TRIGGERPOLARITY_RISING             TIM_INPUTCHANNELPOLARITY_RISING        /*!< Polarity for TIxFPx or TI1_ED trigger sources */
1054 #define TIM_TRIGGERPOLARITY_FALLING            TIM_INPUTCHANNELPOLARITY_FALLING       /*!< Polarity for TIxFPx or TI1_ED trigger sources */
1055 #define TIM_TRIGGERPOLARITY_BOTHEDGE           TIM_INPUTCHANNELPOLARITY_BOTHEDGE      /*!< Polarity for TIxFPx or TI1_ED trigger sources */
1056 /**
1057   * @}
1058   */
1059 
1060 /** @defgroup TIM_Trigger_Prescaler TIM Trigger Prescaler
1061   * @{
1062   */
1063 #define TIM_TRIGGERPRESCALER_DIV1             TIM_ETRPRESCALER_DIV1             /*!< No prescaler is used                                                       */
1064 #define TIM_TRIGGERPRESCALER_DIV2             TIM_ETRPRESCALER_DIV2             /*!< Prescaler for External ETR Trigger: Capture performed once every 2 events. */
1065 #define TIM_TRIGGERPRESCALER_DIV4             TIM_ETRPRESCALER_DIV4             /*!< Prescaler for External ETR Trigger: Capture performed once every 4 events. */
1066 #define TIM_TRIGGERPRESCALER_DIV8             TIM_ETRPRESCALER_DIV8             /*!< Prescaler for External ETR Trigger: Capture performed once every 8 events. */
1067 /**
1068   * @}
1069   */
1070 
1071 /** @defgroup TIM_TI1_Selection TIM TI1 Input Selection
1072   * @{
1073   */
1074 #define TIM_TI1SELECTION_CH1               0x00000000U                          /*!< The TIMx_CH1 pin is connected to TI1 input */
1075 #define TIM_TI1SELECTION_XORCOMBINATION    TIM_CR2_TI1S                         /*!< The TIMx_CH1, CH2 and CH3 pins are connected to the TI1 input (XOR combination) */
1076 /**
1077   * @}
1078   */
1079 
1080 /** @defgroup TIM_DMA_Burst_Length TIM DMA Burst Length
1081   * @{
1082   */
1083 #define TIM_DMABURSTLENGTH_1TRANSFER       0x00000000U                          /*!< The transfer is done to 1 register starting from TIMx_CR1 + TIMx_DCR.DBA   */
1084 #define TIM_DMABURSTLENGTH_2TRANSFERS      0x00000100U                          /*!< The transfer is done to 2 registers starting from TIMx_CR1 + TIMx_DCR.DBA  */
1085 #define TIM_DMABURSTLENGTH_3TRANSFERS      0x00000200U                          /*!< The transfer is done to 3 registers starting from TIMx_CR1 + TIMx_DCR.DBA  */
1086 #define TIM_DMABURSTLENGTH_4TRANSFERS      0x00000300U                          /*!< The transfer is done to 4 registers starting from TIMx_CR1 + TIMx_DCR.DBA  */
1087 #define TIM_DMABURSTLENGTH_5TRANSFERS      0x00000400U                          /*!< The transfer is done to 5 registers starting from TIMx_CR1 + TIMx_DCR.DBA  */
1088 #define TIM_DMABURSTLENGTH_6TRANSFERS      0x00000500U                          /*!< The transfer is done to 6 registers starting from TIMx_CR1 + TIMx_DCR.DBA  */
1089 #define TIM_DMABURSTLENGTH_7TRANSFERS      0x00000600U                          /*!< The transfer is done to 7 registers starting from TIMx_CR1 + TIMx_DCR.DBA  */
1090 #define TIM_DMABURSTLENGTH_8TRANSFERS      0x00000700U                          /*!< The transfer is done to 8 registers starting from TIMx_CR1 + TIMx_DCR.DBA  */
1091 #define TIM_DMABURSTLENGTH_9TRANSFERS      0x00000800U                          /*!< The transfer is done to 9 registers starting from TIMx_CR1 + TIMx_DCR.DBA  */
1092 #define TIM_DMABURSTLENGTH_10TRANSFERS     0x00000900U                          /*!< The transfer is done to 10 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
1093 #define TIM_DMABURSTLENGTH_11TRANSFERS     0x00000A00U                          /*!< The transfer is done to 11 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
1094 #define TIM_DMABURSTLENGTH_12TRANSFERS     0x00000B00U                          /*!< The transfer is done to 12 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
1095 #define TIM_DMABURSTLENGTH_13TRANSFERS     0x00000C00U                          /*!< The transfer is done to 13 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
1096 #define TIM_DMABURSTLENGTH_14TRANSFERS     0x00000D00U                          /*!< The transfer is done to 14 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
1097 #define TIM_DMABURSTLENGTH_15TRANSFERS     0x00000E00U                          /*!< The transfer is done to 15 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
1098 #define TIM_DMABURSTLENGTH_16TRANSFERS     0x00000F00U                          /*!< The transfer is done to 16 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
1099 #define TIM_DMABURSTLENGTH_17TRANSFERS     0x00001000U                          /*!< The transfer is done to 17 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
1100 #define TIM_DMABURSTLENGTH_18TRANSFERS     0x00001100U                          /*!< The transfer is done to 18 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
1101 /**
1102   * @}
1103   */
1104 
1105 /** @defgroup DMA_Handle_index TIM DMA Handle Index
1106   * @{
1107   */
1108 #define TIM_DMA_ID_UPDATE                ((uint16_t) 0x0000)       /*!< Index of the DMA handle used for Update DMA requests */
1109 #define TIM_DMA_ID_CC1                   ((uint16_t) 0x0001)       /*!< Index of the DMA handle used for Capture/Compare 1 DMA requests */
1110 #define TIM_DMA_ID_CC2                   ((uint16_t) 0x0002)       /*!< Index of the DMA handle used for Capture/Compare 2 DMA requests */
1111 #define TIM_DMA_ID_CC3                   ((uint16_t) 0x0003)       /*!< Index of the DMA handle used for Capture/Compare 3 DMA requests */
1112 #define TIM_DMA_ID_CC4                   ((uint16_t) 0x0004)       /*!< Index of the DMA handle used for Capture/Compare 4 DMA requests */
1113 #define TIM_DMA_ID_COMMUTATION           ((uint16_t) 0x0005)       /*!< Index of the DMA handle used for Commutation DMA requests */
1114 #define TIM_DMA_ID_TRIGGER               ((uint16_t) 0x0006)       /*!< Index of the DMA handle used for Trigger DMA requests */
1115 /**
1116   * @}
1117   */
1118 
1119 /** @defgroup Channel_CC_State TIM Capture/Compare Channel State
1120   * @{
1121   */
1122 #define TIM_CCx_ENABLE                   0x00000001U                            /*!< Input or output channel is enabled */
1123 #define TIM_CCx_DISABLE                  0x00000000U                            /*!< Input or output channel is disabled */
1124 #define TIM_CCxN_ENABLE                  0x00000004U                            /*!< Complementary output channel is enabled */
1125 #define TIM_CCxN_DISABLE                 0x00000000U                            /*!< Complementary output channel is enabled */
1126 /**
1127   * @}
1128   */
1129 
1130 /** @defgroup TIM_Break_System TIM Break System
1131   * @{
1132   */
1133 #define TIM_BREAK_SYSTEM_ECC                 SYSCFG_CFGR2_ECCL   /*!< Enables and locks the ECC error signal with Break Input of TIM1/8/15/16/17 */
1134 #define TIM_BREAK_SYSTEM_PVD                 SYSCFG_CFGR2_PVDL   /*!< Enables and locks the PVD connection with TIM1/8/15/16/17 Break Input and also the PVDE and PLS bits of the Power Control Interface */
1135 #define TIM_BREAK_SYSTEM_SRAM2_PARITY_ERROR  SYSCFG_CFGR2_SPL    /*!< Enables and locks the SRAM2_PARITY error signal with Break Input of TIM1/8/15/16/17 */
1136 #define TIM_BREAK_SYSTEM_LOCKUP              SYSCFG_CFGR2_CLL    /*!< Enables and locks the LOCKUP output of CortexM4 with Break Input of TIM1/8/15/16/17 */
1137 /**
1138   * @}
1139   */
1140 
1141 /**
1142   * @}
1143   */
1144 /* End of exported constants -------------------------------------------------*/
1145 
1146 /* Exported macros -----------------------------------------------------------*/
1147 /** @defgroup TIM_Exported_Macros TIM Exported Macros
1148   * @{
1149   */
1150 
1151 /** @brief  Reset TIM handle state.
1152   * @param  __HANDLE__ TIM handle.
1153   * @retval None
1154   */
1155 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
1156 #define __HAL_TIM_RESET_HANDLE_STATE(__HANDLE__) do {                                                               \
1157                                                       (__HANDLE__)->State            = HAL_TIM_STATE_RESET;         \
1158                                                       (__HANDLE__)->ChannelState[0]  = HAL_TIM_CHANNEL_STATE_RESET; \
1159                                                       (__HANDLE__)->ChannelState[1]  = HAL_TIM_CHANNEL_STATE_RESET; \
1160                                                       (__HANDLE__)->ChannelState[2]  = HAL_TIM_CHANNEL_STATE_RESET; \
1161                                                       (__HANDLE__)->ChannelState[3]  = HAL_TIM_CHANNEL_STATE_RESET; \
1162                                                       (__HANDLE__)->ChannelState[4]  = HAL_TIM_CHANNEL_STATE_RESET; \
1163                                                       (__HANDLE__)->ChannelState[5]  = HAL_TIM_CHANNEL_STATE_RESET; \
1164                                                       (__HANDLE__)->ChannelNState[0] = HAL_TIM_CHANNEL_STATE_RESET; \
1165                                                       (__HANDLE__)->ChannelNState[1] = HAL_TIM_CHANNEL_STATE_RESET; \
1166                                                       (__HANDLE__)->ChannelNState[2] = HAL_TIM_CHANNEL_STATE_RESET; \
1167                                                       (__HANDLE__)->ChannelNState[3] = HAL_TIM_CHANNEL_STATE_RESET; \
1168                                                       (__HANDLE__)->DMABurstState    = HAL_DMA_BURST_STATE_RESET;   \
1169                                                       (__HANDLE__)->Base_MspInitCallback         = NULL;            \
1170                                                       (__HANDLE__)->Base_MspDeInitCallback       = NULL;            \
1171                                                       (__HANDLE__)->IC_MspInitCallback           = NULL;            \
1172                                                       (__HANDLE__)->IC_MspDeInitCallback         = NULL;            \
1173                                                       (__HANDLE__)->OC_MspInitCallback           = NULL;            \
1174                                                       (__HANDLE__)->OC_MspDeInitCallback         = NULL;            \
1175                                                       (__HANDLE__)->PWM_MspInitCallback          = NULL;            \
1176                                                       (__HANDLE__)->PWM_MspDeInitCallback        = NULL;            \
1177                                                       (__HANDLE__)->OnePulse_MspInitCallback     = NULL;            \
1178                                                       (__HANDLE__)->OnePulse_MspDeInitCallback   = NULL;            \
1179                                                       (__HANDLE__)->Encoder_MspInitCallback      = NULL;            \
1180                                                       (__HANDLE__)->Encoder_MspDeInitCallback    = NULL;            \
1181                                                       (__HANDLE__)->HallSensor_MspInitCallback   = NULL;            \
1182                                                       (__HANDLE__)->HallSensor_MspDeInitCallback = NULL;            \
1183                                                      } while(0)
1184 #else
1185 #define __HAL_TIM_RESET_HANDLE_STATE(__HANDLE__) do {                                                               \
1186                                                       (__HANDLE__)->State            = HAL_TIM_STATE_RESET;         \
1187                                                       (__HANDLE__)->ChannelState[0]  = HAL_TIM_CHANNEL_STATE_RESET; \
1188                                                       (__HANDLE__)->ChannelState[1]  = HAL_TIM_CHANNEL_STATE_RESET; \
1189                                                       (__HANDLE__)->ChannelState[2]  = HAL_TIM_CHANNEL_STATE_RESET; \
1190                                                       (__HANDLE__)->ChannelState[3]  = HAL_TIM_CHANNEL_STATE_RESET; \
1191                                                       (__HANDLE__)->ChannelState[4]  = HAL_TIM_CHANNEL_STATE_RESET; \
1192                                                       (__HANDLE__)->ChannelState[5]  = HAL_TIM_CHANNEL_STATE_RESET; \
1193                                                       (__HANDLE__)->ChannelNState[0] = HAL_TIM_CHANNEL_STATE_RESET; \
1194                                                       (__HANDLE__)->ChannelNState[1] = HAL_TIM_CHANNEL_STATE_RESET; \
1195                                                       (__HANDLE__)->ChannelNState[2] = HAL_TIM_CHANNEL_STATE_RESET; \
1196                                                       (__HANDLE__)->ChannelNState[3] = HAL_TIM_CHANNEL_STATE_RESET; \
1197                                                       (__HANDLE__)->DMABurstState    = HAL_DMA_BURST_STATE_RESET;   \
1198                                                      } while(0)
1199 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
1200 
1201 /**
1202   * @brief  Enable the TIM peripheral.
1203   * @param  __HANDLE__ TIM handle
1204   * @retval None
1205   */
1206 #define __HAL_TIM_ENABLE(__HANDLE__)                 ((__HANDLE__)->Instance->CR1|=(TIM_CR1_CEN))
1207 
1208 /**
1209   * @brief  Enable the TIM main Output.
1210   * @param  __HANDLE__ TIM handle
1211   * @retval None
1212   */
1213 #define __HAL_TIM_MOE_ENABLE(__HANDLE__)             ((__HANDLE__)->Instance->BDTR|=(TIM_BDTR_MOE))
1214 
1215 /**
1216   * @brief  Disable the TIM peripheral.
1217   * @param  __HANDLE__ TIM handle
1218   * @retval None
1219   */
1220 #define __HAL_TIM_DISABLE(__HANDLE__) \
1221   do { \
1222     if (((__HANDLE__)->Instance->CCER & TIM_CCER_CCxE_MASK) == 0UL) \
1223     { \
1224       if(((__HANDLE__)->Instance->CCER & TIM_CCER_CCxNE_MASK) == 0UL) \
1225       { \
1226         (__HANDLE__)->Instance->CR1 &= ~(TIM_CR1_CEN); \
1227       } \
1228     } \
1229   } while(0)
1230 
1231 /**
1232   * @brief  Disable the TIM main Output.
1233   * @param  __HANDLE__ TIM handle
1234   * @retval None
1235   * @note The Main Output Enable of a timer instance is disabled only if all the CCx and CCxN channels have been
1236   *       disabled
1237   */
1238 #define __HAL_TIM_MOE_DISABLE(__HANDLE__) \
1239   do { \
1240     if (((__HANDLE__)->Instance->CCER & TIM_CCER_CCxE_MASK) == 0UL) \
1241     { \
1242       if(((__HANDLE__)->Instance->CCER & TIM_CCER_CCxNE_MASK) == 0UL) \
1243       { \
1244         (__HANDLE__)->Instance->BDTR &= ~(TIM_BDTR_MOE); \
1245       } \
1246     } \
1247   } while(0)
1248 
1249 /**
1250   * @brief  Disable the TIM main Output.
1251   * @param  __HANDLE__ TIM handle
1252   * @retval None
1253   * @note The Main Output Enable of a timer instance is disabled unconditionally
1254   */
1255 #define __HAL_TIM_MOE_DISABLE_UNCONDITIONALLY(__HANDLE__)  (__HANDLE__)->Instance->BDTR &= ~(TIM_BDTR_MOE)
1256 
1257 /** @brief  Enable the specified TIM interrupt.
1258   * @param  __HANDLE__ specifies the TIM Handle.
1259   * @param  __INTERRUPT__ specifies the TIM interrupt source to enable.
1260   *          This parameter can be one of the following values:
1261   *            @arg TIM_IT_UPDATE: Update interrupt
1262   *            @arg TIM_IT_CC1:   Capture/Compare 1 interrupt
1263   *            @arg TIM_IT_CC2:  Capture/Compare 2 interrupt
1264   *            @arg TIM_IT_CC3:  Capture/Compare 3 interrupt
1265   *            @arg TIM_IT_CC4:  Capture/Compare 4 interrupt
1266   *            @arg TIM_IT_COM:   Commutation interrupt
1267   *            @arg TIM_IT_TRIGGER: Trigger interrupt
1268   *            @arg TIM_IT_BREAK: Break interrupt
1269   * @retval None
1270   */
1271 #define __HAL_TIM_ENABLE_IT(__HANDLE__, __INTERRUPT__)    ((__HANDLE__)->Instance->DIER |= (__INTERRUPT__))
1272 
1273 /** @brief  Disable the specified TIM interrupt.
1274   * @param  __HANDLE__ specifies the TIM Handle.
1275   * @param  __INTERRUPT__ specifies the TIM interrupt source to disable.
1276   *          This parameter can be one of the following values:
1277   *            @arg TIM_IT_UPDATE: Update interrupt
1278   *            @arg TIM_IT_CC1:   Capture/Compare 1 interrupt
1279   *            @arg TIM_IT_CC2:  Capture/Compare 2 interrupt
1280   *            @arg TIM_IT_CC3:  Capture/Compare 3 interrupt
1281   *            @arg TIM_IT_CC4:  Capture/Compare 4 interrupt
1282   *            @arg TIM_IT_COM:   Commutation interrupt
1283   *            @arg TIM_IT_TRIGGER: Trigger interrupt
1284   *            @arg TIM_IT_BREAK: Break interrupt
1285   * @retval None
1286   */
1287 #define __HAL_TIM_DISABLE_IT(__HANDLE__, __INTERRUPT__)   ((__HANDLE__)->Instance->DIER &= ~(__INTERRUPT__))
1288 
1289 /** @brief  Enable the specified DMA request.
1290   * @param  __HANDLE__ specifies the TIM Handle.
1291   * @param  __DMA__ specifies the TIM DMA request to enable.
1292   *          This parameter can be one of the following values:
1293   *            @arg TIM_DMA_UPDATE: Update DMA request
1294   *            @arg TIM_DMA_CC1:   Capture/Compare 1 DMA request
1295   *            @arg TIM_DMA_CC2:  Capture/Compare 2 DMA request
1296   *            @arg TIM_DMA_CC3:  Capture/Compare 3 DMA request
1297   *            @arg TIM_DMA_CC4:  Capture/Compare 4 DMA request
1298   *            @arg TIM_DMA_COM:   Commutation DMA request
1299   *            @arg TIM_DMA_TRIGGER: Trigger DMA request
1300   * @retval None
1301   */
1302 #define __HAL_TIM_ENABLE_DMA(__HANDLE__, __DMA__)         ((__HANDLE__)->Instance->DIER |= (__DMA__))
1303 
1304 /** @brief  Disable the specified DMA request.
1305   * @param  __HANDLE__ specifies the TIM Handle.
1306   * @param  __DMA__ specifies the TIM DMA request to disable.
1307   *          This parameter can be one of the following values:
1308   *            @arg TIM_DMA_UPDATE: Update DMA request
1309   *            @arg TIM_DMA_CC1:   Capture/Compare 1 DMA request
1310   *            @arg TIM_DMA_CC2:  Capture/Compare 2 DMA request
1311   *            @arg TIM_DMA_CC3:  Capture/Compare 3 DMA request
1312   *            @arg TIM_DMA_CC4:  Capture/Compare 4 DMA request
1313   *            @arg TIM_DMA_COM:   Commutation DMA request
1314   *            @arg TIM_DMA_TRIGGER: Trigger DMA request
1315   * @retval None
1316   */
1317 #define __HAL_TIM_DISABLE_DMA(__HANDLE__, __DMA__)        ((__HANDLE__)->Instance->DIER &= ~(__DMA__))
1318 
1319 /** @brief  Check whether the specified TIM interrupt flag is set or not.
1320   * @param  __HANDLE__ specifies the TIM Handle.
1321   * @param  __FLAG__ specifies the TIM interrupt flag to check.
1322   *        This parameter can be one of the following values:
1323   *            @arg TIM_FLAG_UPDATE: Update interrupt flag
1324   *            @arg TIM_FLAG_CC1: Capture/Compare 1 interrupt flag
1325   *            @arg TIM_FLAG_CC2: Capture/Compare 2 interrupt flag
1326   *            @arg TIM_FLAG_CC3: Capture/Compare 3 interrupt flag
1327   *            @arg TIM_FLAG_CC4: Capture/Compare 4 interrupt flag
1328   *            @arg TIM_FLAG_CC5: Compare 5 interrupt flag
1329   *            @arg TIM_FLAG_CC6: Compare 6 interrupt flag
1330   *            @arg TIM_FLAG_COM:  Commutation interrupt flag
1331   *            @arg TIM_FLAG_TRIGGER: Trigger interrupt flag
1332   *            @arg TIM_FLAG_BREAK: Break interrupt flag
1333   *            @arg TIM_FLAG_BREAK2: Break 2 interrupt flag
1334   *            @arg TIM_FLAG_SYSTEM_BREAK: System Break interrupt flag
1335   *            @arg TIM_FLAG_CC1OF: Capture/Compare 1 overcapture flag
1336   *            @arg TIM_FLAG_CC2OF: Capture/Compare 2 overcapture flag
1337   *            @arg TIM_FLAG_CC3OF: Capture/Compare 3 overcapture flag
1338   *            @arg TIM_FLAG_CC4OF: Capture/Compare 4 overcapture flag
1339   * @retval The new state of __FLAG__ (TRUE or FALSE).
1340   */
1341 #define __HAL_TIM_GET_FLAG(__HANDLE__, __FLAG__)          (((__HANDLE__)->Instance->SR &(__FLAG__)) == (__FLAG__))
1342 
1343 /** @brief  Clear the specified TIM interrupt flag.
1344   * @param  __HANDLE__ specifies the TIM Handle.
1345   * @param  __FLAG__ specifies the TIM interrupt flag to clear.
1346   *        This parameter can be one of the following values:
1347   *            @arg TIM_FLAG_UPDATE: Update interrupt flag
1348   *            @arg TIM_FLAG_CC1: Capture/Compare 1 interrupt flag
1349   *            @arg TIM_FLAG_CC2: Capture/Compare 2 interrupt flag
1350   *            @arg TIM_FLAG_CC3: Capture/Compare 3 interrupt flag
1351   *            @arg TIM_FLAG_CC4: Capture/Compare 4 interrupt flag
1352   *            @arg TIM_FLAG_CC5: Compare 5 interrupt flag
1353   *            @arg TIM_FLAG_CC6: Compare 6 interrupt flag
1354   *            @arg TIM_FLAG_COM:  Commutation interrupt flag
1355   *            @arg TIM_FLAG_TRIGGER: Trigger interrupt flag
1356   *            @arg TIM_FLAG_BREAK: Break interrupt flag
1357   *            @arg TIM_FLAG_BREAK2: Break 2 interrupt flag
1358   *            @arg TIM_FLAG_SYSTEM_BREAK: System Break interrupt flag
1359   *            @arg TIM_FLAG_CC1OF: Capture/Compare 1 overcapture flag
1360   *            @arg TIM_FLAG_CC2OF: Capture/Compare 2 overcapture flag
1361   *            @arg TIM_FLAG_CC3OF: Capture/Compare 3 overcapture flag
1362   *            @arg TIM_FLAG_CC4OF: Capture/Compare 4 overcapture flag
1363   * @retval The new state of __FLAG__ (TRUE or FALSE).
1364   */
1365 #define __HAL_TIM_CLEAR_FLAG(__HANDLE__, __FLAG__)        ((__HANDLE__)->Instance->SR = ~(__FLAG__))
1366 
1367 /**
1368   * @brief  Check whether the specified TIM interrupt source is enabled or not.
1369   * @param  __HANDLE__ TIM handle
1370   * @param  __INTERRUPT__ specifies the TIM interrupt source to check.
1371   *          This parameter can be one of the following values:
1372   *            @arg TIM_IT_UPDATE: Update interrupt
1373   *            @arg TIM_IT_CC1:   Capture/Compare 1 interrupt
1374   *            @arg TIM_IT_CC2:  Capture/Compare 2 interrupt
1375   *            @arg TIM_IT_CC3:  Capture/Compare 3 interrupt
1376   *            @arg TIM_IT_CC4:  Capture/Compare 4 interrupt
1377   *            @arg TIM_IT_COM:   Commutation interrupt
1378   *            @arg TIM_IT_TRIGGER: Trigger interrupt
1379   *            @arg TIM_IT_BREAK: Break interrupt
1380   * @retval The state of TIM_IT (SET or RESET).
1381   */
1382 #define __HAL_TIM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->DIER & (__INTERRUPT__)) \
1383                                                              == (__INTERRUPT__)) ? SET : RESET)
1384 
1385 /** @brief Clear the TIM interrupt pending bits.
1386   * @param  __HANDLE__ TIM handle
1387   * @param  __INTERRUPT__ specifies the interrupt pending bit to clear.
1388   *          This parameter can be one of the following values:
1389   *            @arg TIM_IT_UPDATE: Update interrupt
1390   *            @arg TIM_IT_CC1:   Capture/Compare 1 interrupt
1391   *            @arg TIM_IT_CC2:  Capture/Compare 2 interrupt
1392   *            @arg TIM_IT_CC3:  Capture/Compare 3 interrupt
1393   *            @arg TIM_IT_CC4:  Capture/Compare 4 interrupt
1394   *            @arg TIM_IT_COM:   Commutation interrupt
1395   *            @arg TIM_IT_TRIGGER: Trigger interrupt
1396   *            @arg TIM_IT_BREAK: Break interrupt
1397   * @retval None
1398   */
1399 #define __HAL_TIM_CLEAR_IT(__HANDLE__, __INTERRUPT__)      ((__HANDLE__)->Instance->SR = ~(__INTERRUPT__))
1400 
1401 /**
1402   * @brief  Force a continuous copy of the update interrupt flag (UIF) into the timer counter register (bit 31).
1403   * @note This allows both the counter value and a potential roll-over condition signalled by the UIFCPY flag to be read
1404   *       in an atomic way.
1405   * @param  __HANDLE__ TIM handle.
1406   * @retval None
1407 mode.
1408   */
1409 #define __HAL_TIM_UIFREMAP_ENABLE(__HANDLE__)    (((__HANDLE__)->Instance->CR1 |= TIM_CR1_UIFREMAP))
1410 
1411 /**
1412   * @brief  Disable update interrupt flag (UIF) remapping.
1413   * @param  __HANDLE__ TIM handle.
1414   * @retval None
1415 mode.
1416   */
1417 #define __HAL_TIM_UIFREMAP_DISABLE(__HANDLE__)    (((__HANDLE__)->Instance->CR1 &= ~TIM_CR1_UIFREMAP))
1418 
1419 /**
1420   * @brief  Get update interrupt flag (UIF) copy status.
1421   * @param  __COUNTER__ Counter value.
1422   * @retval The state of UIFCPY (TRUE or FALSE).
1423 mode.
1424   */
1425 #define __HAL_TIM_GET_UIFCPY(__COUNTER__)    (((__COUNTER__) & (TIM_CNT_UIFCPY)) == (TIM_CNT_UIFCPY))
1426 
1427 /**
1428   * @brief  Indicates whether or not the TIM Counter is used as downcounter.
1429   * @param  __HANDLE__ TIM handle.
1430   * @retval False (Counter used as upcounter) or True (Counter used as downcounter)
1431   * @note This macro is particularly useful to get the counting mode when the timer operates in Center-aligned mode
1432   *       or Encoder mode.
1433   */
1434 #define __HAL_TIM_IS_TIM_COUNTING_DOWN(__HANDLE__)    (((__HANDLE__)->Instance->CR1 &(TIM_CR1_DIR)) == (TIM_CR1_DIR))
1435 
1436 /**
1437   * @brief  Set the TIM Prescaler on runtime.
1438   * @param  __HANDLE__ TIM handle.
1439   * @param  __PRESC__ specifies the Prescaler new value.
1440   * @retval None
1441   */
1442 #define __HAL_TIM_SET_PRESCALER(__HANDLE__, __PRESC__)       ((__HANDLE__)->Instance->PSC = (__PRESC__))
1443 
1444 /**
1445   * @brief  Set the TIM Counter Register value on runtime.
1446   * Note Please check if the bit 31 of CNT register is used as UIF copy or not, this may affect the counter range in
1447   *      case of 32 bits counter TIM instance.
1448   *      Bit 31 of CNT can be enabled/disabled using __HAL_TIM_UIFREMAP_ENABLE()/__HAL_TIM_UIFREMAP_DISABLE() macros.
1449   * @param  __HANDLE__ TIM handle.
1450   * @param  __COUNTER__ specifies the Counter register new value.
1451   * @retval None
1452   */
1453 #define __HAL_TIM_SET_COUNTER(__HANDLE__, __COUNTER__)  ((__HANDLE__)->Instance->CNT = (__COUNTER__))
1454 
1455 /**
1456   * @brief  Get the TIM Counter Register value on runtime.
1457   * @param  __HANDLE__ TIM handle.
1458   * @retval 16-bit or 32-bit value of the timer counter register (TIMx_CNT)
1459   */
1460 #define __HAL_TIM_GET_COUNTER(__HANDLE__)  ((__HANDLE__)->Instance->CNT)
1461 
1462 /**
1463   * @brief  Set the TIM Autoreload Register value on runtime without calling another time any Init function.
1464   * @param  __HANDLE__ TIM handle.
1465   * @param  __AUTORELOAD__ specifies the Counter register new value.
1466   * @retval None
1467   */
1468 #define __HAL_TIM_SET_AUTORELOAD(__HANDLE__, __AUTORELOAD__) \
1469   do{                                                    \
1470     (__HANDLE__)->Instance->ARR = (__AUTORELOAD__);  \
1471     (__HANDLE__)->Init.Period = (__AUTORELOAD__);    \
1472   } while(0)
1473 
1474 /**
1475   * @brief  Get the TIM Autoreload Register value on runtime.
1476   * @param  __HANDLE__ TIM handle.
1477   * @retval 16-bit or 32-bit value of the timer auto-reload register(TIMx_ARR)
1478   */
1479 #define __HAL_TIM_GET_AUTORELOAD(__HANDLE__)  ((__HANDLE__)->Instance->ARR)
1480 
1481 /**
1482   * @brief  Set the TIM Clock Division value on runtime without calling another time any Init function.
1483   * @param  __HANDLE__ TIM handle.
1484   * @param  __CKD__ specifies the clock division value.
1485   *          This parameter can be one of the following value:
1486   *            @arg TIM_CLOCKDIVISION_DIV1: tDTS=tCK_INT
1487   *            @arg TIM_CLOCKDIVISION_DIV2: tDTS=2*tCK_INT
1488   *            @arg TIM_CLOCKDIVISION_DIV4: tDTS=4*tCK_INT
1489   * @retval None
1490   */
1491 #define __HAL_TIM_SET_CLOCKDIVISION(__HANDLE__, __CKD__) \
1492   do{                                                   \
1493     (__HANDLE__)->Instance->CR1 &= (~TIM_CR1_CKD);  \
1494     (__HANDLE__)->Instance->CR1 |= (__CKD__);       \
1495     (__HANDLE__)->Init.ClockDivision = (__CKD__);   \
1496   } while(0)
1497 
1498 /**
1499   * @brief  Get the TIM Clock Division value on runtime.
1500   * @param  __HANDLE__ TIM handle.
1501   * @retval The clock division can be one of the following values:
1502   *            @arg TIM_CLOCKDIVISION_DIV1: tDTS=tCK_INT
1503   *            @arg TIM_CLOCKDIVISION_DIV2: tDTS=2*tCK_INT
1504   *            @arg TIM_CLOCKDIVISION_DIV4: tDTS=4*tCK_INT
1505   */
1506 #define __HAL_TIM_GET_CLOCKDIVISION(__HANDLE__)  ((__HANDLE__)->Instance->CR1 & TIM_CR1_CKD)
1507 
1508 /**
1509   * @brief  Set the TIM Input Capture prescaler on runtime without calling another time HAL_TIM_IC_ConfigChannel()
1510   *         function.
1511   * @param  __HANDLE__ TIM handle.
1512   * @param  __CHANNEL__ TIM Channels to be configured.
1513   *          This parameter can be one of the following values:
1514   *            @arg TIM_CHANNEL_1: TIM Channel 1 selected
1515   *            @arg TIM_CHANNEL_2: TIM Channel 2 selected
1516   *            @arg TIM_CHANNEL_3: TIM Channel 3 selected
1517   *            @arg TIM_CHANNEL_4: TIM Channel 4 selected
1518   * @param  __ICPSC__ specifies the Input Capture4 prescaler new value.
1519   *          This parameter can be one of the following values:
1520   *            @arg TIM_ICPSC_DIV1: no prescaler
1521   *            @arg TIM_ICPSC_DIV2: capture is done once every 2 events
1522   *            @arg TIM_ICPSC_DIV4: capture is done once every 4 events
1523   *            @arg TIM_ICPSC_DIV8: capture is done once every 8 events
1524   * @retval None
1525   */
1526 #define __HAL_TIM_SET_ICPRESCALER(__HANDLE__, __CHANNEL__, __ICPSC__) \
1527   do{                                                    \
1528     TIM_RESET_ICPRESCALERVALUE((__HANDLE__), (__CHANNEL__));  \
1529     TIM_SET_ICPRESCALERVALUE((__HANDLE__), (__CHANNEL__), (__ICPSC__)); \
1530   } while(0)
1531 
1532 /**
1533   * @brief  Get the TIM Input Capture prescaler on runtime.
1534   * @param  __HANDLE__ TIM handle.
1535   * @param  __CHANNEL__ TIM Channels to be configured.
1536   *          This parameter can be one of the following values:
1537   *            @arg TIM_CHANNEL_1: get input capture 1 prescaler value
1538   *            @arg TIM_CHANNEL_2: get input capture 2 prescaler value
1539   *            @arg TIM_CHANNEL_3: get input capture 3 prescaler value
1540   *            @arg TIM_CHANNEL_4: get input capture 4 prescaler value
1541   * @retval The input capture prescaler can be one of the following values:
1542   *            @arg TIM_ICPSC_DIV1: no prescaler
1543   *            @arg TIM_ICPSC_DIV2: capture is done once every 2 events
1544   *            @arg TIM_ICPSC_DIV4: capture is done once every 4 events
1545   *            @arg TIM_ICPSC_DIV8: capture is done once every 8 events
1546   */
1547 #define __HAL_TIM_GET_ICPRESCALER(__HANDLE__, __CHANNEL__)  \
1548   (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCMR1 & TIM_CCMR1_IC1PSC) :\
1549    ((__CHANNEL__) == TIM_CHANNEL_2) ? (((__HANDLE__)->Instance->CCMR1 & TIM_CCMR1_IC2PSC) >> 8U) :\
1550    ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 & TIM_CCMR2_IC3PSC) :\
1551    (((__HANDLE__)->Instance->CCMR2 & TIM_CCMR2_IC4PSC)) >> 8U)
1552 
1553 /**
1554   * @brief  Set the TIM Capture Compare Register value on runtime without calling another time ConfigChannel function.
1555   * @param  __HANDLE__ TIM handle.
1556   * @param  __CHANNEL__ TIM Channels to be configured.
1557   *          This parameter can be one of the following values:
1558   *            @arg TIM_CHANNEL_1: TIM Channel 1 selected
1559   *            @arg TIM_CHANNEL_2: TIM Channel 2 selected
1560   *            @arg TIM_CHANNEL_3: TIM Channel 3 selected
1561   *            @arg TIM_CHANNEL_4: TIM Channel 4 selected
1562   *            @arg TIM_CHANNEL_5: TIM Channel 5 selected
1563   *            @arg TIM_CHANNEL_6: TIM Channel 6 selected
1564   * @param  __COMPARE__ specifies the Capture Compare register new value.
1565   * @retval None
1566   */
1567 #define __HAL_TIM_SET_COMPARE(__HANDLE__, __CHANNEL__, __COMPARE__) \
1568   (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCR1 = (__COMPARE__)) :\
1569    ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCR2 = (__COMPARE__)) :\
1570    ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCR3 = (__COMPARE__)) :\
1571    ((__CHANNEL__) == TIM_CHANNEL_4) ? ((__HANDLE__)->Instance->CCR4 = (__COMPARE__)) :\
1572    ((__CHANNEL__) == TIM_CHANNEL_5) ? ((__HANDLE__)->Instance->CCR5 = (__COMPARE__)) :\
1573    ((__HANDLE__)->Instance->CCR6 = (__COMPARE__)))
1574 
1575 /**
1576   * @brief  Get the TIM Capture Compare Register value on runtime.
1577   * @param  __HANDLE__ TIM handle.
1578   * @param  __CHANNEL__ TIM Channel associated with the capture compare register
1579   *          This parameter can be one of the following values:
1580   *            @arg TIM_CHANNEL_1: get capture/compare 1 register value
1581   *            @arg TIM_CHANNEL_2: get capture/compare 2 register value
1582   *            @arg TIM_CHANNEL_3: get capture/compare 3 register value
1583   *            @arg TIM_CHANNEL_4: get capture/compare 4 register value
1584   *            @arg TIM_CHANNEL_5: get capture/compare 5 register value
1585   *            @arg TIM_CHANNEL_6: get capture/compare 6 register value
1586   * @retval 16-bit or 32-bit value of the capture/compare register (TIMx_CCRy)
1587   */
1588 #define __HAL_TIM_GET_COMPARE(__HANDLE__, __CHANNEL__) \
1589   (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCR1) :\
1590    ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCR2) :\
1591    ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCR3) :\
1592    ((__CHANNEL__) == TIM_CHANNEL_4) ? ((__HANDLE__)->Instance->CCR4) :\
1593    ((__CHANNEL__) == TIM_CHANNEL_5) ? ((__HANDLE__)->Instance->CCR5) :\
1594    ((__HANDLE__)->Instance->CCR6))
1595 
1596 /**
1597   * @brief  Set the TIM Output compare preload.
1598   * @param  __HANDLE__ TIM handle.
1599   * @param  __CHANNEL__ TIM Channels to be configured.
1600   *          This parameter can be one of the following values:
1601   *            @arg TIM_CHANNEL_1: TIM Channel 1 selected
1602   *            @arg TIM_CHANNEL_2: TIM Channel 2 selected
1603   *            @arg TIM_CHANNEL_3: TIM Channel 3 selected
1604   *            @arg TIM_CHANNEL_4: TIM Channel 4 selected
1605   *            @arg TIM_CHANNEL_5: TIM Channel 5 selected
1606   *            @arg TIM_CHANNEL_6: TIM Channel 6 selected
1607   * @retval None
1608   */
1609 #define __HAL_TIM_ENABLE_OCxPRELOAD(__HANDLE__, __CHANNEL__)    \
1610   (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCMR1 |= TIM_CCMR1_OC1PE) :\
1611    ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCMR1 |= TIM_CCMR1_OC2PE) :\
1612    ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 |= TIM_CCMR2_OC3PE) :\
1613    ((__CHANNEL__) == TIM_CHANNEL_4) ? ((__HANDLE__)->Instance->CCMR2 |= TIM_CCMR2_OC4PE) :\
1614    ((__CHANNEL__) == TIM_CHANNEL_5) ? ((__HANDLE__)->Instance->CCMR3 |= TIM_CCMR3_OC5PE) :\
1615    ((__HANDLE__)->Instance->CCMR3 |= TIM_CCMR3_OC6PE))
1616 
1617 /**
1618   * @brief  Reset the TIM Output compare preload.
1619   * @param  __HANDLE__ TIM handle.
1620   * @param  __CHANNEL__ TIM Channels to be configured.
1621   *          This parameter can be one of the following values:
1622   *            @arg TIM_CHANNEL_1: TIM Channel 1 selected
1623   *            @arg TIM_CHANNEL_2: TIM Channel 2 selected
1624   *            @arg TIM_CHANNEL_3: TIM Channel 3 selected
1625   *            @arg TIM_CHANNEL_4: TIM Channel 4 selected
1626   *            @arg TIM_CHANNEL_5: TIM Channel 5 selected
1627   *            @arg TIM_CHANNEL_6: TIM Channel 6 selected
1628   * @retval None
1629   */
1630 #define __HAL_TIM_DISABLE_OCxPRELOAD(__HANDLE__, __CHANNEL__)    \
1631   (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCMR1 &= ~TIM_CCMR1_OC1PE) :\
1632    ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCMR1 &= ~TIM_CCMR1_OC2PE) :\
1633    ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 &= ~TIM_CCMR2_OC3PE) :\
1634    ((__CHANNEL__) == TIM_CHANNEL_4) ? ((__HANDLE__)->Instance->CCMR2 &= ~TIM_CCMR2_OC4PE) :\
1635    ((__CHANNEL__) == TIM_CHANNEL_5) ? ((__HANDLE__)->Instance->CCMR3 &= ~TIM_CCMR3_OC5PE) :\
1636    ((__HANDLE__)->Instance->CCMR3 &= ~TIM_CCMR3_OC6PE))
1637 
1638 /**
1639   * @brief  Enable fast mode for a given channel.
1640   * @param  __HANDLE__ TIM handle.
1641   * @param  __CHANNEL__ TIM Channels to be configured.
1642   *          This parameter can be one of the following values:
1643   *            @arg TIM_CHANNEL_1: TIM Channel 1 selected
1644   *            @arg TIM_CHANNEL_2: TIM Channel 2 selected
1645   *            @arg TIM_CHANNEL_3: TIM Channel 3 selected
1646   *            @arg TIM_CHANNEL_4: TIM Channel 4 selected
1647   *            @arg TIM_CHANNEL_5: TIM Channel 5 selected
1648   *            @arg TIM_CHANNEL_6: TIM Channel 6 selected
1649   * @note  When fast mode is enabled an active edge on the trigger input acts
1650   *        like a compare match on CCx output. Delay to sample the trigger
1651   *        input and to activate CCx output is reduced to 3 clock cycles.
1652   * @note  Fast mode acts only if the channel is configured in PWM1 or PWM2 mode.
1653   * @retval None
1654   */
1655 #define __HAL_TIM_ENABLE_OCxFAST(__HANDLE__, __CHANNEL__)    \
1656   (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCMR1 |= TIM_CCMR1_OC1FE) :\
1657    ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCMR1 |= TIM_CCMR1_OC2FE) :\
1658    ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 |= TIM_CCMR2_OC3FE) :\
1659    ((__CHANNEL__) == TIM_CHANNEL_4) ? ((__HANDLE__)->Instance->CCMR2 |= TIM_CCMR2_OC4FE) :\
1660    ((__CHANNEL__) == TIM_CHANNEL_5) ? ((__HANDLE__)->Instance->CCMR3 |= TIM_CCMR3_OC5FE) :\
1661    ((__HANDLE__)->Instance->CCMR3 |= TIM_CCMR3_OC6FE))
1662 
1663 /**
1664   * @brief  Disable fast mode for a given channel.
1665   * @param  __HANDLE__ TIM handle.
1666   * @param  __CHANNEL__ TIM Channels to be configured.
1667   *          This parameter can be one of the following values:
1668   *            @arg TIM_CHANNEL_1: TIM Channel 1 selected
1669   *            @arg TIM_CHANNEL_2: TIM Channel 2 selected
1670   *            @arg TIM_CHANNEL_3: TIM Channel 3 selected
1671   *            @arg TIM_CHANNEL_4: TIM Channel 4 selected
1672   *            @arg TIM_CHANNEL_5: TIM Channel 5 selected
1673   *            @arg TIM_CHANNEL_6: TIM Channel 6 selected
1674   * @note  When fast mode is disabled CCx output behaves normally depending
1675   *        on counter and CCRx values even when the trigger is ON. The minimum
1676   *        delay to activate CCx output when an active edge occurs on the
1677   *        trigger input is 5 clock cycles.
1678   * @retval None
1679   */
1680 #define __HAL_TIM_DISABLE_OCxFAST(__HANDLE__, __CHANNEL__)    \
1681   (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCMR1 &= ~TIM_CCMR1_OC1FE) :\
1682    ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCMR1 &= ~TIM_CCMR1_OC2FE) :\
1683    ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 &= ~TIM_CCMR2_OC3FE) :\
1684    ((__CHANNEL__) == TIM_CHANNEL_4) ? ((__HANDLE__)->Instance->CCMR2 &= ~TIM_CCMR2_OC4FE) :\
1685    ((__CHANNEL__) == TIM_CHANNEL_5) ? ((__HANDLE__)->Instance->CCMR3 &= ~TIM_CCMR3_OC5FE) :\
1686    ((__HANDLE__)->Instance->CCMR3 &= ~TIM_CCMR3_OC6FE))
1687 
1688 /**
1689   * @brief  Set the Update Request Source (URS) bit of the TIMx_CR1 register.
1690   * @param  __HANDLE__ TIM handle.
1691   * @note  When the URS bit of the TIMx_CR1 register is set, only counter
1692   *        overflow/underflow generates an update interrupt or DMA request (if
1693   *        enabled)
1694   * @retval None
1695   */
1696 #define __HAL_TIM_URS_ENABLE(__HANDLE__)  ((__HANDLE__)->Instance->CR1|= TIM_CR1_URS)
1697 
1698 /**
1699   * @brief  Reset the Update Request Source (URS) bit of the TIMx_CR1 register.
1700   * @param  __HANDLE__ TIM handle.
1701   * @note  When the URS bit of the TIMx_CR1 register is reset, any of the
1702   *        following events generate an update interrupt or DMA request (if
1703   *        enabled):
1704   *           _ Counter overflow underflow
1705   *           _ Setting the UG bit
1706   *           _ Update generation through the slave mode controller
1707   * @retval None
1708   */
1709 #define __HAL_TIM_URS_DISABLE(__HANDLE__)  ((__HANDLE__)->Instance->CR1&=~TIM_CR1_URS)
1710 
1711 /**
1712   * @brief  Set the TIM Capture x input polarity on runtime.
1713   * @param  __HANDLE__ TIM handle.
1714   * @param  __CHANNEL__ TIM Channels to be configured.
1715   *          This parameter can be one of the following values:
1716   *            @arg TIM_CHANNEL_1: TIM Channel 1 selected
1717   *            @arg TIM_CHANNEL_2: TIM Channel 2 selected
1718   *            @arg TIM_CHANNEL_3: TIM Channel 3 selected
1719   *            @arg TIM_CHANNEL_4: TIM Channel 4 selected
1720   * @param  __POLARITY__ Polarity for TIx source
1721   *            @arg TIM_INPUTCHANNELPOLARITY_RISING: Rising Edge
1722   *            @arg TIM_INPUTCHANNELPOLARITY_FALLING: Falling Edge
1723   *            @arg TIM_INPUTCHANNELPOLARITY_BOTHEDGE: Rising and Falling Edge
1724   * @retval None
1725   */
1726 #define __HAL_TIM_SET_CAPTUREPOLARITY(__HANDLE__, __CHANNEL__, __POLARITY__)    \
1727   do{                                                                     \
1728     TIM_RESET_CAPTUREPOLARITY((__HANDLE__), (__CHANNEL__));               \
1729     TIM_SET_CAPTUREPOLARITY((__HANDLE__), (__CHANNEL__), (__POLARITY__)); \
1730   }while(0)
1731 
1732 /** @brief  Select the Capture/compare DMA request source.
1733   * @param  __HANDLE__ specifies the TIM Handle.
1734   * @param  __CCDMA__ specifies Capture/compare DMA request source
1735   *          This parameter can be one of the following values:
1736   *            @arg TIM_CCDMAREQUEST_CC: CCx DMA request generated on Capture/Compare event
1737   *            @arg TIM_CCDMAREQUEST_UPDATE: CCx DMA request generated on Update event
1738   * @retval None
1739   */
1740 #define __HAL_TIM_SELECT_CCDMAREQUEST(__HANDLE__, __CCDMA__)    \
1741   MODIFY_REG((__HANDLE__)->Instance->CR2, TIM_CR2_CCDS, (__CCDMA__))
1742 
1743 /**
1744   * @}
1745   */
1746 /* End of exported macros ----------------------------------------------------*/
1747 
1748 /* Private constants ---------------------------------------------------------*/
1749 /** @defgroup TIM_Private_Constants TIM Private Constants
1750   * @{
1751   */
1752 /* The counter of a timer instance is disabled only if all the CCx and CCxN
1753    channels have been disabled */
1754 #define TIM_CCER_CCxE_MASK  ((uint32_t)(TIM_CCER_CC1E | TIM_CCER_CC2E | TIM_CCER_CC3E | TIM_CCER_CC4E))
1755 #define TIM_CCER_CCxNE_MASK ((uint32_t)(TIM_CCER_CC1NE | TIM_CCER_CC2NE | TIM_CCER_CC3NE))
1756 /**
1757   * @}
1758   */
1759 /* End of private constants --------------------------------------------------*/
1760 
1761 /* Private macros ------------------------------------------------------------*/
1762 /** @defgroup TIM_Private_Macros TIM Private Macros
1763   * @{
1764   */
1765 #define IS_TIM_CLEARINPUT_SOURCE(__MODE__)  (((__MODE__) == TIM_CLEARINPUTSOURCE_ETR)      || \
1766                                              ((__MODE__) == TIM_CLEARINPUTSOURCE_COMP1)    || \
1767                                              ((__MODE__) == TIM_CLEARINPUTSOURCE_COMP2)    || \
1768                                              ((__MODE__) == TIM_CLEARINPUTSOURCE_NONE))
1769 
1770 #define IS_TIM_DMA_BASE(__BASE__) (((__BASE__) == TIM_DMABASE_CR1)    || \
1771                                    ((__BASE__) == TIM_DMABASE_CR2)    || \
1772                                    ((__BASE__) == TIM_DMABASE_SMCR)   || \
1773                                    ((__BASE__) == TIM_DMABASE_DIER)   || \
1774                                    ((__BASE__) == TIM_DMABASE_SR)     || \
1775                                    ((__BASE__) == TIM_DMABASE_EGR)    || \
1776                                    ((__BASE__) == TIM_DMABASE_CCMR1)  || \
1777                                    ((__BASE__) == TIM_DMABASE_CCMR2)  || \
1778                                    ((__BASE__) == TIM_DMABASE_CCER)   || \
1779                                    ((__BASE__) == TIM_DMABASE_CNT)    || \
1780                                    ((__BASE__) == TIM_DMABASE_PSC)    || \
1781                                    ((__BASE__) == TIM_DMABASE_ARR)    || \
1782                                    ((__BASE__) == TIM_DMABASE_RCR)    || \
1783                                    ((__BASE__) == TIM_DMABASE_CCR1)   || \
1784                                    ((__BASE__) == TIM_DMABASE_CCR2)   || \
1785                                    ((__BASE__) == TIM_DMABASE_CCR3)   || \
1786                                    ((__BASE__) == TIM_DMABASE_CCR4)   || \
1787                                    ((__BASE__) == TIM_DMABASE_BDTR)   || \
1788                                    ((__BASE__) == TIM_DMABASE_OR)     || \
1789                                    ((__BASE__) == TIM_DMABASE_CCMR3)  || \
1790                                    ((__BASE__) == TIM_DMABASE_CCR5)   || \
1791                                    ((__BASE__) == TIM_DMABASE_CCR6)   || \
1792                                    ((__BASE__) == TIM_DMABASE_AF1)    || \
1793                                    ((__BASE__) == TIM_DMABASE_AF2))
1794 
1795 #define IS_TIM_EVENT_SOURCE(__SOURCE__) ((((__SOURCE__) & 0xFFFFFE00U) == 0x00000000U) && ((__SOURCE__) != 0x00000000U))
1796 
1797 #define IS_TIM_COUNTER_MODE(__MODE__)      (((__MODE__) == TIM_COUNTERMODE_UP)              || \
1798                                             ((__MODE__) == TIM_COUNTERMODE_DOWN)            || \
1799                                             ((__MODE__) == TIM_COUNTERMODE_CENTERALIGNED1)  || \
1800                                             ((__MODE__) == TIM_COUNTERMODE_CENTERALIGNED2)  || \
1801                                             ((__MODE__) == TIM_COUNTERMODE_CENTERALIGNED3))
1802 
1803 #define IS_TIM_UIFREMAP_MODE(__MODE__)     (((__MODE__) == TIM_UIFREMAP_DISABLE) || \
1804                                             ((__MODE__) == TIM_UIFREMAP_ENABLE))
1805 
1806 #define IS_TIM_CLOCKDIVISION_DIV(__DIV__)  (((__DIV__) == TIM_CLOCKDIVISION_DIV1) || \
1807                                             ((__DIV__) == TIM_CLOCKDIVISION_DIV2) || \
1808                                             ((__DIV__) == TIM_CLOCKDIVISION_DIV4))
1809 
1810 #define IS_TIM_AUTORELOAD_PRELOAD(PRELOAD) (((PRELOAD) == TIM_AUTORELOAD_PRELOAD_DISABLE) || \
1811                                             ((PRELOAD) == TIM_AUTORELOAD_PRELOAD_ENABLE))
1812 
1813 #define IS_TIM_FAST_STATE(__STATE__)       (((__STATE__) == TIM_OCFAST_DISABLE) || \
1814                                             ((__STATE__) == TIM_OCFAST_ENABLE))
1815 
1816 #define IS_TIM_OC_POLARITY(__POLARITY__)   (((__POLARITY__) == TIM_OCPOLARITY_HIGH) || \
1817                                             ((__POLARITY__) == TIM_OCPOLARITY_LOW))
1818 
1819 #define IS_TIM_OCN_POLARITY(__POLARITY__)  (((__POLARITY__) == TIM_OCNPOLARITY_HIGH) || \
1820                                             ((__POLARITY__) == TIM_OCNPOLARITY_LOW))
1821 
1822 #define IS_TIM_OCIDLE_STATE(__STATE__)     (((__STATE__) == TIM_OCIDLESTATE_SET) || \
1823                                             ((__STATE__) == TIM_OCIDLESTATE_RESET))
1824 
1825 #define IS_TIM_OCNIDLE_STATE(__STATE__)    (((__STATE__) == TIM_OCNIDLESTATE_SET) || \
1826                                             ((__STATE__) == TIM_OCNIDLESTATE_RESET))
1827 
1828 #define IS_TIM_ENCODERINPUT_POLARITY(__POLARITY__)   (((__POLARITY__) == TIM_ENCODERINPUTPOLARITY_RISING)   || \
1829                                                       ((__POLARITY__) == TIM_ENCODERINPUTPOLARITY_FALLING))
1830 
1831 #define IS_TIM_IC_POLARITY(__POLARITY__)   (((__POLARITY__) == TIM_ICPOLARITY_RISING)   || \
1832                                             ((__POLARITY__) == TIM_ICPOLARITY_FALLING)  || \
1833                                             ((__POLARITY__) == TIM_ICPOLARITY_BOTHEDGE))
1834 
1835 #define IS_TIM_IC_SELECTION(__SELECTION__) (((__SELECTION__) == TIM_ICSELECTION_DIRECTTI) || \
1836                                             ((__SELECTION__) == TIM_ICSELECTION_INDIRECTTI) || \
1837                                             ((__SELECTION__) == TIM_ICSELECTION_TRC))
1838 
1839 #define IS_TIM_IC_PRESCALER(__PRESCALER__) (((__PRESCALER__) == TIM_ICPSC_DIV1) || \
1840                                             ((__PRESCALER__) == TIM_ICPSC_DIV2) || \
1841                                             ((__PRESCALER__) == TIM_ICPSC_DIV4) || \
1842                                             ((__PRESCALER__) == TIM_ICPSC_DIV8))
1843 
1844 #define IS_TIM_CCX_CHANNEL(__INSTANCE__, __CHANNEL__) (IS_TIM_CCX_INSTANCE(__INSTANCE__, __CHANNEL__) && \
1845                                                        ((__CHANNEL__) != (TIM_CHANNEL_5)) && \
1846                                                        ((__CHANNEL__) != (TIM_CHANNEL_6)))
1847 
1848 #define IS_TIM_OPM_MODE(__MODE__)          (((__MODE__) == TIM_OPMODE_SINGLE) || \
1849                                             ((__MODE__) == TIM_OPMODE_REPETITIVE))
1850 
1851 #define IS_TIM_ENCODER_MODE(__MODE__)      (((__MODE__) == TIM_ENCODERMODE_TI1) || \
1852                                             ((__MODE__) == TIM_ENCODERMODE_TI2) || \
1853                                             ((__MODE__) == TIM_ENCODERMODE_TI12))
1854 
1855 #define IS_TIM_DMA_SOURCE(__SOURCE__) ((((__SOURCE__) & 0xFFFF80FFU) == 0x00000000U) && ((__SOURCE__) != 0x00000000U))
1856 
1857 #define IS_TIM_CHANNELS(__CHANNEL__)       (((__CHANNEL__) == TIM_CHANNEL_1) || \
1858                                             ((__CHANNEL__) == TIM_CHANNEL_2) || \
1859                                             ((__CHANNEL__) == TIM_CHANNEL_3) || \
1860                                             ((__CHANNEL__) == TIM_CHANNEL_4) || \
1861                                             ((__CHANNEL__) == TIM_CHANNEL_5) || \
1862                                             ((__CHANNEL__) == TIM_CHANNEL_6) || \
1863                                             ((__CHANNEL__) == TIM_CHANNEL_ALL))
1864 
1865 #define IS_TIM_OPM_CHANNELS(__CHANNEL__)   (((__CHANNEL__) == TIM_CHANNEL_1) || \
1866                                             ((__CHANNEL__) == TIM_CHANNEL_2))
1867 
1868 #define IS_TIM_PERIOD(__HANDLE__, __PERIOD__) ((IS_TIM_32B_COUNTER_INSTANCE(((__HANDLE__)->Instance)) == 0U) ? \
1869                                                (((__PERIOD__) > 0U) && ((__PERIOD__) <= 0x0000FFFFU)) :        \
1870                                                ((__PERIOD__) > 0U))
1871 
1872 #define IS_TIM_COMPLEMENTARY_CHANNELS(__CHANNEL__) (((__CHANNEL__) == TIM_CHANNEL_1) || \
1873                                                     ((__CHANNEL__) == TIM_CHANNEL_2) || \
1874                                                     ((__CHANNEL__) == TIM_CHANNEL_3))
1875 
1876 #define IS_TIM_CLOCKSOURCE(__CLOCK__) (((__CLOCK__) == TIM_CLOCKSOURCE_INTERNAL) || \
1877                                        ((__CLOCK__) == TIM_CLOCKSOURCE_ETRMODE1) || \
1878                                        ((__CLOCK__) == TIM_CLOCKSOURCE_ETRMODE2) || \
1879                                        ((__CLOCK__) == TIM_CLOCKSOURCE_TI1ED)    || \
1880                                        ((__CLOCK__) == TIM_CLOCKSOURCE_TI1)      || \
1881                                        ((__CLOCK__) == TIM_CLOCKSOURCE_TI2)      || \
1882                                        ((__CLOCK__) == TIM_CLOCKSOURCE_ITR0)     || \
1883                                        ((__CLOCK__) == TIM_CLOCKSOURCE_ITR1)     || \
1884                                        ((__CLOCK__) == TIM_CLOCKSOURCE_ITR2)     || \
1885                                        ((__CLOCK__) == TIM_CLOCKSOURCE_ITR3))
1886 
1887 #define IS_TIM_CLOCKPOLARITY(__POLARITY__) (((__POLARITY__) == TIM_CLOCKPOLARITY_INVERTED)    || \
1888                                             ((__POLARITY__) == TIM_CLOCKPOLARITY_NONINVERTED) || \
1889                                             ((__POLARITY__) == TIM_CLOCKPOLARITY_RISING)      || \
1890                                             ((__POLARITY__) == TIM_CLOCKPOLARITY_FALLING)     || \
1891                                             ((__POLARITY__) == TIM_CLOCKPOLARITY_BOTHEDGE))
1892 
1893 #define IS_TIM_CLOCKPRESCALER(__PRESCALER__) (((__PRESCALER__) == TIM_CLOCKPRESCALER_DIV1) || \
1894                                               ((__PRESCALER__) == TIM_CLOCKPRESCALER_DIV2) || \
1895                                               ((__PRESCALER__) == TIM_CLOCKPRESCALER_DIV4) || \
1896                                               ((__PRESCALER__) == TIM_CLOCKPRESCALER_DIV8))
1897 
1898 #define IS_TIM_CLOCKFILTER(__ICFILTER__)      ((__ICFILTER__) <= 0xFU)
1899 
1900 #define IS_TIM_CLEARINPUT_POLARITY(__POLARITY__) (((__POLARITY__) == TIM_CLEARINPUTPOLARITY_INVERTED) || \
1901                                                   ((__POLARITY__) == TIM_CLEARINPUTPOLARITY_NONINVERTED))
1902 
1903 #define IS_TIM_CLEARINPUT_PRESCALER(__PRESCALER__) (((__PRESCALER__) == TIM_CLEARINPUTPRESCALER_DIV1) || \
1904                                                     ((__PRESCALER__) == TIM_CLEARINPUTPRESCALER_DIV2) || \
1905                                                     ((__PRESCALER__) == TIM_CLEARINPUTPRESCALER_DIV4) || \
1906                                                     ((__PRESCALER__) == TIM_CLEARINPUTPRESCALER_DIV8))
1907 
1908 #define IS_TIM_CLEARINPUT_FILTER(__ICFILTER__) ((__ICFILTER__) <= 0xFU)
1909 
1910 #define IS_TIM_OSSR_STATE(__STATE__)       (((__STATE__) == TIM_OSSR_ENABLE) || \
1911                                             ((__STATE__) == TIM_OSSR_DISABLE))
1912 
1913 #define IS_TIM_OSSI_STATE(__STATE__)       (((__STATE__) == TIM_OSSI_ENABLE) || \
1914                                             ((__STATE__) == TIM_OSSI_DISABLE))
1915 
1916 #define IS_TIM_LOCK_LEVEL(__LEVEL__)       (((__LEVEL__) == TIM_LOCKLEVEL_OFF) || \
1917                                             ((__LEVEL__) == TIM_LOCKLEVEL_1)   || \
1918                                             ((__LEVEL__) == TIM_LOCKLEVEL_2)   || \
1919                                             ((__LEVEL__) == TIM_LOCKLEVEL_3))
1920 
1921 #define IS_TIM_BREAK_FILTER(__BRKFILTER__) ((__BRKFILTER__) <= 0xFUL)
1922 
1923 #define IS_TIM_BREAK_STATE(__STATE__)      (((__STATE__) == TIM_BREAK_ENABLE) || \
1924                                             ((__STATE__) == TIM_BREAK_DISABLE))
1925 
1926 #define IS_TIM_BREAK_POLARITY(__POLARITY__) (((__POLARITY__) == TIM_BREAKPOLARITY_LOW) || \
1927                                              ((__POLARITY__) == TIM_BREAKPOLARITY_HIGH))
1928 
1929 #define IS_TIM_BREAK_AFMODE(__AFMODE__) (((__AFMODE__) == TIM_BREAK_AFMODE_INPUT) || \
1930                                          ((__AFMODE__) == TIM_BREAK_AFMODE_BIDIRECTIONAL))
1931 
1932 
1933 #define IS_TIM_BREAK2_STATE(__STATE__)     (((__STATE__) == TIM_BREAK2_ENABLE) || \
1934                                             ((__STATE__) == TIM_BREAK2_DISABLE))
1935 
1936 #define IS_TIM_BREAK2_POLARITY(__POLARITY__) (((__POLARITY__) == TIM_BREAK2POLARITY_LOW) || \
1937                                               ((__POLARITY__) == TIM_BREAK2POLARITY_HIGH))
1938 
1939 #define IS_TIM_BREAK2_AFMODE(__AFMODE__) (((__AFMODE__) == TIM_BREAK2_AFMODE_INPUT) || \
1940                                           ((__AFMODE__) == TIM_BREAK2_AFMODE_BIDIRECTIONAL))
1941 
1942 
1943 #define IS_TIM_AUTOMATIC_OUTPUT_STATE(__STATE__) (((__STATE__) == TIM_AUTOMATICOUTPUT_ENABLE) || \
1944                                                   ((__STATE__) == TIM_AUTOMATICOUTPUT_DISABLE))
1945 
1946 #define IS_TIM_GROUPCH5(__OCREF__) ((((__OCREF__) & 0x1FFFFFFFU) == 0x00000000U))
1947 
1948 #define IS_TIM_TRGO_SOURCE(__SOURCE__) (((__SOURCE__) == TIM_TRGO_RESET)  || \
1949                                         ((__SOURCE__) == TIM_TRGO_ENABLE) || \
1950                                         ((__SOURCE__) == TIM_TRGO_UPDATE) || \
1951                                         ((__SOURCE__) == TIM_TRGO_OC1)    || \
1952                                         ((__SOURCE__) == TIM_TRGO_OC1REF) || \
1953                                         ((__SOURCE__) == TIM_TRGO_OC2REF) || \
1954                                         ((__SOURCE__) == TIM_TRGO_OC3REF) || \
1955                                         ((__SOURCE__) == TIM_TRGO_OC4REF))
1956 
1957 #define IS_TIM_TRGO2_SOURCE(__SOURCE__) (((__SOURCE__) == TIM_TRGO2_RESET)                        || \
1958                                          ((__SOURCE__) == TIM_TRGO2_ENABLE)                       || \
1959                                          ((__SOURCE__) == TIM_TRGO2_UPDATE)                       || \
1960                                          ((__SOURCE__) == TIM_TRGO2_OC1)                          || \
1961                                          ((__SOURCE__) == TIM_TRGO2_OC1REF)                       || \
1962                                          ((__SOURCE__) == TIM_TRGO2_OC2REF)                       || \
1963                                          ((__SOURCE__) == TIM_TRGO2_OC3REF)                       || \
1964                                          ((__SOURCE__) == TIM_TRGO2_OC3REF)                       || \
1965                                          ((__SOURCE__) == TIM_TRGO2_OC4REF)                       || \
1966                                          ((__SOURCE__) == TIM_TRGO2_OC5REF)                       || \
1967                                          ((__SOURCE__) == TIM_TRGO2_OC6REF)                       || \
1968                                          ((__SOURCE__) == TIM_TRGO2_OC4REF_RISINGFALLING)         || \
1969                                          ((__SOURCE__) == TIM_TRGO2_OC6REF_RISINGFALLING)         || \
1970                                          ((__SOURCE__) == TIM_TRGO2_OC4REF_RISING_OC6REF_RISING)  || \
1971                                          ((__SOURCE__) == TIM_TRGO2_OC4REF_RISING_OC6REF_FALLING) || \
1972                                          ((__SOURCE__) == TIM_TRGO2_OC5REF_RISING_OC6REF_RISING)  || \
1973                                          ((__SOURCE__) == TIM_TRGO2_OC5REF_RISING_OC6REF_FALLING))
1974 
1975 #define IS_TIM_MSM_STATE(__STATE__)      (((__STATE__) == TIM_MASTERSLAVEMODE_ENABLE) || \
1976                                           ((__STATE__) == TIM_MASTERSLAVEMODE_DISABLE))
1977 
1978 #define IS_TIM_SLAVE_MODE(__MODE__) (((__MODE__) == TIM_SLAVEMODE_DISABLE)   || \
1979                                      ((__MODE__) == TIM_SLAVEMODE_RESET)     || \
1980                                      ((__MODE__) == TIM_SLAVEMODE_GATED)     || \
1981                                      ((__MODE__) == TIM_SLAVEMODE_TRIGGER)   || \
1982                                      ((__MODE__) == TIM_SLAVEMODE_EXTERNAL1) || \
1983                                      ((__MODE__) == TIM_SLAVEMODE_COMBINED_RESETTRIGGER))
1984 
1985 #define IS_TIM_PWM_MODE(__MODE__) (((__MODE__) == TIM_OCMODE_PWM1)               || \
1986                                    ((__MODE__) == TIM_OCMODE_PWM2)               || \
1987                                    ((__MODE__) == TIM_OCMODE_COMBINED_PWM1)      || \
1988                                    ((__MODE__) == TIM_OCMODE_COMBINED_PWM2)      || \
1989                                    ((__MODE__) == TIM_OCMODE_ASYMMETRIC_PWM1)    || \
1990                                    ((__MODE__) == TIM_OCMODE_ASYMMETRIC_PWM2))
1991 
1992 #define IS_TIM_OC_MODE(__MODE__)  (((__MODE__) == TIM_OCMODE_TIMING)             || \
1993                                    ((__MODE__) == TIM_OCMODE_ACTIVE)             || \
1994                                    ((__MODE__) == TIM_OCMODE_INACTIVE)           || \
1995                                    ((__MODE__) == TIM_OCMODE_TOGGLE)             || \
1996                                    ((__MODE__) == TIM_OCMODE_FORCED_ACTIVE)      || \
1997                                    ((__MODE__) == TIM_OCMODE_FORCED_INACTIVE)    || \
1998                                    ((__MODE__) == TIM_OCMODE_RETRIGERRABLE_OPM1) || \
1999                                    ((__MODE__) == TIM_OCMODE_RETRIGERRABLE_OPM2))
2000 
2001 #define IS_TIM_TRIGGER_SELECTION(__SELECTION__) (((__SELECTION__) == TIM_TS_ITR0)    || \
2002                                                  ((__SELECTION__) == TIM_TS_ITR1)    || \
2003                                                  ((__SELECTION__) == TIM_TS_ITR2)    || \
2004                                                  ((__SELECTION__) == TIM_TS_ITR3)    || \
2005                                                  ((__SELECTION__) == TIM_TS_TI1F_ED) || \
2006                                                  ((__SELECTION__) == TIM_TS_TI1FP1)  || \
2007                                                  ((__SELECTION__) == TIM_TS_TI2FP2)  || \
2008                                                  ((__SELECTION__) == TIM_TS_ETRF))
2009 
2010 #define IS_TIM_INTERNAL_TRIGGEREVENT_SELECTION(__SELECTION__) (((__SELECTION__) == TIM_TS_ITR0) || \
2011                                                                ((__SELECTION__) == TIM_TS_ITR1) || \
2012                                                                ((__SELECTION__) == TIM_TS_ITR2) || \
2013                                                                ((__SELECTION__) == TIM_TS_ITR3) || \
2014                                                                ((__SELECTION__) == TIM_TS_NONE))
2015 
2016 #define IS_TIM_TRIGGERPOLARITY(__POLARITY__)   (((__POLARITY__) == TIM_TRIGGERPOLARITY_INVERTED   ) || \
2017                                                 ((__POLARITY__) == TIM_TRIGGERPOLARITY_NONINVERTED) || \
2018                                                 ((__POLARITY__) == TIM_TRIGGERPOLARITY_RISING     ) || \
2019                                                 ((__POLARITY__) == TIM_TRIGGERPOLARITY_FALLING    ) || \
2020                                                 ((__POLARITY__) == TIM_TRIGGERPOLARITY_BOTHEDGE   ))
2021 
2022 #define IS_TIM_TRIGGERPRESCALER(__PRESCALER__) (((__PRESCALER__) == TIM_TRIGGERPRESCALER_DIV1) || \
2023                                                 ((__PRESCALER__) == TIM_TRIGGERPRESCALER_DIV2) || \
2024                                                 ((__PRESCALER__) == TIM_TRIGGERPRESCALER_DIV4) || \
2025                                                 ((__PRESCALER__) == TIM_TRIGGERPRESCALER_DIV8))
2026 
2027 #define IS_TIM_TRIGGERFILTER(__ICFILTER__) ((__ICFILTER__) <= 0xFU)
2028 
2029 #define IS_TIM_TI1SELECTION(__TI1SELECTION__)  (((__TI1SELECTION__) == TIM_TI1SELECTION_CH1) || \
2030                                                 ((__TI1SELECTION__) == TIM_TI1SELECTION_XORCOMBINATION))
2031 
2032 #define IS_TIM_DMA_LENGTH(__LENGTH__)      (((__LENGTH__) == TIM_DMABURSTLENGTH_1TRANSFER)   || \
2033                                             ((__LENGTH__) == TIM_DMABURSTLENGTH_2TRANSFERS)  || \
2034                                             ((__LENGTH__) == TIM_DMABURSTLENGTH_3TRANSFERS)  || \
2035                                             ((__LENGTH__) == TIM_DMABURSTLENGTH_4TRANSFERS)  || \
2036                                             ((__LENGTH__) == TIM_DMABURSTLENGTH_5TRANSFERS)  || \
2037                                             ((__LENGTH__) == TIM_DMABURSTLENGTH_6TRANSFERS)  || \
2038                                             ((__LENGTH__) == TIM_DMABURSTLENGTH_7TRANSFERS)  || \
2039                                             ((__LENGTH__) == TIM_DMABURSTLENGTH_8TRANSFERS)  || \
2040                                             ((__LENGTH__) == TIM_DMABURSTLENGTH_9TRANSFERS)  || \
2041                                             ((__LENGTH__) == TIM_DMABURSTLENGTH_10TRANSFERS) || \
2042                                             ((__LENGTH__) == TIM_DMABURSTLENGTH_11TRANSFERS) || \
2043                                             ((__LENGTH__) == TIM_DMABURSTLENGTH_12TRANSFERS) || \
2044                                             ((__LENGTH__) == TIM_DMABURSTLENGTH_13TRANSFERS) || \
2045                                             ((__LENGTH__) == TIM_DMABURSTLENGTH_14TRANSFERS) || \
2046                                             ((__LENGTH__) == TIM_DMABURSTLENGTH_15TRANSFERS) || \
2047                                             ((__LENGTH__) == TIM_DMABURSTLENGTH_16TRANSFERS) || \
2048                                             ((__LENGTH__) == TIM_DMABURSTLENGTH_17TRANSFERS) || \
2049                                             ((__LENGTH__) == TIM_DMABURSTLENGTH_18TRANSFERS))
2050 
2051 #define IS_TIM_DMA_DATA_LENGTH(LENGTH) (((LENGTH) >= 0x1U) && ((LENGTH) < 0x10000U))
2052 
2053 #define IS_TIM_IC_FILTER(__ICFILTER__)   ((__ICFILTER__) <= 0xFU)
2054 
2055 #define IS_TIM_DEADTIME(__DEADTIME__)    ((__DEADTIME__) <= 0xFFU)
2056 
2057 #define IS_TIM_BREAK_SYSTEM(__CONFIG__)    (((__CONFIG__) == TIM_BREAK_SYSTEM_ECC)                  || \
2058                                             ((__CONFIG__) == TIM_BREAK_SYSTEM_PVD)                  || \
2059                                             ((__CONFIG__) == TIM_BREAK_SYSTEM_SRAM2_PARITY_ERROR)   || \
2060                                             ((__CONFIG__) == TIM_BREAK_SYSTEM_LOCKUP))
2061 
2062 #define IS_TIM_SLAVEMODE_TRIGGER_ENABLED(__TRIGGER__) (((__TRIGGER__) == TIM_SLAVEMODE_TRIGGER) || \
2063                                                        ((__TRIGGER__) == TIM_SLAVEMODE_COMBINED_RESETTRIGGER))
2064 
2065 #define TIM_SET_ICPRESCALERVALUE(__HANDLE__, __CHANNEL__, __ICPSC__) \
2066   (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCMR1 |= (__ICPSC__)) :\
2067    ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCMR1 |= ((__ICPSC__) << 8U)) :\
2068    ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 |= (__ICPSC__)) :\
2069    ((__HANDLE__)->Instance->CCMR2 |= ((__ICPSC__) << 8U)))
2070 
2071 #define TIM_RESET_ICPRESCALERVALUE(__HANDLE__, __CHANNEL__) \
2072   (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCMR1 &= ~TIM_CCMR1_IC1PSC) :\
2073    ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCMR1 &= ~TIM_CCMR1_IC2PSC) :\
2074    ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 &= ~TIM_CCMR2_IC3PSC) :\
2075    ((__HANDLE__)->Instance->CCMR2 &= ~TIM_CCMR2_IC4PSC))
2076 
2077 #define TIM_SET_CAPTUREPOLARITY(__HANDLE__, __CHANNEL__, __POLARITY__) \
2078   (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCER |= (__POLARITY__)) :\
2079    ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCER |= ((__POLARITY__) << 4U)) :\
2080    ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCER |= ((__POLARITY__) << 8U)) :\
2081    ((__HANDLE__)->Instance->CCER |= (((__POLARITY__) << 12U))))
2082 
2083 #define TIM_RESET_CAPTUREPOLARITY(__HANDLE__, __CHANNEL__) \
2084   (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCER &= ~(TIM_CCER_CC1P | TIM_CCER_CC1NP)) :\
2085    ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCER &= ~(TIM_CCER_CC2P | TIM_CCER_CC2NP)) :\
2086    ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCER &= ~(TIM_CCER_CC3P | TIM_CCER_CC3NP)) :\
2087    ((__HANDLE__)->Instance->CCER &= ~(TIM_CCER_CC4P | TIM_CCER_CC4NP)))
2088 
2089 #define TIM_CHANNEL_STATE_GET(__HANDLE__, __CHANNEL__)\
2090   (((__CHANNEL__) == TIM_CHANNEL_1) ? (__HANDLE__)->ChannelState[0] :\
2091    ((__CHANNEL__) == TIM_CHANNEL_2) ? (__HANDLE__)->ChannelState[1] :\
2092    ((__CHANNEL__) == TIM_CHANNEL_3) ? (__HANDLE__)->ChannelState[2] :\
2093    ((__CHANNEL__) == TIM_CHANNEL_4) ? (__HANDLE__)->ChannelState[3] :\
2094    ((__CHANNEL__) == TIM_CHANNEL_5) ? (__HANDLE__)->ChannelState[4] :\
2095    (__HANDLE__)->ChannelState[5])
2096 
2097 #define TIM_CHANNEL_STATE_SET(__HANDLE__, __CHANNEL__, __CHANNEL_STATE__) \
2098   (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->ChannelState[0] = (__CHANNEL_STATE__)) :\
2099    ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->ChannelState[1] = (__CHANNEL_STATE__)) :\
2100    ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->ChannelState[2] = (__CHANNEL_STATE__)) :\
2101    ((__CHANNEL__) == TIM_CHANNEL_4) ? ((__HANDLE__)->ChannelState[3] = (__CHANNEL_STATE__)) :\
2102    ((__CHANNEL__) == TIM_CHANNEL_5) ? ((__HANDLE__)->ChannelState[4] = (__CHANNEL_STATE__)) :\
2103    ((__HANDLE__)->ChannelState[5] = (__CHANNEL_STATE__)))
2104 
2105 #define TIM_CHANNEL_STATE_SET_ALL(__HANDLE__,  __CHANNEL_STATE__) do { \
2106                                                                        (__HANDLE__)->ChannelState[0]  = \
2107                                                                        (__CHANNEL_STATE__);  \
2108                                                                        (__HANDLE__)->ChannelState[1]  = \
2109                                                                        (__CHANNEL_STATE__);  \
2110                                                                        (__HANDLE__)->ChannelState[2]  = \
2111                                                                        (__CHANNEL_STATE__);  \
2112                                                                        (__HANDLE__)->ChannelState[3]  = \
2113                                                                        (__CHANNEL_STATE__);  \
2114                                                                        (__HANDLE__)->ChannelState[4]  = \
2115                                                                        (__CHANNEL_STATE__);  \
2116                                                                        (__HANDLE__)->ChannelState[5]  = \
2117                                                                        (__CHANNEL_STATE__);  \
2118                                                                      } while(0)
2119 
2120 #define TIM_CHANNEL_N_STATE_GET(__HANDLE__, __CHANNEL__)\
2121   (((__CHANNEL__) == TIM_CHANNEL_1) ? (__HANDLE__)->ChannelNState[0] :\
2122    ((__CHANNEL__) == TIM_CHANNEL_2) ? (__HANDLE__)->ChannelNState[1] :\
2123    ((__CHANNEL__) == TIM_CHANNEL_3) ? (__HANDLE__)->ChannelNState[2] :\
2124    (__HANDLE__)->ChannelNState[3])
2125 
2126 #define TIM_CHANNEL_N_STATE_SET(__HANDLE__, __CHANNEL__, __CHANNEL_STATE__) \
2127   (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->ChannelNState[0] = (__CHANNEL_STATE__)) :\
2128    ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->ChannelNState[1] = (__CHANNEL_STATE__)) :\
2129    ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->ChannelNState[2] = (__CHANNEL_STATE__)) :\
2130    ((__HANDLE__)->ChannelNState[3] = (__CHANNEL_STATE__)))
2131 
2132 #define TIM_CHANNEL_N_STATE_SET_ALL(__HANDLE__,  __CHANNEL_STATE__) do { \
2133                                                                          (__HANDLE__)->ChannelNState[0] = \
2134                                                                          (__CHANNEL_STATE__);  \
2135                                                                          (__HANDLE__)->ChannelNState[1] = \
2136                                                                          (__CHANNEL_STATE__);  \
2137                                                                          (__HANDLE__)->ChannelNState[2] = \
2138                                                                          (__CHANNEL_STATE__);  \
2139                                                                          (__HANDLE__)->ChannelNState[3] = \
2140                                                                          (__CHANNEL_STATE__);  \
2141                                                                        } while(0)
2142 
2143 /**
2144   * @}
2145   */
2146 /* End of private macros -----------------------------------------------------*/
2147 
2148 /* Include TIM HAL Extended module */
2149 #include "stm32wbxx_hal_tim_ex.h"
2150 
2151 /* Exported functions --------------------------------------------------------*/
2152 /** @addtogroup TIM_Exported_Functions TIM Exported Functions
2153   * @{
2154   */
2155 
2156 /** @addtogroup TIM_Exported_Functions_Group1 TIM Time Base functions
2157   *  @brief   Time Base functions
2158   * @{
2159   */
2160 /* Time Base functions ********************************************************/
2161 HAL_StatusTypeDef HAL_TIM_Base_Init(TIM_HandleTypeDef *htim);
2162 HAL_StatusTypeDef HAL_TIM_Base_DeInit(TIM_HandleTypeDef *htim);
2163 void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim);
2164 void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim);
2165 /* Blocking mode: Polling */
2166 HAL_StatusTypeDef HAL_TIM_Base_Start(TIM_HandleTypeDef *htim);
2167 HAL_StatusTypeDef HAL_TIM_Base_Stop(TIM_HandleTypeDef *htim);
2168 /* Non-Blocking mode: Interrupt */
2169 HAL_StatusTypeDef HAL_TIM_Base_Start_IT(TIM_HandleTypeDef *htim);
2170 HAL_StatusTypeDef HAL_TIM_Base_Stop_IT(TIM_HandleTypeDef *htim);
2171 /* Non-Blocking mode: DMA */
2172 HAL_StatusTypeDef HAL_TIM_Base_Start_DMA(TIM_HandleTypeDef *htim, const uint32_t *pData, uint16_t Length);
2173 HAL_StatusTypeDef HAL_TIM_Base_Stop_DMA(TIM_HandleTypeDef *htim);
2174 /**
2175   * @}
2176   */
2177 
2178 /** @addtogroup TIM_Exported_Functions_Group2 TIM Output Compare functions
2179   *  @brief   TIM Output Compare functions
2180   * @{
2181   */
2182 /* Timer Output Compare functions *********************************************/
2183 HAL_StatusTypeDef HAL_TIM_OC_Init(TIM_HandleTypeDef *htim);
2184 HAL_StatusTypeDef HAL_TIM_OC_DeInit(TIM_HandleTypeDef *htim);
2185 void HAL_TIM_OC_MspInit(TIM_HandleTypeDef *htim);
2186 void HAL_TIM_OC_MspDeInit(TIM_HandleTypeDef *htim);
2187 /* Blocking mode: Polling */
2188 HAL_StatusTypeDef HAL_TIM_OC_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
2189 HAL_StatusTypeDef HAL_TIM_OC_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
2190 /* Non-Blocking mode: Interrupt */
2191 HAL_StatusTypeDef HAL_TIM_OC_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
2192 HAL_StatusTypeDef HAL_TIM_OC_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
2193 /* Non-Blocking mode: DMA */
2194 HAL_StatusTypeDef HAL_TIM_OC_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, const uint32_t *pData,
2195                                        uint16_t Length);
2196 HAL_StatusTypeDef HAL_TIM_OC_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
2197 /**
2198   * @}
2199   */
2200 
2201 /** @addtogroup TIM_Exported_Functions_Group3 TIM PWM functions
2202   *  @brief   TIM PWM functions
2203   * @{
2204   */
2205 /* Timer PWM functions ********************************************************/
2206 HAL_StatusTypeDef HAL_TIM_PWM_Init(TIM_HandleTypeDef *htim);
2207 HAL_StatusTypeDef HAL_TIM_PWM_DeInit(TIM_HandleTypeDef *htim);
2208 void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef *htim);
2209 void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef *htim);
2210 /* Blocking mode: Polling */
2211 HAL_StatusTypeDef HAL_TIM_PWM_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
2212 HAL_StatusTypeDef HAL_TIM_PWM_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
2213 /* Non-Blocking mode: Interrupt */
2214 HAL_StatusTypeDef HAL_TIM_PWM_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
2215 HAL_StatusTypeDef HAL_TIM_PWM_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
2216 /* Non-Blocking mode: DMA */
2217 HAL_StatusTypeDef HAL_TIM_PWM_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, const uint32_t *pData,
2218                                         uint16_t Length);
2219 HAL_StatusTypeDef HAL_TIM_PWM_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
2220 /**
2221   * @}
2222   */
2223 
2224 /** @addtogroup TIM_Exported_Functions_Group4 TIM Input Capture functions
2225   *  @brief   TIM Input Capture functions
2226   * @{
2227   */
2228 /* Timer Input Capture functions **********************************************/
2229 HAL_StatusTypeDef HAL_TIM_IC_Init(TIM_HandleTypeDef *htim);
2230 HAL_StatusTypeDef HAL_TIM_IC_DeInit(TIM_HandleTypeDef *htim);
2231 void HAL_TIM_IC_MspInit(TIM_HandleTypeDef *htim);
2232 void HAL_TIM_IC_MspDeInit(TIM_HandleTypeDef *htim);
2233 /* Blocking mode: Polling */
2234 HAL_StatusTypeDef HAL_TIM_IC_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
2235 HAL_StatusTypeDef HAL_TIM_IC_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
2236 /* Non-Blocking mode: Interrupt */
2237 HAL_StatusTypeDef HAL_TIM_IC_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
2238 HAL_StatusTypeDef HAL_TIM_IC_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
2239 /* Non-Blocking mode: DMA */
2240 HAL_StatusTypeDef HAL_TIM_IC_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length);
2241 HAL_StatusTypeDef HAL_TIM_IC_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
2242 /**
2243   * @}
2244   */
2245 
2246 /** @addtogroup TIM_Exported_Functions_Group5 TIM One Pulse functions
2247   *  @brief   TIM One Pulse functions
2248   * @{
2249   */
2250 /* Timer One Pulse functions **************************************************/
2251 HAL_StatusTypeDef HAL_TIM_OnePulse_Init(TIM_HandleTypeDef *htim, uint32_t OnePulseMode);
2252 HAL_StatusTypeDef HAL_TIM_OnePulse_DeInit(TIM_HandleTypeDef *htim);
2253 void HAL_TIM_OnePulse_MspInit(TIM_HandleTypeDef *htim);
2254 void HAL_TIM_OnePulse_MspDeInit(TIM_HandleTypeDef *htim);
2255 /* Blocking mode: Polling */
2256 HAL_StatusTypeDef HAL_TIM_OnePulse_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
2257 HAL_StatusTypeDef HAL_TIM_OnePulse_Stop(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
2258 /* Non-Blocking mode: Interrupt */
2259 HAL_StatusTypeDef HAL_TIM_OnePulse_Start_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
2260 HAL_StatusTypeDef HAL_TIM_OnePulse_Stop_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
2261 /**
2262   * @}
2263   */
2264 
2265 /** @addtogroup TIM_Exported_Functions_Group6 TIM Encoder functions
2266   *  @brief   TIM Encoder functions
2267   * @{
2268   */
2269 /* Timer Encoder functions ****************************************************/
2270 HAL_StatusTypeDef HAL_TIM_Encoder_Init(TIM_HandleTypeDef *htim, const TIM_Encoder_InitTypeDef *sConfig);
2271 HAL_StatusTypeDef HAL_TIM_Encoder_DeInit(TIM_HandleTypeDef *htim);
2272 void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef *htim);
2273 void HAL_TIM_Encoder_MspDeInit(TIM_HandleTypeDef *htim);
2274 /* Blocking mode: Polling */
2275 HAL_StatusTypeDef HAL_TIM_Encoder_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
2276 HAL_StatusTypeDef HAL_TIM_Encoder_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
2277 /* Non-Blocking mode: Interrupt */
2278 HAL_StatusTypeDef HAL_TIM_Encoder_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
2279 HAL_StatusTypeDef HAL_TIM_Encoder_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
2280 /* Non-Blocking mode: DMA */
2281 HAL_StatusTypeDef HAL_TIM_Encoder_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData1,
2282                                             uint32_t *pData2, uint16_t Length);
2283 HAL_StatusTypeDef HAL_TIM_Encoder_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
2284 /**
2285   * @}
2286   */
2287 
2288 /** @addtogroup TIM_Exported_Functions_Group7 TIM IRQ handler management
2289   *  @brief   IRQ handler management
2290   * @{
2291   */
2292 /* Interrupt Handler functions  ***********************************************/
2293 void HAL_TIM_IRQHandler(TIM_HandleTypeDef *htim);
2294 /**
2295   * @}
2296   */
2297 
2298 /** @defgroup TIM_Exported_Functions_Group8 TIM Peripheral Control functions
2299   *  @brief   Peripheral Control functions
2300   * @{
2301   */
2302 /* Control functions  *********************************************************/
2303 HAL_StatusTypeDef HAL_TIM_OC_ConfigChannel(TIM_HandleTypeDef *htim, const TIM_OC_InitTypeDef *sConfig,
2304                                            uint32_t Channel);
2305 HAL_StatusTypeDef HAL_TIM_PWM_ConfigChannel(TIM_HandleTypeDef *htim, const TIM_OC_InitTypeDef *sConfig,
2306                                             uint32_t Channel);
2307 HAL_StatusTypeDef HAL_TIM_IC_ConfigChannel(TIM_HandleTypeDef *htim, const TIM_IC_InitTypeDef *sConfig,
2308                                            uint32_t Channel);
2309 HAL_StatusTypeDef HAL_TIM_OnePulse_ConfigChannel(TIM_HandleTypeDef *htim, TIM_OnePulse_InitTypeDef *sConfig,
2310                                                  uint32_t OutputChannel,  uint32_t InputChannel);
2311 HAL_StatusTypeDef HAL_TIM_ConfigOCrefClear(TIM_HandleTypeDef *htim,
2312                                            const TIM_ClearInputConfigTypeDef *sClearInputConfig,
2313                                            uint32_t Channel);
2314 HAL_StatusTypeDef HAL_TIM_ConfigClockSource(TIM_HandleTypeDef *htim, const TIM_ClockConfigTypeDef *sClockSourceConfig);
2315 HAL_StatusTypeDef HAL_TIM_ConfigTI1Input(TIM_HandleTypeDef *htim, uint32_t TI1_Selection);
2316 HAL_StatusTypeDef HAL_TIM_SlaveConfigSynchro(TIM_HandleTypeDef *htim, const TIM_SlaveConfigTypeDef *sSlaveConfig);
2317 HAL_StatusTypeDef HAL_TIM_SlaveConfigSynchro_IT(TIM_HandleTypeDef *htim, const TIM_SlaveConfigTypeDef *sSlaveConfig);
2318 HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress,
2319                                               uint32_t BurstRequestSrc, const uint32_t  *BurstBuffer,
2320                                               uint32_t  BurstLength);
2321 HAL_StatusTypeDef HAL_TIM_DMABurst_MultiWriteStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress,
2322                                                    uint32_t BurstRequestSrc, const uint32_t *BurstBuffer,
2323                                                    uint32_t BurstLength,  uint32_t DataLength);
2324 HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStop(TIM_HandleTypeDef *htim, uint32_t BurstRequestSrc);
2325 HAL_StatusTypeDef HAL_TIM_DMABurst_ReadStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress,
2326                                              uint32_t BurstRequestSrc, uint32_t  *BurstBuffer, uint32_t  BurstLength);
2327 HAL_StatusTypeDef HAL_TIM_DMABurst_MultiReadStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress,
2328                                                   uint32_t BurstRequestSrc, uint32_t  *BurstBuffer,
2329                                                   uint32_t  BurstLength, uint32_t  DataLength);
2330 HAL_StatusTypeDef HAL_TIM_DMABurst_ReadStop(TIM_HandleTypeDef *htim, uint32_t BurstRequestSrc);
2331 HAL_StatusTypeDef HAL_TIM_GenerateEvent(TIM_HandleTypeDef *htim, uint32_t EventSource);
2332 uint32_t HAL_TIM_ReadCapturedValue(const TIM_HandleTypeDef *htim, uint32_t Channel);
2333 /**
2334   * @}
2335   */
2336 
2337 /** @defgroup TIM_Exported_Functions_Group9 TIM Callbacks functions
2338   *  @brief   TIM Callbacks functions
2339   * @{
2340   */
2341 /* Callback in non blocking modes (Interrupt and DMA) *************************/
2342 void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim);
2343 void HAL_TIM_PeriodElapsedHalfCpltCallback(TIM_HandleTypeDef *htim);
2344 void HAL_TIM_OC_DelayElapsedCallback(TIM_HandleTypeDef *htim);
2345 void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim);
2346 void HAL_TIM_IC_CaptureHalfCpltCallback(TIM_HandleTypeDef *htim);
2347 void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim);
2348 void HAL_TIM_PWM_PulseFinishedHalfCpltCallback(TIM_HandleTypeDef *htim);
2349 void HAL_TIM_TriggerCallback(TIM_HandleTypeDef *htim);
2350 void HAL_TIM_TriggerHalfCpltCallback(TIM_HandleTypeDef *htim);
2351 void HAL_TIM_ErrorCallback(TIM_HandleTypeDef *htim);
2352 
2353 /* Callbacks Register/UnRegister functions  ***********************************/
2354 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
2355 HAL_StatusTypeDef HAL_TIM_RegisterCallback(TIM_HandleTypeDef *htim, HAL_TIM_CallbackIDTypeDef CallbackID,
2356                                            pTIM_CallbackTypeDef pCallback);
2357 HAL_StatusTypeDef HAL_TIM_UnRegisterCallback(TIM_HandleTypeDef *htim, HAL_TIM_CallbackIDTypeDef CallbackID);
2358 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
2359 
2360 /**
2361   * @}
2362   */
2363 
2364 /** @defgroup TIM_Exported_Functions_Group10 TIM Peripheral State functions
2365   *  @brief  Peripheral State functions
2366   * @{
2367   */
2368 /* Peripheral State functions  ************************************************/
2369 HAL_TIM_StateTypeDef HAL_TIM_Base_GetState(const TIM_HandleTypeDef *htim);
2370 HAL_TIM_StateTypeDef HAL_TIM_OC_GetState(const TIM_HandleTypeDef *htim);
2371 HAL_TIM_StateTypeDef HAL_TIM_PWM_GetState(const TIM_HandleTypeDef *htim);
2372 HAL_TIM_StateTypeDef HAL_TIM_IC_GetState(const TIM_HandleTypeDef *htim);
2373 HAL_TIM_StateTypeDef HAL_TIM_OnePulse_GetState(const TIM_HandleTypeDef *htim);
2374 HAL_TIM_StateTypeDef HAL_TIM_Encoder_GetState(const TIM_HandleTypeDef *htim);
2375 
2376 /* Peripheral Channel state functions  ************************************************/
2377 HAL_TIM_ActiveChannel HAL_TIM_GetActiveChannel(const TIM_HandleTypeDef *htim);
2378 HAL_TIM_ChannelStateTypeDef HAL_TIM_GetChannelState(const TIM_HandleTypeDef *htim,  uint32_t Channel);
2379 HAL_TIM_DMABurstStateTypeDef HAL_TIM_DMABurstState(const TIM_HandleTypeDef *htim);
2380 /**
2381   * @}
2382   */
2383 
2384 /**
2385   * @}
2386   */
2387 /* End of exported functions -------------------------------------------------*/
2388 
2389 /* Private functions----------------------------------------------------------*/
2390 /** @defgroup TIM_Private_Functions TIM Private Functions
2391   * @{
2392   */
2393 void TIM_Base_SetConfig(TIM_TypeDef *TIMx, const TIM_Base_InitTypeDef *Structure);
2394 void TIM_TI1_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection, uint32_t TIM_ICFilter);
2395 void TIM_OC2_SetConfig(TIM_TypeDef *TIMx, const TIM_OC_InitTypeDef *OC_Config);
2396 void TIM_ETR_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ExtTRGPrescaler,
2397                        uint32_t TIM_ExtTRGPolarity, uint32_t ExtTRGFilter);
2398 
2399 void TIM_DMADelayPulseHalfCplt(DMA_HandleTypeDef *hdma);
2400 void TIM_DMAError(DMA_HandleTypeDef *hdma);
2401 void TIM_DMACaptureCplt(DMA_HandleTypeDef *hdma);
2402 void TIM_DMACaptureHalfCplt(DMA_HandleTypeDef *hdma);
2403 void TIM_CCxChannelCmd(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t ChannelState);
2404 
2405 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
2406 void TIM_ResetCallback(TIM_HandleTypeDef *htim);
2407 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
2408 
2409 /**
2410   * @}
2411   */
2412 /* End of private functions --------------------------------------------------*/
2413 
2414 /**
2415   * @}
2416   */
2417 
2418 /**
2419   * @}
2420   */
2421 
2422 #ifdef __cplusplus
2423 }
2424 #endif
2425 
2426 #endif /* STM32WBxx_HAL_TIM_H */
2427