2 ******************************************************************************
\r
3 * @file stm32f4xx_hal_tim_ex.c
\r
4 * @author MCD Application Team
\r
6 * @date 18-February-2014
\r
7 * @brief TIM HAL module driver.
\r
8 * This file provides firmware functions to manage the following
\r
9 * functionalities of the Timer extension peripheral:
\r
10 * + Time Hall Sensor Interface Initialization
\r
11 * + Time Hall Sensor Interface Start
\r
12 * + Time Complementary signal bread and dead time configuration
\r
13 * + Time Master and Slave synchronization configuration
\r
15 ==============================================================================
\r
16 ##### TIMER Extended features #####
\r
17 ==============================================================================
\r
19 The Timer Extension features include:
\r
20 (#) 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 from feature used :
\r
36 (++) Complementary Output Compare : HAL_TIM_OC_MspInit()
\r
37 (++) Complementary PWM generation : HAL_TIM_PWM_MspInit()
\r
38 (++) Complementary One-pulse mode output : HAL_TIM_OnePulse_MspInit()
\r
39 (++) Hall Sensor output : HAL_TIM_HallSensor_MspInit()
\r
41 (#) Initialize the TIM low level resources :
\r
42 (##) Enable the TIM interface clock using __TIMx_CLK_ENABLE();
\r
43 (##) TIM pins configuration
\r
44 (+++) Enable the clock for the TIM GPIOs using the following function:
\r
45 __GPIOx_CLK_ENABLE();
\r
46 (+++) Configure these TIM pins in Alternate function mode using HAL_GPIO_Init();
\r
48 (#) The external Clock can be configured, if needed (the default clock is the
\r
49 internal clock from the APBx), using the following function:
\r
50 HAL_TIM_ConfigClockSource, the clock configuration should be done before
\r
53 (#) Configure the TIM in the desired functioning mode using one of the
\r
54 initialization function of this driver:
\r
55 (++) HAL_TIMEx_HallSensor_Init and HAL_TIMEx_ConfigCommutationEvent: to use the
\r
56 Timer Hall Sensor Interface and the commutation event with the corresponding
\r
57 Interrupt and DMA request if needed (Note that One Timer is used to interface
\r
58 with the Hall sensor Interface and another Timer should be used to use
\r
59 the commutation event).
\r
61 (#) Activate the TIM peripheral using one of the start functions:
\r
62 (++) Complementary Output Compare : HAL_TIMEx_OCN_Start(), HAL_TIMEx_OCN_Start_DMA(), HAL_TIMEx_OC_Start_IT()
\r
63 (++) Complementary PWM generation : HAL_TIMEx_PWMN_Start(), HAL_TIMEx_PWMN_Start_DMA(), HAL_TIMEx_PWMN_Start_IT()
\r
64 (++) Complementary One-pulse mode output : HAL_TIMEx_OnePulseN_Start(), HAL_TIMEx_OnePulseN_Start_IT()
\r
65 (++) Hall Sensor output : HAL_TIMEx_HallSensor_Start(), HAL_TIMEx_HallSensor_Start_DMA(), HAL_TIMEx_HallSensor_Start_IT().
\r
69 ******************************************************************************
\r
72 * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
\r
74 * Redistribution and use in source and binary forms, with or without modification,
\r
75 * are permitted provided that the following conditions are met:
\r
76 * 1. Redistributions of source code must retain the above copyright notice,
\r
77 * this list of conditions and the following disclaimer.
\r
78 * 2. Redistributions in binary form must reproduce the above copyright notice,
\r
79 * this list of conditions and the following disclaimer in the documentation
\r
80 * and/or other materials provided with the distribution.
\r
81 * 3. Neither the name of STMicroelectronics nor the names of its contributors
\r
82 * may be used to endorse or promote products derived from this software
\r
83 * without specific prior written permission.
\r
85 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
\r
86 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
\r
87 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
\r
88 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
\r
89 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
\r
90 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
\r
91 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
\r
92 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
\r
93 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
\r
94 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
96 ******************************************************************************
\r
99 /* Includes ------------------------------------------------------------------*/
\r
100 #include "stm32f4xx_hal.h"
\r
102 /** @addtogroup STM32F4xx_HAL_Driver
\r
106 /** @defgroup TIMEx
\r
107 * @brief TIM HAL module driver
\r
111 #ifdef HAL_TIM_MODULE_ENABLED
\r
113 /* Private typedef -----------------------------------------------------------*/
\r
114 /* Private define ------------------------------------------------------------*/
\r
115 /* Private macro -------------------------------------------------------------*/
\r
116 /* Private variables ---------------------------------------------------------*/
\r
117 /* Private function prototypes -----------------------------------------------*/
\r
118 static void TIM_CCxNChannelCmd(TIM_TypeDef* TIMx, uint32_t Channel, uint32_t ChannelNState);
\r
119 /* Private functions ---------------------------------------------------------*/
\r
121 /** @defgroup TIMEx_Private_Functions
\r
125 /** @defgroup TIMEx_Group1 Timer Hall Sensor functions
\r
126 * @brief Timer Hall Sensor functions
\r
129 ==============================================================================
\r
130 ##### Timer Hall Sensor functions #####
\r
131 ==============================================================================
\r
133 This section provides functions allowing to:
\r
134 (+) Initialize and configure TIM HAL Sensor.
\r
135 (+) De-initialize TIM HAL Sensor.
\r
136 (+) Start the Hall Sensor Interface.
\r
137 (+) Stop the Hall Sensor Interface.
\r
138 (+) Start the Hall Sensor Interface and enable interrupts.
\r
139 (+) Stop the Hall Sensor Interface and disable interrupts.
\r
140 (+) Start the Hall Sensor Interface and enable DMA transfers.
\r
141 (+) Stop the Hall Sensor Interface and disable DMA transfers.
\r
147 * @brief Initializes the TIM Hall Sensor Interface and create the associated handle.
\r
148 * @param htim: TIM Encoder Interface handle
\r
149 * @param sConfig: TIM Hall Sensor configuration structure
\r
150 * @retval HAL status
\r
152 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Init(TIM_HandleTypeDef *htim, TIM_HallSensor_InitTypeDef* sConfig)
\r
154 TIM_OC_InitTypeDef OC_Config;
\r
156 /* Check the TIM handle allocation */
\r
162 assert_param(IS_TIM_XOR_INSTANCE(htim->Instance));
\r
163 assert_param(IS_TIM_COUNTER_MODE(htim->Init.CounterMode));
\r
164 assert_param(IS_TIM_CLOCKDIVISION_DIV(htim->Init.ClockDivision));
\r
165 assert_param(IS_TIM_IC_POLARITY(sConfig->IC1Polarity));
\r
166 assert_param(IS_TIM_IC_PRESCALER(sConfig->IC1Prescaler));
\r
167 assert_param(IS_TIM_IC_FILTER(sConfig->IC1Filter));
\r
169 /* Set the TIM state */
\r
170 htim->State= HAL_TIM_STATE_BUSY;
\r
172 /* Init the low level hardware : GPIO, CLOCK, NVIC and DMA */
\r
173 HAL_TIMEx_HallSensor_MspInit(htim);
\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 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 /* DeInit the low level hardware: GPIO, CLOCK, NVIC */
\r
235 HAL_TIMEx_HallSensor_MspDeInit(htim);
\r
237 /* Change TIM state */
\r
238 htim->State = HAL_TIM_STATE_RESET;
\r
241 __HAL_UNLOCK(htim);
\r
247 * @brief Initializes the TIM Hall Sensor MSP.
\r
248 * @param htim: TIM handle
\r
251 __weak void HAL_TIMEx_HallSensor_MspInit(TIM_HandleTypeDef *htim)
\r
253 /* NOTE : This function Should not be modified, when the callback is needed,
\r
254 the HAL_TIMEx_HallSensor_MspInit could be implemented in the user file
\r
259 * @brief DeInitializes TIM Hall Sensor MSP.
\r
260 * @param htim: TIM handle
\r
263 __weak void HAL_TIMEx_HallSensor_MspDeInit(TIM_HandleTypeDef *htim)
\r
265 /* NOTE : This function Should not be modified, when the callback is needed,
\r
266 the HAL_TIMEx_HallSensor_MspDeInit could be implemented in the user file
\r
271 * @brief Starts the TIM Hall Sensor Interface.
\r
272 * @param htim : TIM Hall Sensor handle
\r
273 * @retval HAL status
\r
275 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start(TIM_HandleTypeDef *htim)
\r
277 /* Check the parameters */
\r
278 assert_param(IS_TIM_XOR_INSTANCE(htim->Instance));
\r
280 /* Enable the Input Capture channels 1
\r
281 (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
282 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_ENABLE);
\r
284 /* Enable the Peripheral */
\r
285 __HAL_TIM_ENABLE(htim);
\r
287 /* Return function status */
\r
292 * @brief Stops the TIM Hall sensor Interface.
\r
293 * @param htim : TIM Hall Sensor handle
\r
294 * @retval HAL status
\r
296 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop(TIM_HandleTypeDef *htim)
\r
298 /* Check the parameters */
\r
299 assert_param(IS_TIM_XOR_INSTANCE(htim->Instance));
\r
301 /* Disable the Input Capture channels 1, 2 and 3
\r
302 (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
303 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_DISABLE);
\r
305 /* Disable the Peripheral */
\r
306 __HAL_TIM_DISABLE(htim);
\r
308 /* Return function status */
\r
313 * @brief Starts the TIM Hall Sensor Interface in interrupt mode.
\r
314 * @param htim : TIM Hall Sensor handle
\r
315 * @retval HAL status
\r
317 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_IT(TIM_HandleTypeDef *htim)
\r
319 /* Check the parameters */
\r
320 assert_param(IS_TIM_XOR_INSTANCE(htim->Instance));
\r
322 /* Enable the capture compare Interrupts 1 event */
\r
323 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC1);
\r
325 /* Enable the Input Capture channels 1
\r
326 (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
327 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_ENABLE);
\r
329 /* Enable the Peripheral */
\r
330 __HAL_TIM_ENABLE(htim);
\r
332 /* Return function status */
\r
337 * @brief Stops the TIM Hall Sensor Interface in interrupt mode.
\r
338 * @param htim : TIM handle
\r
339 * @retval HAL status
\r
341 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_IT(TIM_HandleTypeDef *htim)
\r
343 /* Check the parameters */
\r
344 assert_param(IS_TIM_XOR_INSTANCE(htim->Instance));
\r
346 /* Disable the Input Capture channels 1
\r
347 (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
348 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_DISABLE);
\r
350 /* Disable the capture compare Interrupts event */
\r
351 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC1);
\r
353 /* Disable the Peripheral */
\r
354 __HAL_TIM_DISABLE(htim);
\r
356 /* Return function status */
\r
361 * @brief Starts the TIM Hall Sensor Interface in DMA mode.
\r
362 * @param htim : TIM Hall Sensor handle
\r
363 * @param pData: The destination Buffer address.
\r
364 * @param Length: The length of data to be transferred from TIM peripheral to memory.
\r
365 * @retval HAL status
\r
367 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_DMA(TIM_HandleTypeDef *htim, uint32_t *pData, uint16_t Length)
\r
369 /* Check the parameters */
\r
370 assert_param(IS_TIM_XOR_INSTANCE(htim->Instance));
\r
372 if((htim->State == HAL_TIM_STATE_BUSY))
\r
376 else if((htim->State == HAL_TIM_STATE_READY))
\r
378 if(((uint32_t)pData == 0 ) && (Length > 0))
\r
384 htim->State = HAL_TIM_STATE_BUSY;
\r
387 /* Enable the Input Capture channels 1
\r
388 (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
389 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_ENABLE);
\r
391 /* Set the DMA Input Capture 1 Callback */
\r
392 htim->hdma[TIM_DMA_ID_CC1]->XferCpltCallback = HAL_TIM_DMACaptureCplt;
\r
393 /* Set the DMA error callback */
\r
394 htim->hdma[TIM_DMA_ID_CC1]->XferErrorCallback = HAL_TIM_DMAError ;
\r
396 /* Enable the DMA Stream for Capture 1*/
\r
397 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)&htim->Instance->CCR1, (uint32_t)pData, Length);
\r
399 /* Enable the capture compare 1 Interrupt */
\r
400 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC1);
\r
402 /* Enable the Peripheral */
\r
403 __HAL_TIM_ENABLE(htim);
\r
405 /* Return function status */
\r
410 * @brief Stops the TIM Hall Sensor Interface in DMA mode.
\r
411 * @param htim : TIM handle
\r
412 * @retval HAL status
\r
414 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_DMA(TIM_HandleTypeDef *htim)
\r
416 /* Check the parameters */
\r
417 assert_param(IS_TIM_XOR_INSTANCE(htim->Instance));
\r
419 /* Disable the Input Capture channels 1
\r
420 (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
421 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_DISABLE);
\r
424 /* Disable the capture compare Interrupts 1 event */
\r
425 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC1);
\r
427 /* Disable the Peripheral */
\r
428 __HAL_TIM_DISABLE(htim);
\r
430 /* Return function status */
\r
438 /** @defgroup TIMEx_Group2 Timer Complementary Output Compare functions
\r
439 * @brief Timer Complementary Output Compare functions
\r
442 ==============================================================================
\r
443 ##### Timer Complementary Output Compare functions #####
\r
444 ==============================================================================
\r
446 This section provides functions allowing to:
\r
447 (+) Start the Complementary Output Compare/PWM.
\r
448 (+) Stop the Complementary Output Compare/PWM.
\r
449 (+) Start the Complementary Output Compare/PWM and enable interrupts.
\r
450 (+) Stop the Complementary Output Compare/PWM and disable interrupts.
\r
451 (+) Start the Complementary Output Compare/PWM and enable DMA transfers.
\r
452 (+) Stop the Complementary Output Compare/PWM and disable DMA transfers.
\r
459 * @brief Starts the TIM Output Compare signal generation on the complementary
\r
461 * @param htim : TIM Output Compare handle
\r
462 * @param Channel : TIM Channel to be enabled
\r
463 * This parameter can be one of the following values:
\r
464 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
465 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
466 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
467 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
\r
468 * @retval HAL status
\r
470 HAL_StatusTypeDef HAL_TIMEx_OCN_Start(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
472 /* Check the parameters */
\r
473 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, Channel));
\r
475 /* Enable the Capture compare channel N */
\r
476 TIM_CCxNChannelCmd(htim->Instance, Channel, TIM_CCxN_ENABLE);
\r
478 /* Enable the Main Ouput */
\r
479 __HAL_TIM_MOE_ENABLE(htim);
\r
481 /* Enable the Peripheral */
\r
482 __HAL_TIM_ENABLE(htim);
\r
484 /* Return function status */
\r
489 * @brief Stops the TIM Output Compare signal generation on the complementary
\r
491 * @param htim : TIM handle
\r
492 * @param Channel : TIM Channel to be disabled
\r
493 * This parameter can be one of the following values:
\r
494 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
495 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
496 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
497 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
\r
498 * @retval HAL status
\r
500 HAL_StatusTypeDef HAL_TIMEx_OCN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
502 /* Check the parameters */
\r
503 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, Channel));
\r
505 /* Disable the Capture compare channel N */
\r
506 TIM_CCxNChannelCmd(htim->Instance, Channel, TIM_CCxN_DISABLE);
\r
508 /* Disable the Main Ouput */
\r
509 __HAL_TIM_MOE_DISABLE(htim);
\r
511 /* Disable the Peripheral */
\r
512 __HAL_TIM_DISABLE(htim);
\r
514 /* Return function status */
\r
519 * @brief Starts the TIM Output Compare signal generation in interrupt mode
\r
520 * on the complementary output.
\r
521 * @param htim : TIM OC handle
\r
522 * @param Channel : TIM Channel to be enabled
\r
523 * This parameter can be one of the following values:
\r
524 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
525 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
526 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
527 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
\r
528 * @retval HAL status
\r
530 HAL_StatusTypeDef HAL_TIMEx_OCN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
532 /* Check the parameters */
\r
533 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, Channel));
\r
537 case TIM_CHANNEL_1:
\r
539 /* Enable the TIM Output Compare interrupt */
\r
540 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC1);
\r
544 case TIM_CHANNEL_2:
\r
546 /* Enable the TIM Output Compare interrupt */
\r
547 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC2);
\r
551 case TIM_CHANNEL_3:
\r
553 /* Enable the TIM Output Compare interrupt */
\r
554 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC3);
\r
558 case TIM_CHANNEL_4:
\r
560 /* Enable the TIM Output Compare interrupt */
\r
561 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC4);
\r
569 /* Enable the Capture compare channel N */
\r
570 TIM_CCxNChannelCmd(htim->Instance, Channel, TIM_CCxN_ENABLE);
\r
572 /* Enable the Main Ouput */
\r
573 __HAL_TIM_MOE_ENABLE(htim);
\r
575 /* Enable the Peripheral */
\r
576 __HAL_TIM_ENABLE(htim);
\r
578 /* Return function status */
\r
583 * @brief Stops the TIM Output Compare signal generation in interrupt mode
\r
584 * on the complementary output.
\r
585 * @param htim : TIM Output Compare handle
\r
586 * @param Channel : TIM Channel to be disabled
\r
587 * This parameter can be one of the following values:
\r
588 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
589 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
590 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
591 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
\r
592 * @retval HAL status
\r
594 HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
596 /* Check the parameters */
\r
597 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, Channel));
\r
601 case TIM_CHANNEL_1:
\r
603 /* Disable the TIM Output Compare interrupt */
\r
604 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC1);
\r
608 case TIM_CHANNEL_2:
\r
610 /* Disable the TIM Output Compare interrupt */
\r
611 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC2);
\r
615 case TIM_CHANNEL_3:
\r
617 /* Disable the TIM Output Compare interrupt */
\r
618 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC3);
\r
622 case TIM_CHANNEL_4:
\r
624 /* Disable the TIM Output Compare interrupt */
\r
625 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC4);
\r
633 /* Disable the Capture compare channel N */
\r
634 TIM_CCxNChannelCmd(htim->Instance, Channel, TIM_CCxN_DISABLE);
\r
636 /* Disable the Main Ouput */
\r
637 __HAL_TIM_MOE_DISABLE(htim);
\r
639 /* Disable the Peripheral */
\r
640 __HAL_TIM_DISABLE(htim);
\r
642 /* Return function status */
\r
647 * @brief Starts the TIM Output Compare signal generation in DMA mode
\r
648 * on the complementary output.
\r
649 * @param htim : TIM Output Compare handle
\r
650 * @param Channel : TIM Channel to be enabled
\r
651 * This parameter can be one of the following values:
\r
652 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
653 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
654 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
655 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
\r
656 * @param pData: The source Buffer address.
\r
657 * @param Length: The length of data to be transferred from memory to TIM peripheral
\r
658 * @retval HAL status
\r
660 HAL_StatusTypeDef HAL_TIMEx_OCN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length)
\r
662 /* Check the parameters */
\r
663 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, Channel));
\r
665 if((htim->State == HAL_TIM_STATE_BUSY))
\r
669 else if((htim->State == HAL_TIM_STATE_READY))
\r
671 if(((uint32_t)pData == 0 ) && (Length > 0))
\r
677 htim->State = HAL_TIM_STATE_BUSY;
\r
682 case TIM_CHANNEL_1:
\r
684 /* Set the DMA Period elapsed callback */
\r
685 htim->hdma[TIM_DMA_ID_CC1]->XferCpltCallback = HAL_TIM_DMADelayPulseCplt;
\r
687 /* Set the DMA error callback */
\r
688 htim->hdma[TIM_DMA_ID_CC1]->XferErrorCallback = HAL_TIM_DMAError ;
\r
690 /* Enable the DMA Stream */
\r
691 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)pData, (uint32_t)&htim->Instance->CCR1, Length);
\r
693 /* Enable the TIM Output Compare DMA request */
\r
694 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC1);
\r
698 case TIM_CHANNEL_2:
\r
700 /* Set the DMA Period elapsed callback */
\r
701 htim->hdma[TIM_DMA_ID_CC2]->XferCpltCallback = HAL_TIM_DMADelayPulseCplt;
\r
703 /* Set the DMA error callback */
\r
704 htim->hdma[TIM_DMA_ID_CC2]->XferErrorCallback = HAL_TIM_DMAError ;
\r
706 /* Enable the DMA Stream */
\r
707 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)pData, (uint32_t)&htim->Instance->CCR2, Length);
\r
709 /* Enable the TIM Output Compare DMA request */
\r
710 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC2);
\r
714 case TIM_CHANNEL_3:
\r
716 /* Set the DMA Period elapsed callback */
\r
717 htim->hdma[TIM_DMA_ID_CC3]->XferCpltCallback = HAL_TIM_DMADelayPulseCplt;
\r
719 /* Set the DMA error callback */
\r
720 htim->hdma[TIM_DMA_ID_CC3]->XferErrorCallback = HAL_TIM_DMAError ;
\r
722 /* Enable the DMA Stream */
\r
723 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC3], (uint32_t)pData, (uint32_t)&htim->Instance->CCR3,Length);
\r
725 /* Enable the TIM Output Compare DMA request */
\r
726 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC3);
\r
730 case TIM_CHANNEL_4:
\r
732 /* Set the DMA Period elapsed callback */
\r
733 htim->hdma[TIM_DMA_ID_CC4]->XferCpltCallback = HAL_TIM_DMADelayPulseCplt;
\r
735 /* Set the DMA error callback */
\r
736 htim->hdma[TIM_DMA_ID_CC4]->XferErrorCallback = HAL_TIM_DMAError ;
\r
738 /* Enable the DMA Stream */
\r
739 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC4], (uint32_t)pData, (uint32_t)&htim->Instance->CCR4, Length);
\r
741 /* Enable the TIM Output Compare DMA request */
\r
742 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC4);
\r
750 /* Enable the Capture compare channel N */
\r
751 TIM_CCxNChannelCmd(htim->Instance, Channel, TIM_CCxN_ENABLE);
\r
753 /* Enable the Main Ouput */
\r
754 __HAL_TIM_MOE_ENABLE(htim);
\r
756 /* Enable the Peripheral */
\r
757 __HAL_TIM_ENABLE(htim);
\r
759 /* Return function status */
\r
764 * @brief Stops the TIM Output Compare signal generation in DMA mode
\r
765 * on the complementary output.
\r
766 * @param htim : TIM Output Compare handle
\r
767 * @param Channel : TIM Channel to be disabled
\r
768 * This parameter can be one of the following values:
\r
769 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
770 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
771 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
772 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
\r
773 * @retval HAL status
\r
775 HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
777 /* Check the parameters */
\r
778 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, Channel));
\r
782 case TIM_CHANNEL_1:
\r
784 /* Disable the TIM Output Compare DMA request */
\r
785 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC1);
\r
789 case TIM_CHANNEL_2:
\r
791 /* Disable the TIM Output Compare DMA request */
\r
792 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC2);
\r
796 case TIM_CHANNEL_3:
\r
798 /* Disable the TIM Output Compare DMA request */
\r
799 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC3);
\r
803 case TIM_CHANNEL_4:
\r
805 /* Disable the TIM Output Compare interrupt */
\r
806 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC4);
\r
814 /* Disable the Capture compare channel N */
\r
815 TIM_CCxNChannelCmd(htim->Instance, Channel, TIM_CCxN_DISABLE);
\r
817 /* Disable the Main Ouput */
\r
818 __HAL_TIM_MOE_DISABLE(htim);
\r
820 /* Disable the Peripheral */
\r
821 __HAL_TIM_DISABLE(htim);
\r
823 /* Change the htim state */
\r
824 htim->State = HAL_TIM_STATE_READY;
\r
826 /* Return function status */
\r
834 /** @defgroup TIMEx_Group3 Timer Complementary PWM functions
\r
835 * @brief Timer Complementary PWM functions
\r
838 ==============================================================================
\r
839 ##### Timer Complementary PWM functions #####
\r
840 ==============================================================================
\r
842 This section provides functions allowing to:
\r
843 (+) Start the Complementary PWM.
\r
844 (+) Stop the Complementary PWM.
\r
845 (+) Start the Complementary PWM and enable interrupts.
\r
846 (+) Stop the Complementary PWM and disable interrupts.
\r
847 (+) Start the Complementary PWM and enable DMA transfers.
\r
848 (+) Stop the Complementary PWM and disable DMA transfers.
\r
849 (+) Start the Complementary Input Capture measurement.
\r
850 (+) Stop the Complementary Input Capture.
\r
851 (+) Start the Complementary Input Capture and enable interrupts.
\r
852 (+) Stop the Complementary Input Capture and disable interrupts.
\r
853 (+) Start the Complementary Input Capture and enable DMA transfers.
\r
854 (+) Stop the Complementary Input Capture and disable DMA transfers.
\r
855 (+) Start the Complementary One Pulse generation.
\r
856 (+) Stop the Complementary One Pulse.
\r
857 (+) Start the Complementary One Pulse and enable interrupts.
\r
858 (+) Stop the Complementary One Pulse and disable interrupts.
\r
865 * @brief Starts the PWM signal generation on the complementary output.
\r
866 * @param htim : TIM handle
\r
867 * @param Channel : TIM Channel to be enabled
\r
868 * This parameter can be one of the following values:
\r
869 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
870 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
871 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
872 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
\r
873 * @retval HAL status
\r
875 HAL_StatusTypeDef HAL_TIMEx_PWMN_Start(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
877 /* Check the parameters */
\r
878 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, Channel));
\r
880 /* Enable the complementary PWM output */
\r
881 TIM_CCxNChannelCmd(htim->Instance, Channel, TIM_CCxN_ENABLE);
\r
883 /* Enable the Main Ouput */
\r
884 __HAL_TIM_MOE_ENABLE(htim);
\r
886 /* Enable the Peripheral */
\r
887 __HAL_TIM_ENABLE(htim);
\r
889 /* Return function status */
\r
894 * @brief Stops the PWM signal generation on the complementary output.
\r
895 * @param htim : TIM handle
\r
896 * @param Channel : TIM Channel to be disabled
\r
897 * This parameter can be one of the following values:
\r
898 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
899 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
900 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
901 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
\r
902 * @retval HAL status
\r
904 HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
906 /* Check the parameters */
\r
907 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, Channel));
\r
909 /* Disable the complementary PWM output */
\r
910 TIM_CCxNChannelCmd(htim->Instance, Channel, TIM_CCxN_DISABLE);
\r
912 /* Disable the Main Ouput */
\r
913 __HAL_TIM_MOE_DISABLE(htim);
\r
915 /* Disable the Peripheral */
\r
916 __HAL_TIM_DISABLE(htim);
\r
918 /* Return function status */
\r
923 * @brief Starts the PWM signal generation in interrupt mode on the
\r
924 * complementary output.
\r
925 * @param htim : TIM handle
\r
926 * @param Channel : TIM Channel to be disabled
\r
927 * This parameter can be one of the following values:
\r
928 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
929 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
930 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
931 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
\r
932 * @retval HAL status
\r
934 HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
936 /* Check the parameters */
\r
937 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, Channel));
\r
941 case TIM_CHANNEL_1:
\r
943 /* Enable the TIM Capture/Compare 1 interrupt */
\r
944 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC1);
\r
948 case TIM_CHANNEL_2:
\r
950 /* Enable the TIM Capture/Compare 2 interrupt */
\r
951 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC2);
\r
955 case TIM_CHANNEL_3:
\r
957 /* Enable the TIM Capture/Compare 3 interrupt */
\r
958 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC3);
\r
962 case TIM_CHANNEL_4:
\r
964 /* Enable the TIM Capture/Compare 4 interrupt */
\r
965 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC4);
\r
973 /* Enable the TIM Break interrupt */
\r
974 __HAL_TIM_ENABLE_IT(htim, TIM_IT_BREAK);
\r
976 /* Enable the complementary PWM output */
\r
977 TIM_CCxNChannelCmd(htim->Instance, Channel, TIM_CCxN_ENABLE);
\r
979 /* Enable the Main Ouput */
\r
980 __HAL_TIM_MOE_ENABLE(htim);
\r
982 /* Enable the Peripheral */
\r
983 __HAL_TIM_ENABLE(htim);
\r
985 /* Return function status */
\r
990 * @brief Stops the PWM signal generation in interrupt mode on the
\r
991 * complementary output.
\r
992 * @param htim : TIM handle
\r
993 * @param Channel : TIM Channel to be disabled
\r
994 * This parameter can be one of the following values:
\r
995 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
996 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
997 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
998 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
\r
999 * @retval HAL status
\r
1001 HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_IT (TIM_HandleTypeDef *htim, uint32_t Channel)
\r
1003 /* Check the parameters */
\r
1004 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, Channel));
\r
1008 case TIM_CHANNEL_1:
\r
1010 /* Disable the TIM Capture/Compare 1 interrupt */
\r
1011 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC1);
\r
1015 case TIM_CHANNEL_2:
\r
1017 /* Disable the TIM Capture/Compare 2 interrupt */
\r
1018 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC2);
\r
1022 case TIM_CHANNEL_3:
\r
1024 /* Disable the TIM Capture/Compare 3 interrupt */
\r
1025 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC3);
\r
1029 case TIM_CHANNEL_4:
\r
1031 /* Disable the TIM Capture/Compare 3 interrupt */
\r
1032 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC4);
\r
1040 /* Disable the TIM Break interrupt */
\r
1041 __HAL_TIM_DISABLE_IT(htim, TIM_IT_BREAK);
\r
1043 /* Disable the complementary PWM output */
\r
1044 TIM_CCxNChannelCmd(htim->Instance, Channel, TIM_CCxN_DISABLE);
\r
1046 /* Disable the Main Ouput */
\r
1047 __HAL_TIM_MOE_DISABLE(htim);
\r
1049 /* Disable the Peripheral */
\r
1050 __HAL_TIM_DISABLE(htim);
\r
1052 /* Return function status */
\r
1057 * @brief Starts the TIM PWM signal generation in DMA mode on the
\r
1058 * complementary output
\r
1059 * @param htim : TIM handle
\r
1060 * @param Channel : TIM Channel to be enabled
\r
1061 * This parameter can be one of the following values:
\r
1062 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
1063 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
1064 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
1065 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
\r
1066 * @param pData: The source Buffer address.
\r
1067 * @param Length: The length of data to be transferred from memory to TIM peripheral
\r
1068 * @retval HAL status
\r
1070 HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length)
\r
1072 /* Check the parameters */
\r
1073 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, Channel));
\r
1075 if((htim->State == HAL_TIM_STATE_BUSY))
\r
1079 else if((htim->State == HAL_TIM_STATE_READY))
\r
1081 if(((uint32_t)pData == 0 ) && (Length > 0))
\r
1083 return HAL_ERROR;
\r
1087 htim->State = HAL_TIM_STATE_BUSY;
\r
1092 case TIM_CHANNEL_1:
\r
1094 /* Set the DMA Period elapsed callback */
\r
1095 htim->hdma[TIM_DMA_ID_CC1]->XferCpltCallback = HAL_TIM_DMADelayPulseCplt;
\r
1097 /* Set the DMA error callback */
\r
1098 htim->hdma[TIM_DMA_ID_CC1]->XferErrorCallback = HAL_TIM_DMAError ;
\r
1100 /* Enable the DMA Stream */
\r
1101 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)pData, (uint32_t)&htim->Instance->CCR1, Length);
\r
1103 /* Enable the TIM Capture/Compare 1 DMA request */
\r
1104 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC1);
\r
1108 case TIM_CHANNEL_2:
\r
1110 /* Set the DMA Period elapsed callback */
\r
1111 htim->hdma[TIM_DMA_ID_CC2]->XferCpltCallback = HAL_TIM_DMADelayPulseCplt;
\r
1113 /* Set the DMA error callback */
\r
1114 htim->hdma[TIM_DMA_ID_CC2]->XferErrorCallback = HAL_TIM_DMAError ;
\r
1116 /* Enable the DMA Stream */
\r
1117 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)pData, (uint32_t)&htim->Instance->CCR2, Length);
\r
1119 /* Enable the TIM Capture/Compare 2 DMA request */
\r
1120 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC2);
\r
1124 case TIM_CHANNEL_3:
\r
1126 /* Set the DMA Period elapsed callback */
\r
1127 htim->hdma[TIM_DMA_ID_CC3]->XferCpltCallback = HAL_TIM_DMADelayPulseCplt;
\r
1129 /* Set the DMA error callback */
\r
1130 htim->hdma[TIM_DMA_ID_CC3]->XferErrorCallback = HAL_TIM_DMAError ;
\r
1132 /* Enable the DMA Stream */
\r
1133 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC3], (uint32_t)pData, (uint32_t)&htim->Instance->CCR3,Length);
\r
1135 /* Enable the TIM Capture/Compare 3 DMA request */
\r
1136 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC3);
\r
1140 case TIM_CHANNEL_4:
\r
1142 /* Set the DMA Period elapsed callback */
\r
1143 htim->hdma[TIM_DMA_ID_CC4]->XferCpltCallback = HAL_TIM_DMADelayPulseCplt;
\r
1145 /* Set the DMA error callback */
\r
1146 htim->hdma[TIM_DMA_ID_CC4]->XferErrorCallback = HAL_TIM_DMAError ;
\r
1148 /* Enable the DMA Stream */
\r
1149 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC4], (uint32_t)pData, (uint32_t)&htim->Instance->CCR4, Length);
\r
1151 /* Enable the TIM Capture/Compare 4 DMA request */
\r
1152 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC4);
\r
1160 /* Enable the complementary PWM output */
\r
1161 TIM_CCxNChannelCmd(htim->Instance, Channel, TIM_CCxN_ENABLE);
\r
1163 /* Enable the Main Ouput */
\r
1164 __HAL_TIM_MOE_ENABLE(htim);
\r
1166 /* Enable the Peripheral */
\r
1167 __HAL_TIM_ENABLE(htim);
\r
1169 /* Return function status */
\r
1174 * @brief Stops the TIM PWM signal generation in DMA mode on the complementary
\r
1176 * @param htim : TIM handle
\r
1177 * @param Channel : TIM Channel to be disabled
\r
1178 * This parameter can be one of the following values:
\r
1179 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
1180 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
1181 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
\r
1182 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
\r
1183 * @retval HAL status
\r
1185 HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel)
\r
1187 /* Check the parameters */
\r
1188 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, Channel));
\r
1192 case TIM_CHANNEL_1:
\r
1194 /* Disable the TIM Capture/Compare 1 DMA request */
\r
1195 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC1);
\r
1199 case TIM_CHANNEL_2:
\r
1201 /* Disable the TIM Capture/Compare 2 DMA request */
\r
1202 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC2);
\r
1206 case TIM_CHANNEL_3:
\r
1208 /* Disable the TIM Capture/Compare 3 DMA request */
\r
1209 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC3);
\r
1213 case TIM_CHANNEL_4:
\r
1215 /* Disable the TIM Capture/Compare 4 DMA request */
\r
1216 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC4);
\r
1224 /* Disable the complementary PWM output */
\r
1225 TIM_CCxNChannelCmd(htim->Instance, Channel, TIM_CCxN_DISABLE);
\r
1227 /* Disable the Main Ouput */
\r
1228 __HAL_TIM_MOE_DISABLE(htim);
\r
1230 /* Disable the Peripheral */
\r
1231 __HAL_TIM_DISABLE(htim);
\r
1233 /* Change the htim state */
\r
1234 htim->State = HAL_TIM_STATE_READY;
\r
1236 /* Return function status */
\r
1244 /** @defgroup TIMEx_Group4 Timer Complementary One Pulse functions
\r
1245 * @brief Timer Complementary One Pulse functions
\r
1248 ==============================================================================
\r
1249 ##### Timer Complementary One Pulse functions #####
\r
1250 ==============================================================================
\r
1252 This section provides functions allowing to:
\r
1253 (+) Start the Complementary One Pulse generation.
\r
1254 (+) Stop the Complementary One Pulse.
\r
1255 (+) Start the Complementary One Pulse and enable interrupts.
\r
1256 (+) Stop the Complementary One Pulse and disable interrupts.
\r
1263 * @brief Starts the TIM One Pulse signal generation on the complemetary
\r
1265 * @param htim : TIM One Pulse handle
\r
1266 * @param OutputChannel : TIM Channel to be enabled
\r
1267 * This parameter can be one of the following values:
\r
1268 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
1269 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
1270 * @retval HAL status
\r
1272 HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
\r
1274 /* Check the parameters */
\r
1275 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, OutputChannel));
\r
1277 /* Enable the complementary One Pulse output */
\r
1278 TIM_CCxNChannelCmd(htim->Instance, OutputChannel, TIM_CCxN_ENABLE);
\r
1280 /* Enable the Main Ouput */
\r
1281 __HAL_TIM_MOE_ENABLE(htim);
\r
1283 /* Return function status */
\r
1288 * @brief Stops the TIM One Pulse signal generation on the complementary
\r
1290 * @param htim : TIM One Pulse handle
\r
1291 * @param OutputChannel : TIM Channel to be disabled
\r
1292 * This parameter can be one of the following values:
\r
1293 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
1294 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
1295 * @retval HAL status
\r
1297 HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
\r
1300 /* Check the parameters */
\r
1301 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, OutputChannel));
\r
1303 /* Disable the complementary One Pulse output */
\r
1304 TIM_CCxNChannelCmd(htim->Instance, OutputChannel, TIM_CCxN_DISABLE);
\r
1306 /* Disable the Main Ouput */
\r
1307 __HAL_TIM_MOE_DISABLE(htim);
\r
1309 /* Disable the Peripheral */
\r
1310 __HAL_TIM_DISABLE(htim);
\r
1312 /* Return function status */
\r
1317 * @brief Starts the TIM One Pulse signal generation in interrupt mode on the
\r
1318 * complementary channel.
\r
1319 * @param htim : TIM One Pulse handle
\r
1320 * @param OutputChannel : TIM Channel to be enabled
\r
1321 * This parameter can be one of the following values:
\r
1322 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
1323 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
1324 * @retval HAL status
\r
1326 HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
\r
1328 /* Check the parameters */
\r
1329 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, OutputChannel));
\r
1331 /* Enable the TIM Capture/Compare 1 interrupt */
\r
1332 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC1);
\r
1334 /* Enable the TIM Capture/Compare 2 interrupt */
\r
1335 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC2);
\r
1337 /* Enable the complementary One Pulse output */
\r
1338 TIM_CCxNChannelCmd(htim->Instance, OutputChannel, TIM_CCxN_ENABLE);
\r
1340 /* Enable the Main Ouput */
\r
1341 __HAL_TIM_MOE_ENABLE(htim);
\r
1343 /* Return function status */
\r
1348 * @brief Stops the TIM One Pulse signal generation in interrupt mode on the
\r
1349 * complementary channel.
\r
1350 * @param htim : TIM One Pulse handle
\r
1351 * @param OutputChannel : TIM Channel to be disabled
\r
1352 * This parameter can be one of the following values:
\r
1353 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
\r
1354 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
\r
1355 * @retval HAL status
\r
1357 HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
\r
1359 /* Check the parameters */
\r
1360 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, OutputChannel));
\r
1362 /* Disable the TIM Capture/Compare 1 interrupt */
\r
1363 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC1);
\r
1365 /* Disable the TIM Capture/Compare 2 interrupt */
\r
1366 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC2);
\r
1368 /* Disable the complementary One Pulse output */
\r
1369 TIM_CCxNChannelCmd(htim->Instance, OutputChannel, TIM_CCxN_DISABLE);
\r
1371 /* Disable the Main Ouput */
\r
1372 __HAL_TIM_MOE_DISABLE(htim);
\r
1374 /* Disable the Peripheral */
\r
1375 __HAL_TIM_DISABLE(htim);
\r
1377 /* Return function status */
\r
1384 /** @defgroup TIMEx_Group5 Peripheral Control functions
\r
1385 * @brief Peripheral Control functions
\r
1388 ==============================================================================
\r
1389 ##### Peripheral Control functions #####
\r
1390 ==============================================================================
\r
1392 This section provides functions allowing to:
\r
1393 (+) Configure The Input Output channels for OC, PWM, IC or One Pulse mode.
\r
1394 (+) Configure External Clock source.
\r
1395 (+) Configure Complementary channels, break features and dead time.
\r
1396 (+) Configure Master and the Slave synchronization.
\r
1397 (+) Configure the commutation event in case of use of the Hall sensor interface.
\r
1398 (+) Configure the DMA Burst Mode.
\r
1404 * @brief Configure the TIM commutation event sequence.
\r
1405 * @note: this function is mandatory to use the commutation event in order to
\r
1406 * update the configuration at each commutation detection on the TRGI input of the Timer,
\r
1407 * the typical use of this feature is with the use of another Timer(interface Timer)
\r
1408 * configured in Hall sensor interface, this interface Timer will generate the
\r
1409 * commutation at its TRGO output (connected to Timer used in this function) each time
\r
1410 * the TI1 of the Interface Timer detect a commutation at its input TI1.
\r
1411 * @param htim: TIM handle
\r
1412 * @param InputTrigger : the Internal trigger corresponding to the Timer Interfacing with the Hall sensor
\r
1413 * This parameter can be one of the following values:
\r
1414 * @arg TIM_TS_ITR0: Internal trigger 0 selected
\r
1415 * @arg TIM_TS_ITR1: Internal trigger 1 selected
\r
1416 * @arg TIM_TS_ITR2: Internal trigger 2 selected
\r
1417 * @arg TIM_TS_ITR3: Internal trigger 3 selected
\r
1418 * @arg TIM_TS_NONE: No trigger is needed
\r
1419 * @param CommutationSource : the Commutation Event source
\r
1420 * This parameter can be one of the following values:
\r
1421 * @arg TIM_COMMUTATION_TRGI: Commutation source is the TRGI of the Interface Timer
\r
1422 * @arg TIM_COMMUTATION_SOFTWARE: Commutation source is set by software using the COMG bit
\r
1423 * @retval HAL status
\r
1425 HAL_StatusTypeDef HAL_TIMEx_ConfigCommutationEvent(TIM_HandleTypeDef *htim, uint32_t InputTrigger, uint32_t CommutationSource)
\r
1427 /* Check the parameters */
\r
1428 assert_param(IS_TIM_ADVANCED_INSTANCE(htim->Instance));
\r
1429 assert_param(IS_TIM_INTERNAL_TRIGGEREVENT_SELECTION(InputTrigger));
\r
1433 if ((InputTrigger == TIM_TS_ITR0) || (InputTrigger == TIM_TS_ITR1) ||
\r
1434 (InputTrigger == TIM_TS_ITR2) || (InputTrigger == TIM_TS_ITR3))
\r
1436 /* Select the Input trigger */
\r
1437 htim->Instance->SMCR &= ~TIM_SMCR_TS;
\r
1438 htim->Instance->SMCR |= InputTrigger;
\r
1441 /* Select the Capture Compare preload feature */
\r
1442 htim->Instance->CR2 |= TIM_CR2_CCPC;
\r
1443 /* Select the Commutation event source */
\r
1444 htim->Instance->CR2 &= ~TIM_CR2_CCUS;
\r
1445 htim->Instance->CR2 |= CommutationSource;
\r
1447 __HAL_UNLOCK(htim);
\r
1453 * @brief Configure the TIM commutation event sequence with interrupt.
\r
1454 * @note: this function is mandatory to use the commutation event in order to
\r
1455 * update the configuration at each commutation detection on the TRGI input of the Timer,
\r
1456 * the typical use of this feature is with the use of another Timer(interface Timer)
\r
1457 * configured in Hall sensor interface, this interface Timer will generate the
\r
1458 * commutation at its TRGO output (connected to Timer used in this function) each time
\r
1459 * the TI1 of the Interface Timer detect a commutation at its input TI1.
\r
1460 * @param htim: TIM handle
\r
1461 * @param InputTrigger : the Internal trigger corresponding to the Timer Interfacing with the Hall sensor
\r
1462 * This parameter can be one of the following values:
\r
1463 * @arg TIM_TS_ITR0: Internal trigger 0 selected
\r
1464 * @arg TIM_TS_ITR1: Internal trigger 1 selected
\r
1465 * @arg TIM_TS_ITR2: Internal trigger 2 selected
\r
1466 * @arg TIM_TS_ITR3: Internal trigger 3 selected
\r
1467 * @arg TIM_TS_NONE: No trigger is needed
\r
1468 * @param CommutationSource : the Commutation Event source
\r
1469 * This parameter can be one of the following values:
\r
1470 * @arg TIM_COMMUTATION_TRGI: Commutation source is the TRGI of the Interface Timer
\r
1471 * @arg TIM_COMMUTATION_SOFTWARE: Commutation source is set by software using the COMG bit
\r
1472 * @retval HAL status
\r
1474 HAL_StatusTypeDef HAL_TIMEx_ConfigCommutationEvent_IT(TIM_HandleTypeDef *htim, uint32_t InputTrigger, uint32_t CommutationSource)
\r
1476 /* Check the parameters */
\r
1477 assert_param(IS_TIM_ADVANCED_INSTANCE(htim->Instance));
\r
1478 assert_param(IS_TIM_INTERNAL_TRIGGEREVENT_SELECTION(InputTrigger));
\r
1482 if ((InputTrigger == TIM_TS_ITR0) || (InputTrigger == TIM_TS_ITR1) ||
\r
1483 (InputTrigger == TIM_TS_ITR2) || (InputTrigger == TIM_TS_ITR3))
\r
1485 /* Select the Input trigger */
\r
1486 htim->Instance->SMCR &= ~TIM_SMCR_TS;
\r
1487 htim->Instance->SMCR |= InputTrigger;
\r
1490 /* Select the Capture Compare preload feature */
\r
1491 htim->Instance->CR2 |= TIM_CR2_CCPC;
\r
1492 /* Select the Commutation event source */
\r
1493 htim->Instance->CR2 &= ~TIM_CR2_CCUS;
\r
1494 htim->Instance->CR2 |= CommutationSource;
\r
1496 /* Enable the Commutation Interrupt Request */
\r
1497 __HAL_TIM_ENABLE_IT(htim, TIM_IT_COM);
\r
1499 __HAL_UNLOCK(htim);
\r
1505 * @brief Configure the TIM commutation event sequence with DMA.
\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 * @note: The user should configure the DMA in his own software, in This function only the COMDE bit is set
\r
1513 * @param htim: TIM handle
\r
1514 * @param InputTrigger : the Internal trigger corresponding to the Timer Interfacing with the Hall sensor
\r
1515 * This parameter can be one of the following values:
\r
1516 * @arg TIM_TS_ITR0: Internal trigger 0 selected
\r
1517 * @arg TIM_TS_ITR1: Internal trigger 1 selected
\r
1518 * @arg TIM_TS_ITR2: Internal trigger 2 selected
\r
1519 * @arg TIM_TS_ITR3: Internal trigger 3 selected
\r
1520 * @arg TIM_TS_NONE: No trigger is needed
\r
1521 * @param CommutationSource : the Commutation Event source
\r
1522 * This parameter can be one of the following values:
\r
1523 * @arg TIM_COMMUTATION_TRGI: Commutation source is the TRGI of the Interface Timer
\r
1524 * @arg TIM_COMMUTATION_SOFTWARE: Commutation source is set by software using the COMG bit
\r
1525 * @retval HAL status
\r
1527 HAL_StatusTypeDef HAL_TIMEx_ConfigCommutationEvent_DMA(TIM_HandleTypeDef *htim, uint32_t InputTrigger, uint32_t CommutationSource)
\r
1529 /* Check the parameters */
\r
1530 assert_param(IS_TIM_ADVANCED_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 /* Enable the Commutation DMA Request */
\r
1550 /* Set the DMA Commutation Callback */
\r
1551 htim->hdma[TIM_DMA_ID_COMMUTATION]->XferCpltCallback = HAL_TIMEx_DMACommutationCplt;
\r
1552 /* Set the DMA error callback */
\r
1553 htim->hdma[TIM_DMA_ID_COMMUTATION]->XferErrorCallback = HAL_TIM_DMAError;
\r
1555 /* Enable the Commutation DMA Request */
\r
1556 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_COM);
\r
1558 __HAL_UNLOCK(htim);
\r
1564 * @brief Configures the TIM in master mode.
\r
1565 * @param htim: TIM handle.
\r
1566 * @param sMasterConfig: pointer to a TIM_MasterConfigTypeDef structure that
\r
1567 * contains the selected trigger output (TRGO) and the Master/Slave
\r
1569 * @retval HAL status
\r
1571 HAL_StatusTypeDef HAL_TIMEx_MasterConfigSynchronization(TIM_HandleTypeDef *htim, TIM_MasterConfigTypeDef * sMasterConfig)
\r
1573 /* Check the parameters */
\r
1574 assert_param(IS_TIM_MASTER_INSTANCE(htim->Instance));
\r
1575 assert_param(IS_TIM_TRGO_SOURCE(sMasterConfig->MasterOutputTrigger));
\r
1576 assert_param(IS_TIM_MSM_STATE(sMasterConfig->MasterSlaveMode));
\r
1580 htim->State = HAL_TIM_STATE_BUSY;
\r
1582 /* Reset the MMS Bits */
\r
1583 htim->Instance->CR2 &= ~TIM_CR2_MMS;
\r
1584 /* Select the TRGO source */
\r
1585 htim->Instance->CR2 |= sMasterConfig->MasterOutputTrigger;
\r
1587 /* Reset the MSM Bit */
\r
1588 htim->Instance->SMCR &= ~TIM_SMCR_MSM;
\r
1589 /* Set or Reset the MSM Bit */
\r
1590 htim->Instance->SMCR |= sMasterConfig->MasterSlaveMode;
\r
1592 htim->State = HAL_TIM_STATE_READY;
\r
1594 __HAL_UNLOCK(htim);
\r
1600 * @brief Configures the Break feature, dead time, Lock level, OSSI/OSSR State
\r
1601 * and the AOE(automatic output enable).
\r
1602 * @param htim: TIM handle
\r
1603 * @param sBreakDeadTimeConfig: pointer to a TIM_ConfigBreakDeadConfig_TypeDef structure that
\r
1604 * contains the BDTR Register configuration information for the TIM peripheral.
\r
1605 * @retval HAL status
\r
1607 HAL_StatusTypeDef HAL_TIMEx_ConfigBreakDeadTime(TIM_HandleTypeDef *htim,
\r
1608 TIM_BreakDeadTimeConfigTypeDef * sBreakDeadTimeConfig)
\r
1610 /* Check the parameters */
\r
1611 assert_param(IS_TIM_CC4_INSTANCE(htim->Instance));
\r
1612 assert_param(IS_TIM_OSSR_STATE(sBreakDeadTimeConfig->OffStateRunMode));
\r
1613 assert_param(IS_TIM_OSSI_STATE(sBreakDeadTimeConfig->OffStateIDLEMode));
\r
1614 assert_param(IS_TIM_LOCK_LEVEL(sBreakDeadTimeConfig->LockLevel));
\r
1615 assert_param(IS_TIM_BREAK_STATE(sBreakDeadTimeConfig->BreakState));
\r
1616 assert_param(IS_TIM_BREAK_POLARITY(sBreakDeadTimeConfig->BreakPolarity));
\r
1617 assert_param(IS_TIM_AUTOMATIC_OUTPUT_STATE(sBreakDeadTimeConfig->AutomaticOutput));
\r
1619 /* Process Locked */
\r
1622 htim->State = HAL_TIM_STATE_BUSY;
\r
1624 /* Set the Lock level, the Break enable Bit and the Polarity, the OSSR State,
\r
1625 the OSSI State, the dead time value and the Automatic Output Enable Bit */
\r
1626 htim->Instance->BDTR = (uint32_t)sBreakDeadTimeConfig->OffStateRunMode |
\r
1627 sBreakDeadTimeConfig->OffStateIDLEMode |
\r
1628 sBreakDeadTimeConfig->LockLevel |
\r
1629 sBreakDeadTimeConfig->DeadTime |
\r
1630 sBreakDeadTimeConfig->BreakState |
\r
1631 sBreakDeadTimeConfig->BreakPolarity |
\r
1632 sBreakDeadTimeConfig->AutomaticOutput;
\r
1635 htim->State = HAL_TIM_STATE_READY;
\r
1637 __HAL_UNLOCK(htim);
\r
1643 * @brief Configures the TIM2, TIM5 and TIM11 Remapping input capabilities.
\r
1644 * @param htim: TIM handle.
\r
1645 * @param TIM_Remap: specifies the TIM input remapping source.
\r
1646 * This parameter can be one of the following values:
\r
1647 * @arg TIM_TIM2_TIM8_TRGO: TIM2 ITR1 input is connected to TIM8 Trigger output(default)
\r
1648 * @arg TIM_TIM2_ETH_PTP: TIM2 ITR1 input is connected to ETH PTP trogger output.
\r
1649 * @arg TIM_TIM2_USBFS_SOF: TIM2 ITR1 input is connected to USB FS SOF.
\r
1650 * @arg TIM_TIM2_USBHS_SOF: TIM2 ITR1 input is connected to USB HS SOF.
\r
1651 * @arg TIM_TIM5_GPIO: TIM5 CH4 input is connected to dedicated Timer pin(default)
\r
1652 * @arg TIM_TIM5_LSI: TIM5 CH4 input is connected to LSI clock.
\r
1653 * @arg TIM_TIM5_LSE: TIM5 CH4 input is connected to LSE clock.
\r
1654 * @arg TIM_TIM5_RTC: TIM5 CH4 input is connected to RTC Output event.
\r
1655 * @arg TIM_TIM11_GPIO: TIM11 CH4 input is connected to dedicated Timer pin(default)
\r
1656 * @arg TIM_TIM11_HSE: TIM11 CH4 input is connected to HSE_RTC clock
\r
1657 * (HSE divided by a programmable prescaler)
\r
1658 * @retval HAL status
\r
1660 HAL_StatusTypeDef HAL_TIMEx_RemapConfig(TIM_HandleTypeDef *htim, uint32_t Remap)
\r
1664 /* Check parameters */
\r
1665 assert_param(IS_TIM_REMAP_INSTANCE(htim->Instance));
\r
1666 assert_param(IS_TIM_REMAP(Remap));
\r
1668 /* Set the Timer remapping configuration */
\r
1669 htim->Instance->OR = Remap;
\r
1671 htim->State = HAL_TIM_STATE_READY;
\r
1673 __HAL_UNLOCK(htim);
\r
1682 /** @defgroup TIMEx_Group6 Extension Callbacks functions
\r
1683 * @brief Extension Callbacks functions
\r
1686 ==============================================================================
\r
1687 ##### Extension Callbacks functions #####
\r
1688 ==============================================================================
\r
1690 This section provides Extension TIM callback functions:
\r
1691 (+) Timer Commutation callback
\r
1692 (+) Timer Break callback
\r
1699 * @brief Hall commutation changed callback in non blocking mode
\r
1700 * @param htim : TIM handle
\r
1703 __weak void HAL_TIMEx_CommutationCallback(TIM_HandleTypeDef *htim)
\r
1705 /* NOTE : This function Should not be modified, when the callback is needed,
\r
1706 the HAL_TIMEx_CommutationCallback could be implemented in the user file
\r
1711 * @brief Hall Break detection callback in non blocking mode
\r
1712 * @param htim : TIM handle
\r
1715 __weak void HAL_TIMEx_BreakCallback(TIM_HandleTypeDef *htim)
\r
1717 /* NOTE : This function Should not be modified, when the callback is needed,
\r
1718 the HAL_TIMEx_BreakCallback could be implemented in the user file
\r
1726 /** @defgroup TIMEx_Group7 Extension Peripheral State functions
\r
1727 * @brief Extension Peripheral State functions
\r
1730 ==============================================================================
\r
1731 ##### Extension Peripheral State functions #####
\r
1732 ==============================================================================
\r
1734 This subsection permit to get in run-time the status of the peripheral
\r
1735 and the data flow.
\r
1742 * @brief Return the TIM Hall Sensor interface state
\r
1743 * @param htim: TIM Hall Sensor handle
\r
1744 * @retval HAL state
\r
1746 HAL_TIM_StateTypeDef HAL_TIMEx_HallSensor_GetState(TIM_HandleTypeDef *htim)
\r
1748 return htim->State;
\r
1756 * @brief TIM DMA Commutation callback.
\r
1757 * @param hdma : pointer to DMA handle.
\r
1760 void HAL_TIMEx_DMACommutationCplt(DMA_HandleTypeDef *hdma)
\r
1762 TIM_HandleTypeDef* htim = ( TIM_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
\r
1764 htim->State= HAL_TIM_STATE_READY;
\r
1766 HAL_TIMEx_CommutationCallback(htim);
\r
1770 * @brief Enables or disables the TIM Capture Compare Channel xN.
\r
1771 * @param TIMx to select the TIM peripheral
\r
1772 * @param Channel: specifies the TIM Channel
\r
1773 * This parameter can be one of the following values:
\r
1774 * @arg TIM_Channel_1: TIM Channel 1
\r
1775 * @arg TIM_Channel_2: TIM Channel 2
\r
1776 * @arg TIM_Channel_3: TIM Channel 3
\r
1777 * @param ChannelNState: specifies the TIM Channel CCxNE bit new state.
\r
1778 * This parameter can be: TIM_CCxN_ENABLE or TIM_CCxN_Disable.
\r
1781 static void TIM_CCxNChannelCmd(TIM_TypeDef* TIMx, uint32_t Channel, uint32_t ChannelNState)
\r
1785 /* Check the parameters */
\r
1786 assert_param(IS_TIM_CC4_INSTANCE(TIMx));
\r
1787 assert_param(IS_TIM_COMPLEMENTARY_CHANNELS(Channel));
\r
1789 tmp = TIM_CCER_CC1NE << Channel;
\r
1791 /* Reset the CCxNE Bit */
\r
1792 TIMx->CCER &= ~tmp;
\r
1794 /* Set or reset the CCxNE Bit */
\r
1795 TIMx->CCER |= (uint32_t)(ChannelNState << Channel);
\r
1802 #endif /* HAL_TIM_MODULE_ENABLED */
\r
1810 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
\r