2 ******************************************************************************
\r
3 * @file stm32l4xx_hal_tim.c
\r
4 * @author MCD Application Team
\r
5 * @brief TIM HAL module driver.
\r
6 * This file provides firmware functions to manage the following
\r
7 * functionalities of the Timer (TIM) peripheral:
\r
8 * + TIM Time Base Initialization
\r
9 * + TIM Time Base Start
\r
10 * + TIM Time Base Start Interruption
\r
11 * + TIM Time Base Start DMA
\r
12 * + TIM Output Compare/PWM Initialization
\r
13 * + TIM Output Compare/PWM Channel Configuration
\r
14 * + TIM Output Compare/PWM Start
\r
15 * + TIM Output Compare/PWM Start Interruption
\r
16 * + TIM Output Compare/PWM Start DMA
\r
17 * + TIM Input Capture Initialization
\r
18 * + TIM Input Capture Channel Configuration
\r
19 * + TIM Input Capture Start
\r
20 * + TIM Input Capture Start Interruption
\r
21 * + TIM Input Capture Start DMA
\r
22 * + TIM One Pulse Initialization
\r
23 * + TIM One Pulse Channel Configuration
\r
24 * + TIM One Pulse Start
\r
25 * + TIM Encoder Interface Initialization
\r
26 * + TIM Encoder Interface Start
\r
27 * + TIM Encoder Interface Start Interruption
\r
28 * + TIM Encoder Interface Start DMA
\r
29 * + Commutation Event configuration with Interruption and DMA
\r
30 * + TIM OCRef clear configuration
\r
31 * + TIM External Clock configuration
\r
33 ==============================================================================
\r
34 ##### TIMER Generic features #####
\r
35 ==============================================================================
\r
36 [..] The Timer features include:
\r
37 (#) 16-bit up, down, up/down auto-reload counter.
\r
38 (#) 16-bit programmable prescaler allowing dividing (also on the fly) the
\r
39 counter clock frequency either by any factor between 1 and 65536.
\r
40 (#) Up to 4 independent channels for:
\r
43 (++) PWM generation (Edge and Center-aligned Mode)
\r
44 (++) One-pulse mode output
\r
45 (#) Synchronization circuit to control the timer with external signals and to interconnect
\r
46 several timers together.
\r
47 (#) Supports incremental encoder for positioning purposes
\r
49 ##### How to use this driver #####
\r
50 ==============================================================================
\r
52 (#) Initialize the TIM low level resources by implementing the following functions
\r
53 depending on the selected feature:
\r
54 (++) Time Base : HAL_TIM_Base_MspInit()
\r
55 (++) Input Capture : HAL_TIM_IC_MspInit()
\r
56 (++) Output Compare : HAL_TIM_OC_MspInit()
\r
57 (++) PWM generation : HAL_TIM_PWM_MspInit()
\r
58 (++) One-pulse mode output : HAL_TIM_OnePulse_MspInit()
\r
59 (++) Encoder mode output : HAL_TIM_Encoder_MspInit()
\r
61 (#) Initialize the TIM low level resources :
\r
62 (##) Enable the TIM interface clock using __HAL_RCC_TIMx_CLK_ENABLE();
\r
63 (##) TIM pins configuration
\r
64 (+++) Enable the clock for the TIM GPIOs using the following function:
\r
65 __HAL_RCC_GPIOx_CLK_ENABLE();
\r
66 (+++) Configure these TIM pins in Alternate function mode using HAL_GPIO_Init();
\r
68 (#) The external Clock can be configured, if needed (the default clock is the
\r
69 internal clock from the APBx), using the following function:
\r
70 HAL_TIM_ConfigClockSource, the clock configuration should be done before
\r
73 (#) Configure the TIM in the desired functioning mode using one of the
\r
74 Initialization function of this driver:
\r
75 (++) HAL_TIM_Base_Init: to use the Timer to generate a simple time base
\r
76 (++) HAL_TIM_OC_Init and HAL_TIM_OC_ConfigChannel: to use the Timer to generate an
\r
77 Output Compare signal.
\r
78 (++) HAL_TIM_PWM_Init and HAL_TIM_PWM_ConfigChannel: to use the Timer to generate a
\r
80 (++) HAL_TIM_IC_Init and HAL_TIM_IC_ConfigChannel: to use the Timer to measure an
\r
82 (++) HAL_TIM_OnePulse_Init and HAL_TIM_OnePulse_ConfigChannel: to use the Timer
\r
84 (++) HAL_TIM_Encoder_Init: to use the Timer Encoder Interface.
\r
86 (#) Activate the TIM peripheral using one of the start functions depending from the feature used:
\r
87 (++) Time Base : HAL_TIM_Base_Start(), HAL_TIM_Base_Start_DMA(), HAL_TIM_Base_Start_IT()
\r
88 (++) Input Capture : HAL_TIM_IC_Start(), HAL_TIM_IC_Start_DMA(), HAL_TIM_IC_Start_IT()
\r
89 (++) Output Compare : HAL_TIM_OC_Start(), HAL_TIM_OC_Start_DMA(), HAL_TIM_OC_Start_IT()
\r
90 (++) PWM generation : HAL_TIM_PWM_Start(), HAL_TIM_PWM_Start_DMA(), HAL_TIM_PWM_Start_IT()
\r
91 (++) One-pulse mode output : HAL_TIM_OnePulse_Start(), HAL_TIM_OnePulse_Start_IT()
\r
92 (++) Encoder mode output : HAL_TIM_Encoder_Start(), HAL_TIM_Encoder_Start_DMA(), HAL_TIM_Encoder_Start_IT().
\r
94 (#) The DMA Burst is managed with the two following functions:
\r
95 HAL_TIM_DMABurst_WriteStart()
\r
96 HAL_TIM_DMABurst_ReadStart()
\r
98 *** Callback registration ***
\r
99 =============================================
\r
102 The compilation define USE_HAL_TIM_REGISTER_CALLBACKS when set to 1
\r
103 allows the user to configure dynamically the driver callbacks.
\r
106 Use Function @ref HAL_TIM_RegisterCallback() to register a callback.
\r
107 @ref HAL_TIM_RegisterCallback() takes as parameters the HAL peripheral handle,
\r
108 the Callback ID and a pointer to the user callback function.
\r
111 Use function @ref HAL_TIM_UnRegisterCallback() to reset a callback to the default
\r
113 @ref HAL_TIM_UnRegisterCallback takes as parameters the HAL peripheral handle,
\r
114 and the Callback ID.
\r
117 These functions allow to register/unregister following callbacks:
\r
118 (+) Base_MspInitCallback : TIM Base Msp Init Callback.
\r
119 (+) Base_MspDeInitCallback : TIM Base Msp DeInit Callback.
\r
120 (+) IC_MspInitCallback : TIM IC Msp Init Callback.
\r
121 (+) IC_MspDeInitCallback : TIM IC Msp DeInit Callback.
\r
122 (+) OC_MspInitCallback : TIM OC Msp Init Callback.
\r
123 (+) OC_MspDeInitCallback : TIM OC Msp DeInit Callback.
\r
124 (+) PWM_MspInitCallback : TIM PWM Msp Init Callback.
\r
125 (+) PWM_MspDeInitCallback : TIM PWM Msp DeInit Callback.
\r
126 (+) OnePulse_MspInitCallback : TIM One Pulse Msp Init Callback.
\r
127 (+) OnePulse_MspDeInitCallback : TIM One Pulse Msp DeInit Callback.
\r
128 (+) Encoder_MspInitCallback : TIM Encoder Msp Init Callback.
\r
129 (+) Encoder_MspDeInitCallback : TIM Encoder Msp DeInit Callback.
\r
130 (+) HallSensor_MspInitCallback : TIM Hall Sensor Msp Init Callback.
\r
131 (+) HallSensor_MspDeInitCallback : TIM Hall Sensor Msp DeInit Callback.
\r
132 (+) PeriodElapsedCallback : TIM Period Elapsed Callback.
\r
133 (+) PeriodElapsedHalfCpltCallback : TIM Period Elapsed half complete Callback.
\r
134 (+) TriggerCallback : TIM Trigger Callback.
\r
135 (+) TriggerHalfCpltCallback : TIM Trigger half complete Callback.
\r
136 (+) IC_CaptureCallback : TIM Input Capture Callback.
\r
137 (+) IC_CaptureHalfCpltCallback : TIM Input Capture half complete Callback.
\r
138 (+) OC_DelayElapsedCallback : TIM Output Compare Delay Elapsed Callback.
\r
139 (+) PWM_PulseFinishedCallback : TIM PWM Pulse Finished Callback.
\r
140 (+) PWM_PulseFinishedHalfCpltCallback : TIM PWM Pulse Finished half complete Callback.
\r
141 (+) ErrorCallback : TIM Error Callback.
\r
142 (+) CommutationCallback : TIM Commutation Callback.
\r
143 (+) CommutationHalfCpltCallback : TIM Commutation half complete Callback.
\r
144 (+) BreakCallback : TIM Break Callback.
\r
145 (+) Break2Callback : TIM Break2 Callback.
\r
148 By default, after the Init and when the state is HAL_TIM_STATE_RESET
\r
149 all interrupt callbacks are set to the corresponding weak functions:
\r
150 examples @ref HAL_TIM_TriggerCallback(), @ref HAL_TIM_ErrorCallback().
\r
153 Exception done for MspInit and MspDeInit functions that are reset to the legacy weak
\r
154 functionalities in the Init / DeInit only when these callbacks are null
\r
155 (not registered beforehand). If not, MspInit or MspDeInit are not null, the Init / DeInit
\r
156 keep and use the user MspInit / MspDeInit callbacks(registered beforehand)
\r
159 Callbacks can be registered / unregistered in HAL_TIM_STATE_READY state only.
\r
160 Exception done MspInit / MspDeInit that can be registered / unregistered
\r
161 in HAL_TIM_STATE_READY or HAL_TIM_STATE_RESET state,
\r
162 thus registered(user) MspInit / DeInit callbacks can be used during the Init / DeInit.
\r
163 In that case first register the MspInit/MspDeInit user callbacks
\r
164 using @ref HAL_TIM_RegisterCallback() before calling DeInit or Init function.
\r
167 When The compilation define USE_HAL_TIM_REGISTER_CALLBACKS is set to 0 or
\r
168 not defined, the callback registration feature is not available and all callbacks
\r
169 are set to the corresponding weak functions.
\r
172 ******************************************************************************
\r
175 * <h2><center>© Copyright (c) 2017 STMicroelectronics.
\r
176 * All rights reserved.</center></h2>
\r
178 * This software component is licensed by ST under BSD 3-Clause license,
\r
179 * the "License"; You may not use this file except in compliance with the
\r
180 * License. You may obtain a copy of the License at:
\r
181 * opensource.org/licenses/BSD-3-Clause
\r
183 ******************************************************************************
\r
186 /* Includes ------------------------------------------------------------------*/
\r
187 #include "stm32l4xx_hal.h"
\r
189 /** @addtogroup STM32L4xx_HAL_Driver
\r
193 /** @defgroup TIM TIM
\r
194 * @brief TIM HAL module driver
\r
198 #ifdef HAL_TIM_MODULE_ENABLED
\r
200 /* Private typedef -----------------------------------------------------------*/
\r
201 /* Private define ------------------------------------------------------------*/
\r
202 /* Private macro -------------------------------------------------------------*/
\r
203 /* Private variables ---------------------------------------------------------*/
\r
204 /* Private function prototypes -----------------------------------------------*/
\r
205 /** @addtogroup TIM_Private_Functions
\r
208 static void TIM_OC1_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config);
\r
209 static void TIM_OC3_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config);
\r
210 static void TIM_OC4_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config);
\r
211 static void TIM_OC5_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config);
\r
212 static void TIM_OC6_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config);
\r
213 static void TIM_TI1_ConfigInputStage(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICFilter);
\r
214 static void TIM_TI2_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection,
\r
215 uint32_t TIM_ICFilter);
\r
216 static void TIM_TI2_ConfigInputStage(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICFilter);
\r
217 static void TIM_TI3_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection,
\r
218 uint32_t TIM_ICFilter);
\r
219 static void TIM_TI4_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection,
\r
220 uint32_t TIM_ICFilter);
\r
221 static void TIM_ITRx_SetConfig(TIM_TypeDef *TIMx, uint32_t InputTriggerSource);
\r
222 static void TIM_DMAPeriodElapsedCplt(DMA_HandleTypeDef *hdma);
\r
223 static void TIM_DMAPeriodElapsedHalfCplt(DMA_HandleTypeDef *hdma);
\r
224 static void TIM_DMATriggerCplt(DMA_HandleTypeDef *hdma);
\r
225 static void TIM_DMATriggerHalfCplt(DMA_HandleTypeDef *hdma);
\r
226 static HAL_StatusTypeDef TIM_SlaveTimer_SetConfig(TIM_HandleTypeDef *htim,
\r
227 TIM_SlaveConfigTypeDef *sSlaveConfig);
\r
231 /* Exported functions --------------------------------------------------------*/
\r
233 /** @defgroup TIM_Exported_Functions TIM Exported Functions
\r
237 /** @defgroup TIM_Exported_Functions_Group1 TIM Time Base functions
\r
238 * @brief Time Base functions
\r
241 ==============================================================================
\r
242 ##### Time Base functions #####
\r
243 ==============================================================================
\r
245 This section provides functions allowing to:
\r
246 (+) Initialize and configure the TIM base.
\r
247 (+) De-initialize the TIM base.
\r
248 (+) Start the Time Base.
\r
249 (+) Stop the Time Base.
\r
250 (+) Start the Time Base and enable interrupt.
\r
251 (+) Stop the Time Base and disable interrupt.
\r
252 (+) Start the Time Base and enable DMA transfer.
\r
253 (+) Stop the Time Base and disable DMA transfer.
\r
259 * @brief Initializes the TIM Time base Unit according to the specified
\r
260 * parameters in the TIM_HandleTypeDef and initialize the associated handle.
\r
261 * @note Switching from Center Aligned counter mode to Edge counter mode (or reverse)
\r
262 * requires a timer reset to avoid unexpected direction
\r
263 * due to DIR bit readonly in center aligned mode.
\r
264 * Ex: call @ref HAL_TIM_Base_DeInit() before HAL_TIM_Base_Init()
\r
265 * @param htim TIM Base handle
\r
266 * @retval HAL status
\r
268 HAL_StatusTypeDef HAL_TIM_Base_Init(TIM_HandleTypeDef *htim)
\r
270 /* Check the TIM handle allocation */
\r
276 /* Check the parameters */
\r
277 assert_param(IS_TIM_INSTANCE(htim->Instance));
\r
278 assert_param(IS_TIM_COUNTER_MODE(htim->Init.CounterMode));
\r
279 assert_param(IS_TIM_CLOCKDIVISION_DIV(htim->Init.ClockDivision));
\r
280 assert_param(IS_TIM_AUTORELOAD_PRELOAD(htim->Init.AutoReloadPreload));
\r
282 if (htim->State == HAL_TIM_STATE_RESET)
\r
284 /* Allocate lock resource and initialize it */
\r
285 htim->Lock = HAL_UNLOCKED;
\r
287 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
288 /* Reset interrupt callbacks to legacy weak callbacks */
\r
289 TIM_ResetCallback(htim);
\r
291 if (htim->Base_MspInitCallback == NULL)
\r
293 htim->Base_MspInitCallback = HAL_TIM_Base_MspInit;
\r
295 /* Init the low level hardware : GPIO, CLOCK, NVIC */
\r
296 htim->Base_MspInitCallback(htim);
\r
298 /* Init the low level hardware : GPIO, CLOCK, NVIC */
\r
299 HAL_TIM_Base_MspInit(htim);
\r
300 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
303 /* Set the TIM state */
\r
304 htim->State = HAL_TIM_STATE_BUSY;
\r
306 /* Set the Time Base configuration */
\r
307 TIM_Base_SetConfig(htim->Instance, &htim->Init);
\r
309 /* Initialize the TIM state*/
\r
310 htim->State = HAL_TIM_STATE_READY;
\r
316 * @brief DeInitializes the TIM Base peripheral
\r
317 * @param htim TIM Base handle
\r
318 * @retval HAL status
\r
320 HAL_StatusTypeDef HAL_TIM_Base_DeInit(TIM_HandleTypeDef *htim)
\r
322 /* Check the parameters */
\r
323 assert_param(IS_TIM_INSTANCE(htim->Instance));
\r
325 htim->State = HAL_TIM_STATE_BUSY;
\r
327 /* Disable the TIM Peripheral Clock */
\r
328 __HAL_TIM_DISABLE(htim);
\r
330 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
331 if (htim->Base_MspDeInitCallback == NULL)
\r
333 htim->Base_MspDeInitCallback = HAL_TIM_Base_MspDeInit;
\r
335 /* DeInit the low level hardware */
\r
336 htim->Base_MspDeInitCallback(htim);
\r
338 /* DeInit the low level hardware: GPIO, CLOCK, NVIC */
\r
339 HAL_TIM_Base_MspDeInit(htim);
\r
340 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
342 /* Change TIM state */
\r
343 htim->State = HAL_TIM_STATE_RESET;
\r
346 __HAL_UNLOCK(htim);
\r
352 * @brief Initializes the TIM Base MSP.
\r
353 * @param htim TIM Base handle
\r
356 __weak void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim)
\r
358 /* Prevent unused argument(s) compilation warning */
\r
361 /* NOTE : This function should not be modified, when the callback is needed,
\r
362 the HAL_TIM_Base_MspInit could be implemented in the user file
\r
367 * @brief DeInitializes TIM Base MSP.
\r
368 * @param htim TIM Base handle
\r
371 __weak void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim)
\r
373 /* Prevent unused argument(s) compilation warning */
\r
376 /* NOTE : This function should not be modified, when the callback is needed,
\r
377 the HAL_TIM_Base_MspDeInit could be implemented in the user file
\r
383 * @brief Starts the TIM Base generation.
\r
384 * @param htim TIM Base handle
\r
385 * @retval HAL status
\r
387 HAL_StatusTypeDef HAL_TIM_Base_Start(TIM_HandleTypeDef *htim)
\r
391 /* Check the parameters */
\r
392 assert_param(IS_TIM_INSTANCE(htim->Instance));
\r
394 /* Set the TIM state */
\r
395 htim->State = HAL_TIM_STATE_BUSY;
\r
397 /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
\r
398 tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
\r
399 if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
\r
401 __HAL_TIM_ENABLE(htim);
\r
404 /* Change the TIM state*/
\r
405 htim->State = HAL_TIM_STATE_READY;
\r
407 /* Return function status */
\r
412 * @brief Stops the TIM Base generation.
\r
413 * @param htim TIM Base handle
\r
414 * @retval HAL status
\r
416 HAL_StatusTypeDef HAL_TIM_Base_Stop(TIM_HandleTypeDef *htim)
\r
418 /* Check the parameters */
\r
419 assert_param(IS_TIM_INSTANCE(htim->Instance));
\r
421 /* Set the TIM state */
\r
422 htim->State = HAL_TIM_STATE_BUSY;
\r
424 /* Disable the Peripheral */
\r
425 __HAL_TIM_DISABLE(htim);
\r
427 /* Change the TIM state*/
\r
428 htim->State = HAL_TIM_STATE_READY;
\r
430 /* Return function status */
\r
435 * @brief Starts the TIM Base generation in interrupt mode.
\r
436 * @param htim TIM Base handle
\r
437 * @retval HAL status
\r
439 HAL_StatusTypeDef HAL_TIM_Base_Start_IT(TIM_HandleTypeDef *htim)
\r
443 /* Check the parameters */
\r
444 assert_param(IS_TIM_INSTANCE(htim->Instance));
\r
446 /* Enable the TIM Update interrupt */
\r
447 __HAL_TIM_ENABLE_IT(htim, TIM_IT_UPDATE);
\r
449 /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
\r
450 tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
\r
451 if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
\r
453 __HAL_TIM_ENABLE(htim);
\r
456 /* Return function status */
\r
461 * @brief Stops the TIM Base generation in interrupt mode.
\r
462 * @param htim TIM Base handle
\r
463 * @retval HAL status
\r
465 HAL_StatusTypeDef HAL_TIM_Base_Stop_IT(TIM_HandleTypeDef *htim)
\r
467 /* Check the parameters */
\r
468 assert_param(IS_TIM_INSTANCE(htim->Instance));
\r
469 /* Disable the TIM Update interrupt */
\r
470 __HAL_TIM_DISABLE_IT(htim, TIM_IT_UPDATE);
\r
472 /* Disable the Peripheral */
\r
473 __HAL_TIM_DISABLE(htim);
\r
475 /* Return function status */
\r
480 * @brief Starts the TIM Base generation in DMA mode.
\r
481 * @param htim TIM Base handle
\r
482 * @param pData The source Buffer address.
\r
483 * @param Length The length of data to be transferred from memory to peripheral.
\r
484 * @retval HAL status
\r
486 HAL_StatusTypeDef HAL_TIM_Base_Start_DMA(TIM_HandleTypeDef *htim, uint32_t *pData, uint16_t Length)
\r
490 /* Check the parameters */
\r
491 assert_param(IS_TIM_DMA_INSTANCE(htim->Instance));
\r
493 if ((htim->State == HAL_TIM_STATE_BUSY))
\r
497 else if ((htim->State == HAL_TIM_STATE_READY))
\r
499 if ((pData == NULL) && (Length > 0U))
\r
505 htim->State = HAL_TIM_STATE_BUSY;
\r
510 /* nothing to do */
\r
513 /* Set the DMA Period elapsed callbacks */
\r
514 htim->hdma[TIM_DMA_ID_UPDATE]->XferCpltCallback = TIM_DMAPeriodElapsedCplt;
\r
515 htim->hdma[TIM_DMA_ID_UPDATE]->XferHalfCpltCallback = TIM_DMAPeriodElapsedHalfCplt;
\r
517 /* Set the DMA error callback */
\r
518 htim->hdma[TIM_DMA_ID_UPDATE]->XferErrorCallback = TIM_DMAError ;
\r
520 /* Enable the DMA channel */
\r
521 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_UPDATE], (uint32_t)pData, (uint32_t)&htim->Instance->ARR, Length) != HAL_OK)
\r
526 /* Enable the TIM Update DMA request */
\r
527 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_UPDATE);
\r
529 /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
\r
530 tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
\r
531 if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
\r
533 __HAL_TIM_ENABLE(htim);
\r
536 /* Return function status */
\r
541 * @brief Stops the TIM Base generation in DMA mode.
\r
542 * @param htim TIM Base handle
\r
543 * @retval HAL status
\r
545 HAL_StatusTypeDef HAL_TIM_Base_Stop_DMA(TIM_HandleTypeDef *htim)
\r
547 /* Check the parameters */
\r
548 assert_param(IS_TIM_DMA_INSTANCE(htim->Instance));
\r
550 /* Disable the TIM Update DMA request */
\r
551 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_UPDATE);
\r
553 (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_UPDATE]);
\r
555 /* Disable the Peripheral */
\r
556 __HAL_TIM_DISABLE(htim);
\r
558 /* Change the htim state */
\r
559 htim->State = HAL_TIM_STATE_READY;
\r
561 /* Return function status */
\r
569 /** @defgroup TIM_Exported_Functions_Group2 TIM Output Compare functions
\r
570 * @brief TIM Output Compare functions
\r
573 ==============================================================================
\r
574 ##### TIM Output Compare functions #####
\r
575 ==============================================================================
\r
577 This section provides functions allowing to:
\r
578 (+) Initialize and configure the TIM Output Compare.
\r
579 (+) De-initialize the TIM Output Compare.
\r
580 (+) Start the TIM Output Compare.
\r
581 (+) Stop the TIM Output Compare.
\r
582 (+) Start the TIM Output Compare and enable interrupt.
\r
583 (+) Stop the TIM Output Compare and disable interrupt.
\r
584 (+) Start the TIM Output Compare and enable DMA transfer.
\r
585 (+) Stop the TIM Output Compare and disable DMA transfer.
\r
591 * @brief Initializes the TIM Output Compare according to the specified
\r
592 * parameters in the TIM_HandleTypeDef and initializes the associated handle.
\r
593 * @note Switching from Center Aligned counter mode to Edge counter mode (or reverse)
\r
594 * requires a timer reset to avoid unexpected direction
\r
595 * due to DIR bit readonly in center aligned mode.
\r
596 * Ex: call @ref HAL_TIM_OC_DeInit() before HAL_TIM_OC_Init()
\r
597 * @param htim TIM Output Compare handle
\r
598 * @retval HAL status
\r
600 HAL_StatusTypeDef HAL_TIM_OC_Init(TIM_HandleTypeDef *htim)
\r
602 /* Check the TIM handle allocation */
\r
608 /* Check the parameters */
\r
609 assert_param(IS_TIM_INSTANCE(htim->Instance));
\r
610 assert_param(IS_TIM_COUNTER_MODE(htim->Init.CounterMode));
\r
611 assert_param(IS_TIM_CLOCKDIVISION_DIV(htim->Init.ClockDivision));
\r
612 assert_param(IS_TIM_AUTORELOAD_PRELOAD(htim->Init.AutoReloadPreload));
\r
614 if (htim->State == HAL_TIM_STATE_RESET)
\r
616 /* Allocate lock resource and initialize it */
\r
617 htim->Lock = HAL_UNLOCKED;
\r
619 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
620 /* Reset interrupt callbacks to legacy weak callbacks */
\r
621 TIM_ResetCallback(htim);
\r
623 if (htim->OC_MspInitCallback == NULL)
\r
625 htim->OC_MspInitCallback = HAL_TIM_OC_MspInit;
\r
627 /* Init the low level hardware : GPIO, CLOCK, NVIC */
\r
628 htim->OC_MspInitCallback(htim);
\r
630 /* Init the low level hardware : GPIO, CLOCK, NVIC and DMA */
\r
631 HAL_TIM_OC_MspInit(htim);
\r
632 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
635 /* Set the TIM state */
\r
636 htim->State = HAL_TIM_STATE_BUSY;
\r
638 /* Init the base time for the Output Compare */
\r
639 TIM_Base_SetConfig(htim->Instance, &htim->Init);
\r
641 /* Initialize the TIM state*/
\r
642 htim->State = HAL_TIM_STATE_READY;
\r
648 * @brief DeInitializes the TIM peripheral
\r
649 * @param htim TIM Output Compare handle
\r
650 * @retval HAL status
\r
652 HAL_StatusTypeDef HAL_TIM_OC_DeInit(TIM_HandleTypeDef *htim)
\r
654 /* Check the parameters */
\r
655 assert_param(IS_TIM_INSTANCE(htim->Instance));
\r
657 htim->State = HAL_TIM_STATE_BUSY;
\r
659 /* Disable the TIM Peripheral Clock */
\r
660 __HAL_TIM_DISABLE(htim);
\r
662 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
663 if (htim->OC_MspDeInitCallback == NULL)
\r
665 htim->OC_MspDeInitCallback = HAL_TIM_OC_MspDeInit;
\r
667 /* DeInit the low level hardware */
\r
668 htim->OC_MspDeInitCallback(htim);
\r
670 /* DeInit the low level hardware: GPIO, CLOCK, NVIC and DMA */
\r
671 HAL_TIM_OC_MspDeInit(htim);
\r
672 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
674 /* Change TIM state */
\r
675 htim->State = HAL_TIM_STATE_RESET;
\r
678 __HAL_UNLOCK(htim);
\r
684 * @brief Initializes the TIM Output Compare MSP.
\r
685 * @param htim TIM Output Compare handle
\r
688 __weak void HAL_TIM_OC_MspInit(TIM_HandleTypeDef *htim)
\r
690 /* Prevent unused argument(s) compilation warning */
\r
693 /* NOTE : This function should not be modified, when the callback is needed,
\r
694 the HAL_TIM_OC_MspInit could be implemented in the user file
\r
699 * @brief DeInitializes TIM Output Compare MSP.
\r
700 * @param htim TIM Output Compare handle
\r
703 __weak void HAL_TIM_OC_MspDeInit(TIM_HandleTypeDef *htim)
\r
705 /* Prevent unused argument(s) compilation warning */
\r
708 /* NOTE : This function should not be modified, when the callback is needed,
\r
709 the HAL_TIM_OC_MspDeInit could be implemented in the user file
\r
714 * @brief Starts the TIM Output Compare signal generation.
\r
715 * @param htim TIM Output Compare handle
\r
716 * @param Channel TIM Channel to be enabled
\r
717 * This parameter can be one of the following values:
\r
718 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
719 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
720 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
721 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
\r
722 * @arg TIM_CHANNEL_5: TIM Channel 5 selected
\r
723 * @arg TIM_CHANNEL_6: TIM Channel 6 selected
\r
724 * @retval HAL status
\r
726 HAL_StatusTypeDef HAL_TIM_OC_Start(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
730 /* Check the parameters */
\r
731 assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
\r
733 /* Enable the Output compare channel */
\r
734 TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
\r
736 if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
\r
738 /* Enable the main output */
\r
739 __HAL_TIM_MOE_ENABLE(htim);
\r
742 /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
\r
743 tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
\r
744 if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
\r
746 __HAL_TIM_ENABLE(htim);
\r
749 /* Return function status */
\r
754 * @brief Stops the TIM Output Compare signal generation.
\r
755 * @param htim TIM Output Compare handle
\r
756 * @param Channel TIM Channel to be disabled
\r
757 * This parameter can be one of the following values:
\r
758 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
759 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
760 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
761 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
\r
762 * @arg TIM_CHANNEL_5: TIM Channel 5 selected
\r
763 * @arg TIM_CHANNEL_6: TIM Channel 6 selected
\r
764 * @retval HAL status
\r
766 HAL_StatusTypeDef HAL_TIM_OC_Stop(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
768 /* Check the parameters */
\r
769 assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
\r
771 /* Disable the Output compare channel */
\r
772 TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
\r
774 if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
\r
776 /* Disable the Main Output */
\r
777 __HAL_TIM_MOE_DISABLE(htim);
\r
780 /* Disable the Peripheral */
\r
781 __HAL_TIM_DISABLE(htim);
\r
783 /* Return function status */
\r
788 * @brief Starts the TIM Output Compare signal generation in interrupt mode.
\r
789 * @param htim TIM Output Compare handle
\r
790 * @param Channel TIM Channel to be enabled
\r
791 * This parameter can be one of the following values:
\r
792 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
793 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
794 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
795 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
\r
796 * @retval HAL status
\r
798 HAL_StatusTypeDef HAL_TIM_OC_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
802 /* Check the parameters */
\r
803 assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
\r
807 case TIM_CHANNEL_1:
\r
809 /* Enable the TIM Capture/Compare 1 interrupt */
\r
810 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC1);
\r
814 case TIM_CHANNEL_2:
\r
816 /* Enable the TIM Capture/Compare 2 interrupt */
\r
817 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC2);
\r
821 case TIM_CHANNEL_3:
\r
823 /* Enable the TIM Capture/Compare 3 interrupt */
\r
824 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC3);
\r
828 case TIM_CHANNEL_4:
\r
830 /* Enable the TIM Capture/Compare 4 interrupt */
\r
831 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC4);
\r
839 /* Enable the Output compare channel */
\r
840 TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
\r
842 if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
\r
844 /* Enable the main output */
\r
845 __HAL_TIM_MOE_ENABLE(htim);
\r
848 /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
\r
849 tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
\r
850 if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
\r
852 __HAL_TIM_ENABLE(htim);
\r
855 /* Return function status */
\r
860 * @brief Stops the TIM Output Compare signal generation in interrupt mode.
\r
861 * @param htim TIM Output Compare handle
\r
862 * @param Channel TIM Channel to be disabled
\r
863 * This parameter can be one of the following values:
\r
864 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
865 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
866 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
867 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
\r
868 * @retval HAL status
\r
870 HAL_StatusTypeDef HAL_TIM_OC_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
872 /* Check the parameters */
\r
873 assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
\r
877 case TIM_CHANNEL_1:
\r
879 /* Disable the TIM Capture/Compare 1 interrupt */
\r
880 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC1);
\r
884 case TIM_CHANNEL_2:
\r
886 /* Disable the TIM Capture/Compare 2 interrupt */
\r
887 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC2);
\r
891 case TIM_CHANNEL_3:
\r
893 /* Disable the TIM Capture/Compare 3 interrupt */
\r
894 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC3);
\r
898 case TIM_CHANNEL_4:
\r
900 /* Disable the TIM Capture/Compare 4 interrupt */
\r
901 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC4);
\r
909 /* Disable the Output compare channel */
\r
910 TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
\r
912 if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
\r
914 /* Disable the Main Output */
\r
915 __HAL_TIM_MOE_DISABLE(htim);
\r
918 /* Disable the Peripheral */
\r
919 __HAL_TIM_DISABLE(htim);
\r
921 /* Return function status */
\r
926 * @brief Starts the TIM Output Compare signal generation in DMA mode.
\r
927 * @param htim TIM Output Compare handle
\r
928 * @param Channel TIM Channel to be enabled
\r
929 * This parameter can be one of the following values:
\r
930 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
931 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
932 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
933 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
\r
934 * @param pData The source Buffer address.
\r
935 * @param Length The length of data to be transferred from memory to TIM peripheral
\r
936 * @retval HAL status
\r
938 HAL_StatusTypeDef HAL_TIM_OC_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length)
\r
942 /* Check the parameters */
\r
943 assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
\r
945 if ((htim->State == HAL_TIM_STATE_BUSY))
\r
949 else if ((htim->State == HAL_TIM_STATE_READY))
\r
951 if ((pData == NULL) && (Length > 0U))
\r
957 htim->State = HAL_TIM_STATE_BUSY;
\r
962 /* nothing to do */
\r
967 case TIM_CHANNEL_1:
\r
969 /* Set the DMA compare callbacks */
\r
970 htim->hdma[TIM_DMA_ID_CC1]->XferCpltCallback = TIM_DMADelayPulseCplt;
\r
971 htim->hdma[TIM_DMA_ID_CC1]->XferHalfCpltCallback = TIM_DMADelayPulseHalfCplt;
\r
973 /* Set the DMA error callback */
\r
974 htim->hdma[TIM_DMA_ID_CC1]->XferErrorCallback = TIM_DMAError ;
\r
976 /* Enable the DMA channel */
\r
977 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)pData, (uint32_t)&htim->Instance->CCR1, Length) != HAL_OK)
\r
982 /* Enable the TIM Capture/Compare 1 DMA request */
\r
983 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC1);
\r
987 case TIM_CHANNEL_2:
\r
989 /* Set the DMA compare callbacks */
\r
990 htim->hdma[TIM_DMA_ID_CC2]->XferCpltCallback = TIM_DMADelayPulseCplt;
\r
991 htim->hdma[TIM_DMA_ID_CC2]->XferHalfCpltCallback = TIM_DMADelayPulseHalfCplt;
\r
993 /* Set the DMA error callback */
\r
994 htim->hdma[TIM_DMA_ID_CC2]->XferErrorCallback = TIM_DMAError ;
\r
996 /* Enable the DMA channel */
\r
997 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)pData, (uint32_t)&htim->Instance->CCR2, Length) != HAL_OK)
\r
1002 /* Enable the TIM Capture/Compare 2 DMA request */
\r
1003 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC2);
\r
1007 case TIM_CHANNEL_3:
\r
1009 /* Set the DMA compare callbacks */
\r
1010 htim->hdma[TIM_DMA_ID_CC3]->XferCpltCallback = TIM_DMADelayPulseCplt;
\r
1011 htim->hdma[TIM_DMA_ID_CC3]->XferHalfCpltCallback = TIM_DMADelayPulseHalfCplt;
\r
1013 /* Set the DMA error callback */
\r
1014 htim->hdma[TIM_DMA_ID_CC3]->XferErrorCallback = TIM_DMAError ;
\r
1016 /* Enable the DMA channel */
\r
1017 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC3], (uint32_t)pData, (uint32_t)&htim->Instance->CCR3, Length) != HAL_OK)
\r
1021 /* Enable the TIM Capture/Compare 3 DMA request */
\r
1022 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC3);
\r
1026 case TIM_CHANNEL_4:
\r
1028 /* Set the DMA compare callbacks */
\r
1029 htim->hdma[TIM_DMA_ID_CC4]->XferCpltCallback = TIM_DMADelayPulseCplt;
\r
1030 htim->hdma[TIM_DMA_ID_CC4]->XferHalfCpltCallback = TIM_DMADelayPulseHalfCplt;
\r
1032 /* Set the DMA error callback */
\r
1033 htim->hdma[TIM_DMA_ID_CC4]->XferErrorCallback = TIM_DMAError ;
\r
1035 /* Enable the DMA channel */
\r
1036 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC4], (uint32_t)pData, (uint32_t)&htim->Instance->CCR4, Length) != HAL_OK)
\r
1040 /* Enable the TIM Capture/Compare 4 DMA request */
\r
1041 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC4);
\r
1049 /* Enable the Output compare channel */
\r
1050 TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
\r
1052 if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
\r
1054 /* Enable the main output */
\r
1055 __HAL_TIM_MOE_ENABLE(htim);
\r
1058 /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
\r
1059 tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
\r
1060 if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
\r
1062 __HAL_TIM_ENABLE(htim);
\r
1065 /* Return function status */
\r
1070 * @brief Stops the TIM Output Compare signal generation in DMA mode.
\r
1071 * @param htim TIM Output Compare handle
\r
1072 * @param Channel TIM Channel to be disabled
\r
1073 * This parameter can be one of the following values:
\r
1074 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
1075 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
1076 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
1077 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
\r
1078 * @retval HAL status
\r
1080 HAL_StatusTypeDef HAL_TIM_OC_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
1082 /* Check the parameters */
\r
1083 assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
\r
1087 case TIM_CHANNEL_1:
\r
1089 /* Disable the TIM Capture/Compare 1 DMA request */
\r
1090 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC1);
\r
1091 (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC1]);
\r
1095 case TIM_CHANNEL_2:
\r
1097 /* Disable the TIM Capture/Compare 2 DMA request */
\r
1098 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC2);
\r
1099 (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC2]);
\r
1103 case TIM_CHANNEL_3:
\r
1105 /* Disable the TIM Capture/Compare 3 DMA request */
\r
1106 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC3);
\r
1107 (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC3]);
\r
1111 case TIM_CHANNEL_4:
\r
1113 /* Disable the TIM Capture/Compare 4 interrupt */
\r
1114 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC4);
\r
1115 (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC4]);
\r
1123 /* Disable the Output compare channel */
\r
1124 TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
\r
1126 if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
\r
1128 /* Disable the Main Output */
\r
1129 __HAL_TIM_MOE_DISABLE(htim);
\r
1132 /* Disable the Peripheral */
\r
1133 __HAL_TIM_DISABLE(htim);
\r
1135 /* Change the htim state */
\r
1136 htim->State = HAL_TIM_STATE_READY;
\r
1138 /* Return function status */
\r
1146 /** @defgroup TIM_Exported_Functions_Group3 TIM PWM functions
\r
1147 * @brief TIM PWM functions
\r
1150 ==============================================================================
\r
1151 ##### TIM PWM functions #####
\r
1152 ==============================================================================
\r
1154 This section provides functions allowing to:
\r
1155 (+) Initialize and configure the TIM PWM.
\r
1156 (+) De-initialize the TIM PWM.
\r
1157 (+) Start the TIM PWM.
\r
1158 (+) Stop the TIM PWM.
\r
1159 (+) Start the TIM PWM and enable interrupt.
\r
1160 (+) Stop the TIM PWM and disable interrupt.
\r
1161 (+) Start the TIM PWM and enable DMA transfer.
\r
1162 (+) Stop the TIM PWM and disable DMA transfer.
\r
1168 * @brief Initializes the TIM PWM Time Base according to the specified
\r
1169 * parameters in the TIM_HandleTypeDef and initializes the associated handle.
\r
1170 * @note Switching from Center Aligned counter mode to Edge counter mode (or reverse)
\r
1171 * requires a timer reset to avoid unexpected direction
\r
1172 * due to DIR bit readonly in center aligned mode.
\r
1173 * Ex: call @ref HAL_TIM_PWM_DeInit() before HAL_TIM_PWM_Init()
\r
1174 * @param htim TIM PWM handle
\r
1175 * @retval HAL status
\r
1177 HAL_StatusTypeDef HAL_TIM_PWM_Init(TIM_HandleTypeDef *htim)
\r
1179 /* Check the TIM handle allocation */
\r
1185 /* Check the parameters */
\r
1186 assert_param(IS_TIM_INSTANCE(htim->Instance));
\r
1187 assert_param(IS_TIM_COUNTER_MODE(htim->Init.CounterMode));
\r
1188 assert_param(IS_TIM_CLOCKDIVISION_DIV(htim->Init.ClockDivision));
\r
1189 assert_param(IS_TIM_AUTORELOAD_PRELOAD(htim->Init.AutoReloadPreload));
\r
1191 if (htim->State == HAL_TIM_STATE_RESET)
\r
1193 /* Allocate lock resource and initialize it */
\r
1194 htim->Lock = HAL_UNLOCKED;
\r
1196 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
1197 /* Reset interrupt callbacks to legacy weak callbacks */
\r
1198 TIM_ResetCallback(htim);
\r
1200 if (htim->PWM_MspInitCallback == NULL)
\r
1202 htim->PWM_MspInitCallback = HAL_TIM_PWM_MspInit;
\r
1204 /* Init the low level hardware : GPIO, CLOCK, NVIC */
\r
1205 htim->PWM_MspInitCallback(htim);
\r
1207 /* Init the low level hardware : GPIO, CLOCK, NVIC and DMA */
\r
1208 HAL_TIM_PWM_MspInit(htim);
\r
1209 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
1212 /* Set the TIM state */
\r
1213 htim->State = HAL_TIM_STATE_BUSY;
\r
1215 /* Init the base time for the PWM */
\r
1216 TIM_Base_SetConfig(htim->Instance, &htim->Init);
\r
1218 /* Initialize the TIM state*/
\r
1219 htim->State = HAL_TIM_STATE_READY;
\r
1225 * @brief DeInitializes the TIM peripheral
\r
1226 * @param htim TIM PWM handle
\r
1227 * @retval HAL status
\r
1229 HAL_StatusTypeDef HAL_TIM_PWM_DeInit(TIM_HandleTypeDef *htim)
\r
1231 /* Check the parameters */
\r
1232 assert_param(IS_TIM_INSTANCE(htim->Instance));
\r
1234 htim->State = HAL_TIM_STATE_BUSY;
\r
1236 /* Disable the TIM Peripheral Clock */
\r
1237 __HAL_TIM_DISABLE(htim);
\r
1239 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
1240 if (htim->PWM_MspDeInitCallback == NULL)
\r
1242 htim->PWM_MspDeInitCallback = HAL_TIM_PWM_MspDeInit;
\r
1244 /* DeInit the low level hardware */
\r
1245 htim->PWM_MspDeInitCallback(htim);
\r
1247 /* DeInit the low level hardware: GPIO, CLOCK, NVIC and DMA */
\r
1248 HAL_TIM_PWM_MspDeInit(htim);
\r
1249 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
1251 /* Change TIM state */
\r
1252 htim->State = HAL_TIM_STATE_RESET;
\r
1254 /* Release Lock */
\r
1255 __HAL_UNLOCK(htim);
\r
1261 * @brief Initializes the TIM PWM MSP.
\r
1262 * @param htim TIM PWM handle
\r
1265 __weak void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef *htim)
\r
1267 /* Prevent unused argument(s) compilation warning */
\r
1270 /* NOTE : This function should not be modified, when the callback is needed,
\r
1271 the HAL_TIM_PWM_MspInit could be implemented in the user file
\r
1276 * @brief DeInitializes TIM PWM MSP.
\r
1277 * @param htim TIM PWM handle
\r
1280 __weak void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef *htim)
\r
1282 /* Prevent unused argument(s) compilation warning */
\r
1285 /* NOTE : This function should not be modified, when the callback is needed,
\r
1286 the HAL_TIM_PWM_MspDeInit could be implemented in the user file
\r
1291 * @brief Starts the PWM signal generation.
\r
1292 * @param htim TIM handle
\r
1293 * @param Channel TIM Channels to be enabled
\r
1294 * This parameter can be one of the following values:
\r
1295 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
1296 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
1297 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
1298 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
\r
1299 * @arg TIM_CHANNEL_5: TIM Channel 5 selected
\r
1300 * @arg TIM_CHANNEL_6: TIM Channel 6 selected
\r
1301 * @retval HAL status
\r
1303 HAL_StatusTypeDef HAL_TIM_PWM_Start(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
1307 /* Check the parameters */
\r
1308 assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
\r
1310 /* Enable the Capture compare channel */
\r
1311 TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
\r
1313 if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
\r
1315 /* Enable the main output */
\r
1316 __HAL_TIM_MOE_ENABLE(htim);
\r
1319 /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
\r
1320 tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
\r
1321 if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
\r
1323 __HAL_TIM_ENABLE(htim);
\r
1326 /* Return function status */
\r
1331 * @brief Stops the PWM signal generation.
\r
1332 * @param htim TIM PWM handle
\r
1333 * @param Channel TIM Channels to be disabled
\r
1334 * This parameter can be one of the following values:
\r
1335 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
1336 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
1337 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
1338 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
\r
1339 * @arg TIM_CHANNEL_5: TIM Channel 5 selected
\r
1340 * @arg TIM_CHANNEL_6: TIM Channel 6 selected
\r
1341 * @retval HAL status
\r
1343 HAL_StatusTypeDef HAL_TIM_PWM_Stop(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
1345 /* Check the parameters */
\r
1346 assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
\r
1348 /* Disable the Capture compare channel */
\r
1349 TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
\r
1351 if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
\r
1353 /* Disable the Main Output */
\r
1354 __HAL_TIM_MOE_DISABLE(htim);
\r
1357 /* Disable the Peripheral */
\r
1358 __HAL_TIM_DISABLE(htim);
\r
1360 /* Change the htim state */
\r
1361 htim->State = HAL_TIM_STATE_READY;
\r
1363 /* Return function status */
\r
1368 * @brief Starts the PWM signal generation in interrupt mode.
\r
1369 * @param htim TIM PWM handle
\r
1370 * @param Channel TIM Channel to be enabled
\r
1371 * This parameter can be one of the following values:
\r
1372 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
1373 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
1374 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
1375 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
\r
1376 * @retval HAL status
\r
1378 HAL_StatusTypeDef HAL_TIM_PWM_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
1381 /* Check the parameters */
\r
1382 assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
\r
1386 case TIM_CHANNEL_1:
\r
1388 /* Enable the TIM Capture/Compare 1 interrupt */
\r
1389 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC1);
\r
1393 case TIM_CHANNEL_2:
\r
1395 /* Enable the TIM Capture/Compare 2 interrupt */
\r
1396 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC2);
\r
1400 case TIM_CHANNEL_3:
\r
1402 /* Enable the TIM Capture/Compare 3 interrupt */
\r
1403 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC3);
\r
1407 case TIM_CHANNEL_4:
\r
1409 /* Enable the TIM Capture/Compare 4 interrupt */
\r
1410 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC4);
\r
1418 /* Enable the Capture compare channel */
\r
1419 TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
\r
1421 if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
\r
1423 /* Enable the main output */
\r
1424 __HAL_TIM_MOE_ENABLE(htim);
\r
1427 /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
\r
1428 tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
\r
1429 if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
\r
1431 __HAL_TIM_ENABLE(htim);
\r
1434 /* Return function status */
\r
1439 * @brief Stops the PWM signal generation in interrupt mode.
\r
1440 * @param htim TIM PWM handle
\r
1441 * @param Channel TIM Channels to be disabled
\r
1442 * This parameter can be one of the following values:
\r
1443 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
1444 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
1445 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
1446 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
\r
1447 * @retval HAL status
\r
1449 HAL_StatusTypeDef HAL_TIM_PWM_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
1451 /* Check the parameters */
\r
1452 assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
\r
1456 case TIM_CHANNEL_1:
\r
1458 /* Disable the TIM Capture/Compare 1 interrupt */
\r
1459 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC1);
\r
1463 case TIM_CHANNEL_2:
\r
1465 /* Disable the TIM Capture/Compare 2 interrupt */
\r
1466 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC2);
\r
1470 case TIM_CHANNEL_3:
\r
1472 /* Disable the TIM Capture/Compare 3 interrupt */
\r
1473 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC3);
\r
1477 case TIM_CHANNEL_4:
\r
1479 /* Disable the TIM Capture/Compare 4 interrupt */
\r
1480 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC4);
\r
1488 /* Disable the Capture compare channel */
\r
1489 TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
\r
1491 if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
\r
1493 /* Disable the Main Output */
\r
1494 __HAL_TIM_MOE_DISABLE(htim);
\r
1497 /* Disable the Peripheral */
\r
1498 __HAL_TIM_DISABLE(htim);
\r
1500 /* Return function status */
\r
1505 * @brief Starts the TIM PWM signal generation in DMA mode.
\r
1506 * @param htim TIM PWM handle
\r
1507 * @param Channel TIM Channels to be enabled
\r
1508 * This parameter can be one of the following values:
\r
1509 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
1510 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
1511 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
1512 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
\r
1513 * @param pData The source Buffer address.
\r
1514 * @param Length The length of data to be transferred from memory to TIM peripheral
\r
1515 * @retval HAL status
\r
1517 HAL_StatusTypeDef HAL_TIM_PWM_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length)
\r
1521 /* Check the parameters */
\r
1522 assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
\r
1524 if ((htim->State == HAL_TIM_STATE_BUSY))
\r
1528 else if ((htim->State == HAL_TIM_STATE_READY))
\r
1530 if ((pData == NULL) && (Length > 0U))
\r
1536 htim->State = HAL_TIM_STATE_BUSY;
\r
1541 /* nothing to do */
\r
1546 case TIM_CHANNEL_1:
\r
1548 /* Set the DMA compare callbacks */
\r
1549 htim->hdma[TIM_DMA_ID_CC1]->XferCpltCallback = TIM_DMADelayPulseCplt;
\r
1550 htim->hdma[TIM_DMA_ID_CC1]->XferHalfCpltCallback = TIM_DMADelayPulseHalfCplt;
\r
1552 /* Set the DMA error callback */
\r
1553 htim->hdma[TIM_DMA_ID_CC1]->XferErrorCallback = TIM_DMAError ;
\r
1555 /* Enable the DMA channel */
\r
1556 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)pData, (uint32_t)&htim->Instance->CCR1, Length) != HAL_OK)
\r
1561 /* Enable the TIM Capture/Compare 1 DMA request */
\r
1562 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC1);
\r
1566 case TIM_CHANNEL_2:
\r
1568 /* Set the DMA compare callbacks */
\r
1569 htim->hdma[TIM_DMA_ID_CC2]->XferCpltCallback = TIM_DMADelayPulseCplt;
\r
1570 htim->hdma[TIM_DMA_ID_CC2]->XferHalfCpltCallback = TIM_DMADelayPulseHalfCplt;
\r
1572 /* Set the DMA error callback */
\r
1573 htim->hdma[TIM_DMA_ID_CC2]->XferErrorCallback = TIM_DMAError ;
\r
1575 /* Enable the DMA channel */
\r
1576 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)pData, (uint32_t)&htim->Instance->CCR2, Length) != HAL_OK)
\r
1580 /* Enable the TIM Capture/Compare 2 DMA request */
\r
1581 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC2);
\r
1585 case TIM_CHANNEL_3:
\r
1587 /* Set the DMA compare callbacks */
\r
1588 htim->hdma[TIM_DMA_ID_CC3]->XferCpltCallback = TIM_DMADelayPulseCplt;
\r
1589 htim->hdma[TIM_DMA_ID_CC3]->XferHalfCpltCallback = TIM_DMADelayPulseHalfCplt;
\r
1591 /* Set the DMA error callback */
\r
1592 htim->hdma[TIM_DMA_ID_CC3]->XferErrorCallback = TIM_DMAError ;
\r
1594 /* Enable the DMA channel */
\r
1595 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC3], (uint32_t)pData, (uint32_t)&htim->Instance->CCR3, Length) != HAL_OK)
\r
1599 /* Enable the TIM Output Capture/Compare 3 request */
\r
1600 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC3);
\r
1604 case TIM_CHANNEL_4:
\r
1606 /* Set the DMA compare callbacks */
\r
1607 htim->hdma[TIM_DMA_ID_CC4]->XferCpltCallback = TIM_DMADelayPulseCplt;
\r
1608 htim->hdma[TIM_DMA_ID_CC4]->XferHalfCpltCallback = TIM_DMADelayPulseHalfCplt;
\r
1610 /* Set the DMA error callback */
\r
1611 htim->hdma[TIM_DMA_ID_CC4]->XferErrorCallback = TIM_DMAError ;
\r
1613 /* Enable the DMA channel */
\r
1614 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC4], (uint32_t)pData, (uint32_t)&htim->Instance->CCR4, Length) != HAL_OK)
\r
1618 /* Enable the TIM Capture/Compare 4 DMA request */
\r
1619 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC4);
\r
1627 /* Enable the Capture compare channel */
\r
1628 TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
\r
1630 if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
\r
1632 /* Enable the main output */
\r
1633 __HAL_TIM_MOE_ENABLE(htim);
\r
1636 /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
\r
1637 tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
\r
1638 if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
\r
1640 __HAL_TIM_ENABLE(htim);
\r
1643 /* Return function status */
\r
1648 * @brief Stops the TIM PWM signal generation in DMA mode.
\r
1649 * @param htim TIM PWM handle
\r
1650 * @param Channel TIM Channels to be disabled
\r
1651 * This parameter can be one of the following values:
\r
1652 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
1653 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
1654 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
1655 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
\r
1656 * @retval HAL status
\r
1658 HAL_StatusTypeDef HAL_TIM_PWM_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
1660 /* Check the parameters */
\r
1661 assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
\r
1665 case TIM_CHANNEL_1:
\r
1667 /* Disable the TIM Capture/Compare 1 DMA request */
\r
1668 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC1);
\r
1669 (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC1]);
\r
1673 case TIM_CHANNEL_2:
\r
1675 /* Disable the TIM Capture/Compare 2 DMA request */
\r
1676 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC2);
\r
1677 (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC2]);
\r
1681 case TIM_CHANNEL_3:
\r
1683 /* Disable the TIM Capture/Compare 3 DMA request */
\r
1684 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC3);
\r
1685 (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC3]);
\r
1689 case TIM_CHANNEL_4:
\r
1691 /* Disable the TIM Capture/Compare 4 interrupt */
\r
1692 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC4);
\r
1693 (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC4]);
\r
1701 /* Disable the Capture compare channel */
\r
1702 TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
\r
1704 if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
\r
1706 /* Disable the Main Output */
\r
1707 __HAL_TIM_MOE_DISABLE(htim);
\r
1710 /* Disable the Peripheral */
\r
1711 __HAL_TIM_DISABLE(htim);
\r
1713 /* Change the htim state */
\r
1714 htim->State = HAL_TIM_STATE_READY;
\r
1716 /* Return function status */
\r
1724 /** @defgroup TIM_Exported_Functions_Group4 TIM Input Capture functions
\r
1725 * @brief TIM Input Capture functions
\r
1728 ==============================================================================
\r
1729 ##### TIM Input Capture functions #####
\r
1730 ==============================================================================
\r
1732 This section provides functions allowing to:
\r
1733 (+) Initialize and configure the TIM Input Capture.
\r
1734 (+) De-initialize the TIM Input Capture.
\r
1735 (+) Start the TIM Input Capture.
\r
1736 (+) Stop the TIM Input Capture.
\r
1737 (+) Start the TIM Input Capture and enable interrupt.
\r
1738 (+) Stop the TIM Input Capture and disable interrupt.
\r
1739 (+) Start the TIM Input Capture and enable DMA transfer.
\r
1740 (+) Stop the TIM Input Capture and disable DMA transfer.
\r
1746 * @brief Initializes the TIM Input Capture Time base according to the specified
\r
1747 * parameters in the TIM_HandleTypeDef and initializes the associated handle.
\r
1748 * @note Switching from Center Aligned counter mode to Edge counter mode (or reverse)
\r
1749 * requires a timer reset to avoid unexpected direction
\r
1750 * due to DIR bit readonly in center aligned mode.
\r
1751 * Ex: call @ref HAL_TIM_IC_DeInit() before HAL_TIM_IC_Init()
\r
1752 * @param htim TIM Input Capture handle
\r
1753 * @retval HAL status
\r
1755 HAL_StatusTypeDef HAL_TIM_IC_Init(TIM_HandleTypeDef *htim)
\r
1757 /* Check the TIM handle allocation */
\r
1763 /* Check the parameters */
\r
1764 assert_param(IS_TIM_INSTANCE(htim->Instance));
\r
1765 assert_param(IS_TIM_COUNTER_MODE(htim->Init.CounterMode));
\r
1766 assert_param(IS_TIM_CLOCKDIVISION_DIV(htim->Init.ClockDivision));
\r
1767 assert_param(IS_TIM_AUTORELOAD_PRELOAD(htim->Init.AutoReloadPreload));
\r
1769 if (htim->State == HAL_TIM_STATE_RESET)
\r
1771 /* Allocate lock resource and initialize it */
\r
1772 htim->Lock = HAL_UNLOCKED;
\r
1774 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
1775 /* Reset interrupt callbacks to legacy weak callbacks */
\r
1776 TIM_ResetCallback(htim);
\r
1778 if (htim->IC_MspInitCallback == NULL)
\r
1780 htim->IC_MspInitCallback = HAL_TIM_IC_MspInit;
\r
1782 /* Init the low level hardware : GPIO, CLOCK, NVIC */
\r
1783 htim->IC_MspInitCallback(htim);
\r
1785 /* Init the low level hardware : GPIO, CLOCK, NVIC and DMA */
\r
1786 HAL_TIM_IC_MspInit(htim);
\r
1787 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
1790 /* Set the TIM state */
\r
1791 htim->State = HAL_TIM_STATE_BUSY;
\r
1793 /* Init the base time for the input capture */
\r
1794 TIM_Base_SetConfig(htim->Instance, &htim->Init);
\r
1796 /* Initialize the TIM state*/
\r
1797 htim->State = HAL_TIM_STATE_READY;
\r
1803 * @brief DeInitializes the TIM peripheral
\r
1804 * @param htim TIM Input Capture handle
\r
1805 * @retval HAL status
\r
1807 HAL_StatusTypeDef HAL_TIM_IC_DeInit(TIM_HandleTypeDef *htim)
\r
1809 /* Check the parameters */
\r
1810 assert_param(IS_TIM_INSTANCE(htim->Instance));
\r
1812 htim->State = HAL_TIM_STATE_BUSY;
\r
1814 /* Disable the TIM Peripheral Clock */
\r
1815 __HAL_TIM_DISABLE(htim);
\r
1817 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
1818 if (htim->IC_MspDeInitCallback == NULL)
\r
1820 htim->IC_MspDeInitCallback = HAL_TIM_IC_MspDeInit;
\r
1822 /* DeInit the low level hardware */
\r
1823 htim->IC_MspDeInitCallback(htim);
\r
1825 /* DeInit the low level hardware: GPIO, CLOCK, NVIC and DMA */
\r
1826 HAL_TIM_IC_MspDeInit(htim);
\r
1827 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
1829 /* Change TIM state */
\r
1830 htim->State = HAL_TIM_STATE_RESET;
\r
1832 /* Release Lock */
\r
1833 __HAL_UNLOCK(htim);
\r
1839 * @brief Initializes the TIM Input Capture MSP.
\r
1840 * @param htim TIM Input Capture handle
\r
1843 __weak void HAL_TIM_IC_MspInit(TIM_HandleTypeDef *htim)
\r
1845 /* Prevent unused argument(s) compilation warning */
\r
1848 /* NOTE : This function should not be modified, when the callback is needed,
\r
1849 the HAL_TIM_IC_MspInit could be implemented in the user file
\r
1854 * @brief DeInitializes TIM Input Capture MSP.
\r
1855 * @param htim TIM handle
\r
1858 __weak void HAL_TIM_IC_MspDeInit(TIM_HandleTypeDef *htim)
\r
1860 /* Prevent unused argument(s) compilation warning */
\r
1863 /* NOTE : This function should not be modified, when the callback is needed,
\r
1864 the HAL_TIM_IC_MspDeInit could be implemented in the user file
\r
1869 * @brief Starts the TIM Input Capture measurement.
\r
1870 * @param htim TIM Input Capture handle
\r
1871 * @param Channel TIM Channels to be enabled
\r
1872 * This parameter can be one of the following values:
\r
1873 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
1874 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
1875 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
1876 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
\r
1877 * @retval HAL status
\r
1879 HAL_StatusTypeDef HAL_TIM_IC_Start(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
1883 /* Check the parameters */
\r
1884 assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
\r
1886 /* Enable the Input Capture channel */
\r
1887 TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
\r
1889 /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
\r
1890 tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
\r
1891 if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
\r
1893 __HAL_TIM_ENABLE(htim);
\r
1896 /* Return function status */
\r
1901 * @brief Stops the TIM Input Capture measurement.
\r
1902 * @param htim TIM Input Capture handle
\r
1903 * @param Channel TIM Channels to be disabled
\r
1904 * This parameter can be one of the following values:
\r
1905 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
1906 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
1907 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
1908 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
\r
1909 * @retval HAL status
\r
1911 HAL_StatusTypeDef HAL_TIM_IC_Stop(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
1913 /* Check the parameters */
\r
1914 assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
\r
1916 /* Disable the Input Capture channel */
\r
1917 TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
\r
1919 /* Disable the Peripheral */
\r
1920 __HAL_TIM_DISABLE(htim);
\r
1922 /* Return function status */
\r
1927 * @brief Starts the TIM Input Capture measurement in interrupt mode.
\r
1928 * @param htim TIM Input Capture handle
\r
1929 * @param Channel TIM Channels to be enabled
\r
1930 * This parameter can be one of the following values:
\r
1931 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
1932 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
1933 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
1934 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
\r
1935 * @retval HAL status
\r
1937 HAL_StatusTypeDef HAL_TIM_IC_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
1941 /* Check the parameters */
\r
1942 assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
\r
1946 case TIM_CHANNEL_1:
\r
1948 /* Enable the TIM Capture/Compare 1 interrupt */
\r
1949 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC1);
\r
1953 case TIM_CHANNEL_2:
\r
1955 /* Enable the TIM Capture/Compare 2 interrupt */
\r
1956 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC2);
\r
1960 case TIM_CHANNEL_3:
\r
1962 /* Enable the TIM Capture/Compare 3 interrupt */
\r
1963 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC3);
\r
1967 case TIM_CHANNEL_4:
\r
1969 /* Enable the TIM Capture/Compare 4 interrupt */
\r
1970 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC4);
\r
1977 /* Enable the Input Capture channel */
\r
1978 TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
\r
1980 /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
\r
1981 tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
\r
1982 if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
\r
1984 __HAL_TIM_ENABLE(htim);
\r
1987 /* Return function status */
\r
1992 * @brief Stops the TIM Input Capture measurement in interrupt mode.
\r
1993 * @param htim TIM Input Capture handle
\r
1994 * @param Channel TIM Channels to be disabled
\r
1995 * This parameter can be one of the following values:
\r
1996 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
1997 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
1998 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
1999 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
\r
2000 * @retval HAL status
\r
2002 HAL_StatusTypeDef HAL_TIM_IC_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
2004 /* Check the parameters */
\r
2005 assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
\r
2009 case TIM_CHANNEL_1:
\r
2011 /* Disable the TIM Capture/Compare 1 interrupt */
\r
2012 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC1);
\r
2016 case TIM_CHANNEL_2:
\r
2018 /* Disable the TIM Capture/Compare 2 interrupt */
\r
2019 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC2);
\r
2023 case TIM_CHANNEL_3:
\r
2025 /* Disable the TIM Capture/Compare 3 interrupt */
\r
2026 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC3);
\r
2030 case TIM_CHANNEL_4:
\r
2032 /* Disable the TIM Capture/Compare 4 interrupt */
\r
2033 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC4);
\r
2041 /* Disable the Input Capture channel */
\r
2042 TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
\r
2044 /* Disable the Peripheral */
\r
2045 __HAL_TIM_DISABLE(htim);
\r
2047 /* Return function status */
\r
2052 * @brief Starts the TIM Input Capture measurement in DMA mode.
\r
2053 * @param htim TIM Input Capture handle
\r
2054 * @param Channel TIM Channels to be enabled
\r
2055 * This parameter can be one of the following values:
\r
2056 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
2057 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
2058 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
2059 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
\r
2060 * @param pData The destination Buffer address.
\r
2061 * @param Length The length of data to be transferred from TIM peripheral to memory.
\r
2062 * @retval HAL status
\r
2064 HAL_StatusTypeDef HAL_TIM_IC_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length)
\r
2068 /* Check the parameters */
\r
2069 assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
\r
2070 assert_param(IS_TIM_DMA_CC_INSTANCE(htim->Instance));
\r
2072 if ((htim->State == HAL_TIM_STATE_BUSY))
\r
2076 else if ((htim->State == HAL_TIM_STATE_READY))
\r
2078 if ((pData == NULL) && (Length > 0U))
\r
2084 htim->State = HAL_TIM_STATE_BUSY;
\r
2089 /* nothing to do */
\r
2094 case TIM_CHANNEL_1:
\r
2096 /* Set the DMA capture callbacks */
\r
2097 htim->hdma[TIM_DMA_ID_CC1]->XferCpltCallback = TIM_DMACaptureCplt;
\r
2098 htim->hdma[TIM_DMA_ID_CC1]->XferHalfCpltCallback = TIM_DMACaptureHalfCplt;
\r
2100 /* Set the DMA error callback */
\r
2101 htim->hdma[TIM_DMA_ID_CC1]->XferErrorCallback = TIM_DMAError ;
\r
2103 /* Enable the DMA channel */
\r
2104 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)&htim->Instance->CCR1, (uint32_t)pData, Length) != HAL_OK)
\r
2108 /* Enable the TIM Capture/Compare 1 DMA request */
\r
2109 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC1);
\r
2113 case TIM_CHANNEL_2:
\r
2115 /* Set the DMA capture callbacks */
\r
2116 htim->hdma[TIM_DMA_ID_CC2]->XferCpltCallback = TIM_DMACaptureCplt;
\r
2117 htim->hdma[TIM_DMA_ID_CC2]->XferHalfCpltCallback = TIM_DMACaptureHalfCplt;
\r
2119 /* Set the DMA error callback */
\r
2120 htim->hdma[TIM_DMA_ID_CC2]->XferErrorCallback = TIM_DMAError ;
\r
2122 /* Enable the DMA channel */
\r
2123 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)&htim->Instance->CCR2, (uint32_t)pData, Length) != HAL_OK)
\r
2127 /* Enable the TIM Capture/Compare 2 DMA request */
\r
2128 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC2);
\r
2132 case TIM_CHANNEL_3:
\r
2134 /* Set the DMA capture callbacks */
\r
2135 htim->hdma[TIM_DMA_ID_CC3]->XferCpltCallback = TIM_DMACaptureCplt;
\r
2136 htim->hdma[TIM_DMA_ID_CC3]->XferHalfCpltCallback = TIM_DMACaptureHalfCplt;
\r
2138 /* Set the DMA error callback */
\r
2139 htim->hdma[TIM_DMA_ID_CC3]->XferErrorCallback = TIM_DMAError ;
\r
2141 /* Enable the DMA channel */
\r
2142 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC3], (uint32_t)&htim->Instance->CCR3, (uint32_t)pData, Length) != HAL_OK)
\r
2146 /* Enable the TIM Capture/Compare 3 DMA request */
\r
2147 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC3);
\r
2151 case TIM_CHANNEL_4:
\r
2153 /* Set the DMA capture callbacks */
\r
2154 htim->hdma[TIM_DMA_ID_CC4]->XferCpltCallback = TIM_DMACaptureCplt;
\r
2155 htim->hdma[TIM_DMA_ID_CC4]->XferHalfCpltCallback = TIM_DMACaptureHalfCplt;
\r
2157 /* Set the DMA error callback */
\r
2158 htim->hdma[TIM_DMA_ID_CC4]->XferErrorCallback = TIM_DMAError ;
\r
2160 /* Enable the DMA channel */
\r
2161 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC4], (uint32_t)&htim->Instance->CCR4, (uint32_t)pData, Length) != HAL_OK)
\r
2165 /* Enable the TIM Capture/Compare 4 DMA request */
\r
2166 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC4);
\r
2174 /* Enable the Input Capture channel */
\r
2175 TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
\r
2177 /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
\r
2178 tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
\r
2179 if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
\r
2181 __HAL_TIM_ENABLE(htim);
\r
2184 /* Return function status */
\r
2189 * @brief Stops the TIM Input Capture measurement in DMA mode.
\r
2190 * @param htim TIM Input Capture handle
\r
2191 * @param Channel TIM Channels to be disabled
\r
2192 * This parameter can be one of the following values:
\r
2193 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
2194 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
2195 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
2196 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
\r
2197 * @retval HAL status
\r
2199 HAL_StatusTypeDef HAL_TIM_IC_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
2201 /* Check the parameters */
\r
2202 assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
\r
2203 assert_param(IS_TIM_DMA_CC_INSTANCE(htim->Instance));
\r
2207 case TIM_CHANNEL_1:
\r
2209 /* Disable the TIM Capture/Compare 1 DMA request */
\r
2210 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC1);
\r
2211 (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC1]);
\r
2215 case TIM_CHANNEL_2:
\r
2217 /* Disable the TIM Capture/Compare 2 DMA request */
\r
2218 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC2);
\r
2219 (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC2]);
\r
2223 case TIM_CHANNEL_3:
\r
2225 /* Disable the TIM Capture/Compare 3 DMA request */
\r
2226 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC3);
\r
2227 (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC3]);
\r
2231 case TIM_CHANNEL_4:
\r
2233 /* Disable the TIM Capture/Compare 4 DMA request */
\r
2234 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC4);
\r
2235 (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC4]);
\r
2243 /* Disable the Input Capture channel */
\r
2244 TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
\r
2246 /* Disable the Peripheral */
\r
2247 __HAL_TIM_DISABLE(htim);
\r
2249 /* Change the htim state */
\r
2250 htim->State = HAL_TIM_STATE_READY;
\r
2252 /* Return function status */
\r
2259 /** @defgroup TIM_Exported_Functions_Group5 TIM One Pulse functions
\r
2260 * @brief TIM One Pulse functions
\r
2263 ==============================================================================
\r
2264 ##### TIM One Pulse functions #####
\r
2265 ==============================================================================
\r
2267 This section provides functions allowing to:
\r
2268 (+) Initialize and configure the TIM One Pulse.
\r
2269 (+) De-initialize the TIM One Pulse.
\r
2270 (+) Start the TIM One Pulse.
\r
2271 (+) Stop the TIM One Pulse.
\r
2272 (+) Start the TIM One Pulse and enable interrupt.
\r
2273 (+) Stop the TIM One Pulse and disable interrupt.
\r
2274 (+) Start the TIM One Pulse and enable DMA transfer.
\r
2275 (+) Stop the TIM One Pulse and disable DMA transfer.
\r
2281 * @brief Initializes the TIM One Pulse Time Base according to the specified
\r
2282 * parameters in the TIM_HandleTypeDef and initializes the associated handle.
\r
2283 * @note Switching from Center Aligned counter mode to Edge counter mode (or reverse)
\r
2284 * requires a timer reset to avoid unexpected direction
\r
2285 * due to DIR bit readonly in center aligned mode.
\r
2286 * Ex: call @ref HAL_TIM_OnePulse_DeInit() before HAL_TIM_OnePulse_Init()
\r
2287 * @param htim TIM One Pulse handle
\r
2288 * @param OnePulseMode Select the One pulse mode.
\r
2289 * This parameter can be one of the following values:
\r
2290 * @arg TIM_OPMODE_SINGLE: Only one pulse will be generated.
\r
2291 * @arg TIM_OPMODE_REPETITIVE: Repetitive pulses will be generated.
\r
2292 * @retval HAL status
\r
2294 HAL_StatusTypeDef HAL_TIM_OnePulse_Init(TIM_HandleTypeDef *htim, uint32_t OnePulseMode)
\r
2296 /* Check the TIM handle allocation */
\r
2302 /* Check the parameters */
\r
2303 assert_param(IS_TIM_INSTANCE(htim->Instance));
\r
2304 assert_param(IS_TIM_COUNTER_MODE(htim->Init.CounterMode));
\r
2305 assert_param(IS_TIM_CLOCKDIVISION_DIV(htim->Init.ClockDivision));
\r
2306 assert_param(IS_TIM_OPM_MODE(OnePulseMode));
\r
2307 assert_param(IS_TIM_AUTORELOAD_PRELOAD(htim->Init.AutoReloadPreload));
\r
2309 if (htim->State == HAL_TIM_STATE_RESET)
\r
2311 /* Allocate lock resource and initialize it */
\r
2312 htim->Lock = HAL_UNLOCKED;
\r
2314 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
2315 /* Reset interrupt callbacks to legacy weak callbacks */
\r
2316 TIM_ResetCallback(htim);
\r
2318 if (htim->OnePulse_MspInitCallback == NULL)
\r
2320 htim->OnePulse_MspInitCallback = HAL_TIM_OnePulse_MspInit;
\r
2322 /* Init the low level hardware : GPIO, CLOCK, NVIC */
\r
2323 htim->OnePulse_MspInitCallback(htim);
\r
2325 /* Init the low level hardware : GPIO, CLOCK, NVIC and DMA */
\r
2326 HAL_TIM_OnePulse_MspInit(htim);
\r
2327 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
2330 /* Set the TIM state */
\r
2331 htim->State = HAL_TIM_STATE_BUSY;
\r
2333 /* Configure the Time base in the One Pulse Mode */
\r
2334 TIM_Base_SetConfig(htim->Instance, &htim->Init);
\r
2336 /* Reset the OPM Bit */
\r
2337 htim->Instance->CR1 &= ~TIM_CR1_OPM;
\r
2339 /* Configure the OPM Mode */
\r
2340 htim->Instance->CR1 |= OnePulseMode;
\r
2342 /* Initialize the TIM state*/
\r
2343 htim->State = HAL_TIM_STATE_READY;
\r
2349 * @brief DeInitializes the TIM One Pulse
\r
2350 * @param htim TIM One Pulse handle
\r
2351 * @retval HAL status
\r
2353 HAL_StatusTypeDef HAL_TIM_OnePulse_DeInit(TIM_HandleTypeDef *htim)
\r
2355 /* Check the parameters */
\r
2356 assert_param(IS_TIM_INSTANCE(htim->Instance));
\r
2358 htim->State = HAL_TIM_STATE_BUSY;
\r
2360 /* Disable the TIM Peripheral Clock */
\r
2361 __HAL_TIM_DISABLE(htim);
\r
2363 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
2364 if (htim->OnePulse_MspDeInitCallback == NULL)
\r
2366 htim->OnePulse_MspDeInitCallback = HAL_TIM_OnePulse_MspDeInit;
\r
2368 /* DeInit the low level hardware */
\r
2369 htim->OnePulse_MspDeInitCallback(htim);
\r
2371 /* DeInit the low level hardware: GPIO, CLOCK, NVIC */
\r
2372 HAL_TIM_OnePulse_MspDeInit(htim);
\r
2373 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
2375 /* Change TIM state */
\r
2376 htim->State = HAL_TIM_STATE_RESET;
\r
2378 /* Release Lock */
\r
2379 __HAL_UNLOCK(htim);
\r
2385 * @brief Initializes the TIM One Pulse MSP.
\r
2386 * @param htim TIM One Pulse handle
\r
2389 __weak void HAL_TIM_OnePulse_MspInit(TIM_HandleTypeDef *htim)
\r
2391 /* Prevent unused argument(s) compilation warning */
\r
2394 /* NOTE : This function should not be modified, when the callback is needed,
\r
2395 the HAL_TIM_OnePulse_MspInit could be implemented in the user file
\r
2400 * @brief DeInitializes TIM One Pulse MSP.
\r
2401 * @param htim TIM One Pulse handle
\r
2404 __weak void HAL_TIM_OnePulse_MspDeInit(TIM_HandleTypeDef *htim)
\r
2406 /* Prevent unused argument(s) compilation warning */
\r
2409 /* NOTE : This function should not be modified, when the callback is needed,
\r
2410 the HAL_TIM_OnePulse_MspDeInit could be implemented in the user file
\r
2415 * @brief Starts the TIM One Pulse signal generation.
\r
2416 * @param htim TIM One Pulse handle
\r
2417 * @param OutputChannel TIM Channels to be enabled
\r
2418 * This parameter can be one of the following values:
\r
2419 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
2420 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
2421 * @retval HAL status
\r
2423 HAL_StatusTypeDef HAL_TIM_OnePulse_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
\r
2425 /* Prevent unused argument(s) compilation warning */
\r
2426 UNUSED(OutputChannel);
\r
2428 /* Enable the Capture compare and the Input Capture channels
\r
2429 (in the OPM Mode the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2)
\r
2430 if TIM_CHANNEL_1 is used as output, the TIM_CHANNEL_2 will be used as input and
\r
2431 if TIM_CHANNEL_1 is used as input, the TIM_CHANNEL_2 will be used as output
\r
2432 in all combinations, the TIM_CHANNEL_1 and TIM_CHANNEL_2 should be enabled together
\r
2434 No need to enable the counter, it's enabled automatically by hardware
\r
2435 (the counter starts in response to a stimulus and generate a pulse */
\r
2437 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_ENABLE);
\r
2438 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_ENABLE);
\r
2440 if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
\r
2442 /* Enable the main output */
\r
2443 __HAL_TIM_MOE_ENABLE(htim);
\r
2446 /* Return function status */
\r
2451 * @brief Stops the TIM One Pulse signal generation.
\r
2452 * @param htim TIM One Pulse handle
\r
2453 * @param OutputChannel TIM Channels to be disable
\r
2454 * This parameter can be one of the following values:
\r
2455 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
2456 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
2457 * @retval HAL status
\r
2459 HAL_StatusTypeDef HAL_TIM_OnePulse_Stop(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
\r
2461 /* Prevent unused argument(s) compilation warning */
\r
2462 UNUSED(OutputChannel);
\r
2464 /* Disable the Capture compare and the Input Capture channels
\r
2465 (in the OPM Mode the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2)
\r
2466 if TIM_CHANNEL_1 is used as output, the TIM_CHANNEL_2 will be used as input and
\r
2467 if TIM_CHANNEL_1 is used as input, the TIM_CHANNEL_2 will be used as output
\r
2468 in all combinations, the TIM_CHANNEL_1 and TIM_CHANNEL_2 should be disabled together */
\r
2470 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_DISABLE);
\r
2471 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_DISABLE);
\r
2473 if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
\r
2475 /* Disable the Main Output */
\r
2476 __HAL_TIM_MOE_DISABLE(htim);
\r
2479 /* Disable the Peripheral */
\r
2480 __HAL_TIM_DISABLE(htim);
\r
2482 /* Return function status */
\r
2487 * @brief Starts the TIM One Pulse signal generation in interrupt mode.
\r
2488 * @param htim TIM One Pulse handle
\r
2489 * @param OutputChannel TIM Channels to be enabled
\r
2490 * This parameter can be one of the following values:
\r
2491 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
2492 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
2493 * @retval HAL status
\r
2495 HAL_StatusTypeDef HAL_TIM_OnePulse_Start_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
\r
2497 /* Prevent unused argument(s) compilation warning */
\r
2498 UNUSED(OutputChannel);
\r
2500 /* Enable the Capture compare and the Input Capture channels
\r
2501 (in the OPM Mode the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2)
\r
2502 if TIM_CHANNEL_1 is used as output, the TIM_CHANNEL_2 will be used as input and
\r
2503 if TIM_CHANNEL_1 is used as input, the TIM_CHANNEL_2 will be used as output
\r
2504 in all combinations, the TIM_CHANNEL_1 and TIM_CHANNEL_2 should be enabled together
\r
2506 No need to enable the counter, it's enabled automatically by hardware
\r
2507 (the counter starts in response to a stimulus and generate a pulse */
\r
2509 /* Enable the TIM Capture/Compare 1 interrupt */
\r
2510 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC1);
\r
2512 /* Enable the TIM Capture/Compare 2 interrupt */
\r
2513 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC2);
\r
2515 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_ENABLE);
\r
2516 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_ENABLE);
\r
2518 if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
\r
2520 /* Enable the main output */
\r
2521 __HAL_TIM_MOE_ENABLE(htim);
\r
2524 /* Return function status */
\r
2529 * @brief Stops the TIM One Pulse signal generation in interrupt mode.
\r
2530 * @param htim TIM One Pulse handle
\r
2531 * @param OutputChannel TIM Channels to be enabled
\r
2532 * This parameter can be one of the following values:
\r
2533 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
2534 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
2535 * @retval HAL status
\r
2537 HAL_StatusTypeDef HAL_TIM_OnePulse_Stop_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
\r
2539 /* Prevent unused argument(s) compilation warning */
\r
2540 UNUSED(OutputChannel);
\r
2542 /* Disable the TIM Capture/Compare 1 interrupt */
\r
2543 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC1);
\r
2545 /* Disable the TIM Capture/Compare 2 interrupt */
\r
2546 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC2);
\r
2548 /* Disable the Capture compare and the Input Capture channels
\r
2549 (in the OPM Mode the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2)
\r
2550 if TIM_CHANNEL_1 is used as output, the TIM_CHANNEL_2 will be used as input and
\r
2551 if TIM_CHANNEL_1 is used as input, the TIM_CHANNEL_2 will be used as output
\r
2552 in all combinations, the TIM_CHANNEL_1 and TIM_CHANNEL_2 should be disabled together */
\r
2553 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_DISABLE);
\r
2554 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_DISABLE);
\r
2556 if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
\r
2558 /* Disable the Main Output */
\r
2559 __HAL_TIM_MOE_DISABLE(htim);
\r
2562 /* Disable the Peripheral */
\r
2563 __HAL_TIM_DISABLE(htim);
\r
2565 /* Return function status */
\r
2573 /** @defgroup TIM_Exported_Functions_Group6 TIM Encoder functions
\r
2574 * @brief TIM Encoder functions
\r
2577 ==============================================================================
\r
2578 ##### TIM Encoder functions #####
\r
2579 ==============================================================================
\r
2581 This section provides functions allowing to:
\r
2582 (+) Initialize and configure the TIM Encoder.
\r
2583 (+) De-initialize the TIM Encoder.
\r
2584 (+) Start the TIM Encoder.
\r
2585 (+) Stop the TIM Encoder.
\r
2586 (+) Start the TIM Encoder and enable interrupt.
\r
2587 (+) Stop the TIM Encoder and disable interrupt.
\r
2588 (+) Start the TIM Encoder and enable DMA transfer.
\r
2589 (+) Stop the TIM Encoder and disable DMA transfer.
\r
2595 * @brief Initializes the TIM Encoder Interface and initialize the associated handle.
\r
2596 * @note Switching from Center Aligned counter mode to Edge counter mode (or reverse)
\r
2597 * requires a timer reset to avoid unexpected direction
\r
2598 * due to DIR bit readonly in center aligned mode.
\r
2599 * Ex: call @ref HAL_TIM_Encoder_DeInit() before HAL_TIM_Encoder_Init()
\r
2600 * @note Encoder mode and External clock mode 2 are not compatible and must not be selected together
\r
2601 * Ex: A call for @ref HAL_TIM_Encoder_Init will erase the settings of @ref HAL_TIM_ConfigClockSource
\r
2602 * using TIM_CLOCKSOURCE_ETRMODE2 and vice versa
\r
2603 * @param htim TIM Encoder Interface handle
\r
2604 * @param sConfig TIM Encoder Interface configuration structure
\r
2605 * @retval HAL status
\r
2607 HAL_StatusTypeDef HAL_TIM_Encoder_Init(TIM_HandleTypeDef *htim, TIM_Encoder_InitTypeDef *sConfig)
\r
2610 uint32_t tmpccmr1;
\r
2613 /* Check the TIM handle allocation */
\r
2619 /* Check the parameters */
\r
2620 assert_param(IS_TIM_COUNTER_MODE(htim->Init.CounterMode));
\r
2621 assert_param(IS_TIM_CLOCKDIVISION_DIV(htim->Init.ClockDivision));
\r
2622 assert_param(IS_TIM_AUTORELOAD_PRELOAD(htim->Init.AutoReloadPreload));
\r
2623 assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
\r
2624 assert_param(IS_TIM_ENCODER_MODE(sConfig->EncoderMode));
\r
2625 assert_param(IS_TIM_IC_SELECTION(sConfig->IC1Selection));
\r
2626 assert_param(IS_TIM_IC_SELECTION(sConfig->IC2Selection));
\r
2627 assert_param(IS_TIM_IC_POLARITY(sConfig->IC1Polarity));
\r
2628 assert_param(IS_TIM_IC_POLARITY(sConfig->IC2Polarity));
\r
2629 assert_param(IS_TIM_IC_PRESCALER(sConfig->IC1Prescaler));
\r
2630 assert_param(IS_TIM_IC_PRESCALER(sConfig->IC2Prescaler));
\r
2631 assert_param(IS_TIM_IC_FILTER(sConfig->IC1Filter));
\r
2632 assert_param(IS_TIM_IC_FILTER(sConfig->IC2Filter));
\r
2634 if (htim->State == HAL_TIM_STATE_RESET)
\r
2636 /* Allocate lock resource and initialize it */
\r
2637 htim->Lock = HAL_UNLOCKED;
\r
2639 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
2640 /* Reset interrupt callbacks to legacy weak callbacks */
\r
2641 TIM_ResetCallback(htim);
\r
2643 if (htim->Encoder_MspInitCallback == NULL)
\r
2645 htim->Encoder_MspInitCallback = HAL_TIM_Encoder_MspInit;
\r
2647 /* Init the low level hardware : GPIO, CLOCK, NVIC */
\r
2648 htim->Encoder_MspInitCallback(htim);
\r
2650 /* Init the low level hardware : GPIO, CLOCK, NVIC and DMA */
\r
2651 HAL_TIM_Encoder_MspInit(htim);
\r
2652 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
2655 /* Set the TIM state */
\r
2656 htim->State = HAL_TIM_STATE_BUSY;
\r
2658 /* Reset the SMS and ECE bits */
\r
2659 htim->Instance->SMCR &= ~(TIM_SMCR_SMS | TIM_SMCR_ECE);
\r
2661 /* Configure the Time base in the Encoder Mode */
\r
2662 TIM_Base_SetConfig(htim->Instance, &htim->Init);
\r
2664 /* Get the TIMx SMCR register value */
\r
2665 tmpsmcr = htim->Instance->SMCR;
\r
2667 /* Get the TIMx CCMR1 register value */
\r
2668 tmpccmr1 = htim->Instance->CCMR1;
\r
2670 /* Get the TIMx CCER register value */
\r
2671 tmpccer = htim->Instance->CCER;
\r
2673 /* Set the encoder Mode */
\r
2674 tmpsmcr |= sConfig->EncoderMode;
\r
2676 /* Select the Capture Compare 1 and the Capture Compare 2 as input */
\r
2677 tmpccmr1 &= ~(TIM_CCMR1_CC1S | TIM_CCMR1_CC2S);
\r
2678 tmpccmr1 |= (sConfig->IC1Selection | (sConfig->IC2Selection << 8U));
\r
2680 /* Set the Capture Compare 1 and the Capture Compare 2 prescalers and filters */
\r
2681 tmpccmr1 &= ~(TIM_CCMR1_IC1PSC | TIM_CCMR1_IC2PSC);
\r
2682 tmpccmr1 &= ~(TIM_CCMR1_IC1F | TIM_CCMR1_IC2F);
\r
2683 tmpccmr1 |= sConfig->IC1Prescaler | (sConfig->IC2Prescaler << 8U);
\r
2684 tmpccmr1 |= (sConfig->IC1Filter << 4U) | (sConfig->IC2Filter << 12U);
\r
2686 /* Set the TI1 and the TI2 Polarities */
\r
2687 tmpccer &= ~(TIM_CCER_CC1P | TIM_CCER_CC2P);
\r
2688 tmpccer &= ~(TIM_CCER_CC1NP | TIM_CCER_CC2NP);
\r
2689 tmpccer |= sConfig->IC1Polarity | (sConfig->IC2Polarity << 4U);
\r
2691 /* Write to TIMx SMCR */
\r
2692 htim->Instance->SMCR = tmpsmcr;
\r
2694 /* Write to TIMx CCMR1 */
\r
2695 htim->Instance->CCMR1 = tmpccmr1;
\r
2697 /* Write to TIMx CCER */
\r
2698 htim->Instance->CCER = tmpccer;
\r
2700 /* Initialize the TIM state*/
\r
2701 htim->State = HAL_TIM_STATE_READY;
\r
2708 * @brief DeInitializes the TIM Encoder interface
\r
2709 * @param htim TIM Encoder Interface handle
\r
2710 * @retval HAL status
\r
2712 HAL_StatusTypeDef HAL_TIM_Encoder_DeInit(TIM_HandleTypeDef *htim)
\r
2714 /* Check the parameters */
\r
2715 assert_param(IS_TIM_INSTANCE(htim->Instance));
\r
2717 htim->State = HAL_TIM_STATE_BUSY;
\r
2719 /* Disable the TIM Peripheral Clock */
\r
2720 __HAL_TIM_DISABLE(htim);
\r
2722 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
2723 if (htim->Encoder_MspDeInitCallback == NULL)
\r
2725 htim->Encoder_MspDeInitCallback = HAL_TIM_Encoder_MspDeInit;
\r
2727 /* DeInit the low level hardware */
\r
2728 htim->Encoder_MspDeInitCallback(htim);
\r
2730 /* DeInit the low level hardware: GPIO, CLOCK, NVIC */
\r
2731 HAL_TIM_Encoder_MspDeInit(htim);
\r
2732 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
2734 /* Change TIM state */
\r
2735 htim->State = HAL_TIM_STATE_RESET;
\r
2737 /* Release Lock */
\r
2738 __HAL_UNLOCK(htim);
\r
2744 * @brief Initializes the TIM Encoder Interface MSP.
\r
2745 * @param htim TIM Encoder Interface handle
\r
2748 __weak void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef *htim)
\r
2750 /* Prevent unused argument(s) compilation warning */
\r
2753 /* NOTE : This function should not be modified, when the callback is needed,
\r
2754 the HAL_TIM_Encoder_MspInit could be implemented in the user file
\r
2759 * @brief DeInitializes TIM Encoder Interface MSP.
\r
2760 * @param htim TIM Encoder Interface handle
\r
2763 __weak void HAL_TIM_Encoder_MspDeInit(TIM_HandleTypeDef *htim)
\r
2765 /* Prevent unused argument(s) compilation warning */
\r
2768 /* NOTE : This function should not be modified, when the callback is needed,
\r
2769 the HAL_TIM_Encoder_MspDeInit could be implemented in the user file
\r
2774 * @brief Starts the TIM Encoder Interface.
\r
2775 * @param htim TIM Encoder Interface handle
\r
2776 * @param Channel TIM Channels to be enabled
\r
2777 * This parameter can be one of the following values:
\r
2778 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
2779 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
2780 * @arg TIM_CHANNEL_ALL: TIM Channel 1 and TIM Channel 2 are selected
\r
2781 * @retval HAL status
\r
2783 HAL_StatusTypeDef HAL_TIM_Encoder_Start(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
2785 /* Check the parameters */
\r
2786 assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
\r
2788 /* Enable the encoder interface channels */
\r
2791 case TIM_CHANNEL_1:
\r
2793 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_ENABLE);
\r
2797 case TIM_CHANNEL_2:
\r
2799 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_ENABLE);
\r
2805 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_ENABLE);
\r
2806 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_ENABLE);
\r
2810 /* Enable the Peripheral */
\r
2811 __HAL_TIM_ENABLE(htim);
\r
2813 /* Return function status */
\r
2818 * @brief Stops the TIM Encoder Interface.
\r
2819 * @param htim TIM Encoder Interface handle
\r
2820 * @param Channel TIM Channels to be disabled
\r
2821 * This parameter can be one of the following values:
\r
2822 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
2823 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
2824 * @arg TIM_CHANNEL_ALL: TIM Channel 1 and TIM Channel 2 are selected
\r
2825 * @retval HAL status
\r
2827 HAL_StatusTypeDef HAL_TIM_Encoder_Stop(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
2829 /* Check the parameters */
\r
2830 assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
\r
2832 /* Disable the Input Capture channels 1 and 2
\r
2833 (in the EncoderInterface the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2) */
\r
2836 case TIM_CHANNEL_1:
\r
2838 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_DISABLE);
\r
2842 case TIM_CHANNEL_2:
\r
2844 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_DISABLE);
\r
2850 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_DISABLE);
\r
2851 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_DISABLE);
\r
2856 /* Disable the Peripheral */
\r
2857 __HAL_TIM_DISABLE(htim);
\r
2859 /* Return function status */
\r
2864 * @brief Starts the TIM Encoder Interface in interrupt mode.
\r
2865 * @param htim TIM Encoder Interface handle
\r
2866 * @param Channel TIM Channels to be enabled
\r
2867 * This parameter can be one of the following values:
\r
2868 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
2869 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
2870 * @arg TIM_CHANNEL_ALL: TIM Channel 1 and TIM Channel 2 are selected
\r
2871 * @retval HAL status
\r
2873 HAL_StatusTypeDef HAL_TIM_Encoder_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
2875 /* Check the parameters */
\r
2876 assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
\r
2878 /* Enable the encoder interface channels */
\r
2879 /* Enable the capture compare Interrupts 1 and/or 2 */
\r
2882 case TIM_CHANNEL_1:
\r
2884 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_ENABLE);
\r
2885 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC1);
\r
2889 case TIM_CHANNEL_2:
\r
2891 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_ENABLE);
\r
2892 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC2);
\r
2898 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_ENABLE);
\r
2899 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_ENABLE);
\r
2900 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC1);
\r
2901 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC2);
\r
2906 /* Enable the Peripheral */
\r
2907 __HAL_TIM_ENABLE(htim);
\r
2909 /* Return function status */
\r
2914 * @brief Stops the TIM Encoder Interface in interrupt mode.
\r
2915 * @param htim TIM Encoder Interface handle
\r
2916 * @param Channel TIM Channels to be disabled
\r
2917 * This parameter can be one of the following values:
\r
2918 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
2919 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
2920 * @arg TIM_CHANNEL_ALL: TIM Channel 1 and TIM Channel 2 are selected
\r
2921 * @retval HAL status
\r
2923 HAL_StatusTypeDef HAL_TIM_Encoder_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
2925 /* Check the parameters */
\r
2926 assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
\r
2928 /* Disable the Input Capture channels 1 and 2
\r
2929 (in the EncoderInterface the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2) */
\r
2930 if (Channel == TIM_CHANNEL_1)
\r
2932 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_DISABLE);
\r
2934 /* Disable the capture compare Interrupts 1 */
\r
2935 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC1);
\r
2937 else if (Channel == TIM_CHANNEL_2)
\r
2939 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_DISABLE);
\r
2941 /* Disable the capture compare Interrupts 2 */
\r
2942 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC2);
\r
2946 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_DISABLE);
\r
2947 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_DISABLE);
\r
2949 /* Disable the capture compare Interrupts 1 and 2 */
\r
2950 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC1);
\r
2951 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC2);
\r
2954 /* Disable the Peripheral */
\r
2955 __HAL_TIM_DISABLE(htim);
\r
2957 /* Change the htim state */
\r
2958 htim->State = HAL_TIM_STATE_READY;
\r
2960 /* Return function status */
\r
2965 * @brief Starts the TIM Encoder Interface in DMA mode.
\r
2966 * @param htim TIM Encoder Interface handle
\r
2967 * @param Channel TIM Channels to be enabled
\r
2968 * This parameter can be one of the following values:
\r
2969 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
2970 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
2971 * @arg TIM_CHANNEL_ALL: TIM Channel 1 and TIM Channel 2 are selected
\r
2972 * @param pData1 The destination Buffer address for IC1.
\r
2973 * @param pData2 The destination Buffer address for IC2.
\r
2974 * @param Length The length of data to be transferred from TIM peripheral to memory.
\r
2975 * @retval HAL status
\r
2977 HAL_StatusTypeDef HAL_TIM_Encoder_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData1,
\r
2978 uint32_t *pData2, uint16_t Length)
\r
2980 /* Check the parameters */
\r
2981 assert_param(IS_TIM_DMA_CC_INSTANCE(htim->Instance));
\r
2983 if ((htim->State == HAL_TIM_STATE_BUSY))
\r
2987 else if ((htim->State == HAL_TIM_STATE_READY))
\r
2989 if ((((pData1 == NULL) || (pData2 == NULL))) && (Length > 0U))
\r
2995 htim->State = HAL_TIM_STATE_BUSY;
\r
3000 /* nothing to do */
\r
3005 case TIM_CHANNEL_1:
\r
3007 /* Set the DMA capture callbacks */
\r
3008 htim->hdma[TIM_DMA_ID_CC1]->XferCpltCallback = TIM_DMACaptureCplt;
\r
3009 htim->hdma[TIM_DMA_ID_CC1]->XferHalfCpltCallback = TIM_DMACaptureHalfCplt;
\r
3011 /* Set the DMA error callback */
\r
3012 htim->hdma[TIM_DMA_ID_CC1]->XferErrorCallback = TIM_DMAError ;
\r
3014 /* Enable the DMA channel */
\r
3015 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)&htim->Instance->CCR1, (uint32_t)pData1, Length) != HAL_OK)
\r
3019 /* Enable the TIM Input Capture DMA request */
\r
3020 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC1);
\r
3022 /* Enable the Peripheral */
\r
3023 __HAL_TIM_ENABLE(htim);
\r
3025 /* Enable the Capture compare channel */
\r
3026 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_ENABLE);
\r
3030 case TIM_CHANNEL_2:
\r
3032 /* Set the DMA capture callbacks */
\r
3033 htim->hdma[TIM_DMA_ID_CC2]->XferCpltCallback = TIM_DMACaptureCplt;
\r
3034 htim->hdma[TIM_DMA_ID_CC2]->XferHalfCpltCallback = TIM_DMACaptureHalfCplt;
\r
3036 /* Set the DMA error callback */
\r
3037 htim->hdma[TIM_DMA_ID_CC2]->XferErrorCallback = TIM_DMAError;
\r
3038 /* Enable the DMA channel */
\r
3039 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)&htim->Instance->CCR2, (uint32_t)pData2, Length) != HAL_OK)
\r
3043 /* Enable the TIM Input Capture DMA request */
\r
3044 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC2);
\r
3046 /* Enable the Peripheral */
\r
3047 __HAL_TIM_ENABLE(htim);
\r
3049 /* Enable the Capture compare channel */
\r
3050 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_ENABLE);
\r
3054 case TIM_CHANNEL_ALL:
\r
3056 /* Set the DMA capture callbacks */
\r
3057 htim->hdma[TIM_DMA_ID_CC1]->XferCpltCallback = TIM_DMACaptureCplt;
\r
3058 htim->hdma[TIM_DMA_ID_CC1]->XferHalfCpltCallback = TIM_DMACaptureHalfCplt;
\r
3060 /* Set the DMA error callback */
\r
3061 htim->hdma[TIM_DMA_ID_CC1]->XferErrorCallback = TIM_DMAError ;
\r
3063 /* Enable the DMA channel */
\r
3064 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)&htim->Instance->CCR1, (uint32_t)pData1, Length) != HAL_OK)
\r
3069 /* Set the DMA capture callbacks */
\r
3070 htim->hdma[TIM_DMA_ID_CC2]->XferCpltCallback = TIM_DMACaptureCplt;
\r
3071 htim->hdma[TIM_DMA_ID_CC2]->XferHalfCpltCallback = TIM_DMACaptureHalfCplt;
\r
3073 /* Set the DMA error callback */
\r
3074 htim->hdma[TIM_DMA_ID_CC2]->XferErrorCallback = TIM_DMAError ;
\r
3076 /* Enable the DMA channel */
\r
3077 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)&htim->Instance->CCR2, (uint32_t)pData2, Length) != HAL_OK)
\r
3081 /* Enable the Peripheral */
\r
3082 __HAL_TIM_ENABLE(htim);
\r
3084 /* Enable the Capture compare channel */
\r
3085 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_ENABLE);
\r
3086 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_ENABLE);
\r
3088 /* Enable the TIM Input Capture DMA request */
\r
3089 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC1);
\r
3090 /* Enable the TIM Input Capture DMA request */
\r
3091 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC2);
\r
3098 /* Return function status */
\r
3103 * @brief Stops the TIM Encoder Interface in DMA mode.
\r
3104 * @param htim TIM Encoder Interface handle
\r
3105 * @param Channel TIM Channels to be enabled
\r
3106 * This parameter can be one of the following values:
\r
3107 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
3108 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
3109 * @arg TIM_CHANNEL_ALL: TIM Channel 1 and TIM Channel 2 are selected
\r
3110 * @retval HAL status
\r
3112 HAL_StatusTypeDef HAL_TIM_Encoder_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
3114 /* Check the parameters */
\r
3115 assert_param(IS_TIM_DMA_CC_INSTANCE(htim->Instance));
\r
3117 /* Disable the Input Capture channels 1 and 2
\r
3118 (in the EncoderInterface the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2) */
\r
3119 if (Channel == TIM_CHANNEL_1)
\r
3121 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_DISABLE);
\r
3123 /* Disable the capture compare DMA Request 1 */
\r
3124 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC1);
\r
3125 (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC1]);
\r
3127 else if (Channel == TIM_CHANNEL_2)
\r
3129 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_DISABLE);
\r
3131 /* Disable the capture compare DMA Request 2 */
\r
3132 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC2);
\r
3133 (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC2]);
\r
3137 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_DISABLE);
\r
3138 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_DISABLE);
\r
3140 /* Disable the capture compare DMA Request 1 and 2 */
\r
3141 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC1);
\r
3142 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC2);
\r
3143 (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC1]);
\r
3144 (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC2]);
\r
3147 /* Disable the Peripheral */
\r
3148 __HAL_TIM_DISABLE(htim);
\r
3150 /* Change the htim state */
\r
3151 htim->State = HAL_TIM_STATE_READY;
\r
3153 /* Return function status */
\r
3160 /** @defgroup TIM_Exported_Functions_Group7 TIM IRQ handler management
\r
3161 * @brief TIM IRQ handler management
\r
3164 ==============================================================================
\r
3165 ##### IRQ handler management #####
\r
3166 ==============================================================================
\r
3168 This section provides Timer IRQ handler function.
\r
3174 * @brief This function handles TIM interrupts requests.
\r
3175 * @param htim TIM handle
\r
3178 void HAL_TIM_IRQHandler(TIM_HandleTypeDef *htim)
\r
3180 /* Capture compare 1 event */
\r
3181 if (__HAL_TIM_GET_FLAG(htim, TIM_FLAG_CC1) != RESET)
\r
3183 if (__HAL_TIM_GET_IT_SOURCE(htim, TIM_IT_CC1) != RESET)
\r
3186 __HAL_TIM_CLEAR_IT(htim, TIM_IT_CC1);
\r
3187 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_1;
\r
3189 /* Input capture event */
\r
3190 if ((htim->Instance->CCMR1 & TIM_CCMR1_CC1S) != 0x00U)
\r
3192 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
3193 htim->IC_CaptureCallback(htim);
\r
3195 HAL_TIM_IC_CaptureCallback(htim);
\r
3196 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
3198 /* Output compare event */
\r
3201 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
3202 htim->OC_DelayElapsedCallback(htim);
\r
3203 htim->PWM_PulseFinishedCallback(htim);
\r
3205 HAL_TIM_OC_DelayElapsedCallback(htim);
\r
3206 HAL_TIM_PWM_PulseFinishedCallback(htim);
\r
3207 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
3209 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_CLEARED;
\r
3213 /* Capture compare 2 event */
\r
3214 if (__HAL_TIM_GET_FLAG(htim, TIM_FLAG_CC2) != RESET)
\r
3216 if (__HAL_TIM_GET_IT_SOURCE(htim, TIM_IT_CC2) != RESET)
\r
3218 __HAL_TIM_CLEAR_IT(htim, TIM_IT_CC2);
\r
3219 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_2;
\r
3220 /* Input capture event */
\r
3221 if ((htim->Instance->CCMR1 & TIM_CCMR1_CC2S) != 0x00U)
\r
3223 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
3224 htim->IC_CaptureCallback(htim);
\r
3226 HAL_TIM_IC_CaptureCallback(htim);
\r
3227 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
3229 /* Output compare event */
\r
3232 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
3233 htim->OC_DelayElapsedCallback(htim);
\r
3234 htim->PWM_PulseFinishedCallback(htim);
\r
3236 HAL_TIM_OC_DelayElapsedCallback(htim);
\r
3237 HAL_TIM_PWM_PulseFinishedCallback(htim);
\r
3238 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
3240 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_CLEARED;
\r
3243 /* Capture compare 3 event */
\r
3244 if (__HAL_TIM_GET_FLAG(htim, TIM_FLAG_CC3) != RESET)
\r
3246 if (__HAL_TIM_GET_IT_SOURCE(htim, TIM_IT_CC3) != RESET)
\r
3248 __HAL_TIM_CLEAR_IT(htim, TIM_IT_CC3);
\r
3249 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_3;
\r
3250 /* Input capture event */
\r
3251 if ((htim->Instance->CCMR2 & TIM_CCMR2_CC3S) != 0x00U)
\r
3253 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
3254 htim->IC_CaptureCallback(htim);
\r
3256 HAL_TIM_IC_CaptureCallback(htim);
\r
3257 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
3259 /* Output compare event */
\r
3262 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
3263 htim->OC_DelayElapsedCallback(htim);
\r
3264 htim->PWM_PulseFinishedCallback(htim);
\r
3266 HAL_TIM_OC_DelayElapsedCallback(htim);
\r
3267 HAL_TIM_PWM_PulseFinishedCallback(htim);
\r
3268 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
3270 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_CLEARED;
\r
3273 /* Capture compare 4 event */
\r
3274 if (__HAL_TIM_GET_FLAG(htim, TIM_FLAG_CC4) != RESET)
\r
3276 if (__HAL_TIM_GET_IT_SOURCE(htim, TIM_IT_CC4) != RESET)
\r
3278 __HAL_TIM_CLEAR_IT(htim, TIM_IT_CC4);
\r
3279 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_4;
\r
3280 /* Input capture event */
\r
3281 if ((htim->Instance->CCMR2 & TIM_CCMR2_CC4S) != 0x00U)
\r
3283 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
3284 htim->IC_CaptureCallback(htim);
\r
3286 HAL_TIM_IC_CaptureCallback(htim);
\r
3287 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
3289 /* Output compare event */
\r
3292 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
3293 htim->OC_DelayElapsedCallback(htim);
\r
3294 htim->PWM_PulseFinishedCallback(htim);
\r
3296 HAL_TIM_OC_DelayElapsedCallback(htim);
\r
3297 HAL_TIM_PWM_PulseFinishedCallback(htim);
\r
3298 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
3300 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_CLEARED;
\r
3303 /* TIM Update event */
\r
3304 if (__HAL_TIM_GET_FLAG(htim, TIM_FLAG_UPDATE) != RESET)
\r
3306 if (__HAL_TIM_GET_IT_SOURCE(htim, TIM_IT_UPDATE) != RESET)
\r
3308 __HAL_TIM_CLEAR_IT(htim, TIM_IT_UPDATE);
\r
3309 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
3310 htim->PeriodElapsedCallback(htim);
\r
3312 HAL_TIM_PeriodElapsedCallback(htim);
\r
3313 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
3316 /* TIM Break input event */
\r
3317 if (__HAL_TIM_GET_FLAG(htim, TIM_FLAG_BREAK) != RESET)
\r
3319 if (__HAL_TIM_GET_IT_SOURCE(htim, TIM_IT_BREAK) != RESET)
\r
3321 __HAL_TIM_CLEAR_IT(htim, TIM_IT_BREAK);
\r
3322 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
3323 htim->BreakCallback(htim);
\r
3325 HAL_TIMEx_BreakCallback(htim);
\r
3326 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
3329 /* TIM Break2 input event */
\r
3330 if (__HAL_TIM_GET_FLAG(htim, TIM_FLAG_BREAK2) != RESET)
\r
3332 if (__HAL_TIM_GET_IT_SOURCE(htim, TIM_IT_BREAK) != RESET)
\r
3334 __HAL_TIM_CLEAR_FLAG(htim, TIM_FLAG_BREAK2);
\r
3335 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
3336 htim->Break2Callback(htim);
\r
3338 HAL_TIMEx_Break2Callback(htim);
\r
3339 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
3342 /* TIM Trigger detection event */
\r
3343 if (__HAL_TIM_GET_FLAG(htim, TIM_FLAG_TRIGGER) != RESET)
\r
3345 if (__HAL_TIM_GET_IT_SOURCE(htim, TIM_IT_TRIGGER) != RESET)
\r
3347 __HAL_TIM_CLEAR_IT(htim, TIM_IT_TRIGGER);
\r
3348 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
3349 htim->TriggerCallback(htim);
\r
3351 HAL_TIM_TriggerCallback(htim);
\r
3352 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
3355 /* TIM commutation event */
\r
3356 if (__HAL_TIM_GET_FLAG(htim, TIM_FLAG_COM) != RESET)
\r
3358 if (__HAL_TIM_GET_IT_SOURCE(htim, TIM_IT_COM) != RESET)
\r
3360 __HAL_TIM_CLEAR_IT(htim, TIM_FLAG_COM);
\r
3361 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
3362 htim->CommutationCallback(htim);
\r
3364 HAL_TIMEx_CommutCallback(htim);
\r
3365 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
3374 /** @defgroup TIM_Exported_Functions_Group8 TIM Peripheral Control functions
\r
3375 * @brief TIM Peripheral Control functions
\r
3378 ==============================================================================
\r
3379 ##### Peripheral Control functions #####
\r
3380 ==============================================================================
\r
3382 This section provides functions allowing to:
\r
3383 (+) Configure The Input Output channels for OC, PWM, IC or One Pulse mode.
\r
3384 (+) Configure External Clock source.
\r
3385 (+) Configure Complementary channels, break features and dead time.
\r
3386 (+) Configure Master and the Slave synchronization.
\r
3387 (+) Configure the DMA Burst Mode.
\r
3394 * @brief Initializes the TIM Output Compare Channels according to the specified
\r
3395 * parameters in the TIM_OC_InitTypeDef.
\r
3396 * @param htim TIM Output Compare handle
\r
3397 * @param sConfig TIM Output Compare configuration structure
\r
3398 * @param Channel TIM Channels to configure
\r
3399 * This parameter can be one of the following values:
\r
3400 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
3401 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
3402 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
3403 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
\r
3404 * @arg TIM_CHANNEL_5: TIM Channel 5 selected
\r
3405 * @arg TIM_CHANNEL_6: TIM Channel 6 selected
\r
3406 * @retval HAL status
\r
3408 HAL_StatusTypeDef HAL_TIM_OC_ConfigChannel(TIM_HandleTypeDef *htim,
\r
3409 TIM_OC_InitTypeDef *sConfig,
\r
3412 /* Check the parameters */
\r
3413 assert_param(IS_TIM_CHANNELS(Channel));
\r
3414 assert_param(IS_TIM_OC_MODE(sConfig->OCMode));
\r
3415 assert_param(IS_TIM_OC_POLARITY(sConfig->OCPolarity));
\r
3417 /* Process Locked */
\r
3420 htim->State = HAL_TIM_STATE_BUSY;
\r
3424 case TIM_CHANNEL_1:
\r
3426 /* Check the parameters */
\r
3427 assert_param(IS_TIM_CC1_INSTANCE(htim->Instance));
\r
3429 /* Configure the TIM Channel 1 in Output Compare */
\r
3430 TIM_OC1_SetConfig(htim->Instance, sConfig);
\r
3434 case TIM_CHANNEL_2:
\r
3436 /* Check the parameters */
\r
3437 assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
\r
3439 /* Configure the TIM Channel 2 in Output Compare */
\r
3440 TIM_OC2_SetConfig(htim->Instance, sConfig);
\r
3444 case TIM_CHANNEL_3:
\r
3446 /* Check the parameters */
\r
3447 assert_param(IS_TIM_CC3_INSTANCE(htim->Instance));
\r
3449 /* Configure the TIM Channel 3 in Output Compare */
\r
3450 TIM_OC3_SetConfig(htim->Instance, sConfig);
\r
3454 case TIM_CHANNEL_4:
\r
3456 /* Check the parameters */
\r
3457 assert_param(IS_TIM_CC4_INSTANCE(htim->Instance));
\r
3459 /* Configure the TIM Channel 4 in Output Compare */
\r
3460 TIM_OC4_SetConfig(htim->Instance, sConfig);
\r
3464 case TIM_CHANNEL_5:
\r
3466 /* Check the parameters */
\r
3467 assert_param(IS_TIM_CC5_INSTANCE(htim->Instance));
\r
3469 /* Configure the TIM Channel 5 in Output Compare */
\r
3470 TIM_OC5_SetConfig(htim->Instance, sConfig);
\r
3474 case TIM_CHANNEL_6:
\r
3476 /* Check the parameters */
\r
3477 assert_param(IS_TIM_CC6_INSTANCE(htim->Instance));
\r
3479 /* Configure the TIM Channel 6 in Output Compare */
\r
3480 TIM_OC6_SetConfig(htim->Instance, sConfig);
\r
3488 htim->State = HAL_TIM_STATE_READY;
\r
3490 __HAL_UNLOCK(htim);
\r
3496 * @brief Initializes the TIM Input Capture Channels according to the specified
\r
3497 * parameters in the TIM_IC_InitTypeDef.
\r
3498 * @param htim TIM IC handle
\r
3499 * @param sConfig TIM Input Capture configuration structure
\r
3500 * @param Channel TIM Channel to configure
\r
3501 * This parameter can be one of the following values:
\r
3502 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
3503 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
3504 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
3505 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
\r
3506 * @retval HAL status
\r
3508 HAL_StatusTypeDef HAL_TIM_IC_ConfigChannel(TIM_HandleTypeDef *htim, TIM_IC_InitTypeDef *sConfig, uint32_t Channel)
\r
3510 /* Check the parameters */
\r
3511 assert_param(IS_TIM_CC1_INSTANCE(htim->Instance));
\r
3512 assert_param(IS_TIM_IC_POLARITY(sConfig->ICPolarity));
\r
3513 assert_param(IS_TIM_IC_SELECTION(sConfig->ICSelection));
\r
3514 assert_param(IS_TIM_IC_PRESCALER(sConfig->ICPrescaler));
\r
3515 assert_param(IS_TIM_IC_FILTER(sConfig->ICFilter));
\r
3517 /* Process Locked */
\r
3520 htim->State = HAL_TIM_STATE_BUSY;
\r
3522 if (Channel == TIM_CHANNEL_1)
\r
3524 /* TI1 Configuration */
\r
3525 TIM_TI1_SetConfig(htim->Instance,
\r
3526 sConfig->ICPolarity,
\r
3527 sConfig->ICSelection,
\r
3528 sConfig->ICFilter);
\r
3530 /* Reset the IC1PSC Bits */
\r
3531 htim->Instance->CCMR1 &= ~TIM_CCMR1_IC1PSC;
\r
3533 /* Set the IC1PSC value */
\r
3534 htim->Instance->CCMR1 |= sConfig->ICPrescaler;
\r
3536 else if (Channel == TIM_CHANNEL_2)
\r
3538 /* TI2 Configuration */
\r
3539 assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
\r
3541 TIM_TI2_SetConfig(htim->Instance,
\r
3542 sConfig->ICPolarity,
\r
3543 sConfig->ICSelection,
\r
3544 sConfig->ICFilter);
\r
3546 /* Reset the IC2PSC Bits */
\r
3547 htim->Instance->CCMR1 &= ~TIM_CCMR1_IC2PSC;
\r
3549 /* Set the IC2PSC value */
\r
3550 htim->Instance->CCMR1 |= (sConfig->ICPrescaler << 8U);
\r
3552 else if (Channel == TIM_CHANNEL_3)
\r
3554 /* TI3 Configuration */
\r
3555 assert_param(IS_TIM_CC3_INSTANCE(htim->Instance));
\r
3557 TIM_TI3_SetConfig(htim->Instance,
\r
3558 sConfig->ICPolarity,
\r
3559 sConfig->ICSelection,
\r
3560 sConfig->ICFilter);
\r
3562 /* Reset the IC3PSC Bits */
\r
3563 htim->Instance->CCMR2 &= ~TIM_CCMR2_IC3PSC;
\r
3565 /* Set the IC3PSC value */
\r
3566 htim->Instance->CCMR2 |= sConfig->ICPrescaler;
\r
3570 /* TI4 Configuration */
\r
3571 assert_param(IS_TIM_CC4_INSTANCE(htim->Instance));
\r
3573 TIM_TI4_SetConfig(htim->Instance,
\r
3574 sConfig->ICPolarity,
\r
3575 sConfig->ICSelection,
\r
3576 sConfig->ICFilter);
\r
3578 /* Reset the IC4PSC Bits */
\r
3579 htim->Instance->CCMR2 &= ~TIM_CCMR2_IC4PSC;
\r
3581 /* Set the IC4PSC value */
\r
3582 htim->Instance->CCMR2 |= (sConfig->ICPrescaler << 8U);
\r
3585 htim->State = HAL_TIM_STATE_READY;
\r
3587 __HAL_UNLOCK(htim);
\r
3593 * @brief Initializes the TIM PWM channels according to the specified
\r
3594 * parameters in the TIM_OC_InitTypeDef.
\r
3595 * @param htim TIM PWM handle
\r
3596 * @param sConfig TIM PWM configuration structure
\r
3597 * @param Channel TIM Channels to be configured
\r
3598 * This parameter can be one of the following values:
\r
3599 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
3600 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
3601 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
3602 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
\r
3603 * @arg TIM_CHANNEL_5: TIM Channel 5 selected
\r
3604 * @arg TIM_CHANNEL_6: TIM Channel 6 selected
\r
3605 * @retval HAL status
\r
3607 HAL_StatusTypeDef HAL_TIM_PWM_ConfigChannel(TIM_HandleTypeDef *htim,
\r
3608 TIM_OC_InitTypeDef *sConfig,
\r
3611 /* Check the parameters */
\r
3612 assert_param(IS_TIM_CHANNELS(Channel));
\r
3613 assert_param(IS_TIM_PWM_MODE(sConfig->OCMode));
\r
3614 assert_param(IS_TIM_OC_POLARITY(sConfig->OCPolarity));
\r
3615 assert_param(IS_TIM_FAST_STATE(sConfig->OCFastMode));
\r
3617 /* Process Locked */
\r
3620 htim->State = HAL_TIM_STATE_BUSY;
\r
3624 case TIM_CHANNEL_1:
\r
3626 /* Check the parameters */
\r
3627 assert_param(IS_TIM_CC1_INSTANCE(htim->Instance));
\r
3629 /* Configure the Channel 1 in PWM mode */
\r
3630 TIM_OC1_SetConfig(htim->Instance, sConfig);
\r
3632 /* Set the Preload enable bit for channel1 */
\r
3633 htim->Instance->CCMR1 |= TIM_CCMR1_OC1PE;
\r
3635 /* Configure the Output Fast mode */
\r
3636 htim->Instance->CCMR1 &= ~TIM_CCMR1_OC1FE;
\r
3637 htim->Instance->CCMR1 |= sConfig->OCFastMode;
\r
3641 case TIM_CHANNEL_2:
\r
3643 /* Check the parameters */
\r
3644 assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
\r
3646 /* Configure the Channel 2 in PWM mode */
\r
3647 TIM_OC2_SetConfig(htim->Instance, sConfig);
\r
3649 /* Set the Preload enable bit for channel2 */
\r
3650 htim->Instance->CCMR1 |= TIM_CCMR1_OC2PE;
\r
3652 /* Configure the Output Fast mode */
\r
3653 htim->Instance->CCMR1 &= ~TIM_CCMR1_OC2FE;
\r
3654 htim->Instance->CCMR1 |= sConfig->OCFastMode << 8U;
\r
3658 case TIM_CHANNEL_3:
\r
3660 /* Check the parameters */
\r
3661 assert_param(IS_TIM_CC3_INSTANCE(htim->Instance));
\r
3663 /* Configure the Channel 3 in PWM mode */
\r
3664 TIM_OC3_SetConfig(htim->Instance, sConfig);
\r
3666 /* Set the Preload enable bit for channel3 */
\r
3667 htim->Instance->CCMR2 |= TIM_CCMR2_OC3PE;
\r
3669 /* Configure the Output Fast mode */
\r
3670 htim->Instance->CCMR2 &= ~TIM_CCMR2_OC3FE;
\r
3671 htim->Instance->CCMR2 |= sConfig->OCFastMode;
\r
3675 case TIM_CHANNEL_4:
\r
3677 /* Check the parameters */
\r
3678 assert_param(IS_TIM_CC4_INSTANCE(htim->Instance));
\r
3680 /* Configure the Channel 4 in PWM mode */
\r
3681 TIM_OC4_SetConfig(htim->Instance, sConfig);
\r
3683 /* Set the Preload enable bit for channel4 */
\r
3684 htim->Instance->CCMR2 |= TIM_CCMR2_OC4PE;
\r
3686 /* Configure the Output Fast mode */
\r
3687 htim->Instance->CCMR2 &= ~TIM_CCMR2_OC4FE;
\r
3688 htim->Instance->CCMR2 |= sConfig->OCFastMode << 8U;
\r
3692 case TIM_CHANNEL_5:
\r
3694 /* Check the parameters */
\r
3695 assert_param(IS_TIM_CC5_INSTANCE(htim->Instance));
\r
3697 /* Configure the Channel 5 in PWM mode */
\r
3698 TIM_OC5_SetConfig(htim->Instance, sConfig);
\r
3700 /* Set the Preload enable bit for channel5*/
\r
3701 htim->Instance->CCMR3 |= TIM_CCMR3_OC5PE;
\r
3703 /* Configure the Output Fast mode */
\r
3704 htim->Instance->CCMR3 &= ~TIM_CCMR3_OC5FE;
\r
3705 htim->Instance->CCMR3 |= sConfig->OCFastMode;
\r
3709 case TIM_CHANNEL_6:
\r
3711 /* Check the parameters */
\r
3712 assert_param(IS_TIM_CC6_INSTANCE(htim->Instance));
\r
3714 /* Configure the Channel 6 in PWM mode */
\r
3715 TIM_OC6_SetConfig(htim->Instance, sConfig);
\r
3717 /* Set the Preload enable bit for channel6 */
\r
3718 htim->Instance->CCMR3 |= TIM_CCMR3_OC6PE;
\r
3720 /* Configure the Output Fast mode */
\r
3721 htim->Instance->CCMR3 &= ~TIM_CCMR3_OC6FE;
\r
3722 htim->Instance->CCMR3 |= sConfig->OCFastMode << 8U;
\r
3730 htim->State = HAL_TIM_STATE_READY;
\r
3732 __HAL_UNLOCK(htim);
\r
3738 * @brief Initializes the TIM One Pulse Channels according to the specified
\r
3739 * parameters in the TIM_OnePulse_InitTypeDef.
\r
3740 * @param htim TIM One Pulse handle
\r
3741 * @param sConfig TIM One Pulse configuration structure
\r
3742 * @param OutputChannel TIM output channel to configure
\r
3743 * This parameter can be one of the following values:
\r
3744 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
3745 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
3746 * @param InputChannel TIM input Channel to configure
\r
3747 * This parameter can be one of the following values:
\r
3748 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
3749 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
3750 * @retval HAL status
\r
3752 HAL_StatusTypeDef HAL_TIM_OnePulse_ConfigChannel(TIM_HandleTypeDef *htim, TIM_OnePulse_InitTypeDef *sConfig,
\r
3753 uint32_t OutputChannel, uint32_t InputChannel)
\r
3755 TIM_OC_InitTypeDef temp1;
\r
3757 /* Check the parameters */
\r
3758 assert_param(IS_TIM_OPM_CHANNELS(OutputChannel));
\r
3759 assert_param(IS_TIM_OPM_CHANNELS(InputChannel));
\r
3761 if (OutputChannel != InputChannel)
\r
3763 /* Process Locked */
\r
3766 htim->State = HAL_TIM_STATE_BUSY;
\r
3768 /* Extract the Output compare configuration from sConfig structure */
\r
3769 temp1.OCMode = sConfig->OCMode;
\r
3770 temp1.Pulse = sConfig->Pulse;
\r
3771 temp1.OCPolarity = sConfig->OCPolarity;
\r
3772 temp1.OCNPolarity = sConfig->OCNPolarity;
\r
3773 temp1.OCIdleState = sConfig->OCIdleState;
\r
3774 temp1.OCNIdleState = sConfig->OCNIdleState;
\r
3776 switch (OutputChannel)
\r
3778 case TIM_CHANNEL_1:
\r
3780 assert_param(IS_TIM_CC1_INSTANCE(htim->Instance));
\r
3782 TIM_OC1_SetConfig(htim->Instance, &temp1);
\r
3785 case TIM_CHANNEL_2:
\r
3787 assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
\r
3789 TIM_OC2_SetConfig(htim->Instance, &temp1);
\r
3796 switch (InputChannel)
\r
3798 case TIM_CHANNEL_1:
\r
3800 assert_param(IS_TIM_CC1_INSTANCE(htim->Instance));
\r
3802 TIM_TI1_SetConfig(htim->Instance, sConfig->ICPolarity,
\r
3803 sConfig->ICSelection, sConfig->ICFilter);
\r
3805 /* Reset the IC1PSC Bits */
\r
3806 htim->Instance->CCMR1 &= ~TIM_CCMR1_IC1PSC;
\r
3808 /* Select the Trigger source */
\r
3809 htim->Instance->SMCR &= ~TIM_SMCR_TS;
\r
3810 htim->Instance->SMCR |= TIM_TS_TI1FP1;
\r
3812 /* Select the Slave Mode */
\r
3813 htim->Instance->SMCR &= ~TIM_SMCR_SMS;
\r
3814 htim->Instance->SMCR |= TIM_SLAVEMODE_TRIGGER;
\r
3817 case TIM_CHANNEL_2:
\r
3819 assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
\r
3821 TIM_TI2_SetConfig(htim->Instance, sConfig->ICPolarity,
\r
3822 sConfig->ICSelection, sConfig->ICFilter);
\r
3824 /* Reset the IC2PSC Bits */
\r
3825 htim->Instance->CCMR1 &= ~TIM_CCMR1_IC2PSC;
\r
3827 /* Select the Trigger source */
\r
3828 htim->Instance->SMCR &= ~TIM_SMCR_TS;
\r
3829 htim->Instance->SMCR |= TIM_TS_TI2FP2;
\r
3831 /* Select the Slave Mode */
\r
3832 htim->Instance->SMCR &= ~TIM_SMCR_SMS;
\r
3833 htim->Instance->SMCR |= TIM_SLAVEMODE_TRIGGER;
\r
3841 htim->State = HAL_TIM_STATE_READY;
\r
3843 __HAL_UNLOCK(htim);
\r
3854 * @brief Configure the DMA Burst to transfer Data from the memory to the TIM peripheral
\r
3855 * @param htim TIM handle
\r
3856 * @param BurstBaseAddress TIM Base address from where the DMA will start the Data write
\r
3857 * This parameter can be one of the following values:
\r
3858 * @arg TIM_DMABASE_CR1
\r
3859 * @arg TIM_DMABASE_CR2
\r
3860 * @arg TIM_DMABASE_SMCR
\r
3861 * @arg TIM_DMABASE_DIER
\r
3862 * @arg TIM_DMABASE_SR
\r
3863 * @arg TIM_DMABASE_EGR
\r
3864 * @arg TIM_DMABASE_CCMR1
\r
3865 * @arg TIM_DMABASE_CCMR2
\r
3866 * @arg TIM_DMABASE_CCER
\r
3867 * @arg TIM_DMABASE_CNT
\r
3868 * @arg TIM_DMABASE_PSC
\r
3869 * @arg TIM_DMABASE_ARR
\r
3870 * @arg TIM_DMABASE_RCR
\r
3871 * @arg TIM_DMABASE_CCR1
\r
3872 * @arg TIM_DMABASE_CCR2
\r
3873 * @arg TIM_DMABASE_CCR3
\r
3874 * @arg TIM_DMABASE_CCR4
\r
3875 * @arg TIM_DMABASE_BDTR
\r
3876 * @arg TIM_DMABASE_OR1
\r
3877 * @arg TIM_DMABASE_CCMR3
\r
3878 * @arg TIM_DMABASE_CCR5
\r
3879 * @arg TIM_DMABASE_CCR6
\r
3880 * @arg TIM_DMABASE_OR2
\r
3881 * @arg TIM_DMABASE_OR3
\r
3882 * @param BurstRequestSrc TIM DMA Request sources
\r
3883 * This parameter can be one of the following values:
\r
3884 * @arg TIM_DMA_UPDATE: TIM update Interrupt source
\r
3885 * @arg TIM_DMA_CC1: TIM Capture Compare 1 DMA source
\r
3886 * @arg TIM_DMA_CC2: TIM Capture Compare 2 DMA source
\r
3887 * @arg TIM_DMA_CC3: TIM Capture Compare 3 DMA source
\r
3888 * @arg TIM_DMA_CC4: TIM Capture Compare 4 DMA source
\r
3889 * @arg TIM_DMA_COM: TIM Commutation DMA source
\r
3890 * @arg TIM_DMA_TRIGGER: TIM Trigger DMA source
\r
3891 * @param BurstBuffer The Buffer address.
\r
3892 * @param BurstLength DMA Burst length. This parameter can be one value
\r
3893 * between: TIM_DMABURSTLENGTH_1TRANSFER and TIM_DMABURSTLENGTH_18TRANSFERS.
\r
3894 * @note This function should be used only when BurstLength is equal to DMA data transfer length.
\r
3895 * @retval HAL status
\r
3897 HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress, uint32_t BurstRequestSrc,
\r
3898 uint32_t *BurstBuffer, uint32_t BurstLength)
\r
3900 /* Check the parameters */
\r
3901 assert_param(IS_TIM_DMABURST_INSTANCE(htim->Instance));
\r
3902 assert_param(IS_TIM_DMA_BASE(BurstBaseAddress));
\r
3903 assert_param(IS_TIM_DMA_SOURCE(BurstRequestSrc));
\r
3904 assert_param(IS_TIM_DMA_LENGTH(BurstLength));
\r
3906 if ((htim->State == HAL_TIM_STATE_BUSY))
\r
3910 else if ((htim->State == HAL_TIM_STATE_READY))
\r
3912 if ((BurstBuffer == NULL) && (BurstLength > 0U))
\r
3918 htim->State = HAL_TIM_STATE_BUSY;
\r
3923 /* nothing to do */
\r
3925 switch (BurstRequestSrc)
\r
3927 case TIM_DMA_UPDATE:
\r
3929 /* Set the DMA Period elapsed callbacks */
\r
3930 htim->hdma[TIM_DMA_ID_UPDATE]->XferCpltCallback = TIM_DMAPeriodElapsedCplt;
\r
3931 htim->hdma[TIM_DMA_ID_UPDATE]->XferHalfCpltCallback = TIM_DMAPeriodElapsedHalfCplt;
\r
3933 /* Set the DMA error callback */
\r
3934 htim->hdma[TIM_DMA_ID_UPDATE]->XferErrorCallback = TIM_DMAError ;
\r
3936 /* Enable the DMA channel */
\r
3937 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_UPDATE], (uint32_t)BurstBuffer, (uint32_t)&htim->Instance->DMAR, ((BurstLength) >> 8U) + 1U) != HAL_OK)
\r
3945 /* Set the DMA compare callbacks */
\r
3946 htim->hdma[TIM_DMA_ID_CC1]->XferCpltCallback = TIM_DMADelayPulseCplt;
\r
3947 htim->hdma[TIM_DMA_ID_CC1]->XferHalfCpltCallback = TIM_DMADelayPulseHalfCplt;
\r
3949 /* Set the DMA error callback */
\r
3950 htim->hdma[TIM_DMA_ID_CC1]->XferErrorCallback = TIM_DMAError ;
\r
3952 /* Enable the DMA channel */
\r
3953 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)BurstBuffer,
\r
3954 (uint32_t)&htim->Instance->DMAR, ((BurstLength) >> 8U) + 1U) != HAL_OK)
\r
3962 /* Set the DMA compare callbacks */
\r
3963 htim->hdma[TIM_DMA_ID_CC2]->XferCpltCallback = TIM_DMADelayPulseCplt;
\r
3964 htim->hdma[TIM_DMA_ID_CC2]->XferHalfCpltCallback = TIM_DMADelayPulseHalfCplt;
\r
3966 /* Set the DMA error callback */
\r
3967 htim->hdma[TIM_DMA_ID_CC2]->XferErrorCallback = TIM_DMAError ;
\r
3969 /* Enable the DMA channel */
\r
3970 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)BurstBuffer,
\r
3971 (uint32_t)&htim->Instance->DMAR, ((BurstLength) >> 8U) + 1U) != HAL_OK)
\r
3979 /* Set the DMA compare callbacks */
\r
3980 htim->hdma[TIM_DMA_ID_CC3]->XferCpltCallback = TIM_DMADelayPulseCplt;
\r
3981 htim->hdma[TIM_DMA_ID_CC3]->XferHalfCpltCallback = TIM_DMADelayPulseHalfCplt;
\r
3983 /* Set the DMA error callback */
\r
3984 htim->hdma[TIM_DMA_ID_CC3]->XferErrorCallback = TIM_DMAError ;
\r
3986 /* Enable the DMA channel */
\r
3987 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC3], (uint32_t)BurstBuffer,
\r
3988 (uint32_t)&htim->Instance->DMAR, ((BurstLength) >> 8U) + 1U) != HAL_OK)
\r
3996 /* Set the DMA compare callbacks */
\r
3997 htim->hdma[TIM_DMA_ID_CC4]->XferCpltCallback = TIM_DMADelayPulseCplt;
\r
3998 htim->hdma[TIM_DMA_ID_CC4]->XferHalfCpltCallback = TIM_DMADelayPulseHalfCplt;
\r
4000 /* Set the DMA error callback */
\r
4001 htim->hdma[TIM_DMA_ID_CC4]->XferErrorCallback = TIM_DMAError ;
\r
4003 /* Enable the DMA channel */
\r
4004 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC4], (uint32_t)BurstBuffer,
\r
4005 (uint32_t)&htim->Instance->DMAR, ((BurstLength) >> 8U) + 1U) != HAL_OK)
\r
4013 /* Set the DMA commutation callbacks */
\r
4014 htim->hdma[TIM_DMA_ID_COMMUTATION]->XferCpltCallback = TIMEx_DMACommutationCplt;
\r
4015 htim->hdma[TIM_DMA_ID_COMMUTATION]->XferHalfCpltCallback = TIMEx_DMACommutationHalfCplt;
\r
4017 /* Set the DMA error callback */
\r
4018 htim->hdma[TIM_DMA_ID_COMMUTATION]->XferErrorCallback = TIM_DMAError ;
\r
4020 /* Enable the DMA channel */
\r
4021 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_COMMUTATION], (uint32_t)BurstBuffer,
\r
4022 (uint32_t)&htim->Instance->DMAR, ((BurstLength) >> 8U) + 1U) != HAL_OK)
\r
4028 case TIM_DMA_TRIGGER:
\r
4030 /* Set the DMA trigger callbacks */
\r
4031 htim->hdma[TIM_DMA_ID_TRIGGER]->XferCpltCallback = TIM_DMATriggerCplt;
\r
4032 htim->hdma[TIM_DMA_ID_TRIGGER]->XferHalfCpltCallback = TIM_DMATriggerHalfCplt;
\r
4034 /* Set the DMA error callback */
\r
4035 htim->hdma[TIM_DMA_ID_TRIGGER]->XferErrorCallback = TIM_DMAError ;
\r
4037 /* Enable the DMA channel */
\r
4038 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_TRIGGER], (uint32_t)BurstBuffer,
\r
4039 (uint32_t)&htim->Instance->DMAR, ((BurstLength) >> 8U) + 1U) != HAL_OK)
\r
4048 /* configure the DMA Burst Mode */
\r
4049 htim->Instance->DCR = (BurstBaseAddress | BurstLength);
\r
4051 /* Enable the TIM DMA Request */
\r
4052 __HAL_TIM_ENABLE_DMA(htim, BurstRequestSrc);
\r
4054 htim->State = HAL_TIM_STATE_READY;
\r
4056 /* Return function status */
\r
4061 * @brief Stops the TIM DMA Burst mode
\r
4062 * @param htim TIM handle
\r
4063 * @param BurstRequestSrc TIM DMA Request sources to disable
\r
4064 * @retval HAL status
\r
4066 HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStop(TIM_HandleTypeDef *htim, uint32_t BurstRequestSrc)
\r
4068 HAL_StatusTypeDef status = HAL_OK;
\r
4069 /* Check the parameters */
\r
4070 assert_param(IS_TIM_DMA_SOURCE(BurstRequestSrc));
\r
4072 /* Abort the DMA transfer (at least disable the DMA channel) */
\r
4073 switch (BurstRequestSrc)
\r
4075 case TIM_DMA_UPDATE:
\r
4077 status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_UPDATE]);
\r
4082 status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC1]);
\r
4087 status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC2]);
\r
4092 status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC3]);
\r
4097 status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC4]);
\r
4102 status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_COMMUTATION]);
\r
4105 case TIM_DMA_TRIGGER:
\r
4107 status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_TRIGGER]);
\r
4114 if (HAL_OK == status)
\r
4116 /* Disable the TIM Update DMA request */
\r
4117 __HAL_TIM_DISABLE_DMA(htim, BurstRequestSrc);
\r
4120 /* Return function status */
\r
4125 * @brief Configure the DMA Burst to transfer Data from the TIM peripheral to the memory
\r
4126 * @param htim TIM handle
\r
4127 * @param BurstBaseAddress TIM Base address from where the DMA will start the Data read
\r
4128 * This parameter can be one of the following values:
\r
4129 * @arg TIM_DMABASE_CR1
\r
4130 * @arg TIM_DMABASE_CR2
\r
4131 * @arg TIM_DMABASE_SMCR
\r
4132 * @arg TIM_DMABASE_DIER
\r
4133 * @arg TIM_DMABASE_SR
\r
4134 * @arg TIM_DMABASE_EGR
\r
4135 * @arg TIM_DMABASE_CCMR1
\r
4136 * @arg TIM_DMABASE_CCMR2
\r
4137 * @arg TIM_DMABASE_CCER
\r
4138 * @arg TIM_DMABASE_CNT
\r
4139 * @arg TIM_DMABASE_PSC
\r
4140 * @arg TIM_DMABASE_ARR
\r
4141 * @arg TIM_DMABASE_RCR
\r
4142 * @arg TIM_DMABASE_CCR1
\r
4143 * @arg TIM_DMABASE_CCR2
\r
4144 * @arg TIM_DMABASE_CCR3
\r
4145 * @arg TIM_DMABASE_CCR4
\r
4146 * @arg TIM_DMABASE_BDTR
\r
4147 * @arg TIM_DMABASE_OR1
\r
4148 * @arg TIM_DMABASE_CCMR3
\r
4149 * @arg TIM_DMABASE_CCR5
\r
4150 * @arg TIM_DMABASE_CCR6
\r
4151 * @arg TIM_DMABASE_OR2
\r
4152 * @arg TIM_DMABASE_OR3
\r
4153 * @param BurstRequestSrc TIM DMA Request sources
\r
4154 * This parameter can be one of the following values:
\r
4155 * @arg TIM_DMA_UPDATE: TIM update Interrupt source
\r
4156 * @arg TIM_DMA_CC1: TIM Capture Compare 1 DMA source
\r
4157 * @arg TIM_DMA_CC2: TIM Capture Compare 2 DMA source
\r
4158 * @arg TIM_DMA_CC3: TIM Capture Compare 3 DMA source
\r
4159 * @arg TIM_DMA_CC4: TIM Capture Compare 4 DMA source
\r
4160 * @arg TIM_DMA_COM: TIM Commutation DMA source
\r
4161 * @arg TIM_DMA_TRIGGER: TIM Trigger DMA source
\r
4162 * @param BurstBuffer The Buffer address.
\r
4163 * @param BurstLength DMA Burst length. This parameter can be one value
\r
4164 * between: TIM_DMABURSTLENGTH_1TRANSFER and TIM_DMABURSTLENGTH_18TRANSFERS.
\r
4165 * @note This function should be used only when BurstLength is equal to DMA data transfer length.
\r
4166 * @retval HAL status
\r
4168 HAL_StatusTypeDef HAL_TIM_DMABurst_ReadStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress,
\r
4169 uint32_t BurstRequestSrc, uint32_t *BurstBuffer, uint32_t BurstLength)
\r
4171 /* Check the parameters */
\r
4172 assert_param(IS_TIM_DMABURST_INSTANCE(htim->Instance));
\r
4173 assert_param(IS_TIM_DMA_BASE(BurstBaseAddress));
\r
4174 assert_param(IS_TIM_DMA_SOURCE(BurstRequestSrc));
\r
4175 assert_param(IS_TIM_DMA_LENGTH(BurstLength));
\r
4177 if ((htim->State == HAL_TIM_STATE_BUSY))
\r
4181 else if ((htim->State == HAL_TIM_STATE_READY))
\r
4183 if ((BurstBuffer == NULL) && (BurstLength > 0U))
\r
4189 htim->State = HAL_TIM_STATE_BUSY;
\r
4194 /* nothing to do */
\r
4196 switch (BurstRequestSrc)
\r
4198 case TIM_DMA_UPDATE:
\r
4200 /* Set the DMA Period elapsed callbacks */
\r
4201 htim->hdma[TIM_DMA_ID_UPDATE]->XferCpltCallback = TIM_DMAPeriodElapsedCplt;
\r
4202 htim->hdma[TIM_DMA_ID_UPDATE]->XferHalfCpltCallback = TIM_DMAPeriodElapsedHalfCplt;
\r
4204 /* Set the DMA error callback */
\r
4205 htim->hdma[TIM_DMA_ID_UPDATE]->XferErrorCallback = TIM_DMAError ;
\r
4207 /* Enable the DMA channel */
\r
4208 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_UPDATE], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer, ((BurstLength) >> 8U) + 1U) != HAL_OK)
\r
4216 /* Set the DMA capture callbacks */
\r
4217 htim->hdma[TIM_DMA_ID_CC1]->XferCpltCallback = TIM_DMACaptureCplt;
\r
4218 htim->hdma[TIM_DMA_ID_CC1]->XferHalfCpltCallback = TIM_DMACaptureHalfCplt;
\r
4220 /* Set the DMA error callback */
\r
4221 htim->hdma[TIM_DMA_ID_CC1]->XferErrorCallback = TIM_DMAError ;
\r
4223 /* Enable the DMA channel */
\r
4224 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer, ((BurstLength) >> 8U) + 1U) != HAL_OK)
\r
4232 /* Set the DMA capture/compare callbacks */
\r
4233 htim->hdma[TIM_DMA_ID_CC2]->XferCpltCallback = TIM_DMACaptureCplt;
\r
4234 htim->hdma[TIM_DMA_ID_CC2]->XferHalfCpltCallback = TIM_DMACaptureHalfCplt;
\r
4236 /* Set the DMA error callback */
\r
4237 htim->hdma[TIM_DMA_ID_CC2]->XferErrorCallback = TIM_DMAError ;
\r
4239 /* Enable the DMA channel */
\r
4240 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer, ((BurstLength) >> 8U) + 1U) != HAL_OK)
\r
4248 /* Set the DMA capture callbacks */
\r
4249 htim->hdma[TIM_DMA_ID_CC3]->XferCpltCallback = TIM_DMACaptureCplt;
\r
4250 htim->hdma[TIM_DMA_ID_CC3]->XferHalfCpltCallback = TIM_DMACaptureHalfCplt;
\r
4252 /* Set the DMA error callback */
\r
4253 htim->hdma[TIM_DMA_ID_CC3]->XferErrorCallback = TIM_DMAError ;
\r
4255 /* Enable the DMA channel */
\r
4256 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC3], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer, ((BurstLength) >> 8U) + 1U) != HAL_OK)
\r
4264 /* Set the DMA capture callbacks */
\r
4265 htim->hdma[TIM_DMA_ID_CC4]->XferCpltCallback = TIM_DMACaptureCplt;
\r
4266 htim->hdma[TIM_DMA_ID_CC4]->XferHalfCpltCallback = TIM_DMACaptureHalfCplt;
\r
4268 /* Set the DMA error callback */
\r
4269 htim->hdma[TIM_DMA_ID_CC4]->XferErrorCallback = TIM_DMAError ;
\r
4271 /* Enable the DMA channel */
\r
4272 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC4], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer, ((BurstLength) >> 8U) + 1U) != HAL_OK)
\r
4280 /* Set the DMA commutation callbacks */
\r
4281 htim->hdma[TIM_DMA_ID_COMMUTATION]->XferCpltCallback = TIMEx_DMACommutationCplt;
\r
4282 htim->hdma[TIM_DMA_ID_COMMUTATION]->XferHalfCpltCallback = TIMEx_DMACommutationHalfCplt;
\r
4284 /* Set the DMA error callback */
\r
4285 htim->hdma[TIM_DMA_ID_COMMUTATION]->XferErrorCallback = TIM_DMAError ;
\r
4287 /* Enable the DMA channel */
\r
4288 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_COMMUTATION], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer, ((BurstLength) >> 8U) + 1U) != HAL_OK)
\r
4294 case TIM_DMA_TRIGGER:
\r
4296 /* Set the DMA trigger callbacks */
\r
4297 htim->hdma[TIM_DMA_ID_TRIGGER]->XferCpltCallback = TIM_DMATriggerCplt;
\r
4298 htim->hdma[TIM_DMA_ID_TRIGGER]->XferHalfCpltCallback = TIM_DMATriggerHalfCplt;
\r
4300 /* Set the DMA error callback */
\r
4301 htim->hdma[TIM_DMA_ID_TRIGGER]->XferErrorCallback = TIM_DMAError ;
\r
4303 /* Enable the DMA channel */
\r
4304 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_TRIGGER], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer, ((BurstLength) >> 8U) + 1U) != HAL_OK)
\r
4314 /* configure the DMA Burst Mode */
\r
4315 htim->Instance->DCR = (BurstBaseAddress | BurstLength);
\r
4317 /* Enable the TIM DMA Request */
\r
4318 __HAL_TIM_ENABLE_DMA(htim, BurstRequestSrc);
\r
4320 htim->State = HAL_TIM_STATE_READY;
\r
4322 /* Return function status */
\r
4327 * @brief Stop the DMA burst reading
\r
4328 * @param htim TIM handle
\r
4329 * @param BurstRequestSrc TIM DMA Request sources to disable.
\r
4330 * @retval HAL status
\r
4332 HAL_StatusTypeDef HAL_TIM_DMABurst_ReadStop(TIM_HandleTypeDef *htim, uint32_t BurstRequestSrc)
\r
4334 HAL_StatusTypeDef status = HAL_OK;
\r
4335 /* Check the parameters */
\r
4336 assert_param(IS_TIM_DMA_SOURCE(BurstRequestSrc));
\r
4338 /* Abort the DMA transfer (at least disable the DMA channel) */
\r
4339 switch (BurstRequestSrc)
\r
4341 case TIM_DMA_UPDATE:
\r
4343 status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_UPDATE]);
\r
4348 status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC1]);
\r
4353 status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC2]);
\r
4358 status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC3]);
\r
4363 status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC4]);
\r
4368 status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_COMMUTATION]);
\r
4371 case TIM_DMA_TRIGGER:
\r
4373 status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_TRIGGER]);
\r
4380 if (HAL_OK == status)
\r
4382 /* Disable the TIM Update DMA request */
\r
4383 __HAL_TIM_DISABLE_DMA(htim, BurstRequestSrc);
\r
4386 /* Return function status */
\r
4391 * @brief Generate a software event
\r
4392 * @param htim TIM handle
\r
4393 * @param EventSource specifies the event source.
\r
4394 * This parameter can be one of the following values:
\r
4395 * @arg TIM_EVENTSOURCE_UPDATE: Timer update Event source
\r
4396 * @arg TIM_EVENTSOURCE_CC1: Timer Capture Compare 1 Event source
\r
4397 * @arg TIM_EVENTSOURCE_CC2: Timer Capture Compare 2 Event source
\r
4398 * @arg TIM_EVENTSOURCE_CC3: Timer Capture Compare 3 Event source
\r
4399 * @arg TIM_EVENTSOURCE_CC4: Timer Capture Compare 4 Event source
\r
4400 * @arg TIM_EVENTSOURCE_COM: Timer COM event source
\r
4401 * @arg TIM_EVENTSOURCE_TRIGGER: Timer Trigger Event source
\r
4402 * @arg TIM_EVENTSOURCE_BREAK: Timer Break event source
\r
4403 * @arg TIM_EVENTSOURCE_BREAK2: Timer Break2 event source
\r
4404 * @note Basic timers can only generate an update event.
\r
4405 * @note TIM_EVENTSOURCE_COM is relevant only with advanced timer instances.
\r
4406 * @note TIM_EVENTSOURCE_BREAK and TIM_EVENTSOURCE_BREAK2 are relevant
\r
4407 * only for timer instances supporting break input(s).
\r
4408 * @retval HAL status
\r
4411 HAL_StatusTypeDef HAL_TIM_GenerateEvent(TIM_HandleTypeDef *htim, uint32_t EventSource)
\r
4413 /* Check the parameters */
\r
4414 assert_param(IS_TIM_INSTANCE(htim->Instance));
\r
4415 assert_param(IS_TIM_EVENT_SOURCE(EventSource));
\r
4417 /* Process Locked */
\r
4420 /* Change the TIM state */
\r
4421 htim->State = HAL_TIM_STATE_BUSY;
\r
4423 /* Set the event sources */
\r
4424 htim->Instance->EGR = EventSource;
\r
4426 /* Change the TIM state */
\r
4427 htim->State = HAL_TIM_STATE_READY;
\r
4429 __HAL_UNLOCK(htim);
\r
4431 /* Return function status */
\r
4436 * @brief Configures the OCRef clear feature
\r
4437 * @param htim TIM handle
\r
4438 * @param sClearInputConfig pointer to a TIM_ClearInputConfigTypeDef structure that
\r
4439 * contains the OCREF clear feature and parameters for the TIM peripheral.
\r
4440 * @param Channel specifies the TIM Channel
\r
4441 * This parameter can be one of the following values:
\r
4442 * @arg TIM_CHANNEL_1: TIM Channel 1
\r
4443 * @arg TIM_CHANNEL_2: TIM Channel 2
\r
4444 * @arg TIM_CHANNEL_3: TIM Channel 3
\r
4445 * @arg TIM_CHANNEL_4: TIM Channel 4
\r
4446 * @arg TIM_CHANNEL_5: TIM Channel 5
\r
4447 * @arg TIM_CHANNEL_6: TIM Channel 6
\r
4448 * @retval HAL status
\r
4450 HAL_StatusTypeDef HAL_TIM_ConfigOCrefClear(TIM_HandleTypeDef *htim,
\r
4451 TIM_ClearInputConfigTypeDef *sClearInputConfig,
\r
4454 /* Check the parameters */
\r
4455 assert_param(IS_TIM_OCXREF_CLEAR_INSTANCE(htim->Instance));
\r
4456 assert_param(IS_TIM_CLEARINPUT_SOURCE(sClearInputConfig->ClearInputSource));
\r
4458 /* Process Locked */
\r
4461 htim->State = HAL_TIM_STATE_BUSY;
\r
4463 switch (sClearInputConfig->ClearInputSource)
\r
4465 case TIM_CLEARINPUTSOURCE_NONE:
\r
4467 /* Clear the OCREF clear selection bit and the the ETR Bits */
\r
4468 CLEAR_BIT(htim->Instance->SMCR, (TIM_SMCR_OCCS | TIM_SMCR_ETF | TIM_SMCR_ETPS | TIM_SMCR_ECE | TIM_SMCR_ETP));
\r
4471 case TIM_CLEARINPUTSOURCE_OCREFCLR:
\r
4473 /* Clear the OCREF clear selection bit */
\r
4474 CLEAR_BIT(htim->Instance->SMCR, TIM_SMCR_OCCS);
\r
4478 case TIM_CLEARINPUTSOURCE_ETR:
\r
4480 /* Check the parameters */
\r
4481 assert_param(IS_TIM_CLEARINPUT_POLARITY(sClearInputConfig->ClearInputPolarity));
\r
4482 assert_param(IS_TIM_CLEARINPUT_PRESCALER(sClearInputConfig->ClearInputPrescaler));
\r
4483 assert_param(IS_TIM_CLEARINPUT_FILTER(sClearInputConfig->ClearInputFilter));
\r
4485 /* When OCRef clear feature is used with ETR source, ETR prescaler must be off */
\r
4486 if (sClearInputConfig->ClearInputPrescaler != TIM_CLEARINPUTPRESCALER_DIV1)
\r
4488 htim->State = HAL_TIM_STATE_READY;
\r
4489 __HAL_UNLOCK(htim);
\r
4493 TIM_ETR_SetConfig(htim->Instance,
\r
4494 sClearInputConfig->ClearInputPrescaler,
\r
4495 sClearInputConfig->ClearInputPolarity,
\r
4496 sClearInputConfig->ClearInputFilter);
\r
4498 /* Set the OCREF clear selection bit */
\r
4499 SET_BIT(htim->Instance->SMCR, TIM_SMCR_OCCS);
\r
4509 case TIM_CHANNEL_1:
\r
4511 if (sClearInputConfig->ClearInputState != (uint32_t)DISABLE)
\r
4513 /* Enable the OCREF clear feature for Channel 1 */
\r
4514 SET_BIT(htim->Instance->CCMR1, TIM_CCMR1_OC1CE);
\r
4518 /* Disable the OCREF clear feature for Channel 1 */
\r
4519 CLEAR_BIT(htim->Instance->CCMR1, TIM_CCMR1_OC1CE);
\r
4523 case TIM_CHANNEL_2:
\r
4525 if (sClearInputConfig->ClearInputState != (uint32_t)DISABLE)
\r
4527 /* Enable the OCREF clear feature for Channel 2 */
\r
4528 SET_BIT(htim->Instance->CCMR1, TIM_CCMR1_OC2CE);
\r
4532 /* Disable the OCREF clear feature for Channel 2 */
\r
4533 CLEAR_BIT(htim->Instance->CCMR1, TIM_CCMR1_OC2CE);
\r
4537 case TIM_CHANNEL_3:
\r
4539 if (sClearInputConfig->ClearInputState != (uint32_t)DISABLE)
\r
4541 /* Enable the OCREF clear feature for Channel 3 */
\r
4542 SET_BIT(htim->Instance->CCMR2, TIM_CCMR2_OC3CE);
\r
4546 /* Disable the OCREF clear feature for Channel 3 */
\r
4547 CLEAR_BIT(htim->Instance->CCMR2, TIM_CCMR2_OC3CE);
\r
4551 case TIM_CHANNEL_4:
\r
4553 if (sClearInputConfig->ClearInputState != (uint32_t)DISABLE)
\r
4555 /* Enable the OCREF clear feature for Channel 4 */
\r
4556 SET_BIT(htim->Instance->CCMR2, TIM_CCMR2_OC4CE);
\r
4560 /* Disable the OCREF clear feature for Channel 4 */
\r
4561 CLEAR_BIT(htim->Instance->CCMR2, TIM_CCMR2_OC4CE);
\r
4565 case TIM_CHANNEL_5:
\r
4567 if (sClearInputConfig->ClearInputState != (uint32_t)DISABLE)
\r
4569 /* Enable the OCREF clear feature for Channel 5 */
\r
4570 SET_BIT(htim->Instance->CCMR3, TIM_CCMR3_OC5CE);
\r
4574 /* Disable the OCREF clear feature for Channel 5 */
\r
4575 CLEAR_BIT(htim->Instance->CCMR3, TIM_CCMR3_OC5CE);
\r
4579 case TIM_CHANNEL_6:
\r
4581 if (sClearInputConfig->ClearInputState != (uint32_t)DISABLE)
\r
4583 /* Enable the OCREF clear feature for Channel 6 */
\r
4584 SET_BIT(htim->Instance->CCMR3, TIM_CCMR3_OC6CE);
\r
4588 /* Disable the OCREF clear feature for Channel 6 */
\r
4589 CLEAR_BIT(htim->Instance->CCMR3, TIM_CCMR3_OC6CE);
\r
4597 htim->State = HAL_TIM_STATE_READY;
\r
4599 __HAL_UNLOCK(htim);
\r
4605 * @brief Configures the clock source to be used
\r
4606 * @param htim TIM handle
\r
4607 * @param sClockSourceConfig pointer to a TIM_ClockConfigTypeDef structure that
\r
4608 * contains the clock source information for the TIM peripheral.
\r
4609 * @retval HAL status
\r
4611 HAL_StatusTypeDef HAL_TIM_ConfigClockSource(TIM_HandleTypeDef *htim, TIM_ClockConfigTypeDef *sClockSourceConfig)
\r
4615 /* Process Locked */
\r
4618 htim->State = HAL_TIM_STATE_BUSY;
\r
4620 /* Check the parameters */
\r
4621 assert_param(IS_TIM_CLOCKSOURCE(sClockSourceConfig->ClockSource));
\r
4623 /* Reset the SMS, TS, ECE, ETPS and ETRF bits */
\r
4624 tmpsmcr = htim->Instance->SMCR;
\r
4625 tmpsmcr &= ~(TIM_SMCR_SMS | TIM_SMCR_TS);
\r
4626 tmpsmcr &= ~(TIM_SMCR_ETF | TIM_SMCR_ETPS | TIM_SMCR_ECE | TIM_SMCR_ETP);
\r
4627 htim->Instance->SMCR = tmpsmcr;
\r
4629 switch (sClockSourceConfig->ClockSource)
\r
4631 case TIM_CLOCKSOURCE_INTERNAL:
\r
4633 assert_param(IS_TIM_INSTANCE(htim->Instance));
\r
4637 case TIM_CLOCKSOURCE_ETRMODE1:
\r
4639 /* Check whether or not the timer instance supports external trigger input mode 1 (ETRF)*/
\r
4640 assert_param(IS_TIM_CLOCKSOURCE_ETRMODE1_INSTANCE(htim->Instance));
\r
4642 /* Check ETR input conditioning related parameters */
\r
4643 assert_param(IS_TIM_CLOCKPRESCALER(sClockSourceConfig->ClockPrescaler));
\r
4644 assert_param(IS_TIM_CLOCKPOLARITY(sClockSourceConfig->ClockPolarity));
\r
4645 assert_param(IS_TIM_CLOCKFILTER(sClockSourceConfig->ClockFilter));
\r
4647 /* Configure the ETR Clock source */
\r
4648 TIM_ETR_SetConfig(htim->Instance,
\r
4649 sClockSourceConfig->ClockPrescaler,
\r
4650 sClockSourceConfig->ClockPolarity,
\r
4651 sClockSourceConfig->ClockFilter);
\r
4653 /* Select the External clock mode1 and the ETRF trigger */
\r
4654 tmpsmcr = htim->Instance->SMCR;
\r
4655 tmpsmcr |= (TIM_SLAVEMODE_EXTERNAL1 | TIM_CLOCKSOURCE_ETRMODE1);
\r
4656 /* Write to TIMx SMCR */
\r
4657 htim->Instance->SMCR = tmpsmcr;
\r
4661 case TIM_CLOCKSOURCE_ETRMODE2:
\r
4663 /* Check whether or not the timer instance supports external trigger input mode 2 (ETRF)*/
\r
4664 assert_param(IS_TIM_CLOCKSOURCE_ETRMODE2_INSTANCE(htim->Instance));
\r
4666 /* Check ETR input conditioning related parameters */
\r
4667 assert_param(IS_TIM_CLOCKPRESCALER(sClockSourceConfig->ClockPrescaler));
\r
4668 assert_param(IS_TIM_CLOCKPOLARITY(sClockSourceConfig->ClockPolarity));
\r
4669 assert_param(IS_TIM_CLOCKFILTER(sClockSourceConfig->ClockFilter));
\r
4671 /* Configure the ETR Clock source */
\r
4672 TIM_ETR_SetConfig(htim->Instance,
\r
4673 sClockSourceConfig->ClockPrescaler,
\r
4674 sClockSourceConfig->ClockPolarity,
\r
4675 sClockSourceConfig->ClockFilter);
\r
4676 /* Enable the External clock mode2 */
\r
4677 htim->Instance->SMCR |= TIM_SMCR_ECE;
\r
4681 case TIM_CLOCKSOURCE_TI1:
\r
4683 /* Check whether or not the timer instance supports external clock mode 1 */
\r
4684 assert_param(IS_TIM_CLOCKSOURCE_TIX_INSTANCE(htim->Instance));
\r
4686 /* Check TI1 input conditioning related parameters */
\r
4687 assert_param(IS_TIM_CLOCKPOLARITY(sClockSourceConfig->ClockPolarity));
\r
4688 assert_param(IS_TIM_CLOCKFILTER(sClockSourceConfig->ClockFilter));
\r
4690 TIM_TI1_ConfigInputStage(htim->Instance,
\r
4691 sClockSourceConfig->ClockPolarity,
\r
4692 sClockSourceConfig->ClockFilter);
\r
4693 TIM_ITRx_SetConfig(htim->Instance, TIM_CLOCKSOURCE_TI1);
\r
4697 case TIM_CLOCKSOURCE_TI2:
\r
4699 /* Check whether or not the timer instance supports external clock mode 1 (ETRF)*/
\r
4700 assert_param(IS_TIM_CLOCKSOURCE_TIX_INSTANCE(htim->Instance));
\r
4702 /* Check TI2 input conditioning related parameters */
\r
4703 assert_param(IS_TIM_CLOCKPOLARITY(sClockSourceConfig->ClockPolarity));
\r
4704 assert_param(IS_TIM_CLOCKFILTER(sClockSourceConfig->ClockFilter));
\r
4706 TIM_TI2_ConfigInputStage(htim->Instance,
\r
4707 sClockSourceConfig->ClockPolarity,
\r
4708 sClockSourceConfig->ClockFilter);
\r
4709 TIM_ITRx_SetConfig(htim->Instance, TIM_CLOCKSOURCE_TI2);
\r
4713 case TIM_CLOCKSOURCE_TI1ED:
\r
4715 /* Check whether or not the timer instance supports external clock mode 1 */
\r
4716 assert_param(IS_TIM_CLOCKSOURCE_TIX_INSTANCE(htim->Instance));
\r
4718 /* Check TI1 input conditioning related parameters */
\r
4719 assert_param(IS_TIM_CLOCKPOLARITY(sClockSourceConfig->ClockPolarity));
\r
4720 assert_param(IS_TIM_CLOCKFILTER(sClockSourceConfig->ClockFilter));
\r
4722 TIM_TI1_ConfigInputStage(htim->Instance,
\r
4723 sClockSourceConfig->ClockPolarity,
\r
4724 sClockSourceConfig->ClockFilter);
\r
4725 TIM_ITRx_SetConfig(htim->Instance, TIM_CLOCKSOURCE_TI1ED);
\r
4729 case TIM_CLOCKSOURCE_ITR0:
\r
4730 case TIM_CLOCKSOURCE_ITR1:
\r
4731 case TIM_CLOCKSOURCE_ITR2:
\r
4732 case TIM_CLOCKSOURCE_ITR3:
\r
4734 /* Check whether or not the timer instance supports internal trigger input */
\r
4735 assert_param(IS_TIM_CLOCKSOURCE_ITRX_INSTANCE(htim->Instance));
\r
4737 TIM_ITRx_SetConfig(htim->Instance, sClockSourceConfig->ClockSource);
\r
4744 htim->State = HAL_TIM_STATE_READY;
\r
4746 __HAL_UNLOCK(htim);
\r
4752 * @brief Selects the signal connected to the TI1 input: direct from CH1_input
\r
4753 * or a XOR combination between CH1_input, CH2_input & CH3_input
\r
4754 * @param htim TIM handle.
\r
4755 * @param TI1_Selection Indicate whether or not channel 1 is connected to the
\r
4756 * output of a XOR gate.
\r
4757 * This parameter can be one of the following values:
\r
4758 * @arg TIM_TI1SELECTION_CH1: The TIMx_CH1 pin is connected to TI1 input
\r
4759 * @arg TIM_TI1SELECTION_XORCOMBINATION: The TIMx_CH1, CH2 and CH3
\r
4760 * pins are connected to the TI1 input (XOR combination)
\r
4761 * @retval HAL status
\r
4763 HAL_StatusTypeDef HAL_TIM_ConfigTI1Input(TIM_HandleTypeDef *htim, uint32_t TI1_Selection)
\r
4767 /* Check the parameters */
\r
4768 assert_param(IS_TIM_XOR_INSTANCE(htim->Instance));
\r
4769 assert_param(IS_TIM_TI1SELECTION(TI1_Selection));
\r
4771 /* Get the TIMx CR2 register value */
\r
4772 tmpcr2 = htim->Instance->CR2;
\r
4774 /* Reset the TI1 selection */
\r
4775 tmpcr2 &= ~TIM_CR2_TI1S;
\r
4777 /* Set the TI1 selection */
\r
4778 tmpcr2 |= TI1_Selection;
\r
4780 /* Write to TIMxCR2 */
\r
4781 htim->Instance->CR2 = tmpcr2;
\r
4787 * @brief Configures the TIM in Slave mode
\r
4788 * @param htim TIM handle.
\r
4789 * @param sSlaveConfig pointer to a TIM_SlaveConfigTypeDef structure that
\r
4790 * contains the selected trigger (internal trigger input, filtered
\r
4791 * timer input or external trigger input) and the Slave mode
\r
4792 * (Disable, Reset, Gated, Trigger, External clock mode 1).
\r
4793 * @retval HAL status
\r
4795 HAL_StatusTypeDef HAL_TIM_SlaveConfigSynchro(TIM_HandleTypeDef *htim, TIM_SlaveConfigTypeDef *sSlaveConfig)
\r
4797 /* Check the parameters */
\r
4798 assert_param(IS_TIM_SLAVE_INSTANCE(htim->Instance));
\r
4799 assert_param(IS_TIM_SLAVE_MODE(sSlaveConfig->SlaveMode));
\r
4800 assert_param(IS_TIM_TRIGGER_SELECTION(sSlaveConfig->InputTrigger));
\r
4804 htim->State = HAL_TIM_STATE_BUSY;
\r
4806 if (TIM_SlaveTimer_SetConfig(htim, sSlaveConfig) != HAL_OK)
\r
4808 htim->State = HAL_TIM_STATE_READY;
\r
4809 __HAL_UNLOCK(htim);
\r
4813 /* Disable Trigger Interrupt */
\r
4814 __HAL_TIM_DISABLE_IT(htim, TIM_IT_TRIGGER);
\r
4816 /* Disable Trigger DMA request */
\r
4817 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_TRIGGER);
\r
4819 htim->State = HAL_TIM_STATE_READY;
\r
4821 __HAL_UNLOCK(htim);
\r
4827 * @brief Configures the TIM in Slave mode in interrupt mode
\r
4828 * @param htim TIM handle.
\r
4829 * @param sSlaveConfig pointer to a TIM_SlaveConfigTypeDef structure that
\r
4830 * contains the selected trigger (internal trigger input, filtered
\r
4831 * timer input or external trigger input) and the Slave mode
\r
4832 * (Disable, Reset, Gated, Trigger, External clock mode 1).
\r
4833 * @retval HAL status
\r
4835 HAL_StatusTypeDef HAL_TIM_SlaveConfigSynchro_IT(TIM_HandleTypeDef *htim,
\r
4836 TIM_SlaveConfigTypeDef *sSlaveConfig)
\r
4838 /* Check the parameters */
\r
4839 assert_param(IS_TIM_SLAVE_INSTANCE(htim->Instance));
\r
4840 assert_param(IS_TIM_SLAVE_MODE(sSlaveConfig->SlaveMode));
\r
4841 assert_param(IS_TIM_TRIGGER_SELECTION(sSlaveConfig->InputTrigger));
\r
4845 htim->State = HAL_TIM_STATE_BUSY;
\r
4847 if (TIM_SlaveTimer_SetConfig(htim, sSlaveConfig) != HAL_OK)
\r
4849 htim->State = HAL_TIM_STATE_READY;
\r
4850 __HAL_UNLOCK(htim);
\r
4854 /* Enable Trigger Interrupt */
\r
4855 __HAL_TIM_ENABLE_IT(htim, TIM_IT_TRIGGER);
\r
4857 /* Disable Trigger DMA request */
\r
4858 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_TRIGGER);
\r
4860 htim->State = HAL_TIM_STATE_READY;
\r
4862 __HAL_UNLOCK(htim);
\r
4868 * @brief Read the captured value from Capture Compare unit
\r
4869 * @param htim TIM handle.
\r
4870 * @param Channel TIM Channels to be enabled
\r
4871 * This parameter can be one of the following values:
\r
4872 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
4873 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
4874 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
4875 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
\r
4876 * @retval Captured value
\r
4878 uint32_t HAL_TIM_ReadCapturedValue(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
4880 uint32_t tmpreg = 0U;
\r
4884 case TIM_CHANNEL_1:
\r
4886 /* Check the parameters */
\r
4887 assert_param(IS_TIM_CC1_INSTANCE(htim->Instance));
\r
4889 /* Return the capture 1 value */
\r
4890 tmpreg = htim->Instance->CCR1;
\r
4894 case TIM_CHANNEL_2:
\r
4896 /* Check the parameters */
\r
4897 assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
\r
4899 /* Return the capture 2 value */
\r
4900 tmpreg = htim->Instance->CCR2;
\r
4905 case TIM_CHANNEL_3:
\r
4907 /* Check the parameters */
\r
4908 assert_param(IS_TIM_CC3_INSTANCE(htim->Instance));
\r
4910 /* Return the capture 3 value */
\r
4911 tmpreg = htim->Instance->CCR3;
\r
4916 case TIM_CHANNEL_4:
\r
4918 /* Check the parameters */
\r
4919 assert_param(IS_TIM_CC4_INSTANCE(htim->Instance));
\r
4921 /* Return the capture 4 value */
\r
4922 tmpreg = htim->Instance->CCR4;
\r
4938 /** @defgroup TIM_Exported_Functions_Group9 TIM Callbacks functions
\r
4939 * @brief TIM Callbacks functions
\r
4942 ==============================================================================
\r
4943 ##### TIM Callbacks functions #####
\r
4944 ==============================================================================
\r
4946 This section provides TIM callback functions:
\r
4947 (+) TIM Period elapsed callback
\r
4948 (+) TIM Output Compare callback
\r
4949 (+) TIM Input capture callback
\r
4950 (+) TIM Trigger callback
\r
4951 (+) TIM Error callback
\r
4958 * @brief Period elapsed callback in non-blocking mode
\r
4959 * @param htim TIM handle
\r
4962 __weak void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
\r
4964 /* Prevent unused argument(s) compilation warning */
\r
4967 /* NOTE : This function should not be modified, when the callback is needed,
\r
4968 the HAL_TIM_PeriodElapsedCallback could be implemented in the user file
\r
4973 * @brief Period elapsed half complete callback in non-blocking mode
\r
4974 * @param htim TIM handle
\r
4977 __weak void HAL_TIM_PeriodElapsedHalfCpltCallback(TIM_HandleTypeDef *htim)
\r
4979 /* Prevent unused argument(s) compilation warning */
\r
4982 /* NOTE : This function should not be modified, when the callback is needed,
\r
4983 the HAL_TIM_PeriodElapsedHalfCpltCallback could be implemented in the user file
\r
4988 * @brief Output Compare callback in non-blocking mode
\r
4989 * @param htim TIM OC handle
\r
4992 __weak void HAL_TIM_OC_DelayElapsedCallback(TIM_HandleTypeDef *htim)
\r
4994 /* Prevent unused argument(s) compilation warning */
\r
4997 /* NOTE : This function should not be modified, when the callback is needed,
\r
4998 the HAL_TIM_OC_DelayElapsedCallback could be implemented in the user file
\r
5003 * @brief Input Capture callback in non-blocking mode
\r
5004 * @param htim TIM IC handle
\r
5007 __weak void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim)
\r
5009 /* Prevent unused argument(s) compilation warning */
\r
5012 /* NOTE : This function should not be modified, when the callback is needed,
\r
5013 the HAL_TIM_IC_CaptureCallback could be implemented in the user file
\r
5018 * @brief Input Capture half complete callback in non-blocking mode
\r
5019 * @param htim TIM IC handle
\r
5022 __weak void HAL_TIM_IC_CaptureHalfCpltCallback(TIM_HandleTypeDef *htim)
\r
5024 /* Prevent unused argument(s) compilation warning */
\r
5027 /* NOTE : This function should not be modified, when the callback is needed,
\r
5028 the HAL_TIM_IC_CaptureHalfCpltCallback could be implemented in the user file
\r
5033 * @brief PWM Pulse finished callback in non-blocking mode
\r
5034 * @param htim TIM handle
\r
5037 __weak void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim)
\r
5039 /* Prevent unused argument(s) compilation warning */
\r
5042 /* NOTE : This function should not be modified, when the callback is needed,
\r
5043 the HAL_TIM_PWM_PulseFinishedCallback could be implemented in the user file
\r
5048 * @brief PWM Pulse finished half complete callback in non-blocking mode
\r
5049 * @param htim TIM handle
\r
5052 __weak void HAL_TIM_PWM_PulseFinishedHalfCpltCallback(TIM_HandleTypeDef *htim)
\r
5054 /* Prevent unused argument(s) compilation warning */
\r
5057 /* NOTE : This function should not be modified, when the callback is needed,
\r
5058 the HAL_TIM_PWM_PulseFinishedHalfCpltCallback could be implemented in the user file
\r
5063 * @brief Hall Trigger detection callback in non-blocking mode
\r
5064 * @param htim TIM handle
\r
5067 __weak void HAL_TIM_TriggerCallback(TIM_HandleTypeDef *htim)
\r
5069 /* Prevent unused argument(s) compilation warning */
\r
5072 /* NOTE : This function should not be modified, when the callback is needed,
\r
5073 the HAL_TIM_TriggerCallback could be implemented in the user file
\r
5078 * @brief Hall Trigger detection half complete callback in non-blocking mode
\r
5079 * @param htim TIM handle
\r
5082 __weak void HAL_TIM_TriggerHalfCpltCallback(TIM_HandleTypeDef *htim)
\r
5084 /* Prevent unused argument(s) compilation warning */
\r
5087 /* NOTE : This function should not be modified, when the callback is needed,
\r
5088 the HAL_TIM_TriggerHalfCpltCallback could be implemented in the user file
\r
5093 * @brief Timer error callback in non-blocking mode
\r
5094 * @param htim TIM handle
\r
5097 __weak void HAL_TIM_ErrorCallback(TIM_HandleTypeDef *htim)
\r
5099 /* Prevent unused argument(s) compilation warning */
\r
5102 /* NOTE : This function should not be modified, when the callback is needed,
\r
5103 the HAL_TIM_ErrorCallback could be implemented in the user file
\r
5107 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
5109 * @brief Register a User TIM callback to be used instead of the weak predefined callback
\r
5110 * @param htim tim handle
\r
5111 * @param CallbackID ID of the callback to be registered
\r
5112 * This parameter can be one of the following values:
\r
5113 * @arg @ref HAL_TIM_BASE_MSPINIT_CB_ID Base MspInit Callback ID
\r
5114 * @arg @ref HAL_TIM_BASE_MSPDEINIT_CB_ID Base MspDeInit Callback ID
\r
5115 * @arg @ref HAL_TIM_IC_MSPINIT_CB_ID IC MspInit Callback ID
\r
5116 * @arg @ref HAL_TIM_IC_MSPDEINIT_CB_ID IC MspDeInit Callback ID
\r
5117 * @arg @ref HAL_TIM_OC_MSPINIT_CB_ID OC MspInit Callback ID
\r
5118 * @arg @ref HAL_TIM_OC_MSPDEINIT_CB_ID OC MspDeInit Callback ID
\r
5119 * @arg @ref HAL_TIM_PWM_MSPINIT_CB_ID PWM MspInit Callback ID
\r
5120 * @arg @ref HAL_TIM_PWM_MSPDEINIT_CB_ID PWM MspDeInit Callback ID
\r
5121 * @arg @ref HAL_TIM_ONE_PULSE_MSPINIT_CB_ID One Pulse MspInit Callback ID
\r
5122 * @arg @ref HAL_TIM_ONE_PULSE_MSPDEINIT_CB_ID One Pulse MspDeInit Callback ID
\r
5123 * @arg @ref HAL_TIM_ENCODER_MSPINIT_CB_ID Encoder MspInit Callback ID
\r
5124 * @arg @ref HAL_TIM_ENCODER_MSPDEINIT_CB_ID Encoder MspDeInit Callback ID
\r
5125 * @arg @ref HAL_TIM_HALL_SENSOR_MSPINIT_CB_ID Hall Sensor MspInit Callback ID
\r
5126 * @arg @ref HAL_TIM_HALL_SENSOR_MSPDEINIT_CB_ID Hall Sensor MspDeInit Callback ID
\r
5127 * @arg @ref HAL_TIM_PERIOD_ELAPSED_CB_ID Period Elapsed Callback ID
\r
5128 * @arg @ref HAL_TIM_PERIOD_ELAPSED_HALF_CB_ID Period Elapsed half complete Callback ID
\r
5129 * @arg @ref HAL_TIM_TRIGGER_CB_ID Trigger Callback ID
\r
5130 * @arg @ref HAL_TIM_TRIGGER_HALF_CB_ID Trigger half complete Callback ID
\r
5131 * @arg @ref HAL_TIM_IC_CAPTURE_CB_ID Input Capture Callback ID
\r
5132 * @arg @ref HAL_TIM_IC_CAPTURE_HALF_CB_ID Input Capture half complete Callback ID
\r
5133 * @arg @ref HAL_TIM_OC_DELAY_ELAPSED_CB_ID Output Compare Delay Elapsed Callback ID
\r
5134 * @arg @ref HAL_TIM_PWM_PULSE_FINISHED_CB_ID PWM Pulse Finished Callback ID
\r
5135 * @arg @ref HAL_TIM_PWM_PULSE_FINISHED_HALF_CB_ID PWM Pulse Finished half complete Callback ID
\r
5136 * @arg @ref HAL_TIM_ERROR_CB_ID Error Callback ID
\r
5137 * @arg @ref HAL_TIM_COMMUTATION_CB_ID Commutation Callback ID
\r
5138 * @arg @ref HAL_TIM_COMMUTATION_HALF_CB_ID Commutation half complete Callback ID
\r
5139 * @arg @ref HAL_TIM_BREAK_CB_ID Break Callback ID
\r
5140 * @arg @ref HAL_TIM_BREAK2_CB_ID Break2 Callback ID
\r
5141 * @param pCallback pointer to the callback function
\r
5144 HAL_StatusTypeDef HAL_TIM_RegisterCallback(TIM_HandleTypeDef *htim, HAL_TIM_CallbackIDTypeDef CallbackID,
\r
5145 pTIM_CallbackTypeDef pCallback)
\r
5147 HAL_StatusTypeDef status = HAL_OK;
\r
5149 if (pCallback == NULL)
\r
5153 /* Process locked */
\r
5156 if (htim->State == HAL_TIM_STATE_READY)
\r
5158 switch (CallbackID)
\r
5160 case HAL_TIM_BASE_MSPINIT_CB_ID :
\r
5161 htim->Base_MspInitCallback = pCallback;
\r
5164 case HAL_TIM_BASE_MSPDEINIT_CB_ID :
\r
5165 htim->Base_MspDeInitCallback = pCallback;
\r
5168 case HAL_TIM_IC_MSPINIT_CB_ID :
\r
5169 htim->IC_MspInitCallback = pCallback;
\r
5172 case HAL_TIM_IC_MSPDEINIT_CB_ID :
\r
5173 htim->IC_MspDeInitCallback = pCallback;
\r
5176 case HAL_TIM_OC_MSPINIT_CB_ID :
\r
5177 htim->OC_MspInitCallback = pCallback;
\r
5180 case HAL_TIM_OC_MSPDEINIT_CB_ID :
\r
5181 htim->OC_MspDeInitCallback = pCallback;
\r
5184 case HAL_TIM_PWM_MSPINIT_CB_ID :
\r
5185 htim->PWM_MspInitCallback = pCallback;
\r
5188 case HAL_TIM_PWM_MSPDEINIT_CB_ID :
\r
5189 htim->PWM_MspDeInitCallback = pCallback;
\r
5192 case HAL_TIM_ONE_PULSE_MSPINIT_CB_ID :
\r
5193 htim->OnePulse_MspInitCallback = pCallback;
\r
5196 case HAL_TIM_ONE_PULSE_MSPDEINIT_CB_ID :
\r
5197 htim->OnePulse_MspDeInitCallback = pCallback;
\r
5200 case HAL_TIM_ENCODER_MSPINIT_CB_ID :
\r
5201 htim->Encoder_MspInitCallback = pCallback;
\r
5204 case HAL_TIM_ENCODER_MSPDEINIT_CB_ID :
\r
5205 htim->Encoder_MspDeInitCallback = pCallback;
\r
5208 case HAL_TIM_HALL_SENSOR_MSPINIT_CB_ID :
\r
5209 htim->HallSensor_MspInitCallback = pCallback;
\r
5212 case HAL_TIM_HALL_SENSOR_MSPDEINIT_CB_ID :
\r
5213 htim->HallSensor_MspDeInitCallback = pCallback;
\r
5216 case HAL_TIM_PERIOD_ELAPSED_CB_ID :
\r
5217 htim->PeriodElapsedCallback = pCallback;
\r
5220 case HAL_TIM_PERIOD_ELAPSED_HALF_CB_ID :
\r
5221 htim->PeriodElapsedHalfCpltCallback = pCallback;
\r
5224 case HAL_TIM_TRIGGER_CB_ID :
\r
5225 htim->TriggerCallback = pCallback;
\r
5228 case HAL_TIM_TRIGGER_HALF_CB_ID :
\r
5229 htim->TriggerHalfCpltCallback = pCallback;
\r
5232 case HAL_TIM_IC_CAPTURE_CB_ID :
\r
5233 htim->IC_CaptureCallback = pCallback;
\r
5236 case HAL_TIM_IC_CAPTURE_HALF_CB_ID :
\r
5237 htim->IC_CaptureHalfCpltCallback = pCallback;
\r
5240 case HAL_TIM_OC_DELAY_ELAPSED_CB_ID :
\r
5241 htim->OC_DelayElapsedCallback = pCallback;
\r
5244 case HAL_TIM_PWM_PULSE_FINISHED_CB_ID :
\r
5245 htim->PWM_PulseFinishedCallback = pCallback;
\r
5248 case HAL_TIM_PWM_PULSE_FINISHED_HALF_CB_ID :
\r
5249 htim->PWM_PulseFinishedHalfCpltCallback = pCallback;
\r
5252 case HAL_TIM_ERROR_CB_ID :
\r
5253 htim->ErrorCallback = pCallback;
\r
5256 case HAL_TIM_COMMUTATION_CB_ID :
\r
5257 htim->CommutationCallback = pCallback;
\r
5260 case HAL_TIM_COMMUTATION_HALF_CB_ID :
\r
5261 htim->CommutationHalfCpltCallback = pCallback;
\r
5264 case HAL_TIM_BREAK_CB_ID :
\r
5265 htim->BreakCallback = pCallback;
\r
5268 case HAL_TIM_BREAK2_CB_ID :
\r
5269 htim->Break2Callback = pCallback;
\r
5273 /* Return error status */
\r
5274 status = HAL_ERROR;
\r
5278 else if (htim->State == HAL_TIM_STATE_RESET)
\r
5280 switch (CallbackID)
\r
5282 case HAL_TIM_BASE_MSPINIT_CB_ID :
\r
5283 htim->Base_MspInitCallback = pCallback;
\r
5286 case HAL_TIM_BASE_MSPDEINIT_CB_ID :
\r
5287 htim->Base_MspDeInitCallback = pCallback;
\r
5290 case HAL_TIM_IC_MSPINIT_CB_ID :
\r
5291 htim->IC_MspInitCallback = pCallback;
\r
5294 case HAL_TIM_IC_MSPDEINIT_CB_ID :
\r
5295 htim->IC_MspDeInitCallback = pCallback;
\r
5298 case HAL_TIM_OC_MSPINIT_CB_ID :
\r
5299 htim->OC_MspInitCallback = pCallback;
\r
5302 case HAL_TIM_OC_MSPDEINIT_CB_ID :
\r
5303 htim->OC_MspDeInitCallback = pCallback;
\r
5306 case HAL_TIM_PWM_MSPINIT_CB_ID :
\r
5307 htim->PWM_MspInitCallback = pCallback;
\r
5310 case HAL_TIM_PWM_MSPDEINIT_CB_ID :
\r
5311 htim->PWM_MspDeInitCallback = pCallback;
\r
5314 case HAL_TIM_ONE_PULSE_MSPINIT_CB_ID :
\r
5315 htim->OnePulse_MspInitCallback = pCallback;
\r
5318 case HAL_TIM_ONE_PULSE_MSPDEINIT_CB_ID :
\r
5319 htim->OnePulse_MspDeInitCallback = pCallback;
\r
5322 case HAL_TIM_ENCODER_MSPINIT_CB_ID :
\r
5323 htim->Encoder_MspInitCallback = pCallback;
\r
5326 case HAL_TIM_ENCODER_MSPDEINIT_CB_ID :
\r
5327 htim->Encoder_MspDeInitCallback = pCallback;
\r
5330 case HAL_TIM_HALL_SENSOR_MSPINIT_CB_ID :
\r
5331 htim->HallSensor_MspInitCallback = pCallback;
\r
5334 case HAL_TIM_HALL_SENSOR_MSPDEINIT_CB_ID :
\r
5335 htim->HallSensor_MspDeInitCallback = pCallback;
\r
5339 /* Return error status */
\r
5340 status = HAL_ERROR;
\r
5346 /* Return error status */
\r
5347 status = HAL_ERROR;
\r
5350 /* Release Lock */
\r
5351 __HAL_UNLOCK(htim);
\r
5357 * @brief Unregister a TIM callback
\r
5358 * TIM callback is redirected to the weak predefined callback
\r
5359 * @param htim tim handle
\r
5360 * @param CallbackID ID of the callback to be unregistered
\r
5361 * This parameter can be one of the following values:
\r
5362 * @arg @ref HAL_TIM_BASE_MSPINIT_CB_ID Base MspInit Callback ID
\r
5363 * @arg @ref HAL_TIM_BASE_MSPDEINIT_CB_ID Base MspDeInit Callback ID
\r
5364 * @arg @ref HAL_TIM_IC_MSPINIT_CB_ID IC MspInit Callback ID
\r
5365 * @arg @ref HAL_TIM_IC_MSPDEINIT_CB_ID IC MspDeInit Callback ID
\r
5366 * @arg @ref HAL_TIM_OC_MSPINIT_CB_ID OC MspInit Callback ID
\r
5367 * @arg @ref HAL_TIM_OC_MSPDEINIT_CB_ID OC MspDeInit Callback ID
\r
5368 * @arg @ref HAL_TIM_PWM_MSPINIT_CB_ID PWM MspInit Callback ID
\r
5369 * @arg @ref HAL_TIM_PWM_MSPDEINIT_CB_ID PWM MspDeInit Callback ID
\r
5370 * @arg @ref HAL_TIM_ONE_PULSE_MSPINIT_CB_ID One Pulse MspInit Callback ID
\r
5371 * @arg @ref HAL_TIM_ONE_PULSE_MSPDEINIT_CB_ID One Pulse MspDeInit Callback ID
\r
5372 * @arg @ref HAL_TIM_ENCODER_MSPINIT_CB_ID Encoder MspInit Callback ID
\r
5373 * @arg @ref HAL_TIM_ENCODER_MSPDEINIT_CB_ID Encoder MspDeInit Callback ID
\r
5374 * @arg @ref HAL_TIM_HALL_SENSOR_MSPINIT_CB_ID Hall Sensor MspInit Callback ID
\r
5375 * @arg @ref HAL_TIM_HALL_SENSOR_MSPDEINIT_CB_ID Hall Sensor MspDeInit Callback ID
\r
5376 * @arg @ref HAL_TIM_PERIOD_ELAPSED_CB_ID Period Elapsed Callback ID
\r
5377 * @arg @ref HAL_TIM_PERIOD_ELAPSED_HALF_CB_ID Period Elapsed half complete Callback ID
\r
5378 * @arg @ref HAL_TIM_TRIGGER_CB_ID Trigger Callback ID
\r
5379 * @arg @ref HAL_TIM_TRIGGER_HALF_CB_ID Trigger half complete Callback ID
\r
5380 * @arg @ref HAL_TIM_IC_CAPTURE_CB_ID Input Capture Callback ID
\r
5381 * @arg @ref HAL_TIM_IC_CAPTURE_HALF_CB_ID Input Capture half complete Callback ID
\r
5382 * @arg @ref HAL_TIM_OC_DELAY_ELAPSED_CB_ID Output Compare Delay Elapsed Callback ID
\r
5383 * @arg @ref HAL_TIM_PWM_PULSE_FINISHED_CB_ID PWM Pulse Finished Callback ID
\r
5384 * @arg @ref HAL_TIM_PWM_PULSE_FINISHED_HALF_CB_ID PWM Pulse Finished half complete Callback ID
\r
5385 * @arg @ref HAL_TIM_ERROR_CB_ID Error Callback ID
\r
5386 * @arg @ref HAL_TIM_COMMUTATION_CB_ID Commutation Callback ID
\r
5387 * @arg @ref HAL_TIM_COMMUTATION_HALF_CB_ID Commutation half complete Callback ID
\r
5388 * @arg @ref HAL_TIM_BREAK_CB_ID Break Callback ID
\r
5389 * @arg @ref HAL_TIM_BREAK2_CB_ID Break2 Callback ID
\r
5392 HAL_StatusTypeDef HAL_TIM_UnRegisterCallback(TIM_HandleTypeDef *htim, HAL_TIM_CallbackIDTypeDef CallbackID)
\r
5394 HAL_StatusTypeDef status = HAL_OK;
\r
5396 /* Process locked */
\r
5399 if (htim->State == HAL_TIM_STATE_READY)
\r
5401 switch (CallbackID)
\r
5403 case HAL_TIM_BASE_MSPINIT_CB_ID :
\r
5404 htim->Base_MspInitCallback = HAL_TIM_Base_MspInit; /* Legacy weak Base MspInit Callback */
\r
5407 case HAL_TIM_BASE_MSPDEINIT_CB_ID :
\r
5408 htim->Base_MspDeInitCallback = HAL_TIM_Base_MspDeInit; /* Legacy weak Base Msp DeInit Callback */
\r
5411 case HAL_TIM_IC_MSPINIT_CB_ID :
\r
5412 htim->IC_MspInitCallback = HAL_TIM_IC_MspInit; /* Legacy weak IC Msp Init Callback */
\r
5415 case HAL_TIM_IC_MSPDEINIT_CB_ID :
\r
5416 htim->IC_MspDeInitCallback = HAL_TIM_IC_MspDeInit; /* Legacy weak IC Msp DeInit Callback */
\r
5419 case HAL_TIM_OC_MSPINIT_CB_ID :
\r
5420 htim->OC_MspInitCallback = HAL_TIM_OC_MspInit; /* Legacy weak OC Msp Init Callback */
\r
5423 case HAL_TIM_OC_MSPDEINIT_CB_ID :
\r
5424 htim->OC_MspDeInitCallback = HAL_TIM_OC_MspDeInit; /* Legacy weak OC Msp DeInit Callback */
\r
5427 case HAL_TIM_PWM_MSPINIT_CB_ID :
\r
5428 htim->PWM_MspInitCallback = HAL_TIM_PWM_MspInit; /* Legacy weak PWM Msp Init Callback */
\r
5431 case HAL_TIM_PWM_MSPDEINIT_CB_ID :
\r
5432 htim->PWM_MspDeInitCallback = HAL_TIM_PWM_MspDeInit; /* Legacy weak PWM Msp DeInit Callback */
\r
5435 case HAL_TIM_ONE_PULSE_MSPINIT_CB_ID :
\r
5436 htim->OnePulse_MspInitCallback = HAL_TIM_OnePulse_MspInit; /* Legacy weak One Pulse Msp Init Callback */
\r
5439 case HAL_TIM_ONE_PULSE_MSPDEINIT_CB_ID :
\r
5440 htim->OnePulse_MspDeInitCallback = HAL_TIM_OnePulse_MspDeInit; /* Legacy weak One Pulse Msp DeInit Callback */
\r
5443 case HAL_TIM_ENCODER_MSPINIT_CB_ID :
\r
5444 htim->Encoder_MspInitCallback = HAL_TIM_Encoder_MspInit; /* Legacy weak Encoder Msp Init Callback */
\r
5447 case HAL_TIM_ENCODER_MSPDEINIT_CB_ID :
\r
5448 htim->Encoder_MspDeInitCallback = HAL_TIM_Encoder_MspDeInit; /* Legacy weak Encoder Msp DeInit Callback */
\r
5451 case HAL_TIM_HALL_SENSOR_MSPINIT_CB_ID :
\r
5452 htim->HallSensor_MspInitCallback = HAL_TIMEx_HallSensor_MspInit; /* Legacy weak Hall Sensor Msp Init Callback */
\r
5455 case HAL_TIM_HALL_SENSOR_MSPDEINIT_CB_ID :
\r
5456 htim->HallSensor_MspDeInitCallback = HAL_TIMEx_HallSensor_MspDeInit; /* Legacy weak Hall Sensor Msp DeInit Callback */
\r
5459 case HAL_TIM_PERIOD_ELAPSED_CB_ID :
\r
5460 htim->PeriodElapsedCallback = HAL_TIM_PeriodElapsedCallback; /* Legacy weak Period Elapsed Callback */
\r
5463 case HAL_TIM_PERIOD_ELAPSED_HALF_CB_ID :
\r
5464 htim->PeriodElapsedHalfCpltCallback = HAL_TIM_PeriodElapsedHalfCpltCallback; /* Legacy weak Period Elapsed half complete Callback */
\r
5467 case HAL_TIM_TRIGGER_CB_ID :
\r
5468 htim->TriggerCallback = HAL_TIM_TriggerCallback; /* Legacy weak Trigger Callback */
\r
5471 case HAL_TIM_TRIGGER_HALF_CB_ID :
\r
5472 htim->TriggerHalfCpltCallback = HAL_TIM_TriggerHalfCpltCallback; /* Legacy weak Trigger half complete Callback */
\r
5475 case HAL_TIM_IC_CAPTURE_CB_ID :
\r
5476 htim->IC_CaptureCallback = HAL_TIM_IC_CaptureCallback; /* Legacy weak IC Capture Callback */
\r
5479 case HAL_TIM_IC_CAPTURE_HALF_CB_ID :
\r
5480 htim->IC_CaptureHalfCpltCallback = HAL_TIM_IC_CaptureHalfCpltCallback; /* Legacy weak IC Capture half complete Callback */
\r
5483 case HAL_TIM_OC_DELAY_ELAPSED_CB_ID :
\r
5484 htim->OC_DelayElapsedCallback = HAL_TIM_OC_DelayElapsedCallback; /* Legacy weak OC Delay Elapsed Callback */
\r
5487 case HAL_TIM_PWM_PULSE_FINISHED_CB_ID :
\r
5488 htim->PWM_PulseFinishedCallback = HAL_TIM_PWM_PulseFinishedCallback; /* Legacy weak PWM Pulse Finished Callback */
\r
5491 case HAL_TIM_PWM_PULSE_FINISHED_HALF_CB_ID :
\r
5492 htim->PWM_PulseFinishedHalfCpltCallback = HAL_TIM_PWM_PulseFinishedHalfCpltCallback; /* Legacy weak PWM Pulse Finished half complete Callback */
\r
5495 case HAL_TIM_ERROR_CB_ID :
\r
5496 htim->ErrorCallback = HAL_TIM_ErrorCallback; /* Legacy weak Error Callback */
\r
5499 case HAL_TIM_COMMUTATION_CB_ID :
\r
5500 htim->CommutationCallback = HAL_TIMEx_CommutCallback; /* Legacy weak Commutation Callback */
\r
5503 case HAL_TIM_COMMUTATION_HALF_CB_ID :
\r
5504 htim->CommutationHalfCpltCallback = HAL_TIMEx_CommutHalfCpltCallback; /* Legacy weak Commutation half complete Callback */
\r
5507 case HAL_TIM_BREAK_CB_ID :
\r
5508 htim->BreakCallback = HAL_TIMEx_BreakCallback; /* Legacy weak Break Callback */
\r
5511 case HAL_TIM_BREAK2_CB_ID :
\r
5512 htim->Break2Callback = HAL_TIMEx_Break2Callback; /* Legacy weak Break2 Callback */
\r
5516 /* Return error status */
\r
5517 status = HAL_ERROR;
\r
5521 else if (htim->State == HAL_TIM_STATE_RESET)
\r
5523 switch (CallbackID)
\r
5525 case HAL_TIM_BASE_MSPINIT_CB_ID :
\r
5526 htim->Base_MspInitCallback = HAL_TIM_Base_MspInit; /* Legacy weak Base MspInit Callback */
\r
5529 case HAL_TIM_BASE_MSPDEINIT_CB_ID :
\r
5530 htim->Base_MspDeInitCallback = HAL_TIM_Base_MspDeInit; /* Legacy weak Base Msp DeInit Callback */
\r
5533 case HAL_TIM_IC_MSPINIT_CB_ID :
\r
5534 htim->IC_MspInitCallback = HAL_TIM_IC_MspInit; /* Legacy weak IC Msp Init Callback */
\r
5537 case HAL_TIM_IC_MSPDEINIT_CB_ID :
\r
5538 htim->IC_MspDeInitCallback = HAL_TIM_IC_MspDeInit; /* Legacy weak IC Msp DeInit Callback */
\r
5541 case HAL_TIM_OC_MSPINIT_CB_ID :
\r
5542 htim->OC_MspInitCallback = HAL_TIM_OC_MspInit; /* Legacy weak OC Msp Init Callback */
\r
5545 case HAL_TIM_OC_MSPDEINIT_CB_ID :
\r
5546 htim->OC_MspDeInitCallback = HAL_TIM_OC_MspDeInit; /* Legacy weak OC Msp DeInit Callback */
\r
5549 case HAL_TIM_PWM_MSPINIT_CB_ID :
\r
5550 htim->PWM_MspInitCallback = HAL_TIM_PWM_MspInit; /* Legacy weak PWM Msp Init Callback */
\r
5553 case HAL_TIM_PWM_MSPDEINIT_CB_ID :
\r
5554 htim->PWM_MspDeInitCallback = HAL_TIM_PWM_MspDeInit; /* Legacy weak PWM Msp DeInit Callback */
\r
5557 case HAL_TIM_ONE_PULSE_MSPINIT_CB_ID :
\r
5558 htim->OnePulse_MspInitCallback = HAL_TIM_OnePulse_MspInit; /* Legacy weak One Pulse Msp Init Callback */
\r
5561 case HAL_TIM_ONE_PULSE_MSPDEINIT_CB_ID :
\r
5562 htim->OnePulse_MspDeInitCallback = HAL_TIM_OnePulse_MspDeInit; /* Legacy weak One Pulse Msp DeInit Callback */
\r
5565 case HAL_TIM_ENCODER_MSPINIT_CB_ID :
\r
5566 htim->Encoder_MspInitCallback = HAL_TIM_Encoder_MspInit; /* Legacy weak Encoder Msp Init Callback */
\r
5569 case HAL_TIM_ENCODER_MSPDEINIT_CB_ID :
\r
5570 htim->Encoder_MspDeInitCallback = HAL_TIM_Encoder_MspDeInit; /* Legacy weak Encoder Msp DeInit Callback */
\r
5573 case HAL_TIM_HALL_SENSOR_MSPINIT_CB_ID :
\r
5574 htim->HallSensor_MspInitCallback = HAL_TIMEx_HallSensor_MspInit; /* Legacy weak Hall Sensor Msp Init Callback */
\r
5577 case HAL_TIM_HALL_SENSOR_MSPDEINIT_CB_ID :
\r
5578 htim->HallSensor_MspDeInitCallback = HAL_TIMEx_HallSensor_MspDeInit; /* Legacy weak Hall Sensor Msp DeInit Callback */
\r
5582 /* Return error status */
\r
5583 status = HAL_ERROR;
\r
5589 /* Return error status */
\r
5590 status = HAL_ERROR;
\r
5593 /* Release Lock */
\r
5594 __HAL_UNLOCK(htim);
\r
5598 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
5604 /** @defgroup TIM_Exported_Functions_Group10 TIM Peripheral State functions
\r
5605 * @brief TIM Peripheral State functions
\r
5608 ==============================================================================
\r
5609 ##### Peripheral State functions #####
\r
5610 ==============================================================================
\r
5612 This subsection permits to get in run-time the status of the peripheral
\r
5613 and the data flow.
\r
5620 * @brief Return the TIM Base handle state.
\r
5621 * @param htim TIM Base handle
\r
5622 * @retval HAL state
\r
5624 HAL_TIM_StateTypeDef HAL_TIM_Base_GetState(TIM_HandleTypeDef *htim)
\r
5626 return htim->State;
\r
5630 * @brief Return the TIM OC handle state.
\r
5631 * @param htim TIM Output Compare handle
\r
5632 * @retval HAL state
\r
5634 HAL_TIM_StateTypeDef HAL_TIM_OC_GetState(TIM_HandleTypeDef *htim)
\r
5636 return htim->State;
\r
5640 * @brief Return the TIM PWM handle state.
\r
5641 * @param htim TIM handle
\r
5642 * @retval HAL state
\r
5644 HAL_TIM_StateTypeDef HAL_TIM_PWM_GetState(TIM_HandleTypeDef *htim)
\r
5646 return htim->State;
\r
5650 * @brief Return the TIM Input Capture handle state.
\r
5651 * @param htim TIM IC handle
\r
5652 * @retval HAL state
\r
5654 HAL_TIM_StateTypeDef HAL_TIM_IC_GetState(TIM_HandleTypeDef *htim)
\r
5656 return htim->State;
\r
5660 * @brief Return the TIM One Pulse Mode handle state.
\r
5661 * @param htim TIM OPM handle
\r
5662 * @retval HAL state
\r
5664 HAL_TIM_StateTypeDef HAL_TIM_OnePulse_GetState(TIM_HandleTypeDef *htim)
\r
5666 return htim->State;
\r
5670 * @brief Return the TIM Encoder Mode handle state.
\r
5671 * @param htim TIM Encoder Interface handle
\r
5672 * @retval HAL state
\r
5674 HAL_TIM_StateTypeDef HAL_TIM_Encoder_GetState(TIM_HandleTypeDef *htim)
\r
5676 return htim->State;
\r
5687 /** @defgroup TIM_Private_Functions TIM Private Functions
\r
5692 * @brief TIM DMA error callback
\r
5693 * @param hdma pointer to DMA handle.
\r
5696 void TIM_DMAError(DMA_HandleTypeDef *hdma)
\r
5698 TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
\r
5700 htim->State = HAL_TIM_STATE_READY;
\r
5702 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
5703 htim->ErrorCallback(htim);
\r
5705 HAL_TIM_ErrorCallback(htim);
\r
5706 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
5710 * @brief TIM DMA Delay Pulse complete callback.
\r
5711 * @param hdma pointer to DMA handle.
\r
5714 void TIM_DMADelayPulseCplt(DMA_HandleTypeDef *hdma)
\r
5716 TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
\r
5718 htim->State = HAL_TIM_STATE_READY;
\r
5720 if (hdma == htim->hdma[TIM_DMA_ID_CC1])
\r
5722 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_1;
\r
5724 else if (hdma == htim->hdma[TIM_DMA_ID_CC2])
\r
5726 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_2;
\r
5728 else if (hdma == htim->hdma[TIM_DMA_ID_CC3])
\r
5730 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_3;
\r
5732 else if (hdma == htim->hdma[TIM_DMA_ID_CC4])
\r
5734 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_4;
\r
5738 /* nothing to do */
\r
5741 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
5742 htim->PWM_PulseFinishedCallback(htim);
\r
5744 HAL_TIM_PWM_PulseFinishedCallback(htim);
\r
5745 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
5747 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_CLEARED;
\r
5751 * @brief TIM DMA Delay Pulse half complete callback.
\r
5752 * @param hdma pointer to DMA handle.
\r
5755 void TIM_DMADelayPulseHalfCplt(DMA_HandleTypeDef *hdma)
\r
5757 TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
\r
5759 htim->State = HAL_TIM_STATE_READY;
\r
5761 if (hdma == htim->hdma[TIM_DMA_ID_CC1])
\r
5763 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_1;
\r
5765 else if (hdma == htim->hdma[TIM_DMA_ID_CC2])
\r
5767 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_2;
\r
5769 else if (hdma == htim->hdma[TIM_DMA_ID_CC3])
\r
5771 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_3;
\r
5773 else if (hdma == htim->hdma[TIM_DMA_ID_CC4])
\r
5775 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_4;
\r
5779 /* nothing to do */
\r
5782 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
5783 htim->PWM_PulseFinishedHalfCpltCallback(htim);
\r
5785 HAL_TIM_PWM_PulseFinishedHalfCpltCallback(htim);
\r
5786 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
5788 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_CLEARED;
\r
5792 * @brief TIM DMA Capture complete callback.
\r
5793 * @param hdma pointer to DMA handle.
\r
5796 void TIM_DMACaptureCplt(DMA_HandleTypeDef *hdma)
\r
5798 TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
\r
5800 htim->State = HAL_TIM_STATE_READY;
\r
5802 if (hdma == htim->hdma[TIM_DMA_ID_CC1])
\r
5804 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_1;
\r
5806 else if (hdma == htim->hdma[TIM_DMA_ID_CC2])
\r
5808 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_2;
\r
5810 else if (hdma == htim->hdma[TIM_DMA_ID_CC3])
\r
5812 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_3;
\r
5814 else if (hdma == htim->hdma[TIM_DMA_ID_CC4])
\r
5816 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_4;
\r
5820 /* nothing to do */
\r
5823 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
5824 htim->IC_CaptureCallback(htim);
\r
5826 HAL_TIM_IC_CaptureCallback(htim);
\r
5827 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
5829 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_CLEARED;
\r
5833 * @brief TIM DMA Capture half complete callback.
\r
5834 * @param hdma pointer to DMA handle.
\r
5837 void TIM_DMACaptureHalfCplt(DMA_HandleTypeDef *hdma)
\r
5839 TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
\r
5841 htim->State = HAL_TIM_STATE_READY;
\r
5843 if (hdma == htim->hdma[TIM_DMA_ID_CC1])
\r
5845 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_1;
\r
5847 else if (hdma == htim->hdma[TIM_DMA_ID_CC2])
\r
5849 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_2;
\r
5851 else if (hdma == htim->hdma[TIM_DMA_ID_CC3])
\r
5853 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_3;
\r
5855 else if (hdma == htim->hdma[TIM_DMA_ID_CC4])
\r
5857 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_4;
\r
5861 /* nothing to do */
\r
5864 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
5865 htim->IC_CaptureHalfCpltCallback(htim);
\r
5867 HAL_TIM_IC_CaptureHalfCpltCallback(htim);
\r
5868 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
5870 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_CLEARED;
\r
5874 * @brief TIM DMA Period Elapse complete callback.
\r
5875 * @param hdma pointer to DMA handle.
\r
5878 static void TIM_DMAPeriodElapsedCplt(DMA_HandleTypeDef *hdma)
\r
5880 TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
\r
5882 htim->State = HAL_TIM_STATE_READY;
\r
5884 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
5885 htim->PeriodElapsedCallback(htim);
\r
5887 HAL_TIM_PeriodElapsedCallback(htim);
\r
5888 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
5892 * @brief TIM DMA Period Elapse half complete callback.
\r
5893 * @param hdma pointer to DMA handle.
\r
5896 static void TIM_DMAPeriodElapsedHalfCplt(DMA_HandleTypeDef *hdma)
\r
5898 TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
\r
5900 htim->State = HAL_TIM_STATE_READY;
\r
5902 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
5903 htim->PeriodElapsedHalfCpltCallback(htim);
\r
5905 HAL_TIM_PeriodElapsedHalfCpltCallback(htim);
\r
5906 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
5910 * @brief TIM DMA Trigger callback.
\r
5911 * @param hdma pointer to DMA handle.
\r
5914 static void TIM_DMATriggerCplt(DMA_HandleTypeDef *hdma)
\r
5916 TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
\r
5918 htim->State = HAL_TIM_STATE_READY;
\r
5920 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
5921 htim->TriggerCallback(htim);
\r
5923 HAL_TIM_TriggerCallback(htim);
\r
5924 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
5928 * @brief TIM DMA Trigger half complete callback.
\r
5929 * @param hdma pointer to DMA handle.
\r
5932 static void TIM_DMATriggerHalfCplt(DMA_HandleTypeDef *hdma)
\r
5934 TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
\r
5936 htim->State = HAL_TIM_STATE_READY;
\r
5938 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
5939 htim->TriggerHalfCpltCallback(htim);
\r
5941 HAL_TIM_TriggerHalfCpltCallback(htim);
\r
5942 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
5946 * @brief Time Base configuration
\r
5947 * @param TIMx TIM peripheral
\r
5948 * @param Structure TIM Base configuration structure
\r
5951 void TIM_Base_SetConfig(TIM_TypeDef *TIMx, TIM_Base_InitTypeDef *Structure)
\r
5954 tmpcr1 = TIMx->CR1;
\r
5956 /* Set TIM Time Base Unit parameters ---------------------------------------*/
\r
5957 if (IS_TIM_COUNTER_MODE_SELECT_INSTANCE(TIMx))
\r
5959 /* Select the Counter Mode */
\r
5960 tmpcr1 &= ~(TIM_CR1_DIR | TIM_CR1_CMS);
\r
5961 tmpcr1 |= Structure->CounterMode;
\r
5964 if (IS_TIM_CLOCK_DIVISION_INSTANCE(TIMx))
\r
5966 /* Set the clock division */
\r
5967 tmpcr1 &= ~TIM_CR1_CKD;
\r
5968 tmpcr1 |= (uint32_t)Structure->ClockDivision;
\r
5971 /* Set the auto-reload preload */
\r
5972 MODIFY_REG(tmpcr1, TIM_CR1_ARPE, Structure->AutoReloadPreload);
\r
5974 TIMx->CR1 = tmpcr1;
\r
5976 /* Set the Autoreload value */
\r
5977 TIMx->ARR = (uint32_t)Structure->Period ;
\r
5979 /* Set the Prescaler value */
\r
5980 TIMx->PSC = Structure->Prescaler;
\r
5982 if (IS_TIM_REPETITION_COUNTER_INSTANCE(TIMx))
\r
5984 /* Set the Repetition Counter value */
\r
5985 TIMx->RCR = Structure->RepetitionCounter;
\r
5988 /* Generate an update event to reload the Prescaler
\r
5989 and the repetition counter (only for advanced timer) value immediately */
\r
5990 TIMx->EGR = TIM_EGR_UG;
\r
5994 * @brief Timer Output Compare 1 configuration
\r
5995 * @param TIMx to select the TIM peripheral
\r
5996 * @param OC_Config The ouput configuration structure
\r
5999 static void TIM_OC1_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
\r
6001 uint32_t tmpccmrx;
\r
6005 /* Disable the Channel 1: Reset the CC1E Bit */
\r
6006 TIMx->CCER &= ~TIM_CCER_CC1E;
\r
6008 /* Get the TIMx CCER register value */
\r
6009 tmpccer = TIMx->CCER;
\r
6010 /* Get the TIMx CR2 register value */
\r
6011 tmpcr2 = TIMx->CR2;
\r
6013 /* Get the TIMx CCMR1 register value */
\r
6014 tmpccmrx = TIMx->CCMR1;
\r
6016 /* Reset the Output Compare Mode Bits */
\r
6017 tmpccmrx &= ~TIM_CCMR1_OC1M;
\r
6018 tmpccmrx &= ~TIM_CCMR1_CC1S;
\r
6019 /* Select the Output Compare Mode */
\r
6020 tmpccmrx |= OC_Config->OCMode;
\r
6022 /* Reset the Output Polarity level */
\r
6023 tmpccer &= ~TIM_CCER_CC1P;
\r
6024 /* Set the Output Compare Polarity */
\r
6025 tmpccer |= OC_Config->OCPolarity;
\r
6027 if (IS_TIM_CCXN_INSTANCE(TIMx, TIM_CHANNEL_1))
\r
6029 /* Check parameters */
\r
6030 assert_param(IS_TIM_OCN_POLARITY(OC_Config->OCNPolarity));
\r
6032 /* Reset the Output N Polarity level */
\r
6033 tmpccer &= ~TIM_CCER_CC1NP;
\r
6034 /* Set the Output N Polarity */
\r
6035 tmpccer |= OC_Config->OCNPolarity;
\r
6036 /* Reset the Output N State */
\r
6037 tmpccer &= ~TIM_CCER_CC1NE;
\r
6040 if (IS_TIM_BREAK_INSTANCE(TIMx))
\r
6042 /* Check parameters */
\r
6043 assert_param(IS_TIM_OCNIDLE_STATE(OC_Config->OCNIdleState));
\r
6044 assert_param(IS_TIM_OCIDLE_STATE(OC_Config->OCIdleState));
\r
6046 /* Reset the Output Compare and Output Compare N IDLE State */
\r
6047 tmpcr2 &= ~TIM_CR2_OIS1;
\r
6048 tmpcr2 &= ~TIM_CR2_OIS1N;
\r
6049 /* Set the Output Idle state */
\r
6050 tmpcr2 |= OC_Config->OCIdleState;
\r
6051 /* Set the Output N Idle state */
\r
6052 tmpcr2 |= OC_Config->OCNIdleState;
\r
6055 /* Write to TIMx CR2 */
\r
6056 TIMx->CR2 = tmpcr2;
\r
6058 /* Write to TIMx CCMR1 */
\r
6059 TIMx->CCMR1 = tmpccmrx;
\r
6061 /* Set the Capture Compare Register value */
\r
6062 TIMx->CCR1 = OC_Config->Pulse;
\r
6064 /* Write to TIMx CCER */
\r
6065 TIMx->CCER = tmpccer;
\r
6069 * @brief Timer Output Compare 2 configuration
\r
6070 * @param TIMx to select the TIM peripheral
\r
6071 * @param OC_Config The ouput configuration structure
\r
6074 void TIM_OC2_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
\r
6076 uint32_t tmpccmrx;
\r
6080 /* Disable the Channel 2: Reset the CC2E Bit */
\r
6081 TIMx->CCER &= ~TIM_CCER_CC2E;
\r
6083 /* Get the TIMx CCER register value */
\r
6084 tmpccer = TIMx->CCER;
\r
6085 /* Get the TIMx CR2 register value */
\r
6086 tmpcr2 = TIMx->CR2;
\r
6088 /* Get the TIMx CCMR1 register value */
\r
6089 tmpccmrx = TIMx->CCMR1;
\r
6091 /* Reset the Output Compare mode and Capture/Compare selection Bits */
\r
6092 tmpccmrx &= ~TIM_CCMR1_OC2M;
\r
6093 tmpccmrx &= ~TIM_CCMR1_CC2S;
\r
6095 /* Select the Output Compare Mode */
\r
6096 tmpccmrx |= (OC_Config->OCMode << 8U);
\r
6098 /* Reset the Output Polarity level */
\r
6099 tmpccer &= ~TIM_CCER_CC2P;
\r
6100 /* Set the Output Compare Polarity */
\r
6101 tmpccer |= (OC_Config->OCPolarity << 4U);
\r
6103 if (IS_TIM_CCXN_INSTANCE(TIMx, TIM_CHANNEL_2))
\r
6105 assert_param(IS_TIM_OCN_POLARITY(OC_Config->OCNPolarity));
\r
6107 /* Reset the Output N Polarity level */
\r
6108 tmpccer &= ~TIM_CCER_CC2NP;
\r
6109 /* Set the Output N Polarity */
\r
6110 tmpccer |= (OC_Config->OCNPolarity << 4U);
\r
6111 /* Reset the Output N State */
\r
6112 tmpccer &= ~TIM_CCER_CC2NE;
\r
6116 if (IS_TIM_BREAK_INSTANCE(TIMx))
\r
6118 /* Check parameters */
\r
6119 assert_param(IS_TIM_OCNIDLE_STATE(OC_Config->OCNIdleState));
\r
6120 assert_param(IS_TIM_OCIDLE_STATE(OC_Config->OCIdleState));
\r
6122 /* Reset the Output Compare and Output Compare N IDLE State */
\r
6123 tmpcr2 &= ~TIM_CR2_OIS2;
\r
6124 tmpcr2 &= ~TIM_CR2_OIS2N;
\r
6125 /* Set the Output Idle state */
\r
6126 tmpcr2 |= (OC_Config->OCIdleState << 2U);
\r
6127 /* Set the Output N Idle state */
\r
6128 tmpcr2 |= (OC_Config->OCNIdleState << 2U);
\r
6131 /* Write to TIMx CR2 */
\r
6132 TIMx->CR2 = tmpcr2;
\r
6134 /* Write to TIMx CCMR1 */
\r
6135 TIMx->CCMR1 = tmpccmrx;
\r
6137 /* Set the Capture Compare Register value */
\r
6138 TIMx->CCR2 = OC_Config->Pulse;
\r
6140 /* Write to TIMx CCER */
\r
6141 TIMx->CCER = tmpccer;
\r
6145 * @brief Timer Output Compare 3 configuration
\r
6146 * @param TIMx to select the TIM peripheral
\r
6147 * @param OC_Config The ouput configuration structure
\r
6150 static void TIM_OC3_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
\r
6152 uint32_t tmpccmrx;
\r
6156 /* Disable the Channel 3: Reset the CC2E Bit */
\r
6157 TIMx->CCER &= ~TIM_CCER_CC3E;
\r
6159 /* Get the TIMx CCER register value */
\r
6160 tmpccer = TIMx->CCER;
\r
6161 /* Get the TIMx CR2 register value */
\r
6162 tmpcr2 = TIMx->CR2;
\r
6164 /* Get the TIMx CCMR2 register value */
\r
6165 tmpccmrx = TIMx->CCMR2;
\r
6167 /* Reset the Output Compare mode and Capture/Compare selection Bits */
\r
6168 tmpccmrx &= ~TIM_CCMR2_OC3M;
\r
6169 tmpccmrx &= ~TIM_CCMR2_CC3S;
\r
6170 /* Select the Output Compare Mode */
\r
6171 tmpccmrx |= OC_Config->OCMode;
\r
6173 /* Reset the Output Polarity level */
\r
6174 tmpccer &= ~TIM_CCER_CC3P;
\r
6175 /* Set the Output Compare Polarity */
\r
6176 tmpccer |= (OC_Config->OCPolarity << 8U);
\r
6178 if (IS_TIM_CCXN_INSTANCE(TIMx, TIM_CHANNEL_3))
\r
6180 assert_param(IS_TIM_OCN_POLARITY(OC_Config->OCNPolarity));
\r
6182 /* Reset the Output N Polarity level */
\r
6183 tmpccer &= ~TIM_CCER_CC3NP;
\r
6184 /* Set the Output N Polarity */
\r
6185 tmpccer |= (OC_Config->OCNPolarity << 8U);
\r
6186 /* Reset the Output N State */
\r
6187 tmpccer &= ~TIM_CCER_CC3NE;
\r
6190 if (IS_TIM_BREAK_INSTANCE(TIMx))
\r
6192 /* Check parameters */
\r
6193 assert_param(IS_TIM_OCNIDLE_STATE(OC_Config->OCNIdleState));
\r
6194 assert_param(IS_TIM_OCIDLE_STATE(OC_Config->OCIdleState));
\r
6196 /* Reset the Output Compare and Output Compare N IDLE State */
\r
6197 tmpcr2 &= ~TIM_CR2_OIS3;
\r
6198 tmpcr2 &= ~TIM_CR2_OIS3N;
\r
6199 /* Set the Output Idle state */
\r
6200 tmpcr2 |= (OC_Config->OCIdleState << 4U);
\r
6201 /* Set the Output N Idle state */
\r
6202 tmpcr2 |= (OC_Config->OCNIdleState << 4U);
\r
6205 /* Write to TIMx CR2 */
\r
6206 TIMx->CR2 = tmpcr2;
\r
6208 /* Write to TIMx CCMR2 */
\r
6209 TIMx->CCMR2 = tmpccmrx;
\r
6211 /* Set the Capture Compare Register value */
\r
6212 TIMx->CCR3 = OC_Config->Pulse;
\r
6214 /* Write to TIMx CCER */
\r
6215 TIMx->CCER = tmpccer;
\r
6219 * @brief Timer Output Compare 4 configuration
\r
6220 * @param TIMx to select the TIM peripheral
\r
6221 * @param OC_Config The ouput configuration structure
\r
6224 static void TIM_OC4_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
\r
6226 uint32_t tmpccmrx;
\r
6230 /* Disable the Channel 4: Reset the CC4E Bit */
\r
6231 TIMx->CCER &= ~TIM_CCER_CC4E;
\r
6233 /* Get the TIMx CCER register value */
\r
6234 tmpccer = TIMx->CCER;
\r
6235 /* Get the TIMx CR2 register value */
\r
6236 tmpcr2 = TIMx->CR2;
\r
6238 /* Get the TIMx CCMR2 register value */
\r
6239 tmpccmrx = TIMx->CCMR2;
\r
6241 /* Reset the Output Compare mode and Capture/Compare selection Bits */
\r
6242 tmpccmrx &= ~TIM_CCMR2_OC4M;
\r
6243 tmpccmrx &= ~TIM_CCMR2_CC4S;
\r
6245 /* Select the Output Compare Mode */
\r
6246 tmpccmrx |= (OC_Config->OCMode << 8U);
\r
6248 /* Reset the Output Polarity level */
\r
6249 tmpccer &= ~TIM_CCER_CC4P;
\r
6250 /* Set the Output Compare Polarity */
\r
6251 tmpccer |= (OC_Config->OCPolarity << 12U);
\r
6253 if (IS_TIM_BREAK_INSTANCE(TIMx))
\r
6255 /* Check parameters */
\r
6256 assert_param(IS_TIM_OCIDLE_STATE(OC_Config->OCIdleState));
\r
6258 /* Reset the Output Compare IDLE State */
\r
6259 tmpcr2 &= ~TIM_CR2_OIS4;
\r
6261 /* Set the Output Idle state */
\r
6262 tmpcr2 |= (OC_Config->OCIdleState << 6U);
\r
6265 /* Write to TIMx CR2 */
\r
6266 TIMx->CR2 = tmpcr2;
\r
6268 /* Write to TIMx CCMR2 */
\r
6269 TIMx->CCMR2 = tmpccmrx;
\r
6271 /* Set the Capture Compare Register value */
\r
6272 TIMx->CCR4 = OC_Config->Pulse;
\r
6274 /* Write to TIMx CCER */
\r
6275 TIMx->CCER = tmpccer;
\r
6279 * @brief Timer Output Compare 5 configuration
\r
6280 * @param TIMx to select the TIM peripheral
\r
6281 * @param OC_Config The ouput configuration structure
\r
6284 static void TIM_OC5_SetConfig(TIM_TypeDef *TIMx,
\r
6285 TIM_OC_InitTypeDef *OC_Config)
\r
6287 uint32_t tmpccmrx;
\r
6291 /* Disable the output: Reset the CCxE Bit */
\r
6292 TIMx->CCER &= ~TIM_CCER_CC5E;
\r
6294 /* Get the TIMx CCER register value */
\r
6295 tmpccer = TIMx->CCER;
\r
6296 /* Get the TIMx CR2 register value */
\r
6297 tmpcr2 = TIMx->CR2;
\r
6298 /* Get the TIMx CCMR1 register value */
\r
6299 tmpccmrx = TIMx->CCMR3;
\r
6301 /* Reset the Output Compare Mode Bits */
\r
6302 tmpccmrx &= ~(TIM_CCMR3_OC5M);
\r
6303 /* Select the Output Compare Mode */
\r
6304 tmpccmrx |= OC_Config->OCMode;
\r
6306 /* Reset the Output Polarity level */
\r
6307 tmpccer &= ~TIM_CCER_CC5P;
\r
6308 /* Set the Output Compare Polarity */
\r
6309 tmpccer |= (OC_Config->OCPolarity << 16U);
\r
6311 if (IS_TIM_BREAK_INSTANCE(TIMx))
\r
6313 /* Reset the Output Compare IDLE State */
\r
6314 tmpcr2 &= ~TIM_CR2_OIS5;
\r
6315 /* Set the Output Idle state */
\r
6316 tmpcr2 |= (OC_Config->OCIdleState << 8U);
\r
6318 /* Write to TIMx CR2 */
\r
6319 TIMx->CR2 = tmpcr2;
\r
6321 /* Write to TIMx CCMR3 */
\r
6322 TIMx->CCMR3 = tmpccmrx;
\r
6324 /* Set the Capture Compare Register value */
\r
6325 TIMx->CCR5 = OC_Config->Pulse;
\r
6327 /* Write to TIMx CCER */
\r
6328 TIMx->CCER = tmpccer;
\r
6332 * @brief Timer Output Compare 6 configuration
\r
6333 * @param TIMx to select the TIM peripheral
\r
6334 * @param OC_Config The ouput configuration structure
\r
6337 static void TIM_OC6_SetConfig(TIM_TypeDef *TIMx,
\r
6338 TIM_OC_InitTypeDef *OC_Config)
\r
6340 uint32_t tmpccmrx;
\r
6344 /* Disable the output: Reset the CCxE Bit */
\r
6345 TIMx->CCER &= ~TIM_CCER_CC6E;
\r
6347 /* Get the TIMx CCER register value */
\r
6348 tmpccer = TIMx->CCER;
\r
6349 /* Get the TIMx CR2 register value */
\r
6350 tmpcr2 = TIMx->CR2;
\r
6351 /* Get the TIMx CCMR1 register value */
\r
6352 tmpccmrx = TIMx->CCMR3;
\r
6354 /* Reset the Output Compare Mode Bits */
\r
6355 tmpccmrx &= ~(TIM_CCMR3_OC6M);
\r
6356 /* Select the Output Compare Mode */
\r
6357 tmpccmrx |= (OC_Config->OCMode << 8U);
\r
6359 /* Reset the Output Polarity level */
\r
6360 tmpccer &= (uint32_t)~TIM_CCER_CC6P;
\r
6361 /* Set the Output Compare Polarity */
\r
6362 tmpccer |= (OC_Config->OCPolarity << 20U);
\r
6364 if (IS_TIM_BREAK_INSTANCE(TIMx))
\r
6366 /* Reset the Output Compare IDLE State */
\r
6367 tmpcr2 &= ~TIM_CR2_OIS6;
\r
6368 /* Set the Output Idle state */
\r
6369 tmpcr2 |= (OC_Config->OCIdleState << 10U);
\r
6372 /* Write to TIMx CR2 */
\r
6373 TIMx->CR2 = tmpcr2;
\r
6375 /* Write to TIMx CCMR3 */
\r
6376 TIMx->CCMR3 = tmpccmrx;
\r
6378 /* Set the Capture Compare Register value */
\r
6379 TIMx->CCR6 = OC_Config->Pulse;
\r
6381 /* Write to TIMx CCER */
\r
6382 TIMx->CCER = tmpccer;
\r
6386 * @brief Slave Timer configuration function
\r
6387 * @param htim TIM handle
\r
6388 * @param sSlaveConfig Slave timer configuration
\r
6391 static HAL_StatusTypeDef TIM_SlaveTimer_SetConfig(TIM_HandleTypeDef *htim,
\r
6392 TIM_SlaveConfigTypeDef *sSlaveConfig)
\r
6395 uint32_t tmpccmr1;
\r
6398 /* Get the TIMx SMCR register value */
\r
6399 tmpsmcr = htim->Instance->SMCR;
\r
6401 /* Reset the Trigger Selection Bits */
\r
6402 tmpsmcr &= ~TIM_SMCR_TS;
\r
6403 /* Set the Input Trigger source */
\r
6404 tmpsmcr |= sSlaveConfig->InputTrigger;
\r
6406 /* Reset the slave mode Bits */
\r
6407 tmpsmcr &= ~TIM_SMCR_SMS;
\r
6408 /* Set the slave mode */
\r
6409 tmpsmcr |= sSlaveConfig->SlaveMode;
\r
6411 /* Write to TIMx SMCR */
\r
6412 htim->Instance->SMCR = tmpsmcr;
\r
6414 /* Configure the trigger prescaler, filter, and polarity */
\r
6415 switch (sSlaveConfig->InputTrigger)
\r
6419 /* Check the parameters */
\r
6420 assert_param(IS_TIM_CLOCKSOURCE_ETRMODE1_INSTANCE(htim->Instance));
\r
6421 assert_param(IS_TIM_TRIGGERPRESCALER(sSlaveConfig->TriggerPrescaler));
\r
6422 assert_param(IS_TIM_TRIGGERPOLARITY(sSlaveConfig->TriggerPolarity));
\r
6423 assert_param(IS_TIM_TRIGGERFILTER(sSlaveConfig->TriggerFilter));
\r
6424 /* Configure the ETR Trigger source */
\r
6425 TIM_ETR_SetConfig(htim->Instance,
\r
6426 sSlaveConfig->TriggerPrescaler,
\r
6427 sSlaveConfig->TriggerPolarity,
\r
6428 sSlaveConfig->TriggerFilter);
\r
6432 case TIM_TS_TI1F_ED:
\r
6434 /* Check the parameters */
\r
6435 assert_param(IS_TIM_CC1_INSTANCE(htim->Instance));
\r
6436 assert_param(IS_TIM_TRIGGERFILTER(sSlaveConfig->TriggerFilter));
\r
6438 if(sSlaveConfig->SlaveMode == TIM_SLAVEMODE_GATED)
\r
6443 /* Disable the Channel 1: Reset the CC1E Bit */
\r
6444 tmpccer = htim->Instance->CCER;
\r
6445 htim->Instance->CCER &= ~TIM_CCER_CC1E;
\r
6446 tmpccmr1 = htim->Instance->CCMR1;
\r
6448 /* Set the filter */
\r
6449 tmpccmr1 &= ~TIM_CCMR1_IC1F;
\r
6450 tmpccmr1 |= ((sSlaveConfig->TriggerFilter) << 4U);
\r
6452 /* Write to TIMx CCMR1 and CCER registers */
\r
6453 htim->Instance->CCMR1 = tmpccmr1;
\r
6454 htim->Instance->CCER = tmpccer;
\r
6458 case TIM_TS_TI1FP1:
\r
6460 /* Check the parameters */
\r
6461 assert_param(IS_TIM_CC1_INSTANCE(htim->Instance));
\r
6462 assert_param(IS_TIM_TRIGGERPOLARITY(sSlaveConfig->TriggerPolarity));
\r
6463 assert_param(IS_TIM_TRIGGERFILTER(sSlaveConfig->TriggerFilter));
\r
6465 /* Configure TI1 Filter and Polarity */
\r
6466 TIM_TI1_ConfigInputStage(htim->Instance,
\r
6467 sSlaveConfig->TriggerPolarity,
\r
6468 sSlaveConfig->TriggerFilter);
\r
6472 case TIM_TS_TI2FP2:
\r
6474 /* Check the parameters */
\r
6475 assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
\r
6476 assert_param(IS_TIM_TRIGGERPOLARITY(sSlaveConfig->TriggerPolarity));
\r
6477 assert_param(IS_TIM_TRIGGERFILTER(sSlaveConfig->TriggerFilter));
\r
6479 /* Configure TI2 Filter and Polarity */
\r
6480 TIM_TI2_ConfigInputStage(htim->Instance,
\r
6481 sSlaveConfig->TriggerPolarity,
\r
6482 sSlaveConfig->TriggerFilter);
\r
6491 /* Check the parameter */
\r
6492 assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
\r
6503 * @brief Configure the TI1 as Input.
\r
6504 * @param TIMx to select the TIM peripheral.
\r
6505 * @param TIM_ICPolarity The Input Polarity.
\r
6506 * This parameter can be one of the following values:
\r
6507 * @arg TIM_ICPOLARITY_RISING
\r
6508 * @arg TIM_ICPOLARITY_FALLING
\r
6509 * @arg TIM_ICPOLARITY_BOTHEDGE
\r
6510 * @param TIM_ICSelection specifies the input to be used.
\r
6511 * This parameter can be one of the following values:
\r
6512 * @arg TIM_ICSELECTION_DIRECTTI: TIM Input 1 is selected to be connected to IC1.
\r
6513 * @arg TIM_ICSELECTION_INDIRECTTI: TIM Input 1 is selected to be connected to IC2.
\r
6514 * @arg TIM_ICSELECTION_TRC: TIM Input 1 is selected to be connected to TRC.
\r
6515 * @param TIM_ICFilter Specifies the Input Capture Filter.
\r
6516 * This parameter must be a value between 0x00 and 0x0F.
\r
6518 * @note TIM_ICFilter and TIM_ICPolarity are not used in INDIRECT mode as TI2FP1
\r
6519 * (on channel2 path) is used as the input signal. Therefore CCMR1 must be
\r
6520 * protected against un-initialized filter and polarity values.
\r
6522 void TIM_TI1_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection,
\r
6523 uint32_t TIM_ICFilter)
\r
6525 uint32_t tmpccmr1;
\r
6528 /* Disable the Channel 1: Reset the CC1E Bit */
\r
6529 TIMx->CCER &= ~TIM_CCER_CC1E;
\r
6530 tmpccmr1 = TIMx->CCMR1;
\r
6531 tmpccer = TIMx->CCER;
\r
6533 /* Select the Input */
\r
6534 if (IS_TIM_CC2_INSTANCE(TIMx) != RESET)
\r
6536 tmpccmr1 &= ~TIM_CCMR1_CC1S;
\r
6537 tmpccmr1 |= TIM_ICSelection;
\r
6541 tmpccmr1 |= TIM_CCMR1_CC1S_0;
\r
6544 /* Set the filter */
\r
6545 tmpccmr1 &= ~TIM_CCMR1_IC1F;
\r
6546 tmpccmr1 |= ((TIM_ICFilter << 4U) & TIM_CCMR1_IC1F);
\r
6548 /* Select the Polarity and set the CC1E Bit */
\r
6549 tmpccer &= ~(TIM_CCER_CC1P | TIM_CCER_CC1NP);
\r
6550 tmpccer |= (TIM_ICPolarity & (TIM_CCER_CC1P | TIM_CCER_CC1NP));
\r
6552 /* Write to TIMx CCMR1 and CCER registers */
\r
6553 TIMx->CCMR1 = tmpccmr1;
\r
6554 TIMx->CCER = tmpccer;
\r
6558 * @brief Configure the Polarity and Filter for TI1.
\r
6559 * @param TIMx to select the TIM peripheral.
\r
6560 * @param TIM_ICPolarity The Input Polarity.
\r
6561 * This parameter can be one of the following values:
\r
6562 * @arg TIM_ICPOLARITY_RISING
\r
6563 * @arg TIM_ICPOLARITY_FALLING
\r
6564 * @arg TIM_ICPOLARITY_BOTHEDGE
\r
6565 * @param TIM_ICFilter Specifies the Input Capture Filter.
\r
6566 * This parameter must be a value between 0x00 and 0x0F.
\r
6569 static void TIM_TI1_ConfigInputStage(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICFilter)
\r
6571 uint32_t tmpccmr1;
\r
6574 /* Disable the Channel 1: Reset the CC1E Bit */
\r
6575 tmpccer = TIMx->CCER;
\r
6576 TIMx->CCER &= ~TIM_CCER_CC1E;
\r
6577 tmpccmr1 = TIMx->CCMR1;
\r
6579 /* Set the filter */
\r
6580 tmpccmr1 &= ~TIM_CCMR1_IC1F;
\r
6581 tmpccmr1 |= (TIM_ICFilter << 4U);
\r
6583 /* Select the Polarity and set the CC1E Bit */
\r
6584 tmpccer &= ~(TIM_CCER_CC1P | TIM_CCER_CC1NP);
\r
6585 tmpccer |= TIM_ICPolarity;
\r
6587 /* Write to TIMx CCMR1 and CCER registers */
\r
6588 TIMx->CCMR1 = tmpccmr1;
\r
6589 TIMx->CCER = tmpccer;
\r
6593 * @brief Configure the TI2 as Input.
\r
6594 * @param TIMx to select the TIM peripheral
\r
6595 * @param TIM_ICPolarity The Input Polarity.
\r
6596 * This parameter can be one of the following values:
\r
6597 * @arg TIM_ICPOLARITY_RISING
\r
6598 * @arg TIM_ICPOLARITY_FALLING
\r
6599 * @arg TIM_ICPOLARITY_BOTHEDGE
\r
6600 * @param TIM_ICSelection specifies the input to be used.
\r
6601 * This parameter can be one of the following values:
\r
6602 * @arg TIM_ICSELECTION_DIRECTTI: TIM Input 2 is selected to be connected to IC2.
\r
6603 * @arg TIM_ICSELECTION_INDIRECTTI: TIM Input 2 is selected to be connected to IC1.
\r
6604 * @arg TIM_ICSELECTION_TRC: TIM Input 2 is selected to be connected to TRC.
\r
6605 * @param TIM_ICFilter Specifies the Input Capture Filter.
\r
6606 * This parameter must be a value between 0x00 and 0x0F.
\r
6608 * @note TIM_ICFilter and TIM_ICPolarity are not used in INDIRECT mode as TI1FP2
\r
6609 * (on channel1 path) is used as the input signal. Therefore CCMR1 must be
\r
6610 * protected against un-initialized filter and polarity values.
\r
6612 static void TIM_TI2_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection,
\r
6613 uint32_t TIM_ICFilter)
\r
6615 uint32_t tmpccmr1;
\r
6618 /* Disable the Channel 2: Reset the CC2E Bit */
\r
6619 TIMx->CCER &= ~TIM_CCER_CC2E;
\r
6620 tmpccmr1 = TIMx->CCMR1;
\r
6621 tmpccer = TIMx->CCER;
\r
6623 /* Select the Input */
\r
6624 tmpccmr1 &= ~TIM_CCMR1_CC2S;
\r
6625 tmpccmr1 |= (TIM_ICSelection << 8U);
\r
6627 /* Set the filter */
\r
6628 tmpccmr1 &= ~TIM_CCMR1_IC2F;
\r
6629 tmpccmr1 |= ((TIM_ICFilter << 12U) & TIM_CCMR1_IC2F);
\r
6631 /* Select the Polarity and set the CC2E Bit */
\r
6632 tmpccer &= ~(TIM_CCER_CC2P | TIM_CCER_CC2NP);
\r
6633 tmpccer |= ((TIM_ICPolarity << 4U) & (TIM_CCER_CC2P | TIM_CCER_CC2NP));
\r
6635 /* Write to TIMx CCMR1 and CCER registers */
\r
6636 TIMx->CCMR1 = tmpccmr1 ;
\r
6637 TIMx->CCER = tmpccer;
\r
6641 * @brief Configure the Polarity and Filter for TI2.
\r
6642 * @param TIMx to select the TIM peripheral.
\r
6643 * @param TIM_ICPolarity The Input Polarity.
\r
6644 * This parameter can be one of the following values:
\r
6645 * @arg TIM_ICPOLARITY_RISING
\r
6646 * @arg TIM_ICPOLARITY_FALLING
\r
6647 * @arg TIM_ICPOLARITY_BOTHEDGE
\r
6648 * @param TIM_ICFilter Specifies the Input Capture Filter.
\r
6649 * This parameter must be a value between 0x00 and 0x0F.
\r
6652 static void TIM_TI2_ConfigInputStage(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICFilter)
\r
6654 uint32_t tmpccmr1;
\r
6657 /* Disable the Channel 2: Reset the CC2E Bit */
\r
6658 TIMx->CCER &= ~TIM_CCER_CC2E;
\r
6659 tmpccmr1 = TIMx->CCMR1;
\r
6660 tmpccer = TIMx->CCER;
\r
6662 /* Set the filter */
\r
6663 tmpccmr1 &= ~TIM_CCMR1_IC2F;
\r
6664 tmpccmr1 |= (TIM_ICFilter << 12U);
\r
6666 /* Select the Polarity and set the CC2E Bit */
\r
6667 tmpccer &= ~(TIM_CCER_CC2P | TIM_CCER_CC2NP);
\r
6668 tmpccer |= (TIM_ICPolarity << 4U);
\r
6670 /* Write to TIMx CCMR1 and CCER registers */
\r
6671 TIMx->CCMR1 = tmpccmr1 ;
\r
6672 TIMx->CCER = tmpccer;
\r
6676 * @brief Configure the TI3 as Input.
\r
6677 * @param TIMx to select the TIM peripheral
\r
6678 * @param TIM_ICPolarity The Input Polarity.
\r
6679 * This parameter can be one of the following values:
\r
6680 * @arg TIM_ICPOLARITY_RISING
\r
6681 * @arg TIM_ICPOLARITY_FALLING
\r
6682 * @arg TIM_ICPOLARITY_BOTHEDGE
\r
6683 * @param TIM_ICSelection specifies the input to be used.
\r
6684 * This parameter can be one of the following values:
\r
6685 * @arg TIM_ICSELECTION_DIRECTTI: TIM Input 3 is selected to be connected to IC3.
\r
6686 * @arg TIM_ICSELECTION_INDIRECTTI: TIM Input 3 is selected to be connected to IC4.
\r
6687 * @arg TIM_ICSELECTION_TRC: TIM Input 3 is selected to be connected to TRC.
\r
6688 * @param TIM_ICFilter Specifies the Input Capture Filter.
\r
6689 * This parameter must be a value between 0x00 and 0x0F.
\r
6691 * @note TIM_ICFilter and TIM_ICPolarity are not used in INDIRECT mode as TI3FP4
\r
6692 * (on channel1 path) is used as the input signal. Therefore CCMR2 must be
\r
6693 * protected against un-initialized filter and polarity values.
\r
6695 static void TIM_TI3_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection,
\r
6696 uint32_t TIM_ICFilter)
\r
6698 uint32_t tmpccmr2;
\r
6701 /* Disable the Channel 3: Reset the CC3E Bit */
\r
6702 TIMx->CCER &= ~TIM_CCER_CC3E;
\r
6703 tmpccmr2 = TIMx->CCMR2;
\r
6704 tmpccer = TIMx->CCER;
\r
6706 /* Select the Input */
\r
6707 tmpccmr2 &= ~TIM_CCMR2_CC3S;
\r
6708 tmpccmr2 |= TIM_ICSelection;
\r
6710 /* Set the filter */
\r
6711 tmpccmr2 &= ~TIM_CCMR2_IC3F;
\r
6712 tmpccmr2 |= ((TIM_ICFilter << 4U) & TIM_CCMR2_IC3F);
\r
6714 /* Select the Polarity and set the CC3E Bit */
\r
6715 tmpccer &= ~(TIM_CCER_CC3P | TIM_CCER_CC3NP);
\r
6716 tmpccer |= ((TIM_ICPolarity << 8U) & (TIM_CCER_CC3P | TIM_CCER_CC3NP));
\r
6718 /* Write to TIMx CCMR2 and CCER registers */
\r
6719 TIMx->CCMR2 = tmpccmr2;
\r
6720 TIMx->CCER = tmpccer;
\r
6724 * @brief Configure the TI4 as Input.
\r
6725 * @param TIMx to select the TIM peripheral
\r
6726 * @param TIM_ICPolarity The Input Polarity.
\r
6727 * This parameter can be one of the following values:
\r
6728 * @arg TIM_ICPOLARITY_RISING
\r
6729 * @arg TIM_ICPOLARITY_FALLING
\r
6730 * @arg TIM_ICPOLARITY_BOTHEDGE
\r
6731 * @param TIM_ICSelection specifies the input to be used.
\r
6732 * This parameter can be one of the following values:
\r
6733 * @arg TIM_ICSELECTION_DIRECTTI: TIM Input 4 is selected to be connected to IC4.
\r
6734 * @arg TIM_ICSELECTION_INDIRECTTI: TIM Input 4 is selected to be connected to IC3.
\r
6735 * @arg TIM_ICSELECTION_TRC: TIM Input 4 is selected to be connected to TRC.
\r
6736 * @param TIM_ICFilter Specifies the Input Capture Filter.
\r
6737 * This parameter must be a value between 0x00 and 0x0F.
\r
6738 * @note TIM_ICFilter and TIM_ICPolarity are not used in INDIRECT mode as TI4FP3
\r
6739 * (on channel1 path) is used as the input signal. Therefore CCMR2 must be
\r
6740 * protected against un-initialized filter and polarity values.
\r
6743 static void TIM_TI4_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection,
\r
6744 uint32_t TIM_ICFilter)
\r
6746 uint32_t tmpccmr2;
\r
6749 /* Disable the Channel 4: Reset the CC4E Bit */
\r
6750 TIMx->CCER &= ~TIM_CCER_CC4E;
\r
6751 tmpccmr2 = TIMx->CCMR2;
\r
6752 tmpccer = TIMx->CCER;
\r
6754 /* Select the Input */
\r
6755 tmpccmr2 &= ~TIM_CCMR2_CC4S;
\r
6756 tmpccmr2 |= (TIM_ICSelection << 8U);
\r
6758 /* Set the filter */
\r
6759 tmpccmr2 &= ~TIM_CCMR2_IC4F;
\r
6760 tmpccmr2 |= ((TIM_ICFilter << 12U) & TIM_CCMR2_IC4F);
\r
6762 /* Select the Polarity and set the CC4E Bit */
\r
6763 tmpccer &= ~(TIM_CCER_CC4P | TIM_CCER_CC4NP);
\r
6764 tmpccer |= ((TIM_ICPolarity << 12U) & (TIM_CCER_CC4P | TIM_CCER_CC4NP));
\r
6766 /* Write to TIMx CCMR2 and CCER registers */
\r
6767 TIMx->CCMR2 = tmpccmr2;
\r
6768 TIMx->CCER = tmpccer ;
\r
6772 * @brief Selects the Input Trigger source
\r
6773 * @param TIMx to select the TIM peripheral
\r
6774 * @param InputTriggerSource The Input Trigger source.
\r
6775 * This parameter can be one of the following values:
\r
6776 * @arg TIM_TS_ITR0: Internal Trigger 0
\r
6777 * @arg TIM_TS_ITR1: Internal Trigger 1
\r
6778 * @arg TIM_TS_ITR2: Internal Trigger 2
\r
6779 * @arg TIM_TS_ITR3: Internal Trigger 3
\r
6780 * @arg TIM_TS_TI1F_ED: TI1 Edge Detector
\r
6781 * @arg TIM_TS_TI1FP1: Filtered Timer Input 1
\r
6782 * @arg TIM_TS_TI2FP2: Filtered Timer Input 2
\r
6783 * @arg TIM_TS_ETRF: External Trigger input
\r
6786 static void TIM_ITRx_SetConfig(TIM_TypeDef *TIMx, uint32_t InputTriggerSource)
\r
6790 /* Get the TIMx SMCR register value */
\r
6791 tmpsmcr = TIMx->SMCR;
\r
6792 /* Reset the TS Bits */
\r
6793 tmpsmcr &= ~TIM_SMCR_TS;
\r
6794 /* Set the Input Trigger source and the slave mode*/
\r
6795 tmpsmcr |= (InputTriggerSource | TIM_SLAVEMODE_EXTERNAL1);
\r
6796 /* Write to TIMx SMCR */
\r
6797 TIMx->SMCR = tmpsmcr;
\r
6800 * @brief Configures the TIMx External Trigger (ETR).
\r
6801 * @param TIMx to select the TIM peripheral
\r
6802 * @param TIM_ExtTRGPrescaler The external Trigger Prescaler.
\r
6803 * This parameter can be one of the following values:
\r
6804 * @arg TIM_ETRPRESCALER_DIV1: ETRP Prescaler OFF.
\r
6805 * @arg TIM_ETRPRESCALER_DIV2: ETRP frequency divided by 2.
\r
6806 * @arg TIM_ETRPRESCALER_DIV4: ETRP frequency divided by 4.
\r
6807 * @arg TIM_ETRPRESCALER_DIV8: ETRP frequency divided by 8.
\r
6808 * @param TIM_ExtTRGPolarity The external Trigger Polarity.
\r
6809 * This parameter can be one of the following values:
\r
6810 * @arg TIM_ETRPOLARITY_INVERTED: active low or falling edge active.
\r
6811 * @arg TIM_ETRPOLARITY_NONINVERTED: active high or rising edge active.
\r
6812 * @param ExtTRGFilter External Trigger Filter.
\r
6813 * This parameter must be a value between 0x00 and 0x0F
\r
6816 void TIM_ETR_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ExtTRGPrescaler,
\r
6817 uint32_t TIM_ExtTRGPolarity, uint32_t ExtTRGFilter)
\r
6821 tmpsmcr = TIMx->SMCR;
\r
6823 /* Reset the ETR Bits */
\r
6824 tmpsmcr &= ~(TIM_SMCR_ETF | TIM_SMCR_ETPS | TIM_SMCR_ECE | TIM_SMCR_ETP);
\r
6826 /* Set the Prescaler, the Filter value and the Polarity */
\r
6827 tmpsmcr |= (uint32_t)(TIM_ExtTRGPrescaler | (TIM_ExtTRGPolarity | (ExtTRGFilter << 8U)));
\r
6829 /* Write to TIMx SMCR */
\r
6830 TIMx->SMCR = tmpsmcr;
\r
6834 * @brief Enables or disables the TIM Capture Compare Channel x.
\r
6835 * @param TIMx to select the TIM peripheral
\r
6836 * @param Channel specifies the TIM Channel
\r
6837 * This parameter can be one of the following values:
\r
6838 * @arg TIM_CHANNEL_1: TIM Channel 1
\r
6839 * @arg TIM_CHANNEL_2: TIM Channel 2
\r
6840 * @arg TIM_CHANNEL_3: TIM Channel 3
\r
6841 * @arg TIM_CHANNEL_4: TIM Channel 4
\r
6842 * @arg TIM_CHANNEL_5: TIM Channel 5 selected
\r
6843 * @arg TIM_CHANNEL_6: TIM Channel 6 selected
\r
6844 * @param ChannelState specifies the TIM Channel CCxE bit new state.
\r
6845 * This parameter can be: TIM_CCx_ENABLE or TIM_CCx_DISABLE.
\r
6848 void TIM_CCxChannelCmd(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t ChannelState)
\r
6852 /* Check the parameters */
\r
6853 assert_param(IS_TIM_CC1_INSTANCE(TIMx));
\r
6854 assert_param(IS_TIM_CHANNELS(Channel));
\r
6856 tmp = TIM_CCER_CC1E << (Channel & 0x1FU); /* 0x1FU = 31 bits max shift */
\r
6858 /* Reset the CCxE Bit */
\r
6859 TIMx->CCER &= ~tmp;
\r
6861 /* Set or reset the CCxE Bit */
\r
6862 TIMx->CCER |= (uint32_t)(ChannelState << (Channel & 0x1FU)); /* 0x1FU = 31 bits max shift */
\r
6865 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
6867 * @brief Reset interrupt callbacks to the legacy weak callbacks.
\r
6868 * @param htim pointer to a TIM_HandleTypeDef structure that contains
\r
6869 * the configuration information for TIM module.
\r
6872 void TIM_ResetCallback(TIM_HandleTypeDef *htim)
\r
6874 /* Reset the TIM callback to the legacy weak callbacks */
\r
6875 htim->PeriodElapsedCallback = HAL_TIM_PeriodElapsedCallback; /* Legacy weak PeriodElapsedCallback */
\r
6876 htim->PeriodElapsedHalfCpltCallback = HAL_TIM_PeriodElapsedHalfCpltCallback; /* Legacy weak PeriodElapsedHalfCpltCallback */
\r
6877 htim->TriggerCallback = HAL_TIM_TriggerCallback; /* Legacy weak TriggerCallback */
\r
6878 htim->TriggerHalfCpltCallback = HAL_TIM_TriggerHalfCpltCallback; /* Legacy weak TriggerHalfCpltCallback */
\r
6879 htim->IC_CaptureCallback = HAL_TIM_IC_CaptureCallback; /* Legacy weak IC_CaptureCallback */
\r
6880 htim->IC_CaptureHalfCpltCallback = HAL_TIM_IC_CaptureHalfCpltCallback; /* Legacy weak IC_CaptureHalfCpltCallback */
\r
6881 htim->OC_DelayElapsedCallback = HAL_TIM_OC_DelayElapsedCallback; /* Legacy weak OC_DelayElapsedCallback */
\r
6882 htim->PWM_PulseFinishedCallback = HAL_TIM_PWM_PulseFinishedCallback; /* Legacy weak PWM_PulseFinishedCallback */
\r
6883 htim->PWM_PulseFinishedHalfCpltCallback = HAL_TIM_PWM_PulseFinishedHalfCpltCallback; /* Legacy weak PWM_PulseFinishedHalfCpltCallback */
\r
6884 htim->ErrorCallback = HAL_TIM_ErrorCallback; /* Legacy weak ErrorCallback */
\r
6885 htim->CommutationCallback = HAL_TIMEx_CommutCallback; /* Legacy weak CommutationCallback */
\r
6886 htim->CommutationHalfCpltCallback = HAL_TIMEx_CommutHalfCpltCallback; /* Legacy weak CommutationHalfCpltCallback */
\r
6887 htim->BreakCallback = HAL_TIMEx_BreakCallback; /* Legacy weak BreakCallback */
\r
6888 htim->Break2Callback = HAL_TIMEx_Break2Callback; /* Legacy weak Break2Callback */
\r
6890 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
6896 #endif /* HAL_TIM_MODULE_ENABLED */
\r
6904 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
\r