2 ******************************************************************************
\r
3 * @file stm32l4xx_hal_tim_ex.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 Extended peripheral:
\r
8 * + Time Hall Sensor Interface Initialization
\r
9 * + Time Hall Sensor Interface Start
\r
10 * + Time Complementary signal break and dead time configuration
\r
11 * + Time Master and Slave synchronization configuration
\r
12 * + Time Output Compare/PWM Channel Configuration (for channels 5 and 6)
\r
13 * + Time OCRef clear configuration
\r
14 * + Timer remapping capabilities configuration
\r
16 ==============================================================================
\r
17 ##### TIMER Extended features #####
\r
18 ==============================================================================
\r
20 The Timer Extended features include:
\r
21 (#) Complementary outputs with programmable dead-time for :
\r
23 (++) PWM generation (Edge and Center-aligned Mode)
\r
24 (++) One-pulse mode output
\r
25 (#) Synchronization circuit to control the timer with external signals and to
\r
26 interconnect several timers together.
\r
27 (#) Break input to put the timer output signals in reset state or in a known state.
\r
28 (#) Supports incremental (quadrature) encoder and hall-sensor circuitry for
\r
29 positioning purposes
\r
31 ##### How to use this driver #####
\r
32 ==============================================================================
\r
34 (#) Initialize the TIM low level resources by implementing the following functions
\r
35 depending on the selected feature:
\r
36 (++) Hall Sensor output : HAL_TIMEx_HallSensor_MspInit()
\r
38 (#) Initialize the TIM low level resources :
\r
39 (##) Enable the TIM interface clock using __HAL_RCC_TIMx_CLK_ENABLE();
\r
40 (##) TIM pins configuration
\r
41 (+++) Enable the clock for the TIM GPIOs using the following function:
\r
42 __HAL_RCC_GPIOx_CLK_ENABLE();
\r
43 (+++) Configure these TIM pins in Alternate function mode using HAL_GPIO_Init();
\r
45 (#) The external Clock can be configured, if needed (the default clock is the
\r
46 internal clock from the APBx), using the following function:
\r
47 HAL_TIM_ConfigClockSource, the clock configuration should be done before
\r
50 (#) Configure the TIM in the desired functioning mode using one of the
\r
51 initialization function of this driver:
\r
52 (++) HAL_TIMEx_HallSensor_Init() and HAL_TIMEx_ConfigCommutEvent(): to use the
\r
53 Timer Hall Sensor Interface and the commutation event with the corresponding
\r
54 Interrupt and DMA request if needed (Note that One Timer is used to interface
\r
55 with the Hall sensor Interface and another Timer should be used to use
\r
56 the commutation event).
\r
58 (#) Activate the TIM peripheral using one of the start functions:
\r
59 (++) Complementary Output Compare : HAL_TIMEx_OCN_Start(), HAL_TIMEx_OCN_Start_DMA(), HAL_TIMEx_OC_Start_IT()
\r
60 (++) Complementary PWM generation : HAL_TIMEx_PWMN_Start(), HAL_TIMEx_PWMN_Start_DMA(), HAL_TIMEx_PWMN_Start_IT()
\r
61 (++) Complementary One-pulse mode output : HAL_TIMEx_OnePulseN_Start(), HAL_TIMEx_OnePulseN_Start_IT()
\r
62 (++) Hall Sensor output : HAL_TIMEx_HallSensor_Start(), HAL_TIMEx_HallSensor_Start_DMA(), HAL_TIMEx_HallSensor_Start_IT().
\r
65 ******************************************************************************
\r
68 * <h2><center>© Copyright (c) 2017 STMicroelectronics.
\r
69 * All rights reserved.</center></h2>
\r
71 * This software component is licensed by ST under BSD 3-Clause license,
\r
72 * the "License"; You may not use this file except in compliance with the
\r
73 * License. You may obtain a copy of the License at:
\r
74 * opensource.org/licenses/BSD-3-Clause
\r
76 ******************************************************************************
\r
79 /* Includes ------------------------------------------------------------------*/
\r
80 #include "stm32l4xx_hal.h"
\r
82 /** @addtogroup STM32L4xx_HAL_Driver
\r
86 /** @defgroup TIMEx TIMEx
\r
87 * @brief TIM Extended HAL module driver
\r
91 #ifdef HAL_TIM_MODULE_ENABLED
\r
93 /* Private typedef -----------------------------------------------------------*/
\r
94 /* Private define ------------------------------------------------------------*/
\r
95 /* Private macro -------------------------------------------------------------*/
\r
96 /* Private variables ---------------------------------------------------------*/
\r
97 /* Private function prototypes -----------------------------------------------*/
\r
98 static void TIM_CCxNChannelCmd(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t ChannelNState);
\r
100 /* Exported functions --------------------------------------------------------*/
\r
101 /** @defgroup TIMEx_Exported_Functions TIM Extended Exported Functions
\r
105 /** @defgroup TIMEx_Exported_Functions_Group1 Extended Timer Hall Sensor functions
\r
106 * @brief Timer Hall Sensor functions
\r
109 ==============================================================================
\r
110 ##### Timer Hall Sensor functions #####
\r
111 ==============================================================================
\r
113 This section provides functions allowing to:
\r
114 (+) Initialize and configure TIM HAL Sensor.
\r
115 (+) De-initialize TIM HAL Sensor.
\r
116 (+) Start the Hall Sensor Interface.
\r
117 (+) Stop the Hall Sensor Interface.
\r
118 (+) Start the Hall Sensor Interface and enable interrupts.
\r
119 (+) Stop the Hall Sensor Interface and disable interrupts.
\r
120 (+) Start the Hall Sensor Interface and enable DMA transfers.
\r
121 (+) Stop the Hall Sensor Interface and disable DMA transfers.
\r
127 * @brief Initializes the TIM Hall Sensor Interface and initialize the associated handle.
\r
128 * @param htim TIM Hall Sensor Interface handle
\r
129 * @param sConfig TIM Hall Sensor configuration structure
\r
130 * @retval HAL status
\r
132 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Init(TIM_HandleTypeDef *htim, TIM_HallSensor_InitTypeDef *sConfig)
\r
134 TIM_OC_InitTypeDef OC_Config;
\r
136 /* Check the TIM handle allocation */
\r
142 /* Check the parameters */
\r
143 assert_param(IS_TIM_HALL_SENSOR_INTERFACE_INSTANCE(htim->Instance));
\r
144 assert_param(IS_TIM_COUNTER_MODE(htim->Init.CounterMode));
\r
145 assert_param(IS_TIM_CLOCKDIVISION_DIV(htim->Init.ClockDivision));
\r
146 assert_param(IS_TIM_AUTORELOAD_PRELOAD(htim->Init.AutoReloadPreload));
\r
147 assert_param(IS_TIM_IC_POLARITY(sConfig->IC1Polarity));
\r
148 assert_param(IS_TIM_IC_PRESCALER(sConfig->IC1Prescaler));
\r
149 assert_param(IS_TIM_IC_FILTER(sConfig->IC1Filter));
\r
151 if (htim->State == HAL_TIM_STATE_RESET)
\r
153 /* Allocate lock resource and initialize it */
\r
154 htim->Lock = HAL_UNLOCKED;
\r
156 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
157 /* Reset interrupt callbacks to legacy week callbacks */
\r
158 TIM_ResetCallback(htim);
\r
160 if (htim->HallSensor_MspInitCallback == NULL)
\r
162 htim->HallSensor_MspInitCallback = HAL_TIMEx_HallSensor_MspInit;
\r
164 /* Init the low level hardware : GPIO, CLOCK, NVIC */
\r
165 htim->HallSensor_MspInitCallback(htim);
\r
167 /* Init the low level hardware : GPIO, CLOCK, NVIC and DMA */
\r
168 HAL_TIMEx_HallSensor_MspInit(htim);
\r
169 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
172 /* Set the TIM state */
\r
173 htim->State = HAL_TIM_STATE_BUSY;
\r
175 /* Configure the Time base in the Encoder Mode */
\r
176 TIM_Base_SetConfig(htim->Instance, &htim->Init);
\r
178 /* Configure the Channel 1 as Input Channel to interface with the three Outputs of the Hall sensor */
\r
179 TIM_TI1_SetConfig(htim->Instance, sConfig->IC1Polarity, TIM_ICSELECTION_TRC, sConfig->IC1Filter);
\r
181 /* Reset the IC1PSC Bits */
\r
182 htim->Instance->CCMR1 &= ~TIM_CCMR1_IC1PSC;
\r
183 /* Set the IC1PSC value */
\r
184 htim->Instance->CCMR1 |= sConfig->IC1Prescaler;
\r
186 /* Enable the Hall sensor interface (XOR function of the three inputs) */
\r
187 htim->Instance->CR2 |= TIM_CR2_TI1S;
\r
189 /* Select the TIM_TS_TI1F_ED signal as Input trigger for the TIM */
\r
190 htim->Instance->SMCR &= ~TIM_SMCR_TS;
\r
191 htim->Instance->SMCR |= TIM_TS_TI1F_ED;
\r
193 /* Use the TIM_TS_TI1F_ED signal to reset the TIM counter each edge detection */
\r
194 htim->Instance->SMCR &= ~TIM_SMCR_SMS;
\r
195 htim->Instance->SMCR |= TIM_SLAVEMODE_RESET;
\r
197 /* Program channel 2 in PWM 2 mode with the desired Commutation_Delay*/
\r
198 OC_Config.OCFastMode = TIM_OCFAST_DISABLE;
\r
199 OC_Config.OCIdleState = TIM_OCIDLESTATE_RESET;
\r
200 OC_Config.OCMode = TIM_OCMODE_PWM2;
\r
201 OC_Config.OCNIdleState = TIM_OCNIDLESTATE_RESET;
\r
202 OC_Config.OCNPolarity = TIM_OCNPOLARITY_HIGH;
\r
203 OC_Config.OCPolarity = TIM_OCPOLARITY_HIGH;
\r
204 OC_Config.Pulse = sConfig->Commutation_Delay;
\r
206 TIM_OC2_SetConfig(htim->Instance, &OC_Config);
\r
208 /* Select OC2REF as trigger output on TRGO: write the MMS bits in the TIMx_CR2
\r
210 htim->Instance->CR2 &= ~TIM_CR2_MMS;
\r
211 htim->Instance->CR2 |= TIM_TRGO_OC2REF;
\r
213 /* Initialize the TIM state*/
\r
214 htim->State = HAL_TIM_STATE_READY;
\r
220 * @brief DeInitializes the TIM Hall Sensor interface
\r
221 * @param htim TIM Hall Sensor Interface handle
\r
222 * @retval HAL status
\r
224 HAL_StatusTypeDef HAL_TIMEx_HallSensor_DeInit(TIM_HandleTypeDef *htim)
\r
226 /* Check the parameters */
\r
227 assert_param(IS_TIM_INSTANCE(htim->Instance));
\r
229 htim->State = HAL_TIM_STATE_BUSY;
\r
231 /* Disable the TIM Peripheral Clock */
\r
232 __HAL_TIM_DISABLE(htim);
\r
234 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
235 if (htim->HallSensor_MspDeInitCallback == NULL)
\r
237 htim->HallSensor_MspDeInitCallback = HAL_TIMEx_HallSensor_MspDeInit;
\r
239 /* DeInit the low level hardware */
\r
240 htim->HallSensor_MspDeInitCallback(htim);
\r
242 /* DeInit the low level hardware: GPIO, CLOCK, NVIC */
\r
243 HAL_TIMEx_HallSensor_MspDeInit(htim);
\r
244 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
246 /* Change TIM state */
\r
247 htim->State = HAL_TIM_STATE_RESET;
\r
250 __HAL_UNLOCK(htim);
\r
256 * @brief Initializes the TIM Hall Sensor MSP.
\r
257 * @param htim TIM Hall Sensor Interface handle
\r
260 __weak void HAL_TIMEx_HallSensor_MspInit(TIM_HandleTypeDef *htim)
\r
262 /* Prevent unused argument(s) compilation warning */
\r
265 /* NOTE : This function should not be modified, when the callback is needed,
\r
266 the HAL_TIMEx_HallSensor_MspInit could be implemented in the user file
\r
271 * @brief DeInitializes TIM Hall Sensor MSP.
\r
272 * @param htim TIM Hall Sensor Interface handle
\r
275 __weak void HAL_TIMEx_HallSensor_MspDeInit(TIM_HandleTypeDef *htim)
\r
277 /* Prevent unused argument(s) compilation warning */
\r
280 /* NOTE : This function should not be modified, when the callback is needed,
\r
281 the HAL_TIMEx_HallSensor_MspDeInit could be implemented in the user file
\r
286 * @brief Starts the TIM Hall Sensor Interface.
\r
287 * @param htim TIM Hall Sensor Interface handle
\r
288 * @retval HAL status
\r
290 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start(TIM_HandleTypeDef *htim)
\r
294 /* Check the parameters */
\r
295 assert_param(IS_TIM_HALL_SENSOR_INTERFACE_INSTANCE(htim->Instance));
\r
297 /* Enable the Input Capture channel 1
\r
298 (in the Hall Sensor Interface the three possible channels that can be used are TIM_CHANNEL_1, TIM_CHANNEL_2 and TIM_CHANNEL_3) */
\r
299 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_ENABLE);
\r
301 /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
\r
302 tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
\r
303 if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
\r
305 __HAL_TIM_ENABLE(htim);
\r
308 /* Return function status */
\r
313 * @brief Stops the TIM Hall sensor Interface.
\r
314 * @param htim TIM Hall Sensor Interface handle
\r
315 * @retval HAL status
\r
317 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop(TIM_HandleTypeDef *htim)
\r
319 /* Check the parameters */
\r
320 assert_param(IS_TIM_HALL_SENSOR_INTERFACE_INSTANCE(htim->Instance));
\r
322 /* Disable the Input Capture channels 1, 2 and 3
\r
323 (in the Hall Sensor Interface the three possible channels that can be used are TIM_CHANNEL_1, TIM_CHANNEL_2 and TIM_CHANNEL_3) */
\r
324 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_DISABLE);
\r
326 /* Disable the Peripheral */
\r
327 __HAL_TIM_DISABLE(htim);
\r
329 /* Return function status */
\r
334 * @brief Starts the TIM Hall Sensor Interface in interrupt mode.
\r
335 * @param htim TIM Hall Sensor Interface handle
\r
336 * @retval HAL status
\r
338 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_IT(TIM_HandleTypeDef *htim)
\r
342 /* Check the parameters */
\r
343 assert_param(IS_TIM_HALL_SENSOR_INTERFACE_INSTANCE(htim->Instance));
\r
345 /* Enable the capture compare Interrupts 1 event */
\r
346 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC1);
\r
348 /* Enable the Input Capture channel 1
\r
349 (in the Hall Sensor Interface the three possible channels that can be used are TIM_CHANNEL_1, TIM_CHANNEL_2 and TIM_CHANNEL_3) */
\r
350 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_ENABLE);
\r
352 /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
\r
353 tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
\r
354 if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
\r
356 __HAL_TIM_ENABLE(htim);
\r
359 /* Return function status */
\r
364 * @brief Stops the TIM Hall Sensor Interface in interrupt mode.
\r
365 * @param htim TIM Hall Sensor Interface handle
\r
366 * @retval HAL status
\r
368 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_IT(TIM_HandleTypeDef *htim)
\r
370 /* Check the parameters */
\r
371 assert_param(IS_TIM_HALL_SENSOR_INTERFACE_INSTANCE(htim->Instance));
\r
373 /* Disable the Input Capture channel 1
\r
374 (in the Hall Sensor Interface the three possible channels that can be used are TIM_CHANNEL_1, TIM_CHANNEL_2 and TIM_CHANNEL_3) */
\r
375 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_DISABLE);
\r
377 /* Disable the capture compare Interrupts event */
\r
378 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC1);
\r
380 /* Disable the Peripheral */
\r
381 __HAL_TIM_DISABLE(htim);
\r
383 /* Return function status */
\r
388 * @brief Starts the TIM Hall Sensor Interface in DMA mode.
\r
389 * @param htim TIM Hall Sensor Interface handle
\r
390 * @param pData The destination Buffer address.
\r
391 * @param Length The length of data to be transferred from TIM peripheral to memory.
\r
392 * @retval HAL status
\r
394 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_DMA(TIM_HandleTypeDef *htim, uint32_t *pData, uint16_t Length)
\r
398 /* Check the parameters */
\r
399 assert_param(IS_TIM_HALL_SENSOR_INTERFACE_INSTANCE(htim->Instance));
\r
401 if ((htim->State == HAL_TIM_STATE_BUSY))
\r
405 else if ((htim->State == HAL_TIM_STATE_READY))
\r
407 if (((uint32_t)pData == 0U) && (Length > 0U))
\r
413 htim->State = HAL_TIM_STATE_BUSY;
\r
418 /* nothing to do */
\r
420 /* Enable the Input Capture channel 1
\r
421 (in the Hall Sensor Interface the three possible channels that can be used are TIM_CHANNEL_1, TIM_CHANNEL_2 and TIM_CHANNEL_3) */
\r
422 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_ENABLE);
\r
424 /* Set the DMA Input Capture 1 Callbacks */
\r
425 htim->hdma[TIM_DMA_ID_CC1]->XferCpltCallback = TIM_DMACaptureCplt;
\r
426 htim->hdma[TIM_DMA_ID_CC1]->XferHalfCpltCallback = TIM_DMACaptureHalfCplt;
\r
427 /* Set the DMA error callback */
\r
428 htim->hdma[TIM_DMA_ID_CC1]->XferErrorCallback = TIM_DMAError ;
\r
430 /* Enable the DMA channel for Capture 1*/
\r
431 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)&htim->Instance->CCR1, (uint32_t)pData, Length) != HAL_OK)
\r
435 /* Enable the capture compare 1 Interrupt */
\r
436 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC1);
\r
438 /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
\r
439 tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
\r
440 if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
\r
442 __HAL_TIM_ENABLE(htim);
\r
445 /* Return function status */
\r
450 * @brief Stops the TIM Hall Sensor Interface in DMA mode.
\r
451 * @param htim TIM Hall Sensor Interface handle
\r
452 * @retval HAL status
\r
454 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_DMA(TIM_HandleTypeDef *htim)
\r
456 /* Check the parameters */
\r
457 assert_param(IS_TIM_HALL_SENSOR_INTERFACE_INSTANCE(htim->Instance));
\r
459 /* Disable the Input Capture channel 1
\r
460 (in the Hall Sensor Interface the three possible channels that can be used are TIM_CHANNEL_1, TIM_CHANNEL_2 and TIM_CHANNEL_3) */
\r
461 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_DISABLE);
\r
464 /* Disable the capture compare Interrupts 1 event */
\r
465 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC1);
\r
467 (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC1]);
\r
468 /* Disable the Peripheral */
\r
469 __HAL_TIM_DISABLE(htim);
\r
471 /* Return function status */
\r
479 /** @defgroup TIMEx_Exported_Functions_Group2 Extended Timer Complementary Output Compare functions
\r
480 * @brief Timer Complementary Output Compare functions
\r
483 ==============================================================================
\r
484 ##### Timer Complementary Output Compare functions #####
\r
485 ==============================================================================
\r
487 This section provides functions allowing to:
\r
488 (+) Start the Complementary Output Compare/PWM.
\r
489 (+) Stop the Complementary Output Compare/PWM.
\r
490 (+) Start the Complementary Output Compare/PWM and enable interrupts.
\r
491 (+) Stop the Complementary Output Compare/PWM and disable interrupts.
\r
492 (+) Start the Complementary Output Compare/PWM and enable DMA transfers.
\r
493 (+) Stop the Complementary Output Compare/PWM and disable DMA transfers.
\r
500 * @brief Starts the TIM Output Compare signal generation on the complementary
\r
502 * @param htim TIM Output Compare handle
\r
503 * @param Channel TIM Channel to be enabled
\r
504 * This parameter can be one of the following values:
\r
505 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
506 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
507 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
508 * @retval HAL status
\r
510 HAL_StatusTypeDef HAL_TIMEx_OCN_Start(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
514 /* Check the parameters */
\r
515 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, Channel));
\r
517 /* Enable the Capture compare channel N */
\r
518 TIM_CCxNChannelCmd(htim->Instance, Channel, TIM_CCxN_ENABLE);
\r
520 /* Enable the Main Output */
\r
521 __HAL_TIM_MOE_ENABLE(htim);
\r
523 /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
\r
524 tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
\r
525 if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
\r
527 __HAL_TIM_ENABLE(htim);
\r
530 /* Return function status */
\r
535 * @brief Stops the TIM Output Compare signal generation on the complementary
\r
537 * @param htim TIM handle
\r
538 * @param Channel TIM Channel to be disabled
\r
539 * This parameter can be one of the following values:
\r
540 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
541 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
542 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
543 * @retval HAL status
\r
545 HAL_StatusTypeDef HAL_TIMEx_OCN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
547 /* Check the parameters */
\r
548 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, Channel));
\r
550 /* Disable the Capture compare channel N */
\r
551 TIM_CCxNChannelCmd(htim->Instance, Channel, TIM_CCxN_DISABLE);
\r
553 /* Disable the Main Output */
\r
554 __HAL_TIM_MOE_DISABLE(htim);
\r
556 /* Disable the Peripheral */
\r
557 __HAL_TIM_DISABLE(htim);
\r
559 /* Return function status */
\r
564 * @brief Starts the TIM Output Compare signal generation in interrupt mode
\r
565 * on the complementary output.
\r
566 * @param htim TIM OC handle
\r
567 * @param Channel TIM Channel to be enabled
\r
568 * This parameter can be one of the following values:
\r
569 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
570 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
571 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
572 * @retval HAL status
\r
574 HAL_StatusTypeDef HAL_TIMEx_OCN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
578 /* Check the parameters */
\r
579 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, Channel));
\r
583 case TIM_CHANNEL_1:
\r
585 /* Enable the TIM Output Compare interrupt */
\r
586 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC1);
\r
590 case TIM_CHANNEL_2:
\r
592 /* Enable the TIM Output Compare interrupt */
\r
593 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC2);
\r
597 case TIM_CHANNEL_3:
\r
599 /* Enable the TIM Output Compare interrupt */
\r
600 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC3);
\r
609 /* Enable the TIM Break interrupt */
\r
610 __HAL_TIM_ENABLE_IT(htim, TIM_IT_BREAK);
\r
612 /* Enable the Capture compare channel N */
\r
613 TIM_CCxNChannelCmd(htim->Instance, Channel, TIM_CCxN_ENABLE);
\r
615 /* Enable the Main Output */
\r
616 __HAL_TIM_MOE_ENABLE(htim);
\r
618 /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
\r
619 tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
\r
620 if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
\r
622 __HAL_TIM_ENABLE(htim);
\r
625 /* Return function status */
\r
630 * @brief Stops the TIM Output Compare signal generation in interrupt mode
\r
631 * on the complementary output.
\r
632 * @param htim TIM Output Compare handle
\r
633 * @param Channel TIM Channel to be disabled
\r
634 * This parameter can be one of the following values:
\r
635 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
636 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
637 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
638 * @retval HAL status
\r
640 HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
643 /* Check the parameters */
\r
644 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, Channel));
\r
648 case TIM_CHANNEL_1:
\r
650 /* Disable the TIM Output Compare interrupt */
\r
651 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC1);
\r
655 case TIM_CHANNEL_2:
\r
657 /* Disable the TIM Output Compare interrupt */
\r
658 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC2);
\r
662 case TIM_CHANNEL_3:
\r
664 /* Disable the TIM Output Compare interrupt */
\r
665 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC3);
\r
673 /* Disable the Capture compare channel N */
\r
674 TIM_CCxNChannelCmd(htim->Instance, Channel, TIM_CCxN_DISABLE);
\r
676 /* Disable the TIM Break interrupt (only if no more channel is active) */
\r
677 tmpccer = htim->Instance->CCER;
\r
678 if ((tmpccer & (TIM_CCER_CC1NE | TIM_CCER_CC2NE | TIM_CCER_CC3NE)) == (uint32_t)RESET)
\r
680 __HAL_TIM_DISABLE_IT(htim, TIM_IT_BREAK);
\r
683 /* Disable the Main Output */
\r
684 __HAL_TIM_MOE_DISABLE(htim);
\r
686 /* Disable the Peripheral */
\r
687 __HAL_TIM_DISABLE(htim);
\r
689 /* Return function status */
\r
694 * @brief Starts the TIM Output Compare signal generation in DMA mode
\r
695 * on the complementary output.
\r
696 * @param htim TIM Output Compare handle
\r
697 * @param Channel TIM Channel to be enabled
\r
698 * This parameter can be one of the following values:
\r
699 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
700 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
701 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
702 * @param pData The source Buffer address.
\r
703 * @param Length The length of data to be transferred from memory to TIM peripheral
\r
704 * @retval HAL status
\r
706 HAL_StatusTypeDef HAL_TIMEx_OCN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length)
\r
710 /* Check the parameters */
\r
711 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, Channel));
\r
713 if ((htim->State == HAL_TIM_STATE_BUSY))
\r
717 else if ((htim->State == HAL_TIM_STATE_READY))
\r
719 if (((uint32_t)pData == 0U) && (Length > 0U))
\r
725 htim->State = HAL_TIM_STATE_BUSY;
\r
730 /* nothing to do */
\r
735 case TIM_CHANNEL_1:
\r
737 /* Set the DMA compare callbacks */
\r
738 htim->hdma[TIM_DMA_ID_CC1]->XferCpltCallback = TIM_DMADelayPulseCplt;
\r
739 htim->hdma[TIM_DMA_ID_CC1]->XferHalfCpltCallback = TIM_DMADelayPulseHalfCplt;
\r
741 /* Set the DMA error callback */
\r
742 htim->hdma[TIM_DMA_ID_CC1]->XferErrorCallback = TIM_DMAError ;
\r
744 /* Enable the DMA channel */
\r
745 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)pData, (uint32_t)&htim->Instance->CCR1, Length) != HAL_OK)
\r
749 /* Enable the TIM Output Compare DMA request */
\r
750 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC1);
\r
754 case TIM_CHANNEL_2:
\r
756 /* Set the DMA compare callbacks */
\r
757 htim->hdma[TIM_DMA_ID_CC2]->XferCpltCallback = TIM_DMADelayPulseCplt;
\r
758 htim->hdma[TIM_DMA_ID_CC2]->XferHalfCpltCallback = TIM_DMADelayPulseHalfCplt;
\r
760 /* Set the DMA error callback */
\r
761 htim->hdma[TIM_DMA_ID_CC2]->XferErrorCallback = TIM_DMAError ;
\r
763 /* Enable the DMA channel */
\r
764 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)pData, (uint32_t)&htim->Instance->CCR2, Length) != HAL_OK)
\r
768 /* Enable the TIM Output Compare DMA request */
\r
769 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC2);
\r
773 case TIM_CHANNEL_3:
\r
775 /* Set the DMA compare callbacks */
\r
776 htim->hdma[TIM_DMA_ID_CC3]->XferCpltCallback = TIM_DMADelayPulseCplt;
\r
777 htim->hdma[TIM_DMA_ID_CC3]->XferHalfCpltCallback = TIM_DMADelayPulseHalfCplt;
\r
779 /* Set the DMA error callback */
\r
780 htim->hdma[TIM_DMA_ID_CC3]->XferErrorCallback = TIM_DMAError ;
\r
782 /* Enable the DMA channel */
\r
783 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC3], (uint32_t)pData, (uint32_t)&htim->Instance->CCR3, Length) != HAL_OK)
\r
787 /* Enable the TIM Output Compare DMA request */
\r
788 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC3);
\r
796 /* Enable the Capture compare channel N */
\r
797 TIM_CCxNChannelCmd(htim->Instance, Channel, TIM_CCxN_ENABLE);
\r
799 /* Enable the Main Output */
\r
800 __HAL_TIM_MOE_ENABLE(htim);
\r
802 /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
\r
803 tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
\r
804 if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
\r
806 __HAL_TIM_ENABLE(htim);
\r
809 /* Return function status */
\r
814 * @brief Stops the TIM Output Compare signal generation in DMA mode
\r
815 * on the complementary output.
\r
816 * @param htim TIM Output Compare handle
\r
817 * @param Channel TIM Channel to be disabled
\r
818 * This parameter can be one of the following values:
\r
819 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
820 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
821 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
822 * @retval HAL status
\r
824 HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
826 /* Check the parameters */
\r
827 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, Channel));
\r
831 case TIM_CHANNEL_1:
\r
833 /* Disable the TIM Output Compare DMA request */
\r
834 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC1);
\r
835 (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC1]);
\r
839 case TIM_CHANNEL_2:
\r
841 /* Disable the TIM Output Compare DMA request */
\r
842 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC2);
\r
843 (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC2]);
\r
847 case TIM_CHANNEL_3:
\r
849 /* Disable the TIM Output Compare DMA request */
\r
850 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC3);
\r
851 (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC3]);
\r
859 /* Disable the Capture compare channel N */
\r
860 TIM_CCxNChannelCmd(htim->Instance, Channel, TIM_CCxN_DISABLE);
\r
862 /* Disable the Main Output */
\r
863 __HAL_TIM_MOE_DISABLE(htim);
\r
865 /* Disable the Peripheral */
\r
866 __HAL_TIM_DISABLE(htim);
\r
868 /* Change the htim state */
\r
869 htim->State = HAL_TIM_STATE_READY;
\r
871 /* Return function status */
\r
879 /** @defgroup TIMEx_Exported_Functions_Group3 Extended Timer Complementary PWM functions
\r
880 * @brief Timer Complementary PWM functions
\r
883 ==============================================================================
\r
884 ##### Timer Complementary PWM functions #####
\r
885 ==============================================================================
\r
887 This section provides functions allowing to:
\r
888 (+) Start the Complementary PWM.
\r
889 (+) Stop the Complementary PWM.
\r
890 (+) Start the Complementary PWM and enable interrupts.
\r
891 (+) Stop the Complementary PWM and disable interrupts.
\r
892 (+) Start the Complementary PWM and enable DMA transfers.
\r
893 (+) Stop the Complementary PWM and disable DMA transfers.
\r
894 (+) Start the Complementary Input Capture measurement.
\r
895 (+) Stop the Complementary Input Capture.
\r
896 (+) Start the Complementary Input Capture and enable interrupts.
\r
897 (+) Stop the Complementary Input Capture and disable interrupts.
\r
898 (+) Start the Complementary Input Capture and enable DMA transfers.
\r
899 (+) Stop the Complementary Input Capture and disable DMA transfers.
\r
900 (+) Start the Complementary One Pulse generation.
\r
901 (+) Stop the Complementary One Pulse.
\r
902 (+) Start the Complementary One Pulse and enable interrupts.
\r
903 (+) Stop the Complementary One Pulse and disable interrupts.
\r
910 * @brief Starts the PWM signal generation on the complementary output.
\r
911 * @param htim TIM handle
\r
912 * @param Channel TIM Channel to be enabled
\r
913 * This parameter can be one of the following values:
\r
914 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
915 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
916 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
917 * @retval HAL status
\r
919 HAL_StatusTypeDef HAL_TIMEx_PWMN_Start(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
923 /* Check the parameters */
\r
924 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, Channel));
\r
926 /* Enable the complementary PWM output */
\r
927 TIM_CCxNChannelCmd(htim->Instance, Channel, TIM_CCxN_ENABLE);
\r
929 /* Enable the Main Output */
\r
930 __HAL_TIM_MOE_ENABLE(htim);
\r
932 /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
\r
933 tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
\r
934 if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
\r
936 __HAL_TIM_ENABLE(htim);
\r
939 /* Return function status */
\r
944 * @brief Stops the PWM signal generation on the complementary output.
\r
945 * @param htim TIM handle
\r
946 * @param Channel TIM Channel to be disabled
\r
947 * This parameter can be one of the following values:
\r
948 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
949 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
950 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
951 * @retval HAL status
\r
953 HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
955 /* Check the parameters */
\r
956 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, Channel));
\r
958 /* Disable the complementary PWM output */
\r
959 TIM_CCxNChannelCmd(htim->Instance, Channel, TIM_CCxN_DISABLE);
\r
961 /* Disable the Main Output */
\r
962 __HAL_TIM_MOE_DISABLE(htim);
\r
964 /* Disable the Peripheral */
\r
965 __HAL_TIM_DISABLE(htim);
\r
967 /* Return function status */
\r
972 * @brief Starts the PWM signal generation in interrupt mode on the
\r
973 * complementary output.
\r
974 * @param htim TIM handle
\r
975 * @param Channel TIM Channel to be disabled
\r
976 * This parameter can be one of the following values:
\r
977 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
978 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
979 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
980 * @retval HAL status
\r
982 HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
986 /* Check the parameters */
\r
987 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, Channel));
\r
991 case TIM_CHANNEL_1:
\r
993 /* Enable the TIM Capture/Compare 1 interrupt */
\r
994 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC1);
\r
998 case TIM_CHANNEL_2:
\r
1000 /* Enable the TIM Capture/Compare 2 interrupt */
\r
1001 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC2);
\r
1005 case TIM_CHANNEL_3:
\r
1007 /* Enable the TIM Capture/Compare 3 interrupt */
\r
1008 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC3);
\r
1016 /* Enable the TIM Break interrupt */
\r
1017 __HAL_TIM_ENABLE_IT(htim, TIM_IT_BREAK);
\r
1019 /* Enable the complementary PWM output */
\r
1020 TIM_CCxNChannelCmd(htim->Instance, Channel, TIM_CCxN_ENABLE);
\r
1022 /* Enable the Main Output */
\r
1023 __HAL_TIM_MOE_ENABLE(htim);
\r
1025 /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
\r
1026 tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
\r
1027 if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
\r
1029 __HAL_TIM_ENABLE(htim);
\r
1032 /* Return function status */
\r
1037 * @brief Stops the PWM signal generation in interrupt mode on the
\r
1038 * complementary output.
\r
1039 * @param htim TIM handle
\r
1040 * @param Channel TIM Channel to be disabled
\r
1041 * This parameter can be one of the following values:
\r
1042 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
1043 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
1044 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
1045 * @retval HAL status
\r
1047 HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
1051 /* Check the parameters */
\r
1052 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, Channel));
\r
1056 case TIM_CHANNEL_1:
\r
1058 /* Disable the TIM Capture/Compare 1 interrupt */
\r
1059 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC1);
\r
1063 case TIM_CHANNEL_2:
\r
1065 /* Disable the TIM Capture/Compare 2 interrupt */
\r
1066 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC2);
\r
1070 case TIM_CHANNEL_3:
\r
1072 /* Disable the TIM Capture/Compare 3 interrupt */
\r
1073 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC3);
\r
1081 /* Disable the complementary PWM output */
\r
1082 TIM_CCxNChannelCmd(htim->Instance, Channel, TIM_CCxN_DISABLE);
\r
1084 /* Disable the TIM Break interrupt (only if no more channel is active) */
\r
1085 tmpccer = htim->Instance->CCER;
\r
1086 if ((tmpccer & (TIM_CCER_CC1NE | TIM_CCER_CC2NE | TIM_CCER_CC3NE)) == (uint32_t)RESET)
\r
1088 __HAL_TIM_DISABLE_IT(htim, TIM_IT_BREAK);
\r
1091 /* Disable the Main Output */
\r
1092 __HAL_TIM_MOE_DISABLE(htim);
\r
1094 /* Disable the Peripheral */
\r
1095 __HAL_TIM_DISABLE(htim);
\r
1097 /* Return function status */
\r
1102 * @brief Starts the TIM PWM signal generation in DMA mode on the
\r
1103 * complementary output
\r
1104 * @param htim TIM handle
\r
1105 * @param Channel TIM Channel to be enabled
\r
1106 * This parameter can be one of the following values:
\r
1107 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
1108 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
1109 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
1110 * @param pData The source Buffer address.
\r
1111 * @param Length The length of data to be transferred from memory to TIM peripheral
\r
1112 * @retval HAL status
\r
1114 HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length)
\r
1118 /* Check the parameters */
\r
1119 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, Channel));
\r
1121 if ((htim->State == HAL_TIM_STATE_BUSY))
\r
1125 else if ((htim->State == HAL_TIM_STATE_READY))
\r
1127 if (((uint32_t)pData == 0U) && (Length > 0U))
\r
1133 htim->State = HAL_TIM_STATE_BUSY;
\r
1138 /* nothing to do */
\r
1142 case TIM_CHANNEL_1:
\r
1144 /* Set the DMA compare callbacks */
\r
1145 htim->hdma[TIM_DMA_ID_CC1]->XferCpltCallback = TIM_DMADelayPulseCplt;
\r
1146 htim->hdma[TIM_DMA_ID_CC1]->XferHalfCpltCallback = TIM_DMADelayPulseHalfCplt;
\r
1148 /* Set the DMA error callback */
\r
1149 htim->hdma[TIM_DMA_ID_CC1]->XferErrorCallback = TIM_DMAError ;
\r
1151 /* Enable the DMA channel */
\r
1152 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)pData, (uint32_t)&htim->Instance->CCR1, Length) != HAL_OK)
\r
1156 /* Enable the TIM Capture/Compare 1 DMA request */
\r
1157 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC1);
\r
1161 case TIM_CHANNEL_2:
\r
1163 /* Set the DMA compare callbacks */
\r
1164 htim->hdma[TIM_DMA_ID_CC2]->XferCpltCallback = TIM_DMADelayPulseCplt;
\r
1165 htim->hdma[TIM_DMA_ID_CC2]->XferHalfCpltCallback = TIM_DMADelayPulseHalfCplt;
\r
1167 /* Set the DMA error callback */
\r
1168 htim->hdma[TIM_DMA_ID_CC2]->XferErrorCallback = TIM_DMAError ;
\r
1170 /* Enable the DMA channel */
\r
1171 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)pData, (uint32_t)&htim->Instance->CCR2, Length) != HAL_OK)
\r
1175 /* Enable the TIM Capture/Compare 2 DMA request */
\r
1176 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC2);
\r
1180 case TIM_CHANNEL_3:
\r
1182 /* Set the DMA compare callbacks */
\r
1183 htim->hdma[TIM_DMA_ID_CC3]->XferCpltCallback = TIM_DMADelayPulseCplt;
\r
1184 htim->hdma[TIM_DMA_ID_CC3]->XferHalfCpltCallback = TIM_DMADelayPulseHalfCplt;
\r
1186 /* Set the DMA error callback */
\r
1187 htim->hdma[TIM_DMA_ID_CC3]->XferErrorCallback = TIM_DMAError ;
\r
1189 /* Enable the DMA channel */
\r
1190 if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC3], (uint32_t)pData, (uint32_t)&htim->Instance->CCR3, Length) != HAL_OK)
\r
1194 /* Enable the TIM Capture/Compare 3 DMA request */
\r
1195 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC3);
\r
1203 /* Enable the complementary PWM output */
\r
1204 TIM_CCxNChannelCmd(htim->Instance, Channel, TIM_CCxN_ENABLE);
\r
1206 /* Enable the Main Output */
\r
1207 __HAL_TIM_MOE_ENABLE(htim);
\r
1209 /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
\r
1210 tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
\r
1211 if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
\r
1213 __HAL_TIM_ENABLE(htim);
\r
1216 /* Return function status */
\r
1221 * @brief Stops the TIM PWM signal generation in DMA mode on the complementary
\r
1223 * @param htim TIM handle
\r
1224 * @param Channel TIM Channel to be disabled
\r
1225 * This parameter can be one of the following values:
\r
1226 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
1227 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
1228 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
1229 * @retval HAL status
\r
1231 HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
1233 /* Check the parameters */
\r
1234 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, Channel));
\r
1238 case TIM_CHANNEL_1:
\r
1240 /* Disable the TIM Capture/Compare 1 DMA request */
\r
1241 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC1);
\r
1242 (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC1]);
\r
1246 case TIM_CHANNEL_2:
\r
1248 /* Disable the TIM Capture/Compare 2 DMA request */
\r
1249 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC2);
\r
1250 (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC2]);
\r
1254 case TIM_CHANNEL_3:
\r
1256 /* Disable the TIM Capture/Compare 3 DMA request */
\r
1257 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC3);
\r
1258 (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC3]);
\r
1266 /* Disable the complementary PWM output */
\r
1267 TIM_CCxNChannelCmd(htim->Instance, Channel, TIM_CCxN_DISABLE);
\r
1269 /* Disable the Main Output */
\r
1270 __HAL_TIM_MOE_DISABLE(htim);
\r
1272 /* Disable the Peripheral */
\r
1273 __HAL_TIM_DISABLE(htim);
\r
1275 /* Change the htim state */
\r
1276 htim->State = HAL_TIM_STATE_READY;
\r
1278 /* Return function status */
\r
1286 /** @defgroup TIMEx_Exported_Functions_Group4 Extended Timer Complementary One Pulse functions
\r
1287 * @brief Timer Complementary One Pulse functions
\r
1290 ==============================================================================
\r
1291 ##### Timer Complementary One Pulse functions #####
\r
1292 ==============================================================================
\r
1294 This section provides functions allowing to:
\r
1295 (+) Start the Complementary One Pulse generation.
\r
1296 (+) Stop the Complementary One Pulse.
\r
1297 (+) Start the Complementary One Pulse and enable interrupts.
\r
1298 (+) Stop the Complementary One Pulse and disable interrupts.
\r
1305 * @brief Starts the TIM One Pulse signal generation on the complementary
\r
1307 * @param htim TIM One Pulse handle
\r
1308 * @param OutputChannel TIM Channel to be enabled
\r
1309 * This parameter can be one of the following values:
\r
1310 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
1311 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
1312 * @retval HAL status
\r
1314 HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
\r
1316 /* Check the parameters */
\r
1317 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, OutputChannel));
\r
1319 /* Enable the complementary One Pulse output */
\r
1320 TIM_CCxNChannelCmd(htim->Instance, OutputChannel, TIM_CCxN_ENABLE);
\r
1322 /* Enable the Main Output */
\r
1323 __HAL_TIM_MOE_ENABLE(htim);
\r
1325 /* Return function status */
\r
1330 * @brief Stops the TIM One Pulse signal generation on the complementary
\r
1332 * @param htim TIM One Pulse handle
\r
1333 * @param OutputChannel TIM Channel 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 * @retval HAL status
\r
1339 HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
\r
1342 /* Check the parameters */
\r
1343 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, OutputChannel));
\r
1345 /* Disable the complementary One Pulse output */
\r
1346 TIM_CCxNChannelCmd(htim->Instance, OutputChannel, TIM_CCxN_DISABLE);
\r
1348 /* Disable the Main Output */
\r
1349 __HAL_TIM_MOE_DISABLE(htim);
\r
1351 /* Disable the Peripheral */
\r
1352 __HAL_TIM_DISABLE(htim);
\r
1354 /* Return function status */
\r
1359 * @brief Starts the TIM One Pulse signal generation in interrupt mode on the
\r
1360 * complementary channel.
\r
1361 * @param htim TIM One Pulse handle
\r
1362 * @param OutputChannel TIM Channel to be enabled
\r
1363 * This parameter can be one of the following values:
\r
1364 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
1365 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
1366 * @retval HAL status
\r
1368 HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
\r
1370 /* Check the parameters */
\r
1371 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, OutputChannel));
\r
1373 /* Enable the TIM Capture/Compare 1 interrupt */
\r
1374 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC1);
\r
1376 /* Enable the TIM Capture/Compare 2 interrupt */
\r
1377 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC2);
\r
1379 /* Enable the complementary One Pulse output */
\r
1380 TIM_CCxNChannelCmd(htim->Instance, OutputChannel, TIM_CCxN_ENABLE);
\r
1382 /* Enable the Main Output */
\r
1383 __HAL_TIM_MOE_ENABLE(htim);
\r
1385 /* Return function status */
\r
1390 * @brief Stops the TIM One Pulse signal generation in interrupt mode on the
\r
1391 * complementary channel.
\r
1392 * @param htim TIM One Pulse handle
\r
1393 * @param OutputChannel TIM Channel to be disabled
\r
1394 * This parameter can be one of the following values:
\r
1395 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
1396 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
1397 * @retval HAL status
\r
1399 HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
\r
1401 /* Check the parameters */
\r
1402 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, OutputChannel));
\r
1404 /* Disable the TIM Capture/Compare 1 interrupt */
\r
1405 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC1);
\r
1407 /* Disable the TIM Capture/Compare 2 interrupt */
\r
1408 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC2);
\r
1410 /* Disable the complementary One Pulse output */
\r
1411 TIM_CCxNChannelCmd(htim->Instance, OutputChannel, TIM_CCxN_DISABLE);
\r
1413 /* Disable the Main Output */
\r
1414 __HAL_TIM_MOE_DISABLE(htim);
\r
1416 /* Disable the Peripheral */
\r
1417 __HAL_TIM_DISABLE(htim);
\r
1419 /* Return function status */
\r
1427 /** @defgroup TIMEx_Exported_Functions_Group5 Extended Peripheral Control functions
\r
1428 * @brief Peripheral Control functions
\r
1431 ==============================================================================
\r
1432 ##### Peripheral Control functions #####
\r
1433 ==============================================================================
\r
1435 This section provides functions allowing to:
\r
1436 (+) Configure the commutation event in case of use of the Hall sensor interface.
\r
1437 (+) Configure Output channels for OC and PWM mode.
\r
1439 (+) Configure Complementary channels, break features and dead time.
\r
1440 (+) Configure Master synchronization.
\r
1441 (+) Configure timer remapping capabilities.
\r
1442 (+) Enable or disable channel grouping.
\r
1449 * @brief Configure the TIM commutation event sequence.
\r
1450 * @note This function is mandatory to use the commutation event in order to
\r
1451 * update the configuration at each commutation detection on the TRGI input of the Timer,
\r
1452 * the typical use of this feature is with the use of another Timer(interface Timer)
\r
1453 * configured in Hall sensor interface, this interface Timer will generate the
\r
1454 * commutation at its TRGO output (connected to Timer used in this function) each time
\r
1455 * the TI1 of the Interface Timer detect a commutation at its input TI1.
\r
1456 * @param htim TIM handle
\r
1457 * @param InputTrigger the Internal trigger corresponding to the Timer Interfacing with the Hall sensor
\r
1458 * This parameter can be one of the following values:
\r
1459 * @arg TIM_TS_ITR0: Internal trigger 0 selected
\r
1460 * @arg TIM_TS_ITR1: Internal trigger 1 selected
\r
1461 * @arg TIM_TS_ITR2: Internal trigger 2 selected
\r
1462 * @arg TIM_TS_ITR3: Internal trigger 3 selected
\r
1463 * @arg TIM_TS_NONE: No trigger is needed
\r
1464 * @param CommutationSource the Commutation Event source
\r
1465 * This parameter can be one of the following values:
\r
1466 * @arg TIM_COMMUTATION_TRGI: Commutation source is the TRGI of the Interface Timer
\r
1467 * @arg TIM_COMMUTATION_SOFTWARE: Commutation source is set by software using the COMG bit
\r
1468 * @retval HAL status
\r
1470 HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent(TIM_HandleTypeDef *htim, uint32_t InputTrigger,
\r
1471 uint32_t CommutationSource)
\r
1473 /* Check the parameters */
\r
1474 assert_param(IS_TIM_COMMUTATION_EVENT_INSTANCE(htim->Instance));
\r
1475 assert_param(IS_TIM_INTERNAL_TRIGGEREVENT_SELECTION(InputTrigger));
\r
1479 if ((InputTrigger == TIM_TS_ITR0) || (InputTrigger == TIM_TS_ITR1) ||
\r
1480 (InputTrigger == TIM_TS_ITR2) || (InputTrigger == TIM_TS_ITR3))
\r
1482 /* Select the Input trigger */
\r
1483 htim->Instance->SMCR &= ~TIM_SMCR_TS;
\r
1484 htim->Instance->SMCR |= InputTrigger;
\r
1487 /* Select the Capture Compare preload feature */
\r
1488 htim->Instance->CR2 |= TIM_CR2_CCPC;
\r
1489 /* Select the Commutation event source */
\r
1490 htim->Instance->CR2 &= ~TIM_CR2_CCUS;
\r
1491 htim->Instance->CR2 |= CommutationSource;
\r
1493 /* Disable Commutation Interrupt */
\r
1494 __HAL_TIM_DISABLE_IT(htim, TIM_IT_COM);
\r
1496 /* Disable Commutation DMA request */
\r
1497 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_COM);
\r
1499 __HAL_UNLOCK(htim);
\r
1505 * @brief Configure the TIM commutation event sequence with interrupt.
\r
1506 * @note This function is mandatory to use the commutation event in order to
\r
1507 * update the configuration at each commutation detection on the TRGI input of the Timer,
\r
1508 * the typical use of this feature is with the use of another Timer(interface Timer)
\r
1509 * configured in Hall sensor interface, this interface Timer will generate the
\r
1510 * commutation at its TRGO output (connected to Timer used in this function) each time
\r
1511 * the TI1 of the Interface Timer detect a commutation at its input TI1.
\r
1512 * @param htim TIM handle
\r
1513 * @param InputTrigger the Internal trigger corresponding to the Timer Interfacing with the Hall sensor
\r
1514 * This parameter can be one of the following values:
\r
1515 * @arg TIM_TS_ITR0: Internal trigger 0 selected
\r
1516 * @arg TIM_TS_ITR1: Internal trigger 1 selected
\r
1517 * @arg TIM_TS_ITR2: Internal trigger 2 selected
\r
1518 * @arg TIM_TS_ITR3: Internal trigger 3 selected
\r
1519 * @arg TIM_TS_NONE: No trigger is needed
\r
1520 * @param CommutationSource the Commutation Event source
\r
1521 * This parameter can be one of the following values:
\r
1522 * @arg TIM_COMMUTATION_TRGI: Commutation source is the TRGI of the Interface Timer
\r
1523 * @arg TIM_COMMUTATION_SOFTWARE: Commutation source is set by software using the COMG bit
\r
1524 * @retval HAL status
\r
1526 HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent_IT(TIM_HandleTypeDef *htim, uint32_t InputTrigger,
\r
1527 uint32_t CommutationSource)
\r
1529 /* Check the parameters */
\r
1530 assert_param(IS_TIM_COMMUTATION_EVENT_INSTANCE(htim->Instance));
\r
1531 assert_param(IS_TIM_INTERNAL_TRIGGEREVENT_SELECTION(InputTrigger));
\r
1535 if ((InputTrigger == TIM_TS_ITR0) || (InputTrigger == TIM_TS_ITR1) ||
\r
1536 (InputTrigger == TIM_TS_ITR2) || (InputTrigger == TIM_TS_ITR3))
\r
1538 /* Select the Input trigger */
\r
1539 htim->Instance->SMCR &= ~TIM_SMCR_TS;
\r
1540 htim->Instance->SMCR |= InputTrigger;
\r
1543 /* Select the Capture Compare preload feature */
\r
1544 htim->Instance->CR2 |= TIM_CR2_CCPC;
\r
1545 /* Select the Commutation event source */
\r
1546 htim->Instance->CR2 &= ~TIM_CR2_CCUS;
\r
1547 htim->Instance->CR2 |= CommutationSource;
\r
1549 /* Disable Commutation DMA request */
\r
1550 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_COM);
\r
1552 /* Enable the Commutation Interrupt */
\r
1553 __HAL_TIM_ENABLE_IT(htim, TIM_IT_COM);
\r
1555 __HAL_UNLOCK(htim);
\r
1561 * @brief Configure the TIM commutation event sequence with DMA.
\r
1562 * @note This function is mandatory to use the commutation event in order to
\r
1563 * update the configuration at each commutation detection on the TRGI input of the Timer,
\r
1564 * the typical use of this feature is with the use of another Timer(interface Timer)
\r
1565 * configured in Hall sensor interface, this interface Timer will generate the
\r
1566 * commutation at its TRGO output (connected to Timer used in this function) each time
\r
1567 * the TI1 of the Interface Timer detect a commutation at its input TI1.
\r
1568 * @note The user should configure the DMA in his own software, in This function only the COMDE bit is set
\r
1569 * @param htim TIM handle
\r
1570 * @param InputTrigger the Internal trigger corresponding to the Timer Interfacing with the Hall sensor
\r
1571 * This parameter can be one of the following values:
\r
1572 * @arg TIM_TS_ITR0: Internal trigger 0 selected
\r
1573 * @arg TIM_TS_ITR1: Internal trigger 1 selected
\r
1574 * @arg TIM_TS_ITR2: Internal trigger 2 selected
\r
1575 * @arg TIM_TS_ITR3: Internal trigger 3 selected
\r
1576 * @arg TIM_TS_NONE: No trigger is needed
\r
1577 * @param CommutationSource the Commutation Event source
\r
1578 * This parameter can be one of the following values:
\r
1579 * @arg TIM_COMMUTATION_TRGI: Commutation source is the TRGI of the Interface Timer
\r
1580 * @arg TIM_COMMUTATION_SOFTWARE: Commutation source is set by software using the COMG bit
\r
1581 * @retval HAL status
\r
1583 HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent_DMA(TIM_HandleTypeDef *htim, uint32_t InputTrigger,
\r
1584 uint32_t CommutationSource)
\r
1586 /* Check the parameters */
\r
1587 assert_param(IS_TIM_COMMUTATION_EVENT_INSTANCE(htim->Instance));
\r
1588 assert_param(IS_TIM_INTERNAL_TRIGGEREVENT_SELECTION(InputTrigger));
\r
1592 if ((InputTrigger == TIM_TS_ITR0) || (InputTrigger == TIM_TS_ITR1) ||
\r
1593 (InputTrigger == TIM_TS_ITR2) || (InputTrigger == TIM_TS_ITR3))
\r
1595 /* Select the Input trigger */
\r
1596 htim->Instance->SMCR &= ~TIM_SMCR_TS;
\r
1597 htim->Instance->SMCR |= InputTrigger;
\r
1600 /* Select the Capture Compare preload feature */
\r
1601 htim->Instance->CR2 |= TIM_CR2_CCPC;
\r
1602 /* Select the Commutation event source */
\r
1603 htim->Instance->CR2 &= ~TIM_CR2_CCUS;
\r
1604 htim->Instance->CR2 |= CommutationSource;
\r
1606 /* Enable the Commutation DMA Request */
\r
1607 /* Set the DMA Commutation Callback */
\r
1608 htim->hdma[TIM_DMA_ID_COMMUTATION]->XferCpltCallback = TIMEx_DMACommutationCplt;
\r
1609 htim->hdma[TIM_DMA_ID_COMMUTATION]->XferHalfCpltCallback = TIMEx_DMACommutationHalfCplt;
\r
1610 /* Set the DMA error callback */
\r
1611 htim->hdma[TIM_DMA_ID_COMMUTATION]->XferErrorCallback = TIM_DMAError;
\r
1613 /* Disable Commutation Interrupt */
\r
1614 __HAL_TIM_DISABLE_IT(htim, TIM_IT_COM);
\r
1616 /* Enable the Commutation DMA Request */
\r
1617 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_COM);
\r
1619 __HAL_UNLOCK(htim);
\r
1625 * @brief Configures the TIM in master mode.
\r
1626 * @param htim TIM handle.
\r
1627 * @param sMasterConfig pointer to a TIM_MasterConfigTypeDef structure that
\r
1628 * contains the selected trigger output (TRGO) and the Master/Slave
\r
1630 * @retval HAL status
\r
1632 HAL_StatusTypeDef HAL_TIMEx_MasterConfigSynchronization(TIM_HandleTypeDef *htim,
\r
1633 TIM_MasterConfigTypeDef *sMasterConfig)
\r
1638 /* Check the parameters */
\r
1639 assert_param(IS_TIM_SYNCHRO_INSTANCE(htim->Instance));
\r
1640 assert_param(IS_TIM_TRGO_SOURCE(sMasterConfig->MasterOutputTrigger));
\r
1641 assert_param(IS_TIM_MSM_STATE(sMasterConfig->MasterSlaveMode));
\r
1643 /* Check input state */
\r
1646 /* Change the handler state */
\r
1647 htim->State = HAL_TIM_STATE_BUSY;
\r
1649 /* Get the TIMx CR2 register value */
\r
1650 tmpcr2 = htim->Instance->CR2;
\r
1652 /* Get the TIMx SMCR register value */
\r
1653 tmpsmcr = htim->Instance->SMCR;
\r
1655 /* If the timer supports ADC synchronization through TRGO2, set the master mode selection 2 */
\r
1656 if (IS_TIM_TRGO2_INSTANCE(htim->Instance))
\r
1658 /* Check the parameters */
\r
1659 assert_param(IS_TIM_TRGO2_SOURCE(sMasterConfig->MasterOutputTrigger2));
\r
1661 /* Clear the MMS2 bits */
\r
1662 tmpcr2 &= ~TIM_CR2_MMS2;
\r
1663 /* Select the TRGO2 source*/
\r
1664 tmpcr2 |= sMasterConfig->MasterOutputTrigger2;
\r
1667 /* Reset the MMS Bits */
\r
1668 tmpcr2 &= ~TIM_CR2_MMS;
\r
1669 /* Select the TRGO source */
\r
1670 tmpcr2 |= sMasterConfig->MasterOutputTrigger;
\r
1672 /* Reset the MSM Bit */
\r
1673 tmpsmcr &= ~TIM_SMCR_MSM;
\r
1674 /* Set master mode */
\r
1675 tmpsmcr |= sMasterConfig->MasterSlaveMode;
\r
1677 /* Update TIMx CR2 */
\r
1678 htim->Instance->CR2 = tmpcr2;
\r
1680 /* Update TIMx SMCR */
\r
1681 htim->Instance->SMCR = tmpsmcr;
\r
1683 /* Change the htim state */
\r
1684 htim->State = HAL_TIM_STATE_READY;
\r
1686 __HAL_UNLOCK(htim);
\r
1692 * @brief Configures the Break feature, dead time, Lock level, OSSI/OSSR State
\r
1693 * and the AOE(automatic output enable).
\r
1694 * @param htim TIM handle
\r
1695 * @param sBreakDeadTimeConfig pointer to a TIM_ConfigBreakDeadConfigTypeDef structure that
\r
1696 * contains the BDTR Register configuration information for the TIM peripheral.
\r
1697 * @retval HAL status
\r
1699 HAL_StatusTypeDef HAL_TIMEx_ConfigBreakDeadTime(TIM_HandleTypeDef *htim,
\r
1700 TIM_BreakDeadTimeConfigTypeDef *sBreakDeadTimeConfig)
\r
1702 /* Keep this variable initialized to 0 as it is used to configure BDTR register */
\r
1703 uint32_t tmpbdtr = 0U;
\r
1705 /* Check the parameters */
\r
1706 assert_param(IS_TIM_BREAK_INSTANCE(htim->Instance));
\r
1707 assert_param(IS_TIM_OSSR_STATE(sBreakDeadTimeConfig->OffStateRunMode));
\r
1708 assert_param(IS_TIM_OSSI_STATE(sBreakDeadTimeConfig->OffStateIDLEMode));
\r
1709 assert_param(IS_TIM_LOCK_LEVEL(sBreakDeadTimeConfig->LockLevel));
\r
1710 assert_param(IS_TIM_DEADTIME(sBreakDeadTimeConfig->DeadTime));
\r
1711 assert_param(IS_TIM_BREAK_STATE(sBreakDeadTimeConfig->BreakState));
\r
1712 assert_param(IS_TIM_BREAK_POLARITY(sBreakDeadTimeConfig->BreakPolarity));
\r
1713 assert_param(IS_TIM_BREAK_FILTER(sBreakDeadTimeConfig->BreakFilter));
\r
1714 assert_param(IS_TIM_AUTOMATIC_OUTPUT_STATE(sBreakDeadTimeConfig->AutomaticOutput));
\r
1716 /* Check input state */
\r
1719 /* Set the Lock level, the Break enable Bit and the Polarity, the OSSR State,
\r
1720 the OSSI State, the dead time value and the Automatic Output Enable Bit */
\r
1722 /* Set the BDTR bits */
\r
1723 MODIFY_REG(tmpbdtr, TIM_BDTR_DTG, sBreakDeadTimeConfig->DeadTime);
\r
1724 MODIFY_REG(tmpbdtr, TIM_BDTR_LOCK, sBreakDeadTimeConfig->LockLevel);
\r
1725 MODIFY_REG(tmpbdtr, TIM_BDTR_OSSI, sBreakDeadTimeConfig->OffStateIDLEMode);
\r
1726 MODIFY_REG(tmpbdtr, TIM_BDTR_OSSR, sBreakDeadTimeConfig->OffStateRunMode);
\r
1727 MODIFY_REG(tmpbdtr, TIM_BDTR_BKE, sBreakDeadTimeConfig->BreakState);
\r
1728 MODIFY_REG(tmpbdtr, TIM_BDTR_BKP, sBreakDeadTimeConfig->BreakPolarity);
\r
1729 MODIFY_REG(tmpbdtr, TIM_BDTR_AOE, sBreakDeadTimeConfig->AutomaticOutput);
\r
1730 MODIFY_REG(tmpbdtr, TIM_BDTR_BKF, (sBreakDeadTimeConfig->BreakFilter << TIM_BDTR_BKF_Pos));
\r
1732 if (IS_TIM_BKIN2_INSTANCE(htim->Instance))
\r
1734 /* Check the parameters */
\r
1735 assert_param(IS_TIM_BREAK2_STATE(sBreakDeadTimeConfig->Break2State));
\r
1736 assert_param(IS_TIM_BREAK2_POLARITY(sBreakDeadTimeConfig->Break2Polarity));
\r
1737 assert_param(IS_TIM_BREAK_FILTER(sBreakDeadTimeConfig->Break2Filter));
\r
1739 /* Set the BREAK2 input related BDTR bits */
\r
1740 MODIFY_REG(tmpbdtr, TIM_BDTR_BK2F, (sBreakDeadTimeConfig->Break2Filter << TIM_BDTR_BK2F_Pos));
\r
1741 MODIFY_REG(tmpbdtr, TIM_BDTR_BK2E, sBreakDeadTimeConfig->Break2State);
\r
1742 MODIFY_REG(tmpbdtr, TIM_BDTR_BK2P, sBreakDeadTimeConfig->Break2Polarity);
\r
1745 /* Set TIMx_BDTR */
\r
1746 htim->Instance->BDTR = tmpbdtr;
\r
1748 __HAL_UNLOCK(htim);
\r
1754 * @brief Configures the break input source.
\r
1755 * @param htim TIM handle.
\r
1756 * @param BreakInput Break input to configure
\r
1757 * This parameter can be one of the following values:
\r
1758 * @arg TIM_BREAKINPUT_BRK: Timer break input
\r
1759 * @arg TIM_BREAKINPUT_BRK2: Timer break 2 input
\r
1760 * @param sBreakInputConfig Break input source configuration
\r
1761 * @retval HAL status
\r
1763 HAL_StatusTypeDef HAL_TIMEx_ConfigBreakInput(TIM_HandleTypeDef *htim,
\r
1764 uint32_t BreakInput,
\r
1765 TIMEx_BreakInputConfigTypeDef *sBreakInputConfig)
\r
1769 uint32_t bkin_enable_mask = 0U;
\r
1770 uint32_t bkin_polarity_mask = 0U;
\r
1771 uint32_t bkin_enable_bitpos = 0U;
\r
1772 uint32_t bkin_polarity_bitpos = 0U;
\r
1774 /* Check the parameters */
\r
1775 assert_param(IS_TIM_BREAK_INSTANCE(htim->Instance));
\r
1776 assert_param(IS_TIM_BREAKINPUT(BreakInput));
\r
1777 assert_param(IS_TIM_BREAKINPUTSOURCE(sBreakInputConfig->Source));
\r
1778 assert_param(IS_TIM_BREAKINPUTSOURCE_STATE(sBreakInputConfig->Enable));
\r
1779 #if defined(DFSDM1_Channel0)
\r
1780 if (sBreakInputConfig->Source != TIM_BREAKINPUTSOURCE_DFSDM1)
\r
1782 assert_param(IS_TIM_BREAKINPUTSOURCE_POLARITY(sBreakInputConfig->Polarity));
\r
1785 assert_param(IS_TIM_BREAKINPUTSOURCE_POLARITY(sBreakInputConfig->Polarity));
\r
1786 #endif /* DFSDM1_Channel0 */
\r
1788 /* Check input state */
\r
1791 switch (sBreakInputConfig->Source)
\r
1793 case TIM_BREAKINPUTSOURCE_BKIN:
\r
1795 bkin_enable_mask = TIM1_OR2_BKINE;
\r
1796 bkin_enable_bitpos = TIM1_OR2_BKINE_Pos;
\r
1797 bkin_polarity_mask = TIM1_OR2_BKINP;
\r
1798 bkin_polarity_bitpos = TIM1_OR2_BKINP_Pos;
\r
1801 case TIM_BREAKINPUTSOURCE_COMP1:
\r
1803 bkin_enable_mask = TIM1_OR2_BKCMP1E;
\r
1804 bkin_enable_bitpos = TIM1_OR2_BKCMP1E_Pos;
\r
1805 bkin_polarity_mask = TIM1_OR2_BKCMP1P;
\r
1806 bkin_polarity_bitpos = TIM1_OR2_BKCMP1P_Pos;
\r
1809 case TIM_BREAKINPUTSOURCE_COMP2:
\r
1811 bkin_enable_mask = TIM1_OR2_BKCMP2E;
\r
1812 bkin_enable_bitpos = TIM1_OR2_BKCMP2E_Pos;
\r
1813 bkin_polarity_mask = TIM1_OR2_BKCMP2P;
\r
1814 bkin_polarity_bitpos = TIM1_OR2_BKCMP2P_Pos;
\r
1817 #if defined(DFSDM1_Channel0)
\r
1818 case TIM_BREAKINPUTSOURCE_DFSDM1:
\r
1820 bkin_enable_mask = TIM1_OR2_BKDF1BK0E;
\r
1821 bkin_enable_bitpos = 8U;
\r
1824 #endif /* DFSDM1_Channel0 */
\r
1830 switch (BreakInput)
\r
1832 case TIM_BREAKINPUT_BRK:
\r
1834 /* Get the TIMx_OR2 register value */
\r
1835 tmporx = htim->Instance->OR2;
\r
1837 /* Enable the break input */
\r
1838 tmporx &= ~bkin_enable_mask;
\r
1839 tmporx |= (sBreakInputConfig->Enable << bkin_enable_bitpos) & bkin_enable_mask;
\r
1841 /* Set the break input polarity */
\r
1842 #if defined(DFSDM1_Channel0)
\r
1843 if (sBreakInputConfig->Source != TIM_BREAKINPUTSOURCE_DFSDM1)
\r
1844 #endif /* DFSDM1_Channel0 */
\r
1846 tmporx &= ~bkin_polarity_mask;
\r
1847 tmporx |= (sBreakInputConfig->Polarity << bkin_polarity_bitpos) & bkin_polarity_mask;
\r
1850 /* Set TIMx_OR2 */
\r
1851 htim->Instance->OR2 = tmporx;
\r
1854 case TIM_BREAKINPUT_BRK2:
\r
1856 /* Get the TIMx_OR3 register value */
\r
1857 tmporx = htim->Instance->OR3;
\r
1859 /* Enable the break input */
\r
1860 tmporx &= ~bkin_enable_mask;
\r
1861 tmporx |= (sBreakInputConfig->Enable << bkin_enable_bitpos) & bkin_enable_mask;
\r
1863 /* Set the break input polarity */
\r
1864 #if defined(DFSDM1_Channel0)
\r
1865 if (sBreakInputConfig->Source != TIM_BREAKINPUTSOURCE_DFSDM1)
\r
1866 #endif /* DFSDM1_Channel0 */
\r
1868 tmporx &= ~bkin_polarity_mask;
\r
1869 tmporx |= (sBreakInputConfig->Polarity << bkin_polarity_bitpos) & bkin_polarity_mask;
\r
1872 /* Set TIMx_OR3 */
\r
1873 htim->Instance->OR3 = tmporx;
\r
1880 __HAL_UNLOCK(htim);
\r
1886 * @brief Configures the TIMx Remapping input capabilities.
\r
1887 * @param htim TIM handle.
\r
1888 * @param Remap specifies the TIM remapping source.
\r
1890 * For TIM1, the parameter is a combination of 2 fields (field1 | field2):
\r
1892 * field1 can have the following values:
\r
1893 * @arg TIM_TIM1_ETR_ADC1_NONE: TIM1_ETR is not connected to any ADC1 AWD (analog watchdog)
\r
1894 * @arg TIM_TIM1_ETR_ADC1_AWD1: TIM1_ETR is connected to ADC1 AWD1
\r
1895 * @arg TIM_TIM1_ETR_ADC1_AWD2: TIM1_ETR is connected to ADC1 AWD2
\r
1896 * @arg TIM_TIM1_ETR_ADC1_AWD3: TIM1_ETR is connected to ADC1 AWD3
\r
1898 * field2 can have the following values:
\r
1899 * @arg TIM_TIM1_TI1_GPIO: TIM1 TI1 is connected to GPIO
\r
1900 * @arg TIM_TIM1_TI1_COMP1: TIM1 TI1 is connected to COMP1 output
\r
1904 * For TIM1, the parameter is a combination of 4 fields (field1 | field2 | field3 | field4):
\r
1906 * field1 can have the following values:
\r
1907 * @arg TIM_TIM1_ETR_ADC1_NONE: TIM1_ETR is not connected to any ADC1 AWD (analog watchdog)
\r
1908 * @arg TIM_TIM1_ETR_ADC1_AWD1: TIM1_ETR is connected to ADC1 AWD1
\r
1909 * @arg TIM_TIM1_ETR_ADC1_AWD2: TIM1_ETR is connected to ADC1 AWD2
\r
1910 * @arg TIM_TIM1_ETR_ADC1_AWD3: TIM1_ETR is connected to ADC1 AWD3
\r
1912 * field2 can have the following values:
\r
1913 * @arg TIM_TIM1_ETR_ADC3_NONE: TIM1_ETR is not connected to any ADC3 AWD (analog watchdog)
\r
1914 * @arg TIM_TIM1_ETR_ADC3_AWD1: TIM1_ETR is connected to ADC3 AWD1
\r
1915 * @arg TIM_TIM1_ETR_ADC3_AWD2: TIM1_ETR is connected to ADC3 AWD2
\r
1916 * @arg TIM_TIM1_ETR_ADC3_AWD3: TIM1_ETR is connected to ADC3 AWD3
\r
1918 * field3 can have the following values:
\r
1919 * @arg TIM_TIM1_TI1_GPIO: TIM1 TI1 is connected to GPIO
\r
1920 * @arg TIM_TIM1_TI1_COMP1: TIM1 TI1 is connected to COMP1 output
\r
1922 * field4 can have the following values:
\r
1923 * @arg TIM_TIM1_ETR_COMP1: TIM1_ETR is connected to COMP1 output
\r
1924 * @arg TIM_TIM1_ETR_COMP2: TIM1_ETR is connected to COMP2 output
\r
1925 * @note When field4 is set to TIM_TIM1_ETR_COMP1 or TIM_TIM1_ETR_COMP2 field1 and field2 values are not significant
\r
1928 * For TIM1, the parameter is a combination of 3 fields (field1 | field2 | field3):
\r
1930 * field1 can have the following values:
\r
1931 * @arg TIM_TIM1_ETR_ADC1_NONE: TIM1_ETR is not connected to any ADC1 AWD (analog watchdog)
\r
1932 * @arg TIM_TIM1_ETR_ADC1_AWD1: TIM1_ETR is connected to ADC1 AWD1
\r
1933 * @arg TIM_TIM1_ETR_ADC1_AWD2: TIM1_ETR is connected to ADC1 AWD2
\r
1934 * @arg TIM_TIM1_ETR_ADC1_AWD3: TIM1_ETR is connected to ADC1 AWD3
\r
1936 * field2 can have the following values:
\r
1937 * @arg TIM_TIM1_TI1_GPIO: TIM1 TI1 is connected to GPIO
\r
1938 * @arg TIM_TIM1_TI1_COMP1: TIM1 TI1 is connected to COMP1 output
\r
1940 * field3 can have the following values:
\r
1941 * @arg TIM_TIM1_ETR_COMP1: TIM1_ETR is connected to COMP1 output
\r
1942 * @arg TIM_TIM1_ETR_COMP2: TIM1_ETR is connected to COMP2 output
\r
1944 * @note When field3 is set to TIM_TIM1_ETR_COMP1 or TIM_TIM1_ETR_COMP2 field1 values is not significant
\r
1948 * For TIM2, the parameter is a combination of 3 fields (field1 | field2 | field3):
\r
1950 * field1 can have the following values:
\r
1951 * @arg TIM_TIM2_ITR1_TIM8_TRGO: TIM2_ITR1 is connected to TIM8_TRGO
\r
1952 * @arg TIM_TIM2_ITR1_OTG_FS_SOF: TIM2_ITR1 is connected to OTG_FS SOF
\r
1954 * field2 can have the following values:
\r
1955 * @arg TIM_TIM2_ETR_GPIO: TIM2_ETR is connected to GPIO
\r
1956 * @arg TIM_TIM2_ETR_LSE: TIM2_ETR is connected to LSE
\r
1957 * @arg TIM_TIM2_ETR_COMP1: TIM2_ETR is connected to COMP1 output
\r
1958 * @arg TIM_TIM2_ETR_COMP2: TIM2_ETR is connected to COMP2 output
\r
1960 * field3 can have the following values:
\r
1961 * @arg TIM_TIM2_TI4_GPIO: TIM2 TI4 is connected to GPIO
\r
1962 * @arg TIM_TIM2_TI4_COMP1: TIM2 TI4 is connected to COMP1 output
\r
1963 * @arg TIM_TIM2_TI4_COMP2: TIM2 TI4 is connected to COMP2 output
\r
1964 * @arg TIM_TIM2_TI4_COMP1_COMP2: TIM2 TI4 is connected to logical OR between COMP1 and COMP2 output
\r
1967 * For TIM2, the parameter is a combination of 3 fields (field1 | field2 | field3):
\r
1969 * field1 can have the following values:
\r
1970 * @arg TIM_TIM2_ITR1_NONE: No internal trigger on TIM2_ITR1
\r
1971 * @arg TIM_TIM2_ITR1_USB_SOF: TIM2_ITR1 is connected to USB SOF
\r
1973 * field2 can have the following values:
\r
1974 * @arg TIM_TIM2_ETR_GPIO: TIM2_ETR is connected to GPIO
\r
1975 * @arg TIM_TIM2_ETR_LSE: TIM2_ETR is connected to LSE
\r
1976 * @arg TIM_TIM2_ETR_COMP1: TIM2_ETR is connected to COMP1 output
\r
1978 * field3 can have the following values:
\r
1979 * @arg TIM_TIM2_TI4_GPIO: TIM2 TI4 is connected to GPIO
\r
1980 * @arg TIM_TIM2_TI4_COMP1: TIM2 TI4 is connected to COMP1 output
\r
1984 * For TIM2, the parameter is a combination of 3 fields (field1 | field2 | field3):
\r
1986 * field1 can have the following values:
\r
1987 * @arg TIM_TIM2_ITR1_NONE: No internal trigger on TIM2_ITR1
\r
1988 * @arg TIM_TIM2_ITR1_USB_SOF: TIM2_ITR1 is connected to USB SOF
\r
1990 * field2 can have the following values:
\r
1991 * @arg TIM_TIM2_ETR_GPIO: TIM2_ETR is connected to GPIO
\r
1992 * @arg TIM_TIM2_ETR_LSE: TIM2_ETR is connected to LSE
\r
1993 * @arg TIM_TIM2_ETR_COMP1: TIM2_ETR is connected to COMP1 output
\r
1994 * @arg TIM_TIM2_ETR_COMP2: TIM2_ETR is connected to COMP2 output
\r
1996 * field3 can have the following values:
\r
1997 * @arg TIM_TIM2_TI4_GPIO: TIM2 TI4 is connected to GPIO
\r
1998 * @arg TIM_TIM2_TI4_COMP1: TIM2 TI4 is connected to COMP1 output
\r
1999 * @arg TIM_TIM2_TI4_COMP2: TIM2 TI4 is connected to COMP2 output
\r
2000 * @arg TIM_TIM2_TI4_COMP1_COMP2: TIM2 TI4 is connected to logical OR between COMP1 and COMP2 output
\r
2004 * For TIM3, the parameter is a combination 2 fields(field1 | field2):
\r
2006 * field1 can have the following values:
\r
2007 * @arg TIM_TIM3_TI1_GPIO: TIM3 TI1 is connected to GPIO
\r
2008 * @arg TIM_TIM3_TI1_COMP1: TIM3 TI1 is connected to COMP1 output
\r
2009 * @arg TIM_TIM3_TI1_COMP2: TIM3 TI1 is connected to COMP2 output
\r
2010 * @arg TIM_TIM3_TI1_COMP1_COMP2: TIM3 TI1 is connected to logical OR between COMP1 and COMP2 output
\r
2012 * field2 can have the following values:
\r
2013 * @arg TIM_TIM3_ETR_GPIO: TIM3_ETR is connected to GPIO
\r
2014 * @arg TIM_TIM3_ETR_COMP1: TIM3_ETR is connected to COMP1 output
\r
2018 * For TIM8, the parameter is a combination of 3 fields (field1 | field2 | field3):
\r
2020 * field1 can have the following values:
\r
2021 * @arg TIM_TIM8_ETR_ADC2_NONE: TIM8_ETR is not connected to any ADC2 AWD (analog watchdog)
\r
2022 * @arg TIM_TIM8_ETR_ADC2_AWD1: TIM8_ETR is connected to ADC2 AWD1
\r
2023 * @arg TIM_TIM8_ETR_ADC2_AWD2: TIM8_ETR is connected to ADC2 AWD2
\r
2024 * @arg TIM_TIM8_ETR_ADC2_AWD3: TIM8_ETR is connected to ADC2 AWD3
\r
2026 * field2 can have the following values:
\r
2027 * @arg TIM_TIM8_ETR_ADC3_NONE: TIM8_ETR is not connected to any ADC3 AWD (analog watchdog)
\r
2028 * @arg TIM_TIM8_ETR_ADC3_AWD1: TIM8_ETR is connected to ADC3 AWD1
\r
2029 * @arg TIM_TIM8_ETR_ADC3_AWD2: TIM8_ETR is connected to ADC3 AWD2
\r
2030 * @arg TIM_TIM8_ETR_ADC3_AWD3: TIM8_ETR is connected to ADC3 AWD3
\r
2032 * field3 can have the following values:
\r
2033 * @arg TIM_TIM8_TI1_GPIO: TIM8 TI1 is connected to GPIO
\r
2034 * @arg TIM_TIM8_TI1_COMP2: TIM8 TI1 is connected to COMP2 output
\r
2036 * field4 can have the following values:
\r
2037 * @arg TIM_TIM8_ETR_COMP1: TIM8_ETR is connected to COMP1 output
\r
2038 * @arg TIM_TIM8_ETR_COMP2: TIM8_ETR is connected to COMP2 output
\r
2039 * @note When field4 is set to TIM_TIM8_ETR_COMP1 or TIM_TIM8_ETR_COMP2 field1 and field2 values are not significant
\r
2043 * For TIM15, the parameter is a combination of 2 fields (field1 | field2):
\r
2045 * field1 can have the following values:
\r
2046 * @arg TIM_TIM15_TI1_GPIO: TIM15 TI1 is connected to GPIO
\r
2047 * @arg TIM_TIM15_TI1_LSE: TIM15 TI1 is connected to LSE
\r
2049 * field2 can have the following values:
\r
2050 * @arg TIM_TIM15_ENCODERMODE_NONE: No redirection
\r
2051 * @arg TIM_TIM15_ENCODERMODE_TIM2: TIM2 IC1 and TIM2 IC2 are connected to TIM15 IC1 and TIM15 IC2 respectively
\r
2055 * For TIM15, the parameter is a combination of 2 fields (field1 | field2):
\r
2057 * field1 can have the following values:
\r
2058 * @arg TIM_TIM15_TI1_GPIO: TIM15 TI1 is connected to GPIO
\r
2059 * @arg TIM_TIM15_TI1_LSE: TIM15 TI1 is connected to LSE
\r
2061 * field2 can have the following values:
\r
2062 * @arg TIM_TIM15_ENCODERMODE_NONE: No redirection
\r
2063 * @arg TIM_TIM15_ENCODERMODE_TIM2: TIM2 IC1 and TIM2 IC2 are connected to TIM15 IC1 and TIM15 IC2 respectively
\r
2064 * @arg TIM_TIM15_ENCODERMODE_TIM3: TIM3 IC1 and TIM3 IC2 are connected to TIM15 IC1 and TIM15 IC2 respectively
\r
2065 * @arg TIM_TIM15_ENCODERMODE_TIM4: TIM4 IC1 and TIM4 IC2 are connected to TIM15 IC1 and TIM15 IC2 respectively
\r
2069 * @arg TIM_TIM16_TI1_GPIO: TIM16 TI1 is connected to GPIO
\r
2070 * @arg TIM_TIM16_TI1_LSI: TIM16 TI1 is connected to LSI
\r
2071 * @arg TIM_TIM16_TI1_LSE: TIM16 TI1 is connected to LSE
\r
2072 * @arg TIM_TIM16_TI1_RTC: TIM16 TI1 is connected to RTC wakeup interrupt
\r
2076 * For TIM16, the parameter can have the following values:
\r
2077 * @arg TIM_TIM16_TI1_GPIO: TIM16 TI1 is connected to GPIO
\r
2078 * @arg TIM_TIM16_TI1_LSI: TIM16 TI1 is connected to LSI
\r
2079 * @arg TIM_TIM16_TI1_LSE: TIM16 TI1 is connected to LSE
\r
2080 * @arg TIM_TIM16_TI1_RTC: TIM16 TI1 is connected to RTC wakeup interrupt
\r
2081 * @arg TIM_TIM16_TI1_MSI: TIM16 TI1 is connected to MSI (contraints: MSI clock < 1/4 TIM APB clock)
\r
2082 * @arg TIM_TIM16_TI1_HSE_32: TIM16 TI1 is connected to HSE div 32 (note that HSE div 32 must be selected as RTC clock source)
\r
2083 * @arg TIM_TIM16_TI1_MCO: TIM16 TI1 is connected to MCO
\r
2087 * For TIM16, the parameter can have the following values:
\r
2088 * @arg TIM_TIM16_TI1_GPIO: TIM16 TI1 is connected to GPIO
\r
2089 * @arg TIM_TIM16_TI1_LSI: TIM16 TI1 is connected to LSI
\r
2090 * @arg TIM_TIM16_TI1_LSE: TIM16 TI1 is connected to LSE
\r
2091 * @arg TIM_TIM16_TI1_RTC: TIM16 TI1 is connected to RTC wakeup interrupt
\r
2092 * @arg TIM_TIM16_TI1_MSI: TIM16 TI1 is connected to MSI (contraints: MSI clock < 1/4 TIM APB clock)
\r
2093 * @arg TIM_TIM16_TI1_HSE_32: TIM16 TI1 is connected to HSE div 32 (note that HSE div 32 must be selected as RTC clock source)
\r
2094 * @arg TIM_TIM16_TI1_MCO: TIM16 TI1 is connected to MCO
\r
2098 * For TIM17, the parameter can have the following values:
\r
2099 * @arg TIM_TIM17_TI1_GPIO: TIM17 TI1 is connected to GPIO
\r
2100 * @arg TIM_TIM17_TI1_MSI: TIM17 TI1 is connected to MSI (contraints: MSI clock < 1/4 TIM APB clock)
\r
2101 * @arg TIM_TIM17_TI1_HSE_32: TIM17 TI1 is connected to HSE div 32
\r
2102 * @arg TIM_TIM17_TI1_MCO: TIM17 TI1 is connected to MCO
\r
2105 * @retval HAL status
\r
2107 HAL_StatusTypeDef HAL_TIMEx_RemapConfig(TIM_HandleTypeDef *htim, uint32_t Remap)
\r
2109 uint32_t tmpor1 = 0U;
\r
2110 uint32_t tmpor2 = 0U;
\r
2114 /* Check parameters */
\r
2115 assert_param(IS_TIM_REMAP_INSTANCE(htim->Instance));
\r
2116 assert_param(IS_TIM_REMAP(Remap));
\r
2118 /* Set ETR_SEL bit field (if required) */
\r
2119 if (IS_TIM_ETRSEL_INSTANCE(htim->Instance))
\r
2121 tmpor2 = htim->Instance->OR2;
\r
2122 tmpor2 &= ~TIM1_OR2_ETRSEL_Msk;
\r
2123 tmpor2 |= (Remap & TIM1_OR2_ETRSEL_Msk);
\r
2125 /* Set TIMx_OR2 */
\r
2126 htim->Instance->OR2 = tmpor2;
\r
2129 /* Set other remapping capabilities */
\r
2131 tmpor1 &= ~TIM1_OR2_ETRSEL_Msk;
\r
2133 /* Set TIMx_OR1 */
\r
2134 htim->Instance->OR1 = tmpor1;
\r
2136 __HAL_UNLOCK(htim);
\r
2142 * @brief Group channel 5 and channel 1, 2 or 3
\r
2143 * @param htim TIM handle.
\r
2144 * @param Channels specifies the reference signal(s) the OC5REF is combined with.
\r
2145 * This parameter can be any combination of the following values:
\r
2146 * TIM_GROUPCH5_NONE: No effect of OC5REF on OC1REFC, OC2REFC and OC3REFC
\r
2147 * TIM_GROUPCH5_OC1REFC: OC1REFC is the logical AND of OC1REFC and OC5REF
\r
2148 * TIM_GROUPCH5_OC2REFC: OC2REFC is the logical AND of OC2REFC and OC5REF
\r
2149 * TIM_GROUPCH5_OC3REFC: OC3REFC is the logical AND of OC3REFC and OC5REF
\r
2150 * @retval HAL status
\r
2152 HAL_StatusTypeDef HAL_TIMEx_GroupChannel5(TIM_HandleTypeDef *htim, uint32_t Channels)
\r
2154 /* Check parameters */
\r
2155 assert_param(IS_TIM_COMBINED3PHASEPWM_INSTANCE(htim->Instance));
\r
2156 assert_param(IS_TIM_GROUPCH5(Channels));
\r
2158 /* Process Locked */
\r
2161 htim->State = HAL_TIM_STATE_BUSY;
\r
2163 /* Clear GC5Cx bit fields */
\r
2164 htim->Instance->CCR5 &= ~(TIM_CCR5_GC5C3 | TIM_CCR5_GC5C2 | TIM_CCR5_GC5C1);
\r
2166 /* Set GC5Cx bit fields */
\r
2167 htim->Instance->CCR5 |= Channels;
\r
2169 /* Change the htim state */
\r
2170 htim->State = HAL_TIM_STATE_READY;
\r
2172 __HAL_UNLOCK(htim);
\r
2181 /** @defgroup TIMEx_Exported_Functions_Group6 Extended Callbacks functions
\r
2182 * @brief Extended Callbacks functions
\r
2185 ==============================================================================
\r
2186 ##### Extended Callbacks functions #####
\r
2187 ==============================================================================
\r
2189 This section provides Extended TIM callback functions:
\r
2190 (+) Timer Commutation callback
\r
2191 (+) Timer Break callback
\r
2198 * @brief Hall commutation changed callback in non-blocking mode
\r
2199 * @param htim TIM handle
\r
2202 __weak void HAL_TIMEx_CommutCallback(TIM_HandleTypeDef *htim)
\r
2204 /* Prevent unused argument(s) compilation warning */
\r
2207 /* NOTE : This function should not be modified, when the callback is needed,
\r
2208 the HAL_TIMEx_CommutCallback could be implemented in the user file
\r
2212 * @brief Hall commutation changed half complete callback in non-blocking mode
\r
2213 * @param htim TIM handle
\r
2216 __weak void HAL_TIMEx_CommutHalfCpltCallback(TIM_HandleTypeDef *htim)
\r
2218 /* Prevent unused argument(s) compilation warning */
\r
2221 /* NOTE : This function should not be modified, when the callback is needed,
\r
2222 the HAL_TIMEx_CommutHalfCpltCallback could be implemented in the user file
\r
2227 * @brief Hall Break detection callback in non-blocking mode
\r
2228 * @param htim TIM handle
\r
2231 __weak void HAL_TIMEx_BreakCallback(TIM_HandleTypeDef *htim)
\r
2233 /* Prevent unused argument(s) compilation warning */
\r
2236 /* NOTE : This function should not be modified, when the callback is needed,
\r
2237 the HAL_TIMEx_BreakCallback could be implemented in the user file
\r
2242 * @brief Hall Break2 detection callback in non blocking mode
\r
2243 * @param htim: TIM handle
\r
2246 __weak void HAL_TIMEx_Break2Callback(TIM_HandleTypeDef *htim)
\r
2248 /* Prevent unused argument(s) compilation warning */
\r
2251 /* NOTE : This function Should not be modified, when the callback is needed,
\r
2252 the HAL_TIMEx_Break2Callback could be implemented in the user file
\r
2259 /** @defgroup TIMEx_Exported_Functions_Group7 Extended Peripheral State functions
\r
2260 * @brief Extended Peripheral State functions
\r
2263 ==============================================================================
\r
2264 ##### Extended Peripheral State functions #####
\r
2265 ==============================================================================
\r
2267 This subsection permits to get in run-time the status of the peripheral
\r
2268 and the data flow.
\r
2275 * @brief Return the TIM Hall Sensor interface handle state.
\r
2276 * @param htim TIM Hall Sensor handle
\r
2277 * @retval HAL state
\r
2279 HAL_TIM_StateTypeDef HAL_TIMEx_HallSensor_GetState(TIM_HandleTypeDef *htim)
\r
2281 return htim->State;
\r
2292 /* Private functions ---------------------------------------------------------*/
\r
2293 /** @defgroup TIMEx_Private_Functions TIMEx Private Functions
\r
2298 * @brief TIM DMA Commutation callback.
\r
2299 * @param hdma pointer to DMA handle.
\r
2302 void TIMEx_DMACommutationCplt(DMA_HandleTypeDef *hdma)
\r
2304 TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
\r
2306 /* Change the htim state */
\r
2307 htim->State = HAL_TIM_STATE_READY;
\r
2309 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
2310 htim->CommutationCallback(htim);
\r
2312 HAL_TIMEx_CommutCallback(htim);
\r
2313 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
2317 * @brief TIM DMA Commutation half complete callback.
\r
2318 * @param hdma pointer to DMA handle.
\r
2321 void TIMEx_DMACommutationHalfCplt(DMA_HandleTypeDef *hdma)
\r
2323 TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
\r
2325 /* Change the htim state */
\r
2326 htim->State = HAL_TIM_STATE_READY;
\r
2328 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
\r
2329 htim->CommutationHalfCpltCallback(htim);
\r
2331 HAL_TIMEx_CommutHalfCpltCallback(htim);
\r
2332 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
\r
2337 * @brief Enables or disables the TIM Capture Compare Channel xN.
\r
2338 * @param TIMx to select the TIM peripheral
\r
2339 * @param Channel specifies the TIM Channel
\r
2340 * This parameter can be one of the following values:
\r
2341 * @arg TIM_CHANNEL_1: TIM Channel 1
\r
2342 * @arg TIM_CHANNEL_2: TIM Channel 2
\r
2343 * @arg TIM_CHANNEL_3: TIM Channel 3
\r
2344 * @param ChannelNState specifies the TIM Channel CCxNE bit new state.
\r
2345 * This parameter can be: TIM_CCxN_ENABLE or TIM_CCxN_Disable.
\r
2348 static void TIM_CCxNChannelCmd(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t ChannelNState)
\r
2352 tmp = TIM_CCER_CC1NE << (Channel & 0x1FU); /* 0x1FU = 31 bits max shift */
\r
2354 /* Reset the CCxNE Bit */
\r
2355 TIMx->CCER &= ~tmp;
\r
2357 /* Set or reset the CCxNE Bit */
\r
2358 TIMx->CCER |= (uint32_t)(ChannelNState << (Channel & 0x1FU)); /* 0x1FU = 31 bits max shift */
\r
2364 #endif /* HAL_TIM_MODULE_ENABLED */
\r
2373 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
\r