Initial commit

Dependencies:   FastPWM

Committer:
lypinator
Date:
Wed Sep 16 01:11:49 2020 +0000
Revision:
0:bb348c97df44
Added PWM

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lypinator 0:bb348c97df44 1 /**
lypinator 0:bb348c97df44 2 ******************************************************************************
lypinator 0:bb348c97df44 3 * @file stm32f4xx_hal_tim_ex.c
lypinator 0:bb348c97df44 4 * @author MCD Application Team
lypinator 0:bb348c97df44 5 * @brief TIM HAL module driver.
lypinator 0:bb348c97df44 6 * This file provides firmware functions to manage the following
lypinator 0:bb348c97df44 7 * functionalities of the Timer extension peripheral:
lypinator 0:bb348c97df44 8 * + Time Hall Sensor Interface Initialization
lypinator 0:bb348c97df44 9 * + Time Hall Sensor Interface Start
lypinator 0:bb348c97df44 10 * + Time Complementary signal bread and dead time configuration
lypinator 0:bb348c97df44 11 * + Time Master and Slave synchronization configuration
lypinator 0:bb348c97df44 12 @verbatim
lypinator 0:bb348c97df44 13 ==============================================================================
lypinator 0:bb348c97df44 14 ##### TIMER Extended features #####
lypinator 0:bb348c97df44 15 ==============================================================================
lypinator 0:bb348c97df44 16 [..]
lypinator 0:bb348c97df44 17 The Timer Extension features include:
lypinator 0:bb348c97df44 18 (#) Complementary outputs with programmable dead-time for :
lypinator 0:bb348c97df44 19 (++) Input Capture
lypinator 0:bb348c97df44 20 (++) Output Compare
lypinator 0:bb348c97df44 21 (++) PWM generation (Edge and Center-aligned Mode)
lypinator 0:bb348c97df44 22 (++) One-pulse mode output
lypinator 0:bb348c97df44 23 (#) Synchronization circuit to control the timer with external signals and to
lypinator 0:bb348c97df44 24 interconnect several timers together.
lypinator 0:bb348c97df44 25 (#) Break input to put the timer output signals in reset state or in a known state.
lypinator 0:bb348c97df44 26 (#) Supports incremental (quadrature) encoder and hall-sensor circuitry for
lypinator 0:bb348c97df44 27 positioning purposes
lypinator 0:bb348c97df44 28
lypinator 0:bb348c97df44 29 ##### How to use this driver #####
lypinator 0:bb348c97df44 30 ==============================================================================
lypinator 0:bb348c97df44 31 [..]
lypinator 0:bb348c97df44 32 (#) Initialize the TIM low level resources by implementing the following functions
lypinator 0:bb348c97df44 33 depending from feature used :
lypinator 0:bb348c97df44 34 (++) Complementary Output Compare : HAL_TIM_OC_MspInit()
lypinator 0:bb348c97df44 35 (++) Complementary PWM generation : HAL_TIM_PWM_MspInit()
lypinator 0:bb348c97df44 36 (++) Complementary One-pulse mode output : HAL_TIM_OnePulse_MspInit()
lypinator 0:bb348c97df44 37 (++) Hall Sensor output : HAL_TIM_HallSensor_MspInit()
lypinator 0:bb348c97df44 38
lypinator 0:bb348c97df44 39 (#) Initialize the TIM low level resources :
lypinator 0:bb348c97df44 40 (##) Enable the TIM interface clock using __TIMx_CLK_ENABLE();
lypinator 0:bb348c97df44 41 (##) TIM pins configuration
lypinator 0:bb348c97df44 42 (+++) Enable the clock for the TIM GPIOs using the following function:
lypinator 0:bb348c97df44 43 __GPIOx_CLK_ENABLE();
lypinator 0:bb348c97df44 44 (+++) Configure these TIM pins in Alternate function mode using HAL_GPIO_Init();
lypinator 0:bb348c97df44 45
lypinator 0:bb348c97df44 46 (#) The external Clock can be configured, if needed (the default clock is the
lypinator 0:bb348c97df44 47 internal clock from the APBx), using the following function:
lypinator 0:bb348c97df44 48 HAL_TIM_ConfigClockSource, the clock configuration should be done before
lypinator 0:bb348c97df44 49 any start function.
lypinator 0:bb348c97df44 50
lypinator 0:bb348c97df44 51 (#) Configure the TIM in the desired functioning mode using one of the
lypinator 0:bb348c97df44 52 initialization function of this driver:
lypinator 0:bb348c97df44 53 (++) HAL_TIMEx_HallSensor_Init and HAL_TIMEx_ConfigCommutationEvent: to use the
lypinator 0:bb348c97df44 54 Timer Hall Sensor Interface and the commutation event with the corresponding
lypinator 0:bb348c97df44 55 Interrupt and DMA request if needed (Note that One Timer is used to interface
lypinator 0:bb348c97df44 56 with the Hall sensor Interface and another Timer should be used to use
lypinator 0:bb348c97df44 57 the commutation event).
lypinator 0:bb348c97df44 58
lypinator 0:bb348c97df44 59 (#) Activate the TIM peripheral using one of the start functions:
lypinator 0:bb348c97df44 60 (++) Complementary Output Compare : HAL_TIMEx_OCN_Start(), HAL_TIMEx_OCN_Start_DMA(), HAL_TIMEx_OC_Start_IT()
lypinator 0:bb348c97df44 61 (++) Complementary PWM generation : HAL_TIMEx_PWMN_Start(), HAL_TIMEx_PWMN_Start_DMA(), HAL_TIMEx_PWMN_Start_IT()
lypinator 0:bb348c97df44 62 (++) Complementary One-pulse mode output : HAL_TIMEx_OnePulseN_Start(), HAL_TIMEx_OnePulseN_Start_IT()
lypinator 0:bb348c97df44 63 (++) Hall Sensor output : HAL_TIMEx_HallSensor_Start(), HAL_TIMEx_HallSensor_Start_DMA(), HAL_TIMEx_HallSensor_Start_IT().
lypinator 0:bb348c97df44 64
lypinator 0:bb348c97df44 65
lypinator 0:bb348c97df44 66 @endverbatim
lypinator 0:bb348c97df44 67 ******************************************************************************
lypinator 0:bb348c97df44 68 * @attention
lypinator 0:bb348c97df44 69 *
lypinator 0:bb348c97df44 70 * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
lypinator 0:bb348c97df44 71 *
lypinator 0:bb348c97df44 72 * Redistribution and use in source and binary forms, with or without modification,
lypinator 0:bb348c97df44 73 * are permitted provided that the following conditions are met:
lypinator 0:bb348c97df44 74 * 1. Redistributions of source code must retain the above copyright notice,
lypinator 0:bb348c97df44 75 * this list of conditions and the following disclaimer.
lypinator 0:bb348c97df44 76 * 2. Redistributions in binary form must reproduce the above copyright notice,
lypinator 0:bb348c97df44 77 * this list of conditions and the following disclaimer in the documentation
lypinator 0:bb348c97df44 78 * and/or other materials provided with the distribution.
lypinator 0:bb348c97df44 79 * 3. Neither the name of STMicroelectronics nor the names of its contributors
lypinator 0:bb348c97df44 80 * may be used to endorse or promote products derived from this software
lypinator 0:bb348c97df44 81 * without specific prior written permission.
lypinator 0:bb348c97df44 82 *
lypinator 0:bb348c97df44 83 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
lypinator 0:bb348c97df44 84 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
lypinator 0:bb348c97df44 85 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
lypinator 0:bb348c97df44 86 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
lypinator 0:bb348c97df44 87 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
lypinator 0:bb348c97df44 88 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
lypinator 0:bb348c97df44 89 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
lypinator 0:bb348c97df44 90 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
lypinator 0:bb348c97df44 91 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
lypinator 0:bb348c97df44 92 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
lypinator 0:bb348c97df44 93 *
lypinator 0:bb348c97df44 94 ******************************************************************************
lypinator 0:bb348c97df44 95 */
lypinator 0:bb348c97df44 96
lypinator 0:bb348c97df44 97 /* Includes ------------------------------------------------------------------*/
lypinator 0:bb348c97df44 98 #include "stm32f4xx_hal.h"
lypinator 0:bb348c97df44 99
lypinator 0:bb348c97df44 100 /** @addtogroup STM32F4xx_HAL_Driver
lypinator 0:bb348c97df44 101 * @{
lypinator 0:bb348c97df44 102 */
lypinator 0:bb348c97df44 103
lypinator 0:bb348c97df44 104 /** @defgroup TIMEx TIMEx
lypinator 0:bb348c97df44 105 * @brief TIM HAL module driver
lypinator 0:bb348c97df44 106 * @{
lypinator 0:bb348c97df44 107 */
lypinator 0:bb348c97df44 108
lypinator 0:bb348c97df44 109 #ifdef HAL_TIM_MODULE_ENABLED
lypinator 0:bb348c97df44 110
lypinator 0:bb348c97df44 111 /* Private typedef -----------------------------------------------------------*/
lypinator 0:bb348c97df44 112 /* Private define ------------------------------------------------------------*/
lypinator 0:bb348c97df44 113 /* Private macro -------------------------------------------------------------*/
lypinator 0:bb348c97df44 114 /* Private variables ---------------------------------------------------------*/
lypinator 0:bb348c97df44 115 /** @addtogroup TIMEx_Private_Functions
lypinator 0:bb348c97df44 116 * @{
lypinator 0:bb348c97df44 117 */
lypinator 0:bb348c97df44 118 /* Private function prototypes -----------------------------------------------*/
lypinator 0:bb348c97df44 119 static void TIM_CCxNChannelCmd(TIM_TypeDef* TIMx, uint32_t Channel, uint32_t ChannelNState);
lypinator 0:bb348c97df44 120 /**
lypinator 0:bb348c97df44 121 * @}
lypinator 0:bb348c97df44 122 */
lypinator 0:bb348c97df44 123
lypinator 0:bb348c97df44 124 /* Exported functions --------------------------------------------------------*/
lypinator 0:bb348c97df44 125 /** @defgroup TIMEx_Exported_Functions TIM Exported Functions
lypinator 0:bb348c97df44 126 * @{
lypinator 0:bb348c97df44 127 */
lypinator 0:bb348c97df44 128
lypinator 0:bb348c97df44 129 /** @defgroup TIMEx_Exported_Functions_Group1 Timer Hall Sensor functions
lypinator 0:bb348c97df44 130 * @brief Timer Hall Sensor functions
lypinator 0:bb348c97df44 131 *
lypinator 0:bb348c97df44 132 @verbatim
lypinator 0:bb348c97df44 133 ==============================================================================
lypinator 0:bb348c97df44 134 ##### Timer Hall Sensor functions #####
lypinator 0:bb348c97df44 135 ==============================================================================
lypinator 0:bb348c97df44 136 [..]
lypinator 0:bb348c97df44 137 This section provides functions allowing to:
lypinator 0:bb348c97df44 138 (+) Initialize and configure TIM HAL Sensor.
lypinator 0:bb348c97df44 139 (+) De-initialize TIM HAL Sensor.
lypinator 0:bb348c97df44 140 (+) Start the Hall Sensor Interface.
lypinator 0:bb348c97df44 141 (+) Stop the Hall Sensor Interface.
lypinator 0:bb348c97df44 142 (+) Start the Hall Sensor Interface and enable interrupts.
lypinator 0:bb348c97df44 143 (+) Stop the Hall Sensor Interface and disable interrupts.
lypinator 0:bb348c97df44 144 (+) Start the Hall Sensor Interface and enable DMA transfers.
lypinator 0:bb348c97df44 145 (+) Stop the Hall Sensor Interface and disable DMA transfers.
lypinator 0:bb348c97df44 146
lypinator 0:bb348c97df44 147 @endverbatim
lypinator 0:bb348c97df44 148 * @{
lypinator 0:bb348c97df44 149 */
lypinator 0:bb348c97df44 150 /**
lypinator 0:bb348c97df44 151 * @brief Initializes the TIM Hall Sensor Interface and create the associated handle.
lypinator 0:bb348c97df44 152 * @param htim pointer to a TIM_HandleTypeDef structure that contains
lypinator 0:bb348c97df44 153 * the configuration information for TIM module.
lypinator 0:bb348c97df44 154 * @param sConfig TIM Hall Sensor configuration structure
lypinator 0:bb348c97df44 155 * @retval HAL status
lypinator 0:bb348c97df44 156 */
lypinator 0:bb348c97df44 157 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Init(TIM_HandleTypeDef *htim, TIM_HallSensor_InitTypeDef* sConfig)
lypinator 0:bb348c97df44 158 {
lypinator 0:bb348c97df44 159 TIM_OC_InitTypeDef OC_Config;
lypinator 0:bb348c97df44 160
lypinator 0:bb348c97df44 161 /* Check the TIM handle allocation */
lypinator 0:bb348c97df44 162 if(htim == NULL)
lypinator 0:bb348c97df44 163 {
lypinator 0:bb348c97df44 164 return HAL_ERROR;
lypinator 0:bb348c97df44 165 }
lypinator 0:bb348c97df44 166
lypinator 0:bb348c97df44 167 assert_param(IS_TIM_XOR_INSTANCE(htim->Instance));
lypinator 0:bb348c97df44 168 assert_param(IS_TIM_COUNTER_MODE(htim->Init.CounterMode));
lypinator 0:bb348c97df44 169 assert_param(IS_TIM_CLOCKDIVISION_DIV(htim->Init.ClockDivision));
lypinator 0:bb348c97df44 170 assert_param(IS_TIM_IC_POLARITY(sConfig->IC1Polarity));
lypinator 0:bb348c97df44 171 assert_param(IS_TIM_IC_PRESCALER(sConfig->IC1Prescaler));
lypinator 0:bb348c97df44 172 assert_param(IS_TIM_IC_FILTER(sConfig->IC1Filter));
lypinator 0:bb348c97df44 173
lypinator 0:bb348c97df44 174 /* Set the TIM state */
lypinator 0:bb348c97df44 175 htim->State= HAL_TIM_STATE_BUSY;
lypinator 0:bb348c97df44 176
lypinator 0:bb348c97df44 177 /* Init the low level hardware : GPIO, CLOCK, NVIC and DMA */
lypinator 0:bb348c97df44 178 HAL_TIMEx_HallSensor_MspInit(htim);
lypinator 0:bb348c97df44 179
lypinator 0:bb348c97df44 180 /* Configure the Time base in the Encoder Mode */
lypinator 0:bb348c97df44 181 TIM_Base_SetConfig(htim->Instance, &htim->Init);
lypinator 0:bb348c97df44 182
lypinator 0:bb348c97df44 183 /* Configure the Channel 1 as Input Channel to interface with the three Outputs of the Hall sensor */
lypinator 0:bb348c97df44 184 TIM_TI1_SetConfig(htim->Instance, sConfig->IC1Polarity, TIM_ICSELECTION_TRC, sConfig->IC1Filter);
lypinator 0:bb348c97df44 185
lypinator 0:bb348c97df44 186 /* Reset the IC1PSC Bits */
lypinator 0:bb348c97df44 187 htim->Instance->CCMR1 &= ~TIM_CCMR1_IC1PSC;
lypinator 0:bb348c97df44 188 /* Set the IC1PSC value */
lypinator 0:bb348c97df44 189 htim->Instance->CCMR1 |= sConfig->IC1Prescaler;
lypinator 0:bb348c97df44 190
lypinator 0:bb348c97df44 191 /* Enable the Hall sensor interface (XOR function of the three inputs) */
lypinator 0:bb348c97df44 192 htim->Instance->CR2 |= TIM_CR2_TI1S;
lypinator 0:bb348c97df44 193
lypinator 0:bb348c97df44 194 /* Select the TIM_TS_TI1F_ED signal as Input trigger for the TIM */
lypinator 0:bb348c97df44 195 htim->Instance->SMCR &= ~TIM_SMCR_TS;
lypinator 0:bb348c97df44 196 htim->Instance->SMCR |= TIM_TS_TI1F_ED;
lypinator 0:bb348c97df44 197
lypinator 0:bb348c97df44 198 /* Use the TIM_TS_TI1F_ED signal to reset the TIM counter each edge detection */
lypinator 0:bb348c97df44 199 htim->Instance->SMCR &= ~TIM_SMCR_SMS;
lypinator 0:bb348c97df44 200 htim->Instance->SMCR |= TIM_SLAVEMODE_RESET;
lypinator 0:bb348c97df44 201
lypinator 0:bb348c97df44 202 /* Program channel 2 in PWM 2 mode with the desired Commutation_Delay*/
lypinator 0:bb348c97df44 203 OC_Config.OCFastMode = TIM_OCFAST_DISABLE;
lypinator 0:bb348c97df44 204 OC_Config.OCIdleState = TIM_OCIDLESTATE_RESET;
lypinator 0:bb348c97df44 205 OC_Config.OCMode = TIM_OCMODE_PWM2;
lypinator 0:bb348c97df44 206 OC_Config.OCNIdleState = TIM_OCNIDLESTATE_RESET;
lypinator 0:bb348c97df44 207 OC_Config.OCNPolarity = TIM_OCNPOLARITY_HIGH;
lypinator 0:bb348c97df44 208 OC_Config.OCPolarity = TIM_OCPOLARITY_HIGH;
lypinator 0:bb348c97df44 209 OC_Config.Pulse = sConfig->Commutation_Delay;
lypinator 0:bb348c97df44 210
lypinator 0:bb348c97df44 211 TIM_OC2_SetConfig(htim->Instance, &OC_Config);
lypinator 0:bb348c97df44 212
lypinator 0:bb348c97df44 213 /* Select OC2REF as trigger output on TRGO: write the MMS bits in the TIMx_CR2
lypinator 0:bb348c97df44 214 register to 101 */
lypinator 0:bb348c97df44 215 htim->Instance->CR2 &= ~TIM_CR2_MMS;
lypinator 0:bb348c97df44 216 htim->Instance->CR2 |= TIM_TRGO_OC2REF;
lypinator 0:bb348c97df44 217
lypinator 0:bb348c97df44 218 /* Initialize the TIM state*/
lypinator 0:bb348c97df44 219 htim->State= HAL_TIM_STATE_READY;
lypinator 0:bb348c97df44 220
lypinator 0:bb348c97df44 221 return HAL_OK;
lypinator 0:bb348c97df44 222 }
lypinator 0:bb348c97df44 223
lypinator 0:bb348c97df44 224 /**
lypinator 0:bb348c97df44 225 * @brief DeInitializes the TIM Hall Sensor interface
lypinator 0:bb348c97df44 226 * @param htim pointer to a TIM_HandleTypeDef structure that contains
lypinator 0:bb348c97df44 227 * the configuration information for TIM module.
lypinator 0:bb348c97df44 228 * @retval HAL status
lypinator 0:bb348c97df44 229 */
lypinator 0:bb348c97df44 230 HAL_StatusTypeDef HAL_TIMEx_HallSensor_DeInit(TIM_HandleTypeDef *htim)
lypinator 0:bb348c97df44 231 {
lypinator 0:bb348c97df44 232 /* Check the parameters */
lypinator 0:bb348c97df44 233 assert_param(IS_TIM_INSTANCE(htim->Instance));
lypinator 0:bb348c97df44 234
lypinator 0:bb348c97df44 235 htim->State = HAL_TIM_STATE_BUSY;
lypinator 0:bb348c97df44 236
lypinator 0:bb348c97df44 237 /* Disable the TIM Peripheral Clock */
lypinator 0:bb348c97df44 238 __HAL_TIM_DISABLE(htim);
lypinator 0:bb348c97df44 239
lypinator 0:bb348c97df44 240 /* DeInit the low level hardware: GPIO, CLOCK, NVIC */
lypinator 0:bb348c97df44 241 HAL_TIMEx_HallSensor_MspDeInit(htim);
lypinator 0:bb348c97df44 242
lypinator 0:bb348c97df44 243 /* Change TIM state */
lypinator 0:bb348c97df44 244 htim->State = HAL_TIM_STATE_RESET;
lypinator 0:bb348c97df44 245
lypinator 0:bb348c97df44 246 /* Release Lock */
lypinator 0:bb348c97df44 247 __HAL_UNLOCK(htim);
lypinator 0:bb348c97df44 248
lypinator 0:bb348c97df44 249 return HAL_OK;
lypinator 0:bb348c97df44 250 }
lypinator 0:bb348c97df44 251
lypinator 0:bb348c97df44 252 /**
lypinator 0:bb348c97df44 253 * @brief Initializes the TIM Hall Sensor MSP.
lypinator 0:bb348c97df44 254 * @param htim pointer to a TIM_HandleTypeDef structure that contains
lypinator 0:bb348c97df44 255 * the configuration information for TIM module.
lypinator 0:bb348c97df44 256 * @retval None
lypinator 0:bb348c97df44 257 */
lypinator 0:bb348c97df44 258 __weak void HAL_TIMEx_HallSensor_MspInit(TIM_HandleTypeDef *htim)
lypinator 0:bb348c97df44 259 {
lypinator 0:bb348c97df44 260 /* Prevent unused argument(s) compilation warning */
lypinator 0:bb348c97df44 261 UNUSED(htim);
lypinator 0:bb348c97df44 262 /* NOTE : This function Should not be modified, when the callback is needed,
lypinator 0:bb348c97df44 263 the HAL_TIMEx_HallSensor_MspInit could be implemented in the user file
lypinator 0:bb348c97df44 264 */
lypinator 0:bb348c97df44 265 }
lypinator 0:bb348c97df44 266
lypinator 0:bb348c97df44 267 /**
lypinator 0:bb348c97df44 268 * @brief DeInitializes TIM Hall Sensor MSP.
lypinator 0:bb348c97df44 269 * @param htim pointer to a TIM_HandleTypeDef structure that contains
lypinator 0:bb348c97df44 270 * the configuration information for TIM module.
lypinator 0:bb348c97df44 271 * @retval None
lypinator 0:bb348c97df44 272 */
lypinator 0:bb348c97df44 273 __weak void HAL_TIMEx_HallSensor_MspDeInit(TIM_HandleTypeDef *htim)
lypinator 0:bb348c97df44 274 {
lypinator 0:bb348c97df44 275 /* Prevent unused argument(s) compilation warning */
lypinator 0:bb348c97df44 276 UNUSED(htim);
lypinator 0:bb348c97df44 277 /* NOTE : This function Should not be modified, when the callback is needed,
lypinator 0:bb348c97df44 278 the HAL_TIMEx_HallSensor_MspDeInit could be implemented in the user file
lypinator 0:bb348c97df44 279 */
lypinator 0:bb348c97df44 280 }
lypinator 0:bb348c97df44 281
lypinator 0:bb348c97df44 282 /**
lypinator 0:bb348c97df44 283 * @brief Starts the TIM Hall Sensor Interface.
lypinator 0:bb348c97df44 284 * @param htim pointer to a TIM_HandleTypeDef structure that contains
lypinator 0:bb348c97df44 285 * the configuration information for TIM module.
lypinator 0:bb348c97df44 286 * @retval HAL status
lypinator 0:bb348c97df44 287 */
lypinator 0:bb348c97df44 288 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start(TIM_HandleTypeDef *htim)
lypinator 0:bb348c97df44 289 {
lypinator 0:bb348c97df44 290 /* Check the parameters */
lypinator 0:bb348c97df44 291 assert_param(IS_TIM_XOR_INSTANCE(htim->Instance));
lypinator 0:bb348c97df44 292
lypinator 0:bb348c97df44 293 /* Enable the Input Capture channels 1
lypinator 0:bb348c97df44 294 (in the Hall Sensor Interface the Three possible channels that can be used are TIM_CHANNEL_1, TIM_CHANNEL_2 and TIM_CHANNEL_3) */
lypinator 0:bb348c97df44 295 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_ENABLE);
lypinator 0:bb348c97df44 296
lypinator 0:bb348c97df44 297 /* Enable the Peripheral */
lypinator 0:bb348c97df44 298 __HAL_TIM_ENABLE(htim);
lypinator 0:bb348c97df44 299
lypinator 0:bb348c97df44 300 /* Return function status */
lypinator 0:bb348c97df44 301 return HAL_OK;
lypinator 0:bb348c97df44 302 }
lypinator 0:bb348c97df44 303
lypinator 0:bb348c97df44 304 /**
lypinator 0:bb348c97df44 305 * @brief Stops the TIM Hall sensor Interface.
lypinator 0:bb348c97df44 306 * @param htim pointer to a TIM_HandleTypeDef structure that contains
lypinator 0:bb348c97df44 307 * the configuration information for TIM module.
lypinator 0:bb348c97df44 308 * @retval HAL status
lypinator 0:bb348c97df44 309 */
lypinator 0:bb348c97df44 310 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop(TIM_HandleTypeDef *htim)
lypinator 0:bb348c97df44 311 {
lypinator 0:bb348c97df44 312 /* Check the parameters */
lypinator 0:bb348c97df44 313 assert_param(IS_TIM_XOR_INSTANCE(htim->Instance));
lypinator 0:bb348c97df44 314
lypinator 0:bb348c97df44 315 /* Disable the Input Capture channels 1, 2 and 3
lypinator 0:bb348c97df44 316 (in the Hall Sensor Interface the Three possible channels that can be used are TIM_CHANNEL_1, TIM_CHANNEL_2 and TIM_CHANNEL_3) */
lypinator 0:bb348c97df44 317 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_DISABLE);
lypinator 0:bb348c97df44 318
lypinator 0:bb348c97df44 319 /* Disable the Peripheral */
lypinator 0:bb348c97df44 320 __HAL_TIM_DISABLE(htim);
lypinator 0:bb348c97df44 321
lypinator 0:bb348c97df44 322 /* Return function status */
lypinator 0:bb348c97df44 323 return HAL_OK;
lypinator 0:bb348c97df44 324 }
lypinator 0:bb348c97df44 325
lypinator 0:bb348c97df44 326 /**
lypinator 0:bb348c97df44 327 * @brief Starts the TIM Hall Sensor Interface in interrupt mode.
lypinator 0:bb348c97df44 328 * @param htim pointer to a TIM_HandleTypeDef structure that contains
lypinator 0:bb348c97df44 329 * the configuration information for TIM module.
lypinator 0:bb348c97df44 330 * @retval HAL status
lypinator 0:bb348c97df44 331 */
lypinator 0:bb348c97df44 332 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_IT(TIM_HandleTypeDef *htim)
lypinator 0:bb348c97df44 333 {
lypinator 0:bb348c97df44 334 /* Check the parameters */
lypinator 0:bb348c97df44 335 assert_param(IS_TIM_XOR_INSTANCE(htim->Instance));
lypinator 0:bb348c97df44 336
lypinator 0:bb348c97df44 337 /* Enable the capture compare Interrupts 1 event */
lypinator 0:bb348c97df44 338 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC1);
lypinator 0:bb348c97df44 339
lypinator 0:bb348c97df44 340 /* Enable the Input Capture channels 1
lypinator 0:bb348c97df44 341 (in the Hall Sensor Interface the Three possible channels that can be used are TIM_CHANNEL_1, TIM_CHANNEL_2 and TIM_CHANNEL_3) */
lypinator 0:bb348c97df44 342 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_ENABLE);
lypinator 0:bb348c97df44 343
lypinator 0:bb348c97df44 344 /* Enable the Peripheral */
lypinator 0:bb348c97df44 345 __HAL_TIM_ENABLE(htim);
lypinator 0:bb348c97df44 346
lypinator 0:bb348c97df44 347 /* Return function status */
lypinator 0:bb348c97df44 348 return HAL_OK;
lypinator 0:bb348c97df44 349 }
lypinator 0:bb348c97df44 350
lypinator 0:bb348c97df44 351 /**
lypinator 0:bb348c97df44 352 * @brief Stops the TIM Hall Sensor Interface in interrupt mode.
lypinator 0:bb348c97df44 353 * @param htim pointer to a TIM_HandleTypeDef structure that contains
lypinator 0:bb348c97df44 354 * the configuration information for TIM module.
lypinator 0:bb348c97df44 355 * @retval HAL status
lypinator 0:bb348c97df44 356 */
lypinator 0:bb348c97df44 357 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_IT(TIM_HandleTypeDef *htim)
lypinator 0:bb348c97df44 358 {
lypinator 0:bb348c97df44 359 /* Check the parameters */
lypinator 0:bb348c97df44 360 assert_param(IS_TIM_XOR_INSTANCE(htim->Instance));
lypinator 0:bb348c97df44 361
lypinator 0:bb348c97df44 362 /* Disable the Input Capture channels 1
lypinator 0:bb348c97df44 363 (in the Hall Sensor Interface the Three possible channels that can be used are TIM_CHANNEL_1, TIM_CHANNEL_2 and TIM_CHANNEL_3) */
lypinator 0:bb348c97df44 364 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_DISABLE);
lypinator 0:bb348c97df44 365
lypinator 0:bb348c97df44 366 /* Disable the capture compare Interrupts event */
lypinator 0:bb348c97df44 367 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC1);
lypinator 0:bb348c97df44 368
lypinator 0:bb348c97df44 369 /* Disable the Peripheral */
lypinator 0:bb348c97df44 370 __HAL_TIM_DISABLE(htim);
lypinator 0:bb348c97df44 371
lypinator 0:bb348c97df44 372 /* Return function status */
lypinator 0:bb348c97df44 373 return HAL_OK;
lypinator 0:bb348c97df44 374 }
lypinator 0:bb348c97df44 375
lypinator 0:bb348c97df44 376 /**
lypinator 0:bb348c97df44 377 * @brief Starts the TIM Hall Sensor Interface in DMA mode.
lypinator 0:bb348c97df44 378 * @param htim pointer to a TIM_HandleTypeDef structure that contains
lypinator 0:bb348c97df44 379 * the configuration information for TIM module.
lypinator 0:bb348c97df44 380 * @param pData The destination Buffer address.
lypinator 0:bb348c97df44 381 * @param Length The length of data to be transferred from TIM peripheral to memory.
lypinator 0:bb348c97df44 382 * @retval HAL status
lypinator 0:bb348c97df44 383 */
lypinator 0:bb348c97df44 384 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_DMA(TIM_HandleTypeDef *htim, uint32_t *pData, uint16_t Length)
lypinator 0:bb348c97df44 385 {
lypinator 0:bb348c97df44 386 /* Check the parameters */
lypinator 0:bb348c97df44 387 assert_param(IS_TIM_XOR_INSTANCE(htim->Instance));
lypinator 0:bb348c97df44 388
lypinator 0:bb348c97df44 389 if((htim->State == HAL_TIM_STATE_BUSY))
lypinator 0:bb348c97df44 390 {
lypinator 0:bb348c97df44 391 return HAL_BUSY;
lypinator 0:bb348c97df44 392 }
lypinator 0:bb348c97df44 393 else if((htim->State == HAL_TIM_STATE_READY))
lypinator 0:bb348c97df44 394 {
lypinator 0:bb348c97df44 395 if(((uint32_t)pData == 0U) && (Length > 0))
lypinator 0:bb348c97df44 396 {
lypinator 0:bb348c97df44 397 return HAL_ERROR;
lypinator 0:bb348c97df44 398 }
lypinator 0:bb348c97df44 399 else
lypinator 0:bb348c97df44 400 {
lypinator 0:bb348c97df44 401 htim->State = HAL_TIM_STATE_BUSY;
lypinator 0:bb348c97df44 402 }
lypinator 0:bb348c97df44 403 }
lypinator 0:bb348c97df44 404 /* Enable the Input Capture channels 1
lypinator 0:bb348c97df44 405 (in the Hall Sensor Interface the Three possible channels that can be used are TIM_CHANNEL_1, TIM_CHANNEL_2 and TIM_CHANNEL_3) */
lypinator 0:bb348c97df44 406 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_ENABLE);
lypinator 0:bb348c97df44 407
lypinator 0:bb348c97df44 408 /* Set the DMA Input Capture 1 Callback */
lypinator 0:bb348c97df44 409 htim->hdma[TIM_DMA_ID_CC1]->XferCpltCallback = TIM_DMACaptureCplt;
lypinator 0:bb348c97df44 410 /* Set the DMA error callback */
lypinator 0:bb348c97df44 411 htim->hdma[TIM_DMA_ID_CC1]->XferErrorCallback = TIM_DMAError ;
lypinator 0:bb348c97df44 412
lypinator 0:bb348c97df44 413 /* Enable the DMA Stream for Capture 1*/
lypinator 0:bb348c97df44 414 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)&htim->Instance->CCR1, (uint32_t)pData, Length);
lypinator 0:bb348c97df44 415
lypinator 0:bb348c97df44 416 /* Enable the capture compare 1 Interrupt */
lypinator 0:bb348c97df44 417 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC1);
lypinator 0:bb348c97df44 418
lypinator 0:bb348c97df44 419 /* Enable the Peripheral */
lypinator 0:bb348c97df44 420 __HAL_TIM_ENABLE(htim);
lypinator 0:bb348c97df44 421
lypinator 0:bb348c97df44 422 /* Return function status */
lypinator 0:bb348c97df44 423 return HAL_OK;
lypinator 0:bb348c97df44 424 }
lypinator 0:bb348c97df44 425
lypinator 0:bb348c97df44 426 /**
lypinator 0:bb348c97df44 427 * @brief Stops the TIM Hall Sensor Interface in DMA mode.
lypinator 0:bb348c97df44 428 * @param htim pointer to a TIM_HandleTypeDef structure that contains
lypinator 0:bb348c97df44 429 * the configuration information for TIM module.
lypinator 0:bb348c97df44 430 * @retval HAL status
lypinator 0:bb348c97df44 431 */
lypinator 0:bb348c97df44 432 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_DMA(TIM_HandleTypeDef *htim)
lypinator 0:bb348c97df44 433 {
lypinator 0:bb348c97df44 434 /* Check the parameters */
lypinator 0:bb348c97df44 435 assert_param(IS_TIM_XOR_INSTANCE(htim->Instance));
lypinator 0:bb348c97df44 436
lypinator 0:bb348c97df44 437 /* Disable the Input Capture channels 1
lypinator 0:bb348c97df44 438 (in the Hall Sensor Interface the Three possible channels that can be used are TIM_CHANNEL_1, TIM_CHANNEL_2 and TIM_CHANNEL_3) */
lypinator 0:bb348c97df44 439 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_DISABLE);
lypinator 0:bb348c97df44 440
lypinator 0:bb348c97df44 441
lypinator 0:bb348c97df44 442 /* Disable the capture compare Interrupts 1 event */
lypinator 0:bb348c97df44 443 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC1);
lypinator 0:bb348c97df44 444
lypinator 0:bb348c97df44 445 /* Disable the Peripheral */
lypinator 0:bb348c97df44 446 __HAL_TIM_DISABLE(htim);
lypinator 0:bb348c97df44 447
lypinator 0:bb348c97df44 448 /* Return function status */
lypinator 0:bb348c97df44 449 return HAL_OK;
lypinator 0:bb348c97df44 450 }
lypinator 0:bb348c97df44 451 /**
lypinator 0:bb348c97df44 452 * @}
lypinator 0:bb348c97df44 453 */
lypinator 0:bb348c97df44 454
lypinator 0:bb348c97df44 455 /** @defgroup TIMEx_Exported_Functions_Group2 Timer Complementary Output Compare functions
lypinator 0:bb348c97df44 456 * @brief Timer Complementary Output Compare functions
lypinator 0:bb348c97df44 457 *
lypinator 0:bb348c97df44 458 @verbatim
lypinator 0:bb348c97df44 459 ==============================================================================
lypinator 0:bb348c97df44 460 ##### Timer Complementary Output Compare functions #####
lypinator 0:bb348c97df44 461 ==============================================================================
lypinator 0:bb348c97df44 462 [..]
lypinator 0:bb348c97df44 463 This section provides functions allowing to:
lypinator 0:bb348c97df44 464 (+) Start the Complementary Output Compare/PWM.
lypinator 0:bb348c97df44 465 (+) Stop the Complementary Output Compare/PWM.
lypinator 0:bb348c97df44 466 (+) Start the Complementary Output Compare/PWM and enable interrupts.
lypinator 0:bb348c97df44 467 (+) Stop the Complementary Output Compare/PWM and disable interrupts.
lypinator 0:bb348c97df44 468 (+) Start the Complementary Output Compare/PWM and enable DMA transfers.
lypinator 0:bb348c97df44 469 (+) Stop the Complementary Output Compare/PWM and disable DMA transfers.
lypinator 0:bb348c97df44 470
lypinator 0:bb348c97df44 471 @endverbatim
lypinator 0:bb348c97df44 472 * @{
lypinator 0:bb348c97df44 473 */
lypinator 0:bb348c97df44 474
lypinator 0:bb348c97df44 475 /**
lypinator 0:bb348c97df44 476 * @brief Starts the TIM Output Compare signal generation on the complementary
lypinator 0:bb348c97df44 477 * output.
lypinator 0:bb348c97df44 478 * @param htim pointer to a TIM_HandleTypeDef structure that contains
lypinator 0:bb348c97df44 479 * the configuration information for TIM module.
lypinator 0:bb348c97df44 480 * @param Channel TIM Channel to be enabled.
lypinator 0:bb348c97df44 481 * This parameter can be one of the following values:
lypinator 0:bb348c97df44 482 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
lypinator 0:bb348c97df44 483 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
lypinator 0:bb348c97df44 484 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
lypinator 0:bb348c97df44 485 * @retval HAL status
lypinator 0:bb348c97df44 486 */
lypinator 0:bb348c97df44 487 HAL_StatusTypeDef HAL_TIMEx_OCN_Start(TIM_HandleTypeDef *htim, uint32_t Channel)
lypinator 0:bb348c97df44 488 {
lypinator 0:bb348c97df44 489 /* Check the parameters */
lypinator 0:bb348c97df44 490 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, Channel));
lypinator 0:bb348c97df44 491
lypinator 0:bb348c97df44 492 /* Enable the Capture compare channel N */
lypinator 0:bb348c97df44 493 TIM_CCxNChannelCmd(htim->Instance, Channel, TIM_CCxN_ENABLE);
lypinator 0:bb348c97df44 494
lypinator 0:bb348c97df44 495 /* Enable the Main Output */
lypinator 0:bb348c97df44 496 __HAL_TIM_MOE_ENABLE(htim);
lypinator 0:bb348c97df44 497
lypinator 0:bb348c97df44 498 /* Enable the Peripheral */
lypinator 0:bb348c97df44 499 __HAL_TIM_ENABLE(htim);
lypinator 0:bb348c97df44 500
lypinator 0:bb348c97df44 501 /* Return function status */
lypinator 0:bb348c97df44 502 return HAL_OK;
lypinator 0:bb348c97df44 503 }
lypinator 0:bb348c97df44 504
lypinator 0:bb348c97df44 505 /**
lypinator 0:bb348c97df44 506 * @brief Stops the TIM Output Compare signal generation on the complementary
lypinator 0:bb348c97df44 507 * output.
lypinator 0:bb348c97df44 508 * @param htim pointer to a TIM_HandleTypeDef structure that contains
lypinator 0:bb348c97df44 509 * the configuration information for TIM module.
lypinator 0:bb348c97df44 510 * @param Channel TIM Channel to be disabled.
lypinator 0:bb348c97df44 511 * This parameter can be one of the following values:
lypinator 0:bb348c97df44 512 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
lypinator 0:bb348c97df44 513 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
lypinator 0:bb348c97df44 514 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
lypinator 0:bb348c97df44 515 * @retval HAL status
lypinator 0:bb348c97df44 516 */
lypinator 0:bb348c97df44 517 HAL_StatusTypeDef HAL_TIMEx_OCN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel)
lypinator 0:bb348c97df44 518 {
lypinator 0:bb348c97df44 519 /* Check the parameters */
lypinator 0:bb348c97df44 520 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, Channel));
lypinator 0:bb348c97df44 521
lypinator 0:bb348c97df44 522 /* Disable the Capture compare channel N */
lypinator 0:bb348c97df44 523 TIM_CCxNChannelCmd(htim->Instance, Channel, TIM_CCxN_DISABLE);
lypinator 0:bb348c97df44 524
lypinator 0:bb348c97df44 525 /* Disable the Main Output */
lypinator 0:bb348c97df44 526 __HAL_TIM_MOE_DISABLE(htim);
lypinator 0:bb348c97df44 527
lypinator 0:bb348c97df44 528 /* Disable the Peripheral */
lypinator 0:bb348c97df44 529 __HAL_TIM_DISABLE(htim);
lypinator 0:bb348c97df44 530
lypinator 0:bb348c97df44 531 /* Return function status */
lypinator 0:bb348c97df44 532 return HAL_OK;
lypinator 0:bb348c97df44 533 }
lypinator 0:bb348c97df44 534
lypinator 0:bb348c97df44 535 /**
lypinator 0:bb348c97df44 536 * @brief Starts the TIM Output Compare signal generation in interrupt mode
lypinator 0:bb348c97df44 537 * on the complementary output.
lypinator 0:bb348c97df44 538 * @param htim pointer to a TIM_HandleTypeDef structure that contains
lypinator 0:bb348c97df44 539 * the configuration information for TIM module.
lypinator 0:bb348c97df44 540 * @param Channel TIM Channel to be enabled.
lypinator 0:bb348c97df44 541 * This parameter can be one of the following values:
lypinator 0:bb348c97df44 542 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
lypinator 0:bb348c97df44 543 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
lypinator 0:bb348c97df44 544 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
lypinator 0:bb348c97df44 545 * @retval HAL status
lypinator 0:bb348c97df44 546 */
lypinator 0:bb348c97df44 547 HAL_StatusTypeDef HAL_TIMEx_OCN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
lypinator 0:bb348c97df44 548 {
lypinator 0:bb348c97df44 549 /* Check the parameters */
lypinator 0:bb348c97df44 550 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, Channel));
lypinator 0:bb348c97df44 551
lypinator 0:bb348c97df44 552 switch (Channel)
lypinator 0:bb348c97df44 553 {
lypinator 0:bb348c97df44 554 case TIM_CHANNEL_1:
lypinator 0:bb348c97df44 555 {
lypinator 0:bb348c97df44 556 /* Enable the TIM Output Compare interrupt */
lypinator 0:bb348c97df44 557 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC1);
lypinator 0:bb348c97df44 558 }
lypinator 0:bb348c97df44 559 break;
lypinator 0:bb348c97df44 560
lypinator 0:bb348c97df44 561 case TIM_CHANNEL_2:
lypinator 0:bb348c97df44 562 {
lypinator 0:bb348c97df44 563 /* Enable the TIM Output Compare interrupt */
lypinator 0:bb348c97df44 564 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC2);
lypinator 0:bb348c97df44 565 }
lypinator 0:bb348c97df44 566 break;
lypinator 0:bb348c97df44 567
lypinator 0:bb348c97df44 568 case TIM_CHANNEL_3:
lypinator 0:bb348c97df44 569 {
lypinator 0:bb348c97df44 570 /* Enable the TIM Output Compare interrupt */
lypinator 0:bb348c97df44 571 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC3);
lypinator 0:bb348c97df44 572 }
lypinator 0:bb348c97df44 573 break;
lypinator 0:bb348c97df44 574
lypinator 0:bb348c97df44 575 case TIM_CHANNEL_4:
lypinator 0:bb348c97df44 576 {
lypinator 0:bb348c97df44 577 /* Enable the TIM Output Compare interrupt */
lypinator 0:bb348c97df44 578 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC4);
lypinator 0:bb348c97df44 579 }
lypinator 0:bb348c97df44 580 break;
lypinator 0:bb348c97df44 581
lypinator 0:bb348c97df44 582 default:
lypinator 0:bb348c97df44 583 break;
lypinator 0:bb348c97df44 584 }
lypinator 0:bb348c97df44 585
lypinator 0:bb348c97df44 586 /* Enable the TIM Break interrupt */
lypinator 0:bb348c97df44 587 __HAL_TIM_ENABLE_IT(htim, TIM_IT_BREAK);
lypinator 0:bb348c97df44 588
lypinator 0:bb348c97df44 589 /* Enable the Capture compare channel N */
lypinator 0:bb348c97df44 590 TIM_CCxNChannelCmd(htim->Instance, Channel, TIM_CCxN_ENABLE);
lypinator 0:bb348c97df44 591
lypinator 0:bb348c97df44 592 /* Enable the Main Output */
lypinator 0:bb348c97df44 593 __HAL_TIM_MOE_ENABLE(htim);
lypinator 0:bb348c97df44 594
lypinator 0:bb348c97df44 595 /* Enable the Peripheral */
lypinator 0:bb348c97df44 596 __HAL_TIM_ENABLE(htim);
lypinator 0:bb348c97df44 597
lypinator 0:bb348c97df44 598 /* Return function status */
lypinator 0:bb348c97df44 599 return HAL_OK;
lypinator 0:bb348c97df44 600 }
lypinator 0:bb348c97df44 601
lypinator 0:bb348c97df44 602 /**
lypinator 0:bb348c97df44 603 * @brief Stops the TIM Output Compare signal generation in interrupt mode
lypinator 0:bb348c97df44 604 * on the complementary output.
lypinator 0:bb348c97df44 605 * @param htim pointer to a TIM_HandleTypeDef structure that contains
lypinator 0:bb348c97df44 606 * the configuration information for TIM module.
lypinator 0:bb348c97df44 607 * @param Channel TIM Channel to be disabled.
lypinator 0:bb348c97df44 608 * This parameter can be one of the following values:
lypinator 0:bb348c97df44 609 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
lypinator 0:bb348c97df44 610 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
lypinator 0:bb348c97df44 611 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
lypinator 0:bb348c97df44 612 * @retval HAL status
lypinator 0:bb348c97df44 613 */
lypinator 0:bb348c97df44 614 HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
lypinator 0:bb348c97df44 615 {
lypinator 0:bb348c97df44 616 /* Check the parameters */
lypinator 0:bb348c97df44 617 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, Channel));
lypinator 0:bb348c97df44 618
lypinator 0:bb348c97df44 619 switch (Channel)
lypinator 0:bb348c97df44 620 {
lypinator 0:bb348c97df44 621 case TIM_CHANNEL_1:
lypinator 0:bb348c97df44 622 {
lypinator 0:bb348c97df44 623 /* Disable the TIM Output Compare interrupt */
lypinator 0:bb348c97df44 624 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC1);
lypinator 0:bb348c97df44 625 }
lypinator 0:bb348c97df44 626 break;
lypinator 0:bb348c97df44 627
lypinator 0:bb348c97df44 628 case TIM_CHANNEL_2:
lypinator 0:bb348c97df44 629 {
lypinator 0:bb348c97df44 630 /* Disable the TIM Output Compare interrupt */
lypinator 0:bb348c97df44 631 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC2);
lypinator 0:bb348c97df44 632 }
lypinator 0:bb348c97df44 633 break;
lypinator 0:bb348c97df44 634
lypinator 0:bb348c97df44 635 case TIM_CHANNEL_3:
lypinator 0:bb348c97df44 636 {
lypinator 0:bb348c97df44 637 /* Disable the TIM Output Compare interrupt */
lypinator 0:bb348c97df44 638 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC3);
lypinator 0:bb348c97df44 639 }
lypinator 0:bb348c97df44 640 break;
lypinator 0:bb348c97df44 641
lypinator 0:bb348c97df44 642 case TIM_CHANNEL_4:
lypinator 0:bb348c97df44 643 {
lypinator 0:bb348c97df44 644 /* Disable the TIM Output Compare interrupt */
lypinator 0:bb348c97df44 645 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC4);
lypinator 0:bb348c97df44 646 }
lypinator 0:bb348c97df44 647 break;
lypinator 0:bb348c97df44 648
lypinator 0:bb348c97df44 649 default:
lypinator 0:bb348c97df44 650 break;
lypinator 0:bb348c97df44 651 }
lypinator 0:bb348c97df44 652
lypinator 0:bb348c97df44 653 /* Disable the Capture compare channel N */
lypinator 0:bb348c97df44 654 TIM_CCxNChannelCmd(htim->Instance, Channel, TIM_CCxN_DISABLE);
lypinator 0:bb348c97df44 655
lypinator 0:bb348c97df44 656 /* Disable the TIM Break interrupt (only if no more channel is active) */
lypinator 0:bb348c97df44 657 if((READ_REG(htim->Instance->CCER) & (TIM_CCER_CC1NE | TIM_CCER_CC2NE | TIM_CCER_CC3NE)) == RESET)
lypinator 0:bb348c97df44 658 {
lypinator 0:bb348c97df44 659 __HAL_TIM_DISABLE_IT(htim, TIM_IT_BREAK);
lypinator 0:bb348c97df44 660 }
lypinator 0:bb348c97df44 661
lypinator 0:bb348c97df44 662 /* Disable the Main Output */
lypinator 0:bb348c97df44 663 __HAL_TIM_MOE_DISABLE(htim);
lypinator 0:bb348c97df44 664
lypinator 0:bb348c97df44 665 /* Disable the Peripheral */
lypinator 0:bb348c97df44 666 __HAL_TIM_DISABLE(htim);
lypinator 0:bb348c97df44 667
lypinator 0:bb348c97df44 668 /* Return function status */
lypinator 0:bb348c97df44 669 return HAL_OK;
lypinator 0:bb348c97df44 670 }
lypinator 0:bb348c97df44 671
lypinator 0:bb348c97df44 672 /**
lypinator 0:bb348c97df44 673 * @brief Starts the TIM Output Compare signal generation in DMA mode
lypinator 0:bb348c97df44 674 * on the complementary output.
lypinator 0:bb348c97df44 675 * @param htim pointer to a TIM_HandleTypeDef structure that contains
lypinator 0:bb348c97df44 676 * the configuration information for TIM module.
lypinator 0:bb348c97df44 677 * @param Channel TIM Channel to be enabled.
lypinator 0:bb348c97df44 678 * This parameter can be one of the following values:
lypinator 0:bb348c97df44 679 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
lypinator 0:bb348c97df44 680 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
lypinator 0:bb348c97df44 681 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
lypinator 0:bb348c97df44 682 * @param pData The source Buffer address.
lypinator 0:bb348c97df44 683 * @param Length The length of data to be transferred from memory to TIM peripheral
lypinator 0:bb348c97df44 684 * @retval HAL status
lypinator 0:bb348c97df44 685 */
lypinator 0:bb348c97df44 686 HAL_StatusTypeDef HAL_TIMEx_OCN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length)
lypinator 0:bb348c97df44 687 {
lypinator 0:bb348c97df44 688 /* Check the parameters */
lypinator 0:bb348c97df44 689 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, Channel));
lypinator 0:bb348c97df44 690
lypinator 0:bb348c97df44 691 if((htim->State == HAL_TIM_STATE_BUSY))
lypinator 0:bb348c97df44 692 {
lypinator 0:bb348c97df44 693 return HAL_BUSY;
lypinator 0:bb348c97df44 694 }
lypinator 0:bb348c97df44 695 else if((htim->State == HAL_TIM_STATE_READY))
lypinator 0:bb348c97df44 696 {
lypinator 0:bb348c97df44 697 if(((uint32_t)pData == 0U) && (Length > 0))
lypinator 0:bb348c97df44 698 {
lypinator 0:bb348c97df44 699 return HAL_ERROR;
lypinator 0:bb348c97df44 700 }
lypinator 0:bb348c97df44 701 else
lypinator 0:bb348c97df44 702 {
lypinator 0:bb348c97df44 703 htim->State = HAL_TIM_STATE_BUSY;
lypinator 0:bb348c97df44 704 }
lypinator 0:bb348c97df44 705 }
lypinator 0:bb348c97df44 706 switch (Channel)
lypinator 0:bb348c97df44 707 {
lypinator 0:bb348c97df44 708 case TIM_CHANNEL_1:
lypinator 0:bb348c97df44 709 {
lypinator 0:bb348c97df44 710 /* Set the DMA Period elapsed callback */
lypinator 0:bb348c97df44 711 htim->hdma[TIM_DMA_ID_CC1]->XferCpltCallback = TIM_DMADelayPulseCplt;
lypinator 0:bb348c97df44 712
lypinator 0:bb348c97df44 713 /* Set the DMA error callback */
lypinator 0:bb348c97df44 714 htim->hdma[TIM_DMA_ID_CC1]->XferErrorCallback = TIM_DMAError ;
lypinator 0:bb348c97df44 715
lypinator 0:bb348c97df44 716 /* Enable the DMA Stream */
lypinator 0:bb348c97df44 717 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)pData, (uint32_t)&htim->Instance->CCR1, Length);
lypinator 0:bb348c97df44 718
lypinator 0:bb348c97df44 719 /* Enable the TIM Output Compare DMA request */
lypinator 0:bb348c97df44 720 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC1);
lypinator 0:bb348c97df44 721 }
lypinator 0:bb348c97df44 722 break;
lypinator 0:bb348c97df44 723
lypinator 0:bb348c97df44 724 case TIM_CHANNEL_2:
lypinator 0:bb348c97df44 725 {
lypinator 0:bb348c97df44 726 /* Set the DMA Period elapsed callback */
lypinator 0:bb348c97df44 727 htim->hdma[TIM_DMA_ID_CC2]->XferCpltCallback = TIM_DMADelayPulseCplt;
lypinator 0:bb348c97df44 728
lypinator 0:bb348c97df44 729 /* Set the DMA error callback */
lypinator 0:bb348c97df44 730 htim->hdma[TIM_DMA_ID_CC2]->XferErrorCallback = TIM_DMAError ;
lypinator 0:bb348c97df44 731
lypinator 0:bb348c97df44 732 /* Enable the DMA Stream */
lypinator 0:bb348c97df44 733 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)pData, (uint32_t)&htim->Instance->CCR2, Length);
lypinator 0:bb348c97df44 734
lypinator 0:bb348c97df44 735 /* Enable the TIM Output Compare DMA request */
lypinator 0:bb348c97df44 736 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC2);
lypinator 0:bb348c97df44 737 }
lypinator 0:bb348c97df44 738 break;
lypinator 0:bb348c97df44 739
lypinator 0:bb348c97df44 740 case TIM_CHANNEL_3:
lypinator 0:bb348c97df44 741 {
lypinator 0:bb348c97df44 742 /* Set the DMA Period elapsed callback */
lypinator 0:bb348c97df44 743 htim->hdma[TIM_DMA_ID_CC3]->XferCpltCallback = TIM_DMADelayPulseCplt;
lypinator 0:bb348c97df44 744
lypinator 0:bb348c97df44 745 /* Set the DMA error callback */
lypinator 0:bb348c97df44 746 htim->hdma[TIM_DMA_ID_CC3]->XferErrorCallback = TIM_DMAError ;
lypinator 0:bb348c97df44 747
lypinator 0:bb348c97df44 748 /* Enable the DMA Stream */
lypinator 0:bb348c97df44 749 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC3], (uint32_t)pData, (uint32_t)&htim->Instance->CCR3,Length);
lypinator 0:bb348c97df44 750
lypinator 0:bb348c97df44 751 /* Enable the TIM Output Compare DMA request */
lypinator 0:bb348c97df44 752 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC3);
lypinator 0:bb348c97df44 753 }
lypinator 0:bb348c97df44 754 break;
lypinator 0:bb348c97df44 755
lypinator 0:bb348c97df44 756 case TIM_CHANNEL_4:
lypinator 0:bb348c97df44 757 {
lypinator 0:bb348c97df44 758 /* Set the DMA Period elapsed callback */
lypinator 0:bb348c97df44 759 htim->hdma[TIM_DMA_ID_CC4]->XferCpltCallback = TIM_DMADelayPulseCplt;
lypinator 0:bb348c97df44 760
lypinator 0:bb348c97df44 761 /* Set the DMA error callback */
lypinator 0:bb348c97df44 762 htim->hdma[TIM_DMA_ID_CC4]->XferErrorCallback = TIM_DMAError ;
lypinator 0:bb348c97df44 763
lypinator 0:bb348c97df44 764 /* Enable the DMA Stream */
lypinator 0:bb348c97df44 765 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC4], (uint32_t)pData, (uint32_t)&htim->Instance->CCR4, Length);
lypinator 0:bb348c97df44 766
lypinator 0:bb348c97df44 767 /* Enable the TIM Output Compare DMA request */
lypinator 0:bb348c97df44 768 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC4);
lypinator 0:bb348c97df44 769 }
lypinator 0:bb348c97df44 770 break;
lypinator 0:bb348c97df44 771
lypinator 0:bb348c97df44 772 default:
lypinator 0:bb348c97df44 773 break;
lypinator 0:bb348c97df44 774 }
lypinator 0:bb348c97df44 775
lypinator 0:bb348c97df44 776 /* Enable the Capture compare channel N */
lypinator 0:bb348c97df44 777 TIM_CCxNChannelCmd(htim->Instance, Channel, TIM_CCxN_ENABLE);
lypinator 0:bb348c97df44 778
lypinator 0:bb348c97df44 779 /* Enable the Main Output */
lypinator 0:bb348c97df44 780 __HAL_TIM_MOE_ENABLE(htim);
lypinator 0:bb348c97df44 781
lypinator 0:bb348c97df44 782 /* Enable the Peripheral */
lypinator 0:bb348c97df44 783 __HAL_TIM_ENABLE(htim);
lypinator 0:bb348c97df44 784
lypinator 0:bb348c97df44 785 /* Return function status */
lypinator 0:bb348c97df44 786 return HAL_OK;
lypinator 0:bb348c97df44 787 }
lypinator 0:bb348c97df44 788
lypinator 0:bb348c97df44 789 /**
lypinator 0:bb348c97df44 790 * @brief Stops the TIM Output Compare signal generation in DMA mode
lypinator 0:bb348c97df44 791 * on the complementary output.
lypinator 0:bb348c97df44 792 * @param htim pointer to a TIM_HandleTypeDef structure that contains
lypinator 0:bb348c97df44 793 * the configuration information for TIM module.
lypinator 0:bb348c97df44 794 * @param Channel TIM Channel to be disabled.
lypinator 0:bb348c97df44 795 * This parameter can be one of the following values:
lypinator 0:bb348c97df44 796 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
lypinator 0:bb348c97df44 797 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
lypinator 0:bb348c97df44 798 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
lypinator 0:bb348c97df44 799 * @retval HAL status
lypinator 0:bb348c97df44 800 */
lypinator 0:bb348c97df44 801 HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel)
lypinator 0:bb348c97df44 802 {
lypinator 0:bb348c97df44 803 /* Check the parameters */
lypinator 0:bb348c97df44 804 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, Channel));
lypinator 0:bb348c97df44 805
lypinator 0:bb348c97df44 806 switch (Channel)
lypinator 0:bb348c97df44 807 {
lypinator 0:bb348c97df44 808 case TIM_CHANNEL_1:
lypinator 0:bb348c97df44 809 {
lypinator 0:bb348c97df44 810 /* Disable the TIM Output Compare DMA request */
lypinator 0:bb348c97df44 811 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC1);
lypinator 0:bb348c97df44 812 }
lypinator 0:bb348c97df44 813 break;
lypinator 0:bb348c97df44 814
lypinator 0:bb348c97df44 815 case TIM_CHANNEL_2:
lypinator 0:bb348c97df44 816 {
lypinator 0:bb348c97df44 817 /* Disable the TIM Output Compare DMA request */
lypinator 0:bb348c97df44 818 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC2);
lypinator 0:bb348c97df44 819 }
lypinator 0:bb348c97df44 820 break;
lypinator 0:bb348c97df44 821
lypinator 0:bb348c97df44 822 case TIM_CHANNEL_3:
lypinator 0:bb348c97df44 823 {
lypinator 0:bb348c97df44 824 /* Disable the TIM Output Compare DMA request */
lypinator 0:bb348c97df44 825 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC3);
lypinator 0:bb348c97df44 826 }
lypinator 0:bb348c97df44 827 break;
lypinator 0:bb348c97df44 828
lypinator 0:bb348c97df44 829 case TIM_CHANNEL_4:
lypinator 0:bb348c97df44 830 {
lypinator 0:bb348c97df44 831 /* Disable the TIM Output Compare interrupt */
lypinator 0:bb348c97df44 832 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC4);
lypinator 0:bb348c97df44 833 }
lypinator 0:bb348c97df44 834 break;
lypinator 0:bb348c97df44 835
lypinator 0:bb348c97df44 836 default:
lypinator 0:bb348c97df44 837 break;
lypinator 0:bb348c97df44 838 }
lypinator 0:bb348c97df44 839
lypinator 0:bb348c97df44 840 /* Disable the Capture compare channel N */
lypinator 0:bb348c97df44 841 TIM_CCxNChannelCmd(htim->Instance, Channel, TIM_CCxN_DISABLE);
lypinator 0:bb348c97df44 842
lypinator 0:bb348c97df44 843 /* Disable the Main Output */
lypinator 0:bb348c97df44 844 __HAL_TIM_MOE_DISABLE(htim);
lypinator 0:bb348c97df44 845
lypinator 0:bb348c97df44 846 /* Disable the Peripheral */
lypinator 0:bb348c97df44 847 __HAL_TIM_DISABLE(htim);
lypinator 0:bb348c97df44 848
lypinator 0:bb348c97df44 849 /* Change the htim state */
lypinator 0:bb348c97df44 850 htim->State = HAL_TIM_STATE_READY;
lypinator 0:bb348c97df44 851
lypinator 0:bb348c97df44 852 /* Return function status */
lypinator 0:bb348c97df44 853 return HAL_OK;
lypinator 0:bb348c97df44 854 }
lypinator 0:bb348c97df44 855 /**
lypinator 0:bb348c97df44 856 * @}
lypinator 0:bb348c97df44 857 */
lypinator 0:bb348c97df44 858
lypinator 0:bb348c97df44 859 /** @defgroup TIMEx_Exported_Functions_Group3 Timer Complementary PWM functions
lypinator 0:bb348c97df44 860 * @brief Timer Complementary PWM functions
lypinator 0:bb348c97df44 861 *
lypinator 0:bb348c97df44 862 @verbatim
lypinator 0:bb348c97df44 863 ==============================================================================
lypinator 0:bb348c97df44 864 ##### Timer Complementary PWM functions #####
lypinator 0:bb348c97df44 865 ==============================================================================
lypinator 0:bb348c97df44 866 [..]
lypinator 0:bb348c97df44 867 This section provides functions allowing to:
lypinator 0:bb348c97df44 868 (+) Start the Complementary PWM.
lypinator 0:bb348c97df44 869 (+) Stop the Complementary PWM.
lypinator 0:bb348c97df44 870 (+) Start the Complementary PWM and enable interrupts.
lypinator 0:bb348c97df44 871 (+) Stop the Complementary PWM and disable interrupts.
lypinator 0:bb348c97df44 872 (+) Start the Complementary PWM and enable DMA transfers.
lypinator 0:bb348c97df44 873 (+) Stop the Complementary PWM and disable DMA transfers.
lypinator 0:bb348c97df44 874 (+) Start the Complementary Input Capture measurement.
lypinator 0:bb348c97df44 875 (+) Stop the Complementary Input Capture.
lypinator 0:bb348c97df44 876 (+) Start the Complementary Input Capture and enable interrupts.
lypinator 0:bb348c97df44 877 (+) Stop the Complementary Input Capture and disable interrupts.
lypinator 0:bb348c97df44 878 (+) Start the Complementary Input Capture and enable DMA transfers.
lypinator 0:bb348c97df44 879 (+) Stop the Complementary Input Capture and disable DMA transfers.
lypinator 0:bb348c97df44 880 (+) Start the Complementary One Pulse generation.
lypinator 0:bb348c97df44 881 (+) Stop the Complementary One Pulse.
lypinator 0:bb348c97df44 882 (+) Start the Complementary One Pulse and enable interrupts.
lypinator 0:bb348c97df44 883 (+) Stop the Complementary One Pulse and disable interrupts.
lypinator 0:bb348c97df44 884
lypinator 0:bb348c97df44 885 @endverbatim
lypinator 0:bb348c97df44 886 * @{
lypinator 0:bb348c97df44 887 */
lypinator 0:bb348c97df44 888
lypinator 0:bb348c97df44 889 /**
lypinator 0:bb348c97df44 890 * @brief Starts the PWM signal generation on the complementary output.
lypinator 0:bb348c97df44 891 * @param htim pointer to a TIM_HandleTypeDef structure that contains
lypinator 0:bb348c97df44 892 * the configuration information for TIM module.
lypinator 0:bb348c97df44 893 * @param Channel TIM Channel to be enabled.
lypinator 0:bb348c97df44 894 * This parameter can be one of the following values:
lypinator 0:bb348c97df44 895 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
lypinator 0:bb348c97df44 896 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
lypinator 0:bb348c97df44 897 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
lypinator 0:bb348c97df44 898 * @retval HAL status
lypinator 0:bb348c97df44 899 */
lypinator 0:bb348c97df44 900 HAL_StatusTypeDef HAL_TIMEx_PWMN_Start(TIM_HandleTypeDef *htim, uint32_t Channel)
lypinator 0:bb348c97df44 901 {
lypinator 0:bb348c97df44 902 /* Check the parameters */
lypinator 0:bb348c97df44 903 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, Channel));
lypinator 0:bb348c97df44 904
lypinator 0:bb348c97df44 905 /* Enable the complementary PWM output */
lypinator 0:bb348c97df44 906 TIM_CCxNChannelCmd(htim->Instance, Channel, TIM_CCxN_ENABLE);
lypinator 0:bb348c97df44 907
lypinator 0:bb348c97df44 908 /* Enable the Main Output */
lypinator 0:bb348c97df44 909 __HAL_TIM_MOE_ENABLE(htim);
lypinator 0:bb348c97df44 910
lypinator 0:bb348c97df44 911 /* Enable the Peripheral */
lypinator 0:bb348c97df44 912 __HAL_TIM_ENABLE(htim);
lypinator 0:bb348c97df44 913
lypinator 0:bb348c97df44 914 /* Return function status */
lypinator 0:bb348c97df44 915 return HAL_OK;
lypinator 0:bb348c97df44 916 }
lypinator 0:bb348c97df44 917
lypinator 0:bb348c97df44 918 /**
lypinator 0:bb348c97df44 919 * @brief Stops the PWM signal generation on the complementary output.
lypinator 0:bb348c97df44 920 * @param htim pointer to a TIM_HandleTypeDef structure that contains
lypinator 0:bb348c97df44 921 * the configuration information for TIM module.
lypinator 0:bb348c97df44 922 * @param Channel TIM Channel to be disabled.
lypinator 0:bb348c97df44 923 * This parameter can be one of the following values:
lypinator 0:bb348c97df44 924 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
lypinator 0:bb348c97df44 925 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
lypinator 0:bb348c97df44 926 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
lypinator 0:bb348c97df44 927 * @retval HAL status
lypinator 0:bb348c97df44 928 */
lypinator 0:bb348c97df44 929 HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel)
lypinator 0:bb348c97df44 930 {
lypinator 0:bb348c97df44 931 /* Check the parameters */
lypinator 0:bb348c97df44 932 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, Channel));
lypinator 0:bb348c97df44 933
lypinator 0:bb348c97df44 934 /* Disable the complementary PWM output */
lypinator 0:bb348c97df44 935 TIM_CCxNChannelCmd(htim->Instance, Channel, TIM_CCxN_DISABLE);
lypinator 0:bb348c97df44 936
lypinator 0:bb348c97df44 937 /* Disable the Main Output */
lypinator 0:bb348c97df44 938 __HAL_TIM_MOE_DISABLE(htim);
lypinator 0:bb348c97df44 939
lypinator 0:bb348c97df44 940 /* Disable the Peripheral */
lypinator 0:bb348c97df44 941 __HAL_TIM_DISABLE(htim);
lypinator 0:bb348c97df44 942
lypinator 0:bb348c97df44 943 /* Return function status */
lypinator 0:bb348c97df44 944 return HAL_OK;
lypinator 0:bb348c97df44 945 }
lypinator 0:bb348c97df44 946
lypinator 0:bb348c97df44 947 /**
lypinator 0:bb348c97df44 948 * @brief Starts the PWM signal generation in interrupt mode on the
lypinator 0:bb348c97df44 949 * complementary output.
lypinator 0:bb348c97df44 950 * @param htim pointer to a TIM_HandleTypeDef structure that contains
lypinator 0:bb348c97df44 951 * the configuration information for TIM module.
lypinator 0:bb348c97df44 952 * @param Channel TIM Channel to be disabled.
lypinator 0:bb348c97df44 953 * This parameter can be one of the following values:
lypinator 0:bb348c97df44 954 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
lypinator 0:bb348c97df44 955 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
lypinator 0:bb348c97df44 956 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
lypinator 0:bb348c97df44 957 * @retval HAL status
lypinator 0:bb348c97df44 958 */
lypinator 0:bb348c97df44 959 HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
lypinator 0:bb348c97df44 960 {
lypinator 0:bb348c97df44 961 /* Check the parameters */
lypinator 0:bb348c97df44 962 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, Channel));
lypinator 0:bb348c97df44 963
lypinator 0:bb348c97df44 964 switch (Channel)
lypinator 0:bb348c97df44 965 {
lypinator 0:bb348c97df44 966 case TIM_CHANNEL_1:
lypinator 0:bb348c97df44 967 {
lypinator 0:bb348c97df44 968 /* Enable the TIM Capture/Compare 1 interrupt */
lypinator 0:bb348c97df44 969 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC1);
lypinator 0:bb348c97df44 970 }
lypinator 0:bb348c97df44 971 break;
lypinator 0:bb348c97df44 972
lypinator 0:bb348c97df44 973 case TIM_CHANNEL_2:
lypinator 0:bb348c97df44 974 {
lypinator 0:bb348c97df44 975 /* Enable the TIM Capture/Compare 2 interrupt */
lypinator 0:bb348c97df44 976 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC2);
lypinator 0:bb348c97df44 977 }
lypinator 0:bb348c97df44 978 break;
lypinator 0:bb348c97df44 979
lypinator 0:bb348c97df44 980 case TIM_CHANNEL_3:
lypinator 0:bb348c97df44 981 {
lypinator 0:bb348c97df44 982 /* Enable the TIM Capture/Compare 3 interrupt */
lypinator 0:bb348c97df44 983 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC3);
lypinator 0:bb348c97df44 984 }
lypinator 0:bb348c97df44 985 break;
lypinator 0:bb348c97df44 986
lypinator 0:bb348c97df44 987 case TIM_CHANNEL_4:
lypinator 0:bb348c97df44 988 {
lypinator 0:bb348c97df44 989 /* Enable the TIM Capture/Compare 4 interrupt */
lypinator 0:bb348c97df44 990 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC4);
lypinator 0:bb348c97df44 991 }
lypinator 0:bb348c97df44 992 break;
lypinator 0:bb348c97df44 993
lypinator 0:bb348c97df44 994 default:
lypinator 0:bb348c97df44 995 break;
lypinator 0:bb348c97df44 996 }
lypinator 0:bb348c97df44 997
lypinator 0:bb348c97df44 998 /* Enable the TIM Break interrupt */
lypinator 0:bb348c97df44 999 __HAL_TIM_ENABLE_IT(htim, TIM_IT_BREAK);
lypinator 0:bb348c97df44 1000
lypinator 0:bb348c97df44 1001 /* Enable the complementary PWM output */
lypinator 0:bb348c97df44 1002 TIM_CCxNChannelCmd(htim->Instance, Channel, TIM_CCxN_ENABLE);
lypinator 0:bb348c97df44 1003
lypinator 0:bb348c97df44 1004 /* Enable the Main Output */
lypinator 0:bb348c97df44 1005 __HAL_TIM_MOE_ENABLE(htim);
lypinator 0:bb348c97df44 1006
lypinator 0:bb348c97df44 1007 /* Enable the Peripheral */
lypinator 0:bb348c97df44 1008 __HAL_TIM_ENABLE(htim);
lypinator 0:bb348c97df44 1009
lypinator 0:bb348c97df44 1010 /* Return function status */
lypinator 0:bb348c97df44 1011 return HAL_OK;
lypinator 0:bb348c97df44 1012 }
lypinator 0:bb348c97df44 1013
lypinator 0:bb348c97df44 1014 /**
lypinator 0:bb348c97df44 1015 * @brief Stops the PWM signal generation in interrupt mode on the
lypinator 0:bb348c97df44 1016 * complementary output.
lypinator 0:bb348c97df44 1017 * @param htim pointer to a TIM_HandleTypeDef structure that contains
lypinator 0:bb348c97df44 1018 * the configuration information for TIM module.
lypinator 0:bb348c97df44 1019 * @param Channel TIM Channel to be disabled.
lypinator 0:bb348c97df44 1020 * This parameter can be one of the following values:
lypinator 0:bb348c97df44 1021 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
lypinator 0:bb348c97df44 1022 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
lypinator 0:bb348c97df44 1023 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
lypinator 0:bb348c97df44 1024 * @retval HAL status
lypinator 0:bb348c97df44 1025 */
lypinator 0:bb348c97df44 1026 HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_IT (TIM_HandleTypeDef *htim, uint32_t Channel)
lypinator 0:bb348c97df44 1027 {
lypinator 0:bb348c97df44 1028 /* Check the parameters */
lypinator 0:bb348c97df44 1029 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, Channel));
lypinator 0:bb348c97df44 1030
lypinator 0:bb348c97df44 1031 switch (Channel)
lypinator 0:bb348c97df44 1032 {
lypinator 0:bb348c97df44 1033 case TIM_CHANNEL_1:
lypinator 0:bb348c97df44 1034 {
lypinator 0:bb348c97df44 1035 /* Disable the TIM Capture/Compare 1 interrupt */
lypinator 0:bb348c97df44 1036 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC1);
lypinator 0:bb348c97df44 1037 }
lypinator 0:bb348c97df44 1038 break;
lypinator 0:bb348c97df44 1039
lypinator 0:bb348c97df44 1040 case TIM_CHANNEL_2:
lypinator 0:bb348c97df44 1041 {
lypinator 0:bb348c97df44 1042 /* Disable the TIM Capture/Compare 2 interrupt */
lypinator 0:bb348c97df44 1043 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC2);
lypinator 0:bb348c97df44 1044 }
lypinator 0:bb348c97df44 1045 break;
lypinator 0:bb348c97df44 1046
lypinator 0:bb348c97df44 1047 case TIM_CHANNEL_3:
lypinator 0:bb348c97df44 1048 {
lypinator 0:bb348c97df44 1049 /* Disable the TIM Capture/Compare 3 interrupt */
lypinator 0:bb348c97df44 1050 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC3);
lypinator 0:bb348c97df44 1051 }
lypinator 0:bb348c97df44 1052 break;
lypinator 0:bb348c97df44 1053
lypinator 0:bb348c97df44 1054 case TIM_CHANNEL_4:
lypinator 0:bb348c97df44 1055 {
lypinator 0:bb348c97df44 1056 /* Disable the TIM Capture/Compare 3 interrupt */
lypinator 0:bb348c97df44 1057 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC4);
lypinator 0:bb348c97df44 1058 }
lypinator 0:bb348c97df44 1059 break;
lypinator 0:bb348c97df44 1060
lypinator 0:bb348c97df44 1061 default:
lypinator 0:bb348c97df44 1062 break;
lypinator 0:bb348c97df44 1063 }
lypinator 0:bb348c97df44 1064
lypinator 0:bb348c97df44 1065 /* Disable the complementary PWM output */
lypinator 0:bb348c97df44 1066 TIM_CCxNChannelCmd(htim->Instance, Channel, TIM_CCxN_DISABLE);
lypinator 0:bb348c97df44 1067
lypinator 0:bb348c97df44 1068 /* Disable the TIM Break interrupt (only if no more channel is active) */
lypinator 0:bb348c97df44 1069 if((READ_REG(htim->Instance->CCER) & (TIM_CCER_CC1NE | TIM_CCER_CC2NE | TIM_CCER_CC3NE)) == RESET)
lypinator 0:bb348c97df44 1070 {
lypinator 0:bb348c97df44 1071 __HAL_TIM_DISABLE_IT(htim, TIM_IT_BREAK);
lypinator 0:bb348c97df44 1072 }
lypinator 0:bb348c97df44 1073
lypinator 0:bb348c97df44 1074 /* Disable the Main Output */
lypinator 0:bb348c97df44 1075 __HAL_TIM_MOE_DISABLE(htim);
lypinator 0:bb348c97df44 1076
lypinator 0:bb348c97df44 1077 /* Disable the Peripheral */
lypinator 0:bb348c97df44 1078 __HAL_TIM_DISABLE(htim);
lypinator 0:bb348c97df44 1079
lypinator 0:bb348c97df44 1080 /* Return function status */
lypinator 0:bb348c97df44 1081 return HAL_OK;
lypinator 0:bb348c97df44 1082 }
lypinator 0:bb348c97df44 1083
lypinator 0:bb348c97df44 1084 /**
lypinator 0:bb348c97df44 1085 * @brief Starts the TIM PWM signal generation in DMA mode on the
lypinator 0:bb348c97df44 1086 * complementary output
lypinator 0:bb348c97df44 1087 * @param htim pointer to a TIM_HandleTypeDef structure that contains
lypinator 0:bb348c97df44 1088 * the configuration information for TIM module.
lypinator 0:bb348c97df44 1089 * @param Channel TIM Channel to be enabled.
lypinator 0:bb348c97df44 1090 * This parameter can be one of the following values:
lypinator 0:bb348c97df44 1091 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
lypinator 0:bb348c97df44 1092 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
lypinator 0:bb348c97df44 1093 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
lypinator 0:bb348c97df44 1094 * @param pData The source Buffer address.
lypinator 0:bb348c97df44 1095 * @param Length The length of data to be transferred from memory to TIM peripheral
lypinator 0:bb348c97df44 1096 * @retval HAL status
lypinator 0:bb348c97df44 1097 */
lypinator 0:bb348c97df44 1098 HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length)
lypinator 0:bb348c97df44 1099 {
lypinator 0:bb348c97df44 1100 /* Check the parameters */
lypinator 0:bb348c97df44 1101 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, Channel));
lypinator 0:bb348c97df44 1102
lypinator 0:bb348c97df44 1103 if((htim->State == HAL_TIM_STATE_BUSY))
lypinator 0:bb348c97df44 1104 {
lypinator 0:bb348c97df44 1105 return HAL_BUSY;
lypinator 0:bb348c97df44 1106 }
lypinator 0:bb348c97df44 1107 else if((htim->State == HAL_TIM_STATE_READY))
lypinator 0:bb348c97df44 1108 {
lypinator 0:bb348c97df44 1109 if(((uint32_t)pData == 0U) && (Length > 0))
lypinator 0:bb348c97df44 1110 {
lypinator 0:bb348c97df44 1111 return HAL_ERROR;
lypinator 0:bb348c97df44 1112 }
lypinator 0:bb348c97df44 1113 else
lypinator 0:bb348c97df44 1114 {
lypinator 0:bb348c97df44 1115 htim->State = HAL_TIM_STATE_BUSY;
lypinator 0:bb348c97df44 1116 }
lypinator 0:bb348c97df44 1117 }
lypinator 0:bb348c97df44 1118 switch (Channel)
lypinator 0:bb348c97df44 1119 {
lypinator 0:bb348c97df44 1120 case TIM_CHANNEL_1:
lypinator 0:bb348c97df44 1121 {
lypinator 0:bb348c97df44 1122 /* Set the DMA Period elapsed callback */
lypinator 0:bb348c97df44 1123 htim->hdma[TIM_DMA_ID_CC1]->XferCpltCallback = TIM_DMADelayPulseCplt;
lypinator 0:bb348c97df44 1124
lypinator 0:bb348c97df44 1125 /* Set the DMA error callback */
lypinator 0:bb348c97df44 1126 htim->hdma[TIM_DMA_ID_CC1]->XferErrorCallback = TIM_DMAError ;
lypinator 0:bb348c97df44 1127
lypinator 0:bb348c97df44 1128 /* Enable the DMA Stream */
lypinator 0:bb348c97df44 1129 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)pData, (uint32_t)&htim->Instance->CCR1, Length);
lypinator 0:bb348c97df44 1130
lypinator 0:bb348c97df44 1131 /* Enable the TIM Capture/Compare 1 DMA request */
lypinator 0:bb348c97df44 1132 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC1);
lypinator 0:bb348c97df44 1133 }
lypinator 0:bb348c97df44 1134 break;
lypinator 0:bb348c97df44 1135
lypinator 0:bb348c97df44 1136 case TIM_CHANNEL_2:
lypinator 0:bb348c97df44 1137 {
lypinator 0:bb348c97df44 1138 /* Set the DMA Period elapsed callback */
lypinator 0:bb348c97df44 1139 htim->hdma[TIM_DMA_ID_CC2]->XferCpltCallback = TIM_DMADelayPulseCplt;
lypinator 0:bb348c97df44 1140
lypinator 0:bb348c97df44 1141 /* Set the DMA error callback */
lypinator 0:bb348c97df44 1142 htim->hdma[TIM_DMA_ID_CC2]->XferErrorCallback = TIM_DMAError ;
lypinator 0:bb348c97df44 1143
lypinator 0:bb348c97df44 1144 /* Enable the DMA Stream */
lypinator 0:bb348c97df44 1145 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)pData, (uint32_t)&htim->Instance->CCR2, Length);
lypinator 0:bb348c97df44 1146
lypinator 0:bb348c97df44 1147 /* Enable the TIM Capture/Compare 2 DMA request */
lypinator 0:bb348c97df44 1148 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC2);
lypinator 0:bb348c97df44 1149 }
lypinator 0:bb348c97df44 1150 break;
lypinator 0:bb348c97df44 1151
lypinator 0:bb348c97df44 1152 case TIM_CHANNEL_3:
lypinator 0:bb348c97df44 1153 {
lypinator 0:bb348c97df44 1154 /* Set the DMA Period elapsed callback */
lypinator 0:bb348c97df44 1155 htim->hdma[TIM_DMA_ID_CC3]->XferCpltCallback = TIM_DMADelayPulseCplt;
lypinator 0:bb348c97df44 1156
lypinator 0:bb348c97df44 1157 /* Set the DMA error callback */
lypinator 0:bb348c97df44 1158 htim->hdma[TIM_DMA_ID_CC3]->XferErrorCallback = TIM_DMAError ;
lypinator 0:bb348c97df44 1159
lypinator 0:bb348c97df44 1160 /* Enable the DMA Stream */
lypinator 0:bb348c97df44 1161 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC3], (uint32_t)pData, (uint32_t)&htim->Instance->CCR3,Length);
lypinator 0:bb348c97df44 1162
lypinator 0:bb348c97df44 1163 /* Enable the TIM Capture/Compare 3 DMA request */
lypinator 0:bb348c97df44 1164 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC3);
lypinator 0:bb348c97df44 1165 }
lypinator 0:bb348c97df44 1166 break;
lypinator 0:bb348c97df44 1167
lypinator 0:bb348c97df44 1168 case TIM_CHANNEL_4:
lypinator 0:bb348c97df44 1169 {
lypinator 0:bb348c97df44 1170 /* Set the DMA Period elapsed callback */
lypinator 0:bb348c97df44 1171 htim->hdma[TIM_DMA_ID_CC4]->XferCpltCallback = TIM_DMADelayPulseCplt;
lypinator 0:bb348c97df44 1172
lypinator 0:bb348c97df44 1173 /* Set the DMA error callback */
lypinator 0:bb348c97df44 1174 htim->hdma[TIM_DMA_ID_CC4]->XferErrorCallback = TIM_DMAError ;
lypinator 0:bb348c97df44 1175
lypinator 0:bb348c97df44 1176 /* Enable the DMA Stream */
lypinator 0:bb348c97df44 1177 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC4], (uint32_t)pData, (uint32_t)&htim->Instance->CCR4, Length);
lypinator 0:bb348c97df44 1178
lypinator 0:bb348c97df44 1179 /* Enable the TIM Capture/Compare 4 DMA request */
lypinator 0:bb348c97df44 1180 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC4);
lypinator 0:bb348c97df44 1181 }
lypinator 0:bb348c97df44 1182 break;
lypinator 0:bb348c97df44 1183
lypinator 0:bb348c97df44 1184 default:
lypinator 0:bb348c97df44 1185 break;
lypinator 0:bb348c97df44 1186 }
lypinator 0:bb348c97df44 1187
lypinator 0:bb348c97df44 1188 /* Enable the complementary PWM output */
lypinator 0:bb348c97df44 1189 TIM_CCxNChannelCmd(htim->Instance, Channel, TIM_CCxN_ENABLE);
lypinator 0:bb348c97df44 1190
lypinator 0:bb348c97df44 1191 /* Enable the Main Output */
lypinator 0:bb348c97df44 1192 __HAL_TIM_MOE_ENABLE(htim);
lypinator 0:bb348c97df44 1193
lypinator 0:bb348c97df44 1194 /* Enable the Peripheral */
lypinator 0:bb348c97df44 1195 __HAL_TIM_ENABLE(htim);
lypinator 0:bb348c97df44 1196
lypinator 0:bb348c97df44 1197 /* Return function status */
lypinator 0:bb348c97df44 1198 return HAL_OK;
lypinator 0:bb348c97df44 1199 }
lypinator 0:bb348c97df44 1200
lypinator 0:bb348c97df44 1201 /**
lypinator 0:bb348c97df44 1202 * @brief Stops the TIM PWM signal generation in DMA mode on the complementary
lypinator 0:bb348c97df44 1203 * output
lypinator 0:bb348c97df44 1204 * @param htim pointer to a TIM_HandleTypeDef structure that contains
lypinator 0:bb348c97df44 1205 * the configuration information for TIM module.
lypinator 0:bb348c97df44 1206 * @param Channel TIM Channel to be disabled.
lypinator 0:bb348c97df44 1207 * This parameter can be one of the following values:
lypinator 0:bb348c97df44 1208 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
lypinator 0:bb348c97df44 1209 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
lypinator 0:bb348c97df44 1210 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
lypinator 0:bb348c97df44 1211 * @retval HAL status
lypinator 0:bb348c97df44 1212 */
lypinator 0:bb348c97df44 1213 HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel)
lypinator 0:bb348c97df44 1214 {
lypinator 0:bb348c97df44 1215 /* Check the parameters */
lypinator 0:bb348c97df44 1216 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, Channel));
lypinator 0:bb348c97df44 1217
lypinator 0:bb348c97df44 1218 switch (Channel)
lypinator 0:bb348c97df44 1219 {
lypinator 0:bb348c97df44 1220 case TIM_CHANNEL_1:
lypinator 0:bb348c97df44 1221 {
lypinator 0:bb348c97df44 1222 /* Disable the TIM Capture/Compare 1 DMA request */
lypinator 0:bb348c97df44 1223 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC1);
lypinator 0:bb348c97df44 1224 }
lypinator 0:bb348c97df44 1225 break;
lypinator 0:bb348c97df44 1226
lypinator 0:bb348c97df44 1227 case TIM_CHANNEL_2:
lypinator 0:bb348c97df44 1228 {
lypinator 0:bb348c97df44 1229 /* Disable the TIM Capture/Compare 2 DMA request */
lypinator 0:bb348c97df44 1230 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC2);
lypinator 0:bb348c97df44 1231 }
lypinator 0:bb348c97df44 1232 break;
lypinator 0:bb348c97df44 1233
lypinator 0:bb348c97df44 1234 case TIM_CHANNEL_3:
lypinator 0:bb348c97df44 1235 {
lypinator 0:bb348c97df44 1236 /* Disable the TIM Capture/Compare 3 DMA request */
lypinator 0:bb348c97df44 1237 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC3);
lypinator 0:bb348c97df44 1238 }
lypinator 0:bb348c97df44 1239 break;
lypinator 0:bb348c97df44 1240
lypinator 0:bb348c97df44 1241 case TIM_CHANNEL_4:
lypinator 0:bb348c97df44 1242 {
lypinator 0:bb348c97df44 1243 /* Disable the TIM Capture/Compare 4 DMA request */
lypinator 0:bb348c97df44 1244 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC4);
lypinator 0:bb348c97df44 1245 }
lypinator 0:bb348c97df44 1246 break;
lypinator 0:bb348c97df44 1247
lypinator 0:bb348c97df44 1248 default:
lypinator 0:bb348c97df44 1249 break;
lypinator 0:bb348c97df44 1250 }
lypinator 0:bb348c97df44 1251
lypinator 0:bb348c97df44 1252 /* Disable the complementary PWM output */
lypinator 0:bb348c97df44 1253 TIM_CCxNChannelCmd(htim->Instance, Channel, TIM_CCxN_DISABLE);
lypinator 0:bb348c97df44 1254
lypinator 0:bb348c97df44 1255 /* Disable the Main Output */
lypinator 0:bb348c97df44 1256 __HAL_TIM_MOE_DISABLE(htim);
lypinator 0:bb348c97df44 1257
lypinator 0:bb348c97df44 1258 /* Disable the Peripheral */
lypinator 0:bb348c97df44 1259 __HAL_TIM_DISABLE(htim);
lypinator 0:bb348c97df44 1260
lypinator 0:bb348c97df44 1261 /* Change the htim state */
lypinator 0:bb348c97df44 1262 htim->State = HAL_TIM_STATE_READY;
lypinator 0:bb348c97df44 1263
lypinator 0:bb348c97df44 1264 /* Return function status */
lypinator 0:bb348c97df44 1265 return HAL_OK;
lypinator 0:bb348c97df44 1266 }
lypinator 0:bb348c97df44 1267
lypinator 0:bb348c97df44 1268 /**
lypinator 0:bb348c97df44 1269 * @}
lypinator 0:bb348c97df44 1270 */
lypinator 0:bb348c97df44 1271
lypinator 0:bb348c97df44 1272 /** @defgroup TIMEx_Exported_Functions_Group4 Timer Complementary One Pulse functions
lypinator 0:bb348c97df44 1273 * @brief Timer Complementary One Pulse functions
lypinator 0:bb348c97df44 1274 *
lypinator 0:bb348c97df44 1275 @verbatim
lypinator 0:bb348c97df44 1276 ==============================================================================
lypinator 0:bb348c97df44 1277 ##### Timer Complementary One Pulse functions #####
lypinator 0:bb348c97df44 1278 ==============================================================================
lypinator 0:bb348c97df44 1279 [..]
lypinator 0:bb348c97df44 1280 This section provides functions allowing to:
lypinator 0:bb348c97df44 1281 (+) Start the Complementary One Pulse generation.
lypinator 0:bb348c97df44 1282 (+) Stop the Complementary One Pulse.
lypinator 0:bb348c97df44 1283 (+) Start the Complementary One Pulse and enable interrupts.
lypinator 0:bb348c97df44 1284 (+) Stop the Complementary One Pulse and disable interrupts.
lypinator 0:bb348c97df44 1285
lypinator 0:bb348c97df44 1286 @endverbatim
lypinator 0:bb348c97df44 1287 * @{
lypinator 0:bb348c97df44 1288 */
lypinator 0:bb348c97df44 1289
lypinator 0:bb348c97df44 1290 /**
lypinator 0:bb348c97df44 1291 * @brief Starts the TIM One Pulse signal generation on the complementary
lypinator 0:bb348c97df44 1292 * output.
lypinator 0:bb348c97df44 1293 * @param htim pointer to a TIM_HandleTypeDef structure that contains
lypinator 0:bb348c97df44 1294 * the configuration information for TIM module.
lypinator 0:bb348c97df44 1295 * @param OutputChannel TIM Channel to be enabled.
lypinator 0:bb348c97df44 1296 * This parameter can be one of the following values:
lypinator 0:bb348c97df44 1297 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
lypinator 0:bb348c97df44 1298 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
lypinator 0:bb348c97df44 1299 * @retval HAL status
lypinator 0:bb348c97df44 1300 */
lypinator 0:bb348c97df44 1301 HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
lypinator 0:bb348c97df44 1302 {
lypinator 0:bb348c97df44 1303 /* Check the parameters */
lypinator 0:bb348c97df44 1304 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, OutputChannel));
lypinator 0:bb348c97df44 1305
lypinator 0:bb348c97df44 1306 /* Enable the complementary One Pulse output */
lypinator 0:bb348c97df44 1307 TIM_CCxNChannelCmd(htim->Instance, OutputChannel, TIM_CCxN_ENABLE);
lypinator 0:bb348c97df44 1308
lypinator 0:bb348c97df44 1309 /* Enable the Main Output */
lypinator 0:bb348c97df44 1310 __HAL_TIM_MOE_ENABLE(htim);
lypinator 0:bb348c97df44 1311
lypinator 0:bb348c97df44 1312 /* Return function status */
lypinator 0:bb348c97df44 1313 return HAL_OK;
lypinator 0:bb348c97df44 1314 }
lypinator 0:bb348c97df44 1315
lypinator 0:bb348c97df44 1316 /**
lypinator 0:bb348c97df44 1317 * @brief Stops the TIM One Pulse signal generation on the complementary
lypinator 0:bb348c97df44 1318 * output.
lypinator 0:bb348c97df44 1319 * @param htim pointer to a TIM_HandleTypeDef structure that contains
lypinator 0:bb348c97df44 1320 * the configuration information for TIM module.
lypinator 0:bb348c97df44 1321 * @param OutputChannel TIM Channel to be disabled.
lypinator 0:bb348c97df44 1322 * This parameter can be one of the following values:
lypinator 0:bb348c97df44 1323 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
lypinator 0:bb348c97df44 1324 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
lypinator 0:bb348c97df44 1325 * @retval HAL status
lypinator 0:bb348c97df44 1326 */
lypinator 0:bb348c97df44 1327 HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
lypinator 0:bb348c97df44 1328 {
lypinator 0:bb348c97df44 1329
lypinator 0:bb348c97df44 1330 /* Check the parameters */
lypinator 0:bb348c97df44 1331 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, OutputChannel));
lypinator 0:bb348c97df44 1332
lypinator 0:bb348c97df44 1333 /* Disable the complementary One Pulse output */
lypinator 0:bb348c97df44 1334 TIM_CCxNChannelCmd(htim->Instance, OutputChannel, TIM_CCxN_DISABLE);
lypinator 0:bb348c97df44 1335
lypinator 0:bb348c97df44 1336 /* Disable the Main Output */
lypinator 0:bb348c97df44 1337 __HAL_TIM_MOE_DISABLE(htim);
lypinator 0:bb348c97df44 1338
lypinator 0:bb348c97df44 1339 /* Disable the Peripheral */
lypinator 0:bb348c97df44 1340 __HAL_TIM_DISABLE(htim);
lypinator 0:bb348c97df44 1341
lypinator 0:bb348c97df44 1342 /* Return function status */
lypinator 0:bb348c97df44 1343 return HAL_OK;
lypinator 0:bb348c97df44 1344 }
lypinator 0:bb348c97df44 1345
lypinator 0:bb348c97df44 1346 /**
lypinator 0:bb348c97df44 1347 * @brief Starts the TIM One Pulse signal generation in interrupt mode on the
lypinator 0:bb348c97df44 1348 * complementary channel.
lypinator 0:bb348c97df44 1349 * @param htim pointer to a TIM_HandleTypeDef structure that contains
lypinator 0:bb348c97df44 1350 * the configuration information for TIM module.
lypinator 0:bb348c97df44 1351 * @param OutputChannel TIM Channel to be enabled.
lypinator 0:bb348c97df44 1352 * This parameter can be one of the following values:
lypinator 0:bb348c97df44 1353 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
lypinator 0:bb348c97df44 1354 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
lypinator 0:bb348c97df44 1355 * @retval HAL status
lypinator 0:bb348c97df44 1356 */
lypinator 0:bb348c97df44 1357 HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
lypinator 0:bb348c97df44 1358 {
lypinator 0:bb348c97df44 1359 /* Check the parameters */
lypinator 0:bb348c97df44 1360 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, OutputChannel));
lypinator 0:bb348c97df44 1361
lypinator 0:bb348c97df44 1362 /* Enable the TIM Capture/Compare 1 interrupt */
lypinator 0:bb348c97df44 1363 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC1);
lypinator 0:bb348c97df44 1364
lypinator 0:bb348c97df44 1365 /* Enable the TIM Capture/Compare 2 interrupt */
lypinator 0:bb348c97df44 1366 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC2);
lypinator 0:bb348c97df44 1367
lypinator 0:bb348c97df44 1368 /* Enable the complementary One Pulse output */
lypinator 0:bb348c97df44 1369 TIM_CCxNChannelCmd(htim->Instance, OutputChannel, TIM_CCxN_ENABLE);
lypinator 0:bb348c97df44 1370
lypinator 0:bb348c97df44 1371 /* Enable the Main Output */
lypinator 0:bb348c97df44 1372 __HAL_TIM_MOE_ENABLE(htim);
lypinator 0:bb348c97df44 1373
lypinator 0:bb348c97df44 1374 /* Return function status */
lypinator 0:bb348c97df44 1375 return HAL_OK;
lypinator 0:bb348c97df44 1376 }
lypinator 0:bb348c97df44 1377
lypinator 0:bb348c97df44 1378 /**
lypinator 0:bb348c97df44 1379 * @brief Stops the TIM One Pulse signal generation in interrupt mode on the
lypinator 0:bb348c97df44 1380 * complementary channel.
lypinator 0:bb348c97df44 1381 * @param htim pointer to a TIM_HandleTypeDef structure that contains
lypinator 0:bb348c97df44 1382 * the configuration information for TIM module.
lypinator 0:bb348c97df44 1383 * @param OutputChannel TIM Channel to be disabled.
lypinator 0:bb348c97df44 1384 * This parameter can be one of the following values:
lypinator 0:bb348c97df44 1385 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
lypinator 0:bb348c97df44 1386 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
lypinator 0:bb348c97df44 1387 * @retval HAL status
lypinator 0:bb348c97df44 1388 */
lypinator 0:bb348c97df44 1389 HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
lypinator 0:bb348c97df44 1390 {
lypinator 0:bb348c97df44 1391 /* Check the parameters */
lypinator 0:bb348c97df44 1392 assert_param(IS_TIM_CCXN_INSTANCE(htim->Instance, OutputChannel));
lypinator 0:bb348c97df44 1393
lypinator 0:bb348c97df44 1394 /* Disable the TIM Capture/Compare 1 interrupt */
lypinator 0:bb348c97df44 1395 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC1);
lypinator 0:bb348c97df44 1396
lypinator 0:bb348c97df44 1397 /* Disable the TIM Capture/Compare 2 interrupt */
lypinator 0:bb348c97df44 1398 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC2);
lypinator 0:bb348c97df44 1399
lypinator 0:bb348c97df44 1400 /* Disable the complementary One Pulse output */
lypinator 0:bb348c97df44 1401 TIM_CCxNChannelCmd(htim->Instance, OutputChannel, TIM_CCxN_DISABLE);
lypinator 0:bb348c97df44 1402
lypinator 0:bb348c97df44 1403 /* Disable the Main Output */
lypinator 0:bb348c97df44 1404 __HAL_TIM_MOE_DISABLE(htim);
lypinator 0:bb348c97df44 1405
lypinator 0:bb348c97df44 1406 /* Disable the Peripheral */
lypinator 0:bb348c97df44 1407 __HAL_TIM_DISABLE(htim);
lypinator 0:bb348c97df44 1408
lypinator 0:bb348c97df44 1409 /* Return function status */
lypinator 0:bb348c97df44 1410 return HAL_OK;
lypinator 0:bb348c97df44 1411 }
lypinator 0:bb348c97df44 1412 /**
lypinator 0:bb348c97df44 1413 * @}
lypinator 0:bb348c97df44 1414 */
lypinator 0:bb348c97df44 1415
lypinator 0:bb348c97df44 1416 /** @defgroup TIMEx_Exported_Functions_Group5 Peripheral Control functions
lypinator 0:bb348c97df44 1417 * @brief Peripheral Control functions
lypinator 0:bb348c97df44 1418 *
lypinator 0:bb348c97df44 1419 @verbatim
lypinator 0:bb348c97df44 1420 ==============================================================================
lypinator 0:bb348c97df44 1421 ##### Peripheral Control functions #####
lypinator 0:bb348c97df44 1422 ==============================================================================
lypinator 0:bb348c97df44 1423 [..]
lypinator 0:bb348c97df44 1424 This section provides functions allowing to:
lypinator 0:bb348c97df44 1425 (+) Configure The Input Output channels for OC, PWM, IC or One Pulse mode.
lypinator 0:bb348c97df44 1426 (+) Configure External Clock source.
lypinator 0:bb348c97df44 1427 (+) Configure Complementary channels, break features and dead time.
lypinator 0:bb348c97df44 1428 (+) Configure Master and the Slave synchronization.
lypinator 0:bb348c97df44 1429 (+) Configure the commutation event in case of use of the Hall sensor interface.
lypinator 0:bb348c97df44 1430 (+) Configure the DMA Burst Mode.
lypinator 0:bb348c97df44 1431
lypinator 0:bb348c97df44 1432 @endverbatim
lypinator 0:bb348c97df44 1433 * @{
lypinator 0:bb348c97df44 1434 */
lypinator 0:bb348c97df44 1435 /**
lypinator 0:bb348c97df44 1436 * @brief Configure the TIM commutation event sequence.
lypinator 0:bb348c97df44 1437 * @note This function is mandatory to use the commutation event in order to
lypinator 0:bb348c97df44 1438 * update the configuration at each commutation detection on the TRGI input of the Timer,
lypinator 0:bb348c97df44 1439 * the typical use of this feature is with the use of another Timer(interface Timer)
lypinator 0:bb348c97df44 1440 * configured in Hall sensor interface, this interface Timer will generate the
lypinator 0:bb348c97df44 1441 * commutation at its TRGO output (connected to Timer used in this function) each time
lypinator 0:bb348c97df44 1442 * the TI1 of the Interface Timer detect a commutation at its input TI1.
lypinator 0:bb348c97df44 1443 * @param htim pointer to a TIM_HandleTypeDef structure that contains
lypinator 0:bb348c97df44 1444 * the configuration information for TIM module.
lypinator 0:bb348c97df44 1445 * @param InputTrigger the Internal trigger corresponding to the Timer Interfacing with the Hall sensor.
lypinator 0:bb348c97df44 1446 * This parameter can be one of the following values:
lypinator 0:bb348c97df44 1447 * @arg TIM_TS_ITR0: Internal trigger 0 selected
lypinator 0:bb348c97df44 1448 * @arg TIM_TS_ITR1: Internal trigger 1 selected
lypinator 0:bb348c97df44 1449 * @arg TIM_TS_ITR2: Internal trigger 2 selected
lypinator 0:bb348c97df44 1450 * @arg TIM_TS_ITR3: Internal trigger 3 selected
lypinator 0:bb348c97df44 1451 * @arg TIM_TS_NONE: No trigger is needed
lypinator 0:bb348c97df44 1452 * @param CommutationSource the Commutation Event source.
lypinator 0:bb348c97df44 1453 * This parameter can be one of the following values:
lypinator 0:bb348c97df44 1454 * @arg TIM_COMMUTATION_TRGI: Commutation source is the TRGI of the Interface Timer
lypinator 0:bb348c97df44 1455 * @arg TIM_COMMUTATION_SOFTWARE: Commutation source is set by software using the COMG bit
lypinator 0:bb348c97df44 1456 * @retval HAL status
lypinator 0:bb348c97df44 1457 */
lypinator 0:bb348c97df44 1458 HAL_StatusTypeDef HAL_TIMEx_ConfigCommutationEvent(TIM_HandleTypeDef *htim, uint32_t InputTrigger, uint32_t CommutationSource)
lypinator 0:bb348c97df44 1459 {
lypinator 0:bb348c97df44 1460 /* Check the parameters */
lypinator 0:bb348c97df44 1461 assert_param(IS_TIM_ADVANCED_INSTANCE(htim->Instance));
lypinator 0:bb348c97df44 1462 assert_param(IS_TIM_INTERNAL_TRIGGEREVENT_SELECTION(InputTrigger));
lypinator 0:bb348c97df44 1463
lypinator 0:bb348c97df44 1464 __HAL_LOCK(htim);
lypinator 0:bb348c97df44 1465
lypinator 0:bb348c97df44 1466 if ((InputTrigger == TIM_TS_ITR0) || (InputTrigger == TIM_TS_ITR1) ||
lypinator 0:bb348c97df44 1467 (InputTrigger == TIM_TS_ITR2) || (InputTrigger == TIM_TS_ITR3))
lypinator 0:bb348c97df44 1468 {
lypinator 0:bb348c97df44 1469 /* Select the Input trigger */
lypinator 0:bb348c97df44 1470 htim->Instance->SMCR &= ~TIM_SMCR_TS;
lypinator 0:bb348c97df44 1471 htim->Instance->SMCR |= InputTrigger;
lypinator 0:bb348c97df44 1472 }
lypinator 0:bb348c97df44 1473
lypinator 0:bb348c97df44 1474 /* Select the Capture Compare preload feature */
lypinator 0:bb348c97df44 1475 htim->Instance->CR2 |= TIM_CR2_CCPC;
lypinator 0:bb348c97df44 1476 /* Select the Commutation event source */
lypinator 0:bb348c97df44 1477 htim->Instance->CR2 &= ~TIM_CR2_CCUS;
lypinator 0:bb348c97df44 1478 htim->Instance->CR2 |= CommutationSource;
lypinator 0:bb348c97df44 1479
lypinator 0:bb348c97df44 1480 __HAL_UNLOCK(htim);
lypinator 0:bb348c97df44 1481
lypinator 0:bb348c97df44 1482 return HAL_OK;
lypinator 0:bb348c97df44 1483 }
lypinator 0:bb348c97df44 1484
lypinator 0:bb348c97df44 1485 /**
lypinator 0:bb348c97df44 1486 * @brief Configure the TIM commutation event sequence with interrupt.
lypinator 0:bb348c97df44 1487 * @note This function is mandatory to use the commutation event in order to
lypinator 0:bb348c97df44 1488 * update the configuration at each commutation detection on the TRGI input of the Timer,
lypinator 0:bb348c97df44 1489 * the typical use of this feature is with the use of another Timer(interface Timer)
lypinator 0:bb348c97df44 1490 * configured in Hall sensor interface, this interface Timer will generate the
lypinator 0:bb348c97df44 1491 * commutation at its TRGO output (connected to Timer used in this function) each time
lypinator 0:bb348c97df44 1492 * the TI1 of the Interface Timer detect a commutation at its input TI1.
lypinator 0:bb348c97df44 1493 * @param htim pointer to a TIM_HandleTypeDef structure that contains
lypinator 0:bb348c97df44 1494 * the configuration information for TIM module.
lypinator 0:bb348c97df44 1495 * @param InputTrigger the Internal trigger corresponding to the Timer Interfacing with the Hall sensor.
lypinator 0:bb348c97df44 1496 * This parameter can be one of the following values:
lypinator 0:bb348c97df44 1497 * @arg TIM_TS_ITR0: Internal trigger 0 selected
lypinator 0:bb348c97df44 1498 * @arg TIM_TS_ITR1: Internal trigger 1 selected
lypinator 0:bb348c97df44 1499 * @arg TIM_TS_ITR2: Internal trigger 2 selected
lypinator 0:bb348c97df44 1500 * @arg TIM_TS_ITR3: Internal trigger 3 selected
lypinator 0:bb348c97df44 1501 * @arg TIM_TS_NONE: No trigger is needed
lypinator 0:bb348c97df44 1502 * @param CommutationSource the Commutation Event source.
lypinator 0:bb348c97df44 1503 * This parameter can be one of the following values:
lypinator 0:bb348c97df44 1504 * @arg TIM_COMMUTATION_TRGI: Commutation source is the TRGI of the Interface Timer
lypinator 0:bb348c97df44 1505 * @arg TIM_COMMUTATION_SOFTWARE: Commutation source is set by software using the COMG bit
lypinator 0:bb348c97df44 1506 * @retval HAL status
lypinator 0:bb348c97df44 1507 */
lypinator 0:bb348c97df44 1508 HAL_StatusTypeDef HAL_TIMEx_ConfigCommutationEvent_IT(TIM_HandleTypeDef *htim, uint32_t InputTrigger, uint32_t CommutationSource)
lypinator 0:bb348c97df44 1509 {
lypinator 0:bb348c97df44 1510 /* Check the parameters */
lypinator 0:bb348c97df44 1511 assert_param(IS_TIM_ADVANCED_INSTANCE(htim->Instance));
lypinator 0:bb348c97df44 1512 assert_param(IS_TIM_INTERNAL_TRIGGEREVENT_SELECTION(InputTrigger));
lypinator 0:bb348c97df44 1513
lypinator 0:bb348c97df44 1514 __HAL_LOCK(htim);
lypinator 0:bb348c97df44 1515
lypinator 0:bb348c97df44 1516 if ((InputTrigger == TIM_TS_ITR0) || (InputTrigger == TIM_TS_ITR1) ||
lypinator 0:bb348c97df44 1517 (InputTrigger == TIM_TS_ITR2) || (InputTrigger == TIM_TS_ITR3))
lypinator 0:bb348c97df44 1518 {
lypinator 0:bb348c97df44 1519 /* Select the Input trigger */
lypinator 0:bb348c97df44 1520 htim->Instance->SMCR &= ~TIM_SMCR_TS;
lypinator 0:bb348c97df44 1521 htim->Instance->SMCR |= InputTrigger;
lypinator 0:bb348c97df44 1522 }
lypinator 0:bb348c97df44 1523
lypinator 0:bb348c97df44 1524 /* Select the Capture Compare preload feature */
lypinator 0:bb348c97df44 1525 htim->Instance->CR2 |= TIM_CR2_CCPC;
lypinator 0:bb348c97df44 1526 /* Select the Commutation event source */
lypinator 0:bb348c97df44 1527 htim->Instance->CR2 &= ~TIM_CR2_CCUS;
lypinator 0:bb348c97df44 1528 htim->Instance->CR2 |= CommutationSource;
lypinator 0:bb348c97df44 1529
lypinator 0:bb348c97df44 1530 /* Enable the Commutation Interrupt Request */
lypinator 0:bb348c97df44 1531 __HAL_TIM_ENABLE_IT(htim, TIM_IT_COM);
lypinator 0:bb348c97df44 1532
lypinator 0:bb348c97df44 1533 __HAL_UNLOCK(htim);
lypinator 0:bb348c97df44 1534
lypinator 0:bb348c97df44 1535 return HAL_OK;
lypinator 0:bb348c97df44 1536 }
lypinator 0:bb348c97df44 1537
lypinator 0:bb348c97df44 1538 /**
lypinator 0:bb348c97df44 1539 * @brief Configure the TIM commutation event sequence with DMA.
lypinator 0:bb348c97df44 1540 * @note This function is mandatory to use the commutation event in order to
lypinator 0:bb348c97df44 1541 * update the configuration at each commutation detection on the TRGI input of the Timer,
lypinator 0:bb348c97df44 1542 * the typical use of this feature is with the use of another Timer(interface Timer)
lypinator 0:bb348c97df44 1543 * configured in Hall sensor interface, this interface Timer will generate the
lypinator 0:bb348c97df44 1544 * commutation at its TRGO output (connected to Timer used in this function) each time
lypinator 0:bb348c97df44 1545 * the TI1 of the Interface Timer detect a commutation at its input TI1.
lypinator 0:bb348c97df44 1546 * @note: The user should configure the DMA in his own software, in This function only the COMDE bit is set
lypinator 0:bb348c97df44 1547 * @param htim pointer to a TIM_HandleTypeDef structure that contains
lypinator 0:bb348c97df44 1548 * the configuration information for TIM module.
lypinator 0:bb348c97df44 1549 * @param InputTrigger the Internal trigger corresponding to the Timer Interfacing with the Hall sensor.
lypinator 0:bb348c97df44 1550 * This parameter can be one of the following values:
lypinator 0:bb348c97df44 1551 * @arg TIM_TS_ITR0: Internal trigger 0 selected
lypinator 0:bb348c97df44 1552 * @arg TIM_TS_ITR1: Internal trigger 1 selected
lypinator 0:bb348c97df44 1553 * @arg TIM_TS_ITR2: Internal trigger 2 selected
lypinator 0:bb348c97df44 1554 * @arg TIM_TS_ITR3: Internal trigger 3 selected
lypinator 0:bb348c97df44 1555 * @arg TIM_TS_NONE: No trigger is needed
lypinator 0:bb348c97df44 1556 * @param CommutationSource the Commutation Event source.
lypinator 0:bb348c97df44 1557 * This parameter can be one of the following values:
lypinator 0:bb348c97df44 1558 * @arg TIM_COMMUTATION_TRGI: Commutation source is the TRGI of the Interface Timer
lypinator 0:bb348c97df44 1559 * @arg TIM_COMMUTATION_SOFTWARE: Commutation source is set by software using the COMG bit
lypinator 0:bb348c97df44 1560 * @retval HAL status
lypinator 0:bb348c97df44 1561 */
lypinator 0:bb348c97df44 1562 HAL_StatusTypeDef HAL_TIMEx_ConfigCommutationEvent_DMA(TIM_HandleTypeDef *htim, uint32_t InputTrigger, uint32_t CommutationSource)
lypinator 0:bb348c97df44 1563 {
lypinator 0:bb348c97df44 1564 /* Check the parameters */
lypinator 0:bb348c97df44 1565 assert_param(IS_TIM_ADVANCED_INSTANCE(htim->Instance));
lypinator 0:bb348c97df44 1566 assert_param(IS_TIM_INTERNAL_TRIGGEREVENT_SELECTION(InputTrigger));
lypinator 0:bb348c97df44 1567
lypinator 0:bb348c97df44 1568 __HAL_LOCK(htim);
lypinator 0:bb348c97df44 1569
lypinator 0:bb348c97df44 1570 if ((InputTrigger == TIM_TS_ITR0) || (InputTrigger == TIM_TS_ITR1) ||
lypinator 0:bb348c97df44 1571 (InputTrigger == TIM_TS_ITR2) || (InputTrigger == TIM_TS_ITR3))
lypinator 0:bb348c97df44 1572 {
lypinator 0:bb348c97df44 1573 /* Select the Input trigger */
lypinator 0:bb348c97df44 1574 htim->Instance->SMCR &= ~TIM_SMCR_TS;
lypinator 0:bb348c97df44 1575 htim->Instance->SMCR |= InputTrigger;
lypinator 0:bb348c97df44 1576 }
lypinator 0:bb348c97df44 1577
lypinator 0:bb348c97df44 1578 /* Select the Capture Compare preload feature */
lypinator 0:bb348c97df44 1579 htim->Instance->CR2 |= TIM_CR2_CCPC;
lypinator 0:bb348c97df44 1580 /* Select the Commutation event source */
lypinator 0:bb348c97df44 1581 htim->Instance->CR2 &= ~TIM_CR2_CCUS;
lypinator 0:bb348c97df44 1582 htim->Instance->CR2 |= CommutationSource;
lypinator 0:bb348c97df44 1583
lypinator 0:bb348c97df44 1584 /* Enable the Commutation DMA Request */
lypinator 0:bb348c97df44 1585 /* Set the DMA Commutation Callback */
lypinator 0:bb348c97df44 1586 htim->hdma[TIM_DMA_ID_COMMUTATION]->XferCpltCallback = TIMEx_DMACommutationCplt;
lypinator 0:bb348c97df44 1587 /* Set the DMA error callback */
lypinator 0:bb348c97df44 1588 htim->hdma[TIM_DMA_ID_COMMUTATION]->XferErrorCallback = TIM_DMAError;
lypinator 0:bb348c97df44 1589
lypinator 0:bb348c97df44 1590 /* Enable the Commutation DMA Request */
lypinator 0:bb348c97df44 1591 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_COM);
lypinator 0:bb348c97df44 1592
lypinator 0:bb348c97df44 1593 __HAL_UNLOCK(htim);
lypinator 0:bb348c97df44 1594
lypinator 0:bb348c97df44 1595 return HAL_OK;
lypinator 0:bb348c97df44 1596 }
lypinator 0:bb348c97df44 1597
lypinator 0:bb348c97df44 1598 /**
lypinator 0:bb348c97df44 1599 * @brief Configures the TIM in master mode.
lypinator 0:bb348c97df44 1600 * @param htim pointer to a TIM_HandleTypeDef structure that contains
lypinator 0:bb348c97df44 1601 * the configuration information for TIM module.
lypinator 0:bb348c97df44 1602 * @param sMasterConfig pointer to a TIM_MasterConfigTypeDef structure that
lypinator 0:bb348c97df44 1603 * contains the selected trigger output (TRGO) and the Master/Slave
lypinator 0:bb348c97df44 1604 * mode.
lypinator 0:bb348c97df44 1605 * @retval HAL status
lypinator 0:bb348c97df44 1606 */
lypinator 0:bb348c97df44 1607 HAL_StatusTypeDef HAL_TIMEx_MasterConfigSynchronization(TIM_HandleTypeDef *htim, TIM_MasterConfigTypeDef * sMasterConfig)
lypinator 0:bb348c97df44 1608 {
lypinator 0:bb348c97df44 1609 /* Check the parameters */
lypinator 0:bb348c97df44 1610 assert_param(IS_TIM_MASTER_INSTANCE(htim->Instance));
lypinator 0:bb348c97df44 1611 assert_param(IS_TIM_TRGO_SOURCE(sMasterConfig->MasterOutputTrigger));
lypinator 0:bb348c97df44 1612 assert_param(IS_TIM_MSM_STATE(sMasterConfig->MasterSlaveMode));
lypinator 0:bb348c97df44 1613
lypinator 0:bb348c97df44 1614 __HAL_LOCK(htim);
lypinator 0:bb348c97df44 1615
lypinator 0:bb348c97df44 1616 htim->State = HAL_TIM_STATE_BUSY;
lypinator 0:bb348c97df44 1617
lypinator 0:bb348c97df44 1618 /* Reset the MMS Bits */
lypinator 0:bb348c97df44 1619 htim->Instance->CR2 &= ~TIM_CR2_MMS;
lypinator 0:bb348c97df44 1620 /* Select the TRGO source */
lypinator 0:bb348c97df44 1621 htim->Instance->CR2 |= sMasterConfig->MasterOutputTrigger;
lypinator 0:bb348c97df44 1622
lypinator 0:bb348c97df44 1623 /* Reset the MSM Bit */
lypinator 0:bb348c97df44 1624 htim->Instance->SMCR &= ~TIM_SMCR_MSM;
lypinator 0:bb348c97df44 1625 /* Set or Reset the MSM Bit */
lypinator 0:bb348c97df44 1626 htim->Instance->SMCR |= sMasterConfig->MasterSlaveMode;
lypinator 0:bb348c97df44 1627
lypinator 0:bb348c97df44 1628 htim->State = HAL_TIM_STATE_READY;
lypinator 0:bb348c97df44 1629
lypinator 0:bb348c97df44 1630 __HAL_UNLOCK(htim);
lypinator 0:bb348c97df44 1631
lypinator 0:bb348c97df44 1632 return HAL_OK;
lypinator 0:bb348c97df44 1633 }
lypinator 0:bb348c97df44 1634
lypinator 0:bb348c97df44 1635 /**
lypinator 0:bb348c97df44 1636 * @brief Configures the Break feature, dead time, Lock level, OSSI/OSSR State
lypinator 0:bb348c97df44 1637 * and the AOE(automatic output enable).
lypinator 0:bb348c97df44 1638 * @param htim pointer to a TIM_HandleTypeDef structure that contains
lypinator 0:bb348c97df44 1639 * the configuration information for TIM module.
lypinator 0:bb348c97df44 1640 * @param sBreakDeadTimeConfig pointer to a TIM_ConfigBreakDeadConfig_TypeDef structure that
lypinator 0:bb348c97df44 1641 * contains the BDTR Register configuration information for the TIM peripheral.
lypinator 0:bb348c97df44 1642 * @retval HAL status
lypinator 0:bb348c97df44 1643 */
lypinator 0:bb348c97df44 1644 HAL_StatusTypeDef HAL_TIMEx_ConfigBreakDeadTime(TIM_HandleTypeDef *htim,
lypinator 0:bb348c97df44 1645 TIM_BreakDeadTimeConfigTypeDef * sBreakDeadTimeConfig)
lypinator 0:bb348c97df44 1646 {
lypinator 0:bb348c97df44 1647 uint32_t tmpbdtr = 0U;
lypinator 0:bb348c97df44 1648
lypinator 0:bb348c97df44 1649 /* Check the parameters */
lypinator 0:bb348c97df44 1650 assert_param(IS_TIM_BREAK_INSTANCE(htim->Instance));
lypinator 0:bb348c97df44 1651 assert_param(IS_TIM_OSSR_STATE(sBreakDeadTimeConfig->OffStateRunMode));
lypinator 0:bb348c97df44 1652 assert_param(IS_TIM_OSSI_STATE(sBreakDeadTimeConfig->OffStateIDLEMode));
lypinator 0:bb348c97df44 1653 assert_param(IS_TIM_LOCK_LEVEL(sBreakDeadTimeConfig->LockLevel));
lypinator 0:bb348c97df44 1654 assert_param(IS_TIM_DEADTIME(sBreakDeadTimeConfig->DeadTime));
lypinator 0:bb348c97df44 1655 assert_param(IS_TIM_BREAK_STATE(sBreakDeadTimeConfig->BreakState));
lypinator 0:bb348c97df44 1656 assert_param(IS_TIM_BREAK_POLARITY(sBreakDeadTimeConfig->BreakPolarity));
lypinator 0:bb348c97df44 1657 assert_param(IS_TIM_AUTOMATIC_OUTPUT_STATE(sBreakDeadTimeConfig->AutomaticOutput));
lypinator 0:bb348c97df44 1658
lypinator 0:bb348c97df44 1659 /* Check input state */
lypinator 0:bb348c97df44 1660 __HAL_LOCK(htim);
lypinator 0:bb348c97df44 1661
lypinator 0:bb348c97df44 1662 /* Set the Lock level, the Break enable Bit and the Polarity, the OSSR State,
lypinator 0:bb348c97df44 1663 the OSSI State, the dead time value and the Automatic Output Enable Bit */
lypinator 0:bb348c97df44 1664
lypinator 0:bb348c97df44 1665 /* Set the BDTR bits */
lypinator 0:bb348c97df44 1666 MODIFY_REG(tmpbdtr, TIM_BDTR_DTG, sBreakDeadTimeConfig->DeadTime);
lypinator 0:bb348c97df44 1667 MODIFY_REG(tmpbdtr, TIM_BDTR_LOCK, sBreakDeadTimeConfig->LockLevel);
lypinator 0:bb348c97df44 1668 MODIFY_REG(tmpbdtr, TIM_BDTR_OSSI, sBreakDeadTimeConfig->OffStateIDLEMode);
lypinator 0:bb348c97df44 1669 MODIFY_REG(tmpbdtr, TIM_BDTR_OSSR, sBreakDeadTimeConfig->OffStateRunMode);
lypinator 0:bb348c97df44 1670 MODIFY_REG(tmpbdtr, TIM_BDTR_BKE, sBreakDeadTimeConfig->BreakState);
lypinator 0:bb348c97df44 1671 MODIFY_REG(tmpbdtr, TIM_BDTR_BKP, sBreakDeadTimeConfig->BreakPolarity);
lypinator 0:bb348c97df44 1672 MODIFY_REG(tmpbdtr, TIM_BDTR_AOE, sBreakDeadTimeConfig->AutomaticOutput);
lypinator 0:bb348c97df44 1673 MODIFY_REG(tmpbdtr, TIM_BDTR_MOE, sBreakDeadTimeConfig->AutomaticOutput);
lypinator 0:bb348c97df44 1674
lypinator 0:bb348c97df44 1675 /* Set TIMx_BDTR */
lypinator 0:bb348c97df44 1676 htim->Instance->BDTR = tmpbdtr;
lypinator 0:bb348c97df44 1677
lypinator 0:bb348c97df44 1678 __HAL_UNLOCK(htim);
lypinator 0:bb348c97df44 1679
lypinator 0:bb348c97df44 1680 return HAL_OK;
lypinator 0:bb348c97df44 1681 }
lypinator 0:bb348c97df44 1682
lypinator 0:bb348c97df44 1683 /**
lypinator 0:bb348c97df44 1684 * @brief Configures the TIM2, TIM5 and TIM11 Remapping input capabilities.
lypinator 0:bb348c97df44 1685 * @param htim pointer to a TIM_HandleTypeDef structure that contains
lypinator 0:bb348c97df44 1686 * the configuration information for TIM module.
lypinator 0:bb348c97df44 1687 * @param Remap specifies the TIM input remapping source.
lypinator 0:bb348c97df44 1688 * This parameter can be one of the following values:
lypinator 0:bb348c97df44 1689 * @arg TIM_TIM2_TIM8_TRGO: TIM2 ITR1 input is connected to TIM8 Trigger output(default)
lypinator 0:bb348c97df44 1690 * @arg TIM_TIM2_ETH_PTP: TIM2 ITR1 input is connected to ETH PTP trigger output.
lypinator 0:bb348c97df44 1691 * @arg TIM_TIM2_USBFS_SOF: TIM2 ITR1 input is connected to USB FS SOF.
lypinator 0:bb348c97df44 1692 * @arg TIM_TIM2_USBHS_SOF: TIM2 ITR1 input is connected to USB HS SOF.
lypinator 0:bb348c97df44 1693 * @arg TIM_TIM5_GPIO: TIM5 CH4 input is connected to dedicated Timer pin(default)
lypinator 0:bb348c97df44 1694 * @arg TIM_TIM5_LSI: TIM5 CH4 input is connected to LSI clock.
lypinator 0:bb348c97df44 1695 * @arg TIM_TIM5_LSE: TIM5 CH4 input is connected to LSE clock.
lypinator 0:bb348c97df44 1696 * @arg TIM_TIM5_RTC: TIM5 CH4 input is connected to RTC Output event.
lypinator 0:bb348c97df44 1697 * @arg TIM_TIM11_GPIO: TIM11 CH4 input is connected to dedicated Timer pin(default)
lypinator 0:bb348c97df44 1698 * @arg TIM_TIM11_HSE: TIM11 CH4 input is connected to HSE_RTC clock
lypinator 0:bb348c97df44 1699 * (HSE divided by a programmable prescaler)
lypinator 0:bb348c97df44 1700 * @arg TIM_TIM9_TIM3_TRGO: TIM9 ITR1 input is connected to TIM3 Trigger output(default)
lypinator 0:bb348c97df44 1701 * @arg TIM_TIM9_LPTIM: TIM9 ITR1 input is connected to LPTIM.
lypinator 0:bb348c97df44 1702 * @arg TIM_TIM5_TIM3_TRGO: TIM5 ITR1 input is connected to TIM3 Trigger output(default)
lypinator 0:bb348c97df44 1703 * @arg TIM_TIM5_LPTIM: TIM5 ITR1 input is connected to LPTIM.
lypinator 0:bb348c97df44 1704 * @arg TIM_TIM1_TIM3_TRGO: TIM1 ITR2 input is connected to TIM3 Trigger output(default)
lypinator 0:bb348c97df44 1705 * @arg TIM_TIM1_LPTIM: TIM1 ITR2 input is connected to LPTIM.
lypinator 0:bb348c97df44 1706 * @retval HAL status
lypinator 0:bb348c97df44 1707 */
lypinator 0:bb348c97df44 1708 HAL_StatusTypeDef HAL_TIMEx_RemapConfig(TIM_HandleTypeDef *htim, uint32_t Remap)
lypinator 0:bb348c97df44 1709 {
lypinator 0:bb348c97df44 1710 __HAL_LOCK(htim);
lypinator 0:bb348c97df44 1711
lypinator 0:bb348c97df44 1712 /* Check parameters */
lypinator 0:bb348c97df44 1713 assert_param(IS_TIM_REMAP_INSTANCE(htim->Instance));
lypinator 0:bb348c97df44 1714 assert_param(IS_TIM_REMAP(Remap));
lypinator 0:bb348c97df44 1715
lypinator 0:bb348c97df44 1716 #if defined(LPTIM_OR_TIM1_ITR2_RMP)
lypinator 0:bb348c97df44 1717 if ((Remap == TIM_TIM9_TIM3_TRGO)|| (Remap == TIM_TIM9_LPTIM)||(Remap ==TIM_TIM5_TIM3_TRGO)||\
lypinator 0:bb348c97df44 1718 (Remap == TIM_TIM5_LPTIM)||(Remap == TIM_TIM1_TIM3_TRGO)|| (Remap == TIM_TIM1_LPTIM))
lypinator 0:bb348c97df44 1719 {
lypinator 0:bb348c97df44 1720 __HAL_RCC_LPTIM1_CLK_ENABLE();
lypinator 0:bb348c97df44 1721
lypinator 0:bb348c97df44 1722 LPTIM1->OR = (Remap& 0xEFFFFFFFU);
lypinator 0:bb348c97df44 1723 }
lypinator 0:bb348c97df44 1724 else
lypinator 0:bb348c97df44 1725 {
lypinator 0:bb348c97df44 1726 /* Set the Timer remapping configuration */
lypinator 0:bb348c97df44 1727 htim->Instance->OR = Remap;
lypinator 0:bb348c97df44 1728 }
lypinator 0:bb348c97df44 1729 #else
lypinator 0:bb348c97df44 1730 /* Set the Timer remapping configuration */
lypinator 0:bb348c97df44 1731 htim->Instance->OR = Remap;
lypinator 0:bb348c97df44 1732 #endif
lypinator 0:bb348c97df44 1733 htim->State = HAL_TIM_STATE_READY;
lypinator 0:bb348c97df44 1734
lypinator 0:bb348c97df44 1735 __HAL_UNLOCK(htim);
lypinator 0:bb348c97df44 1736
lypinator 0:bb348c97df44 1737 return HAL_OK;
lypinator 0:bb348c97df44 1738 }
lypinator 0:bb348c97df44 1739
lypinator 0:bb348c97df44 1740 /**
lypinator 0:bb348c97df44 1741 * @}
lypinator 0:bb348c97df44 1742 */
lypinator 0:bb348c97df44 1743
lypinator 0:bb348c97df44 1744 /** @defgroup TIMEx_Exported_Functions_Group6 Extension Callbacks functions
lypinator 0:bb348c97df44 1745 * @brief Extension Callbacks functions
lypinator 0:bb348c97df44 1746 *
lypinator 0:bb348c97df44 1747 @verbatim
lypinator 0:bb348c97df44 1748 ==============================================================================
lypinator 0:bb348c97df44 1749 ##### Extension Callbacks functions #####
lypinator 0:bb348c97df44 1750 ==============================================================================
lypinator 0:bb348c97df44 1751 [..]
lypinator 0:bb348c97df44 1752 This section provides Extension TIM callback functions:
lypinator 0:bb348c97df44 1753 (+) Timer Commutation callback
lypinator 0:bb348c97df44 1754 (+) Timer Break callback
lypinator 0:bb348c97df44 1755
lypinator 0:bb348c97df44 1756 @endverbatim
lypinator 0:bb348c97df44 1757 * @{
lypinator 0:bb348c97df44 1758 */
lypinator 0:bb348c97df44 1759
lypinator 0:bb348c97df44 1760 /**
lypinator 0:bb348c97df44 1761 * @brief Hall commutation changed callback in non blocking mode
lypinator 0:bb348c97df44 1762 * @param htim pointer to a TIM_HandleTypeDef structure that contains
lypinator 0:bb348c97df44 1763 * the configuration information for TIM module.
lypinator 0:bb348c97df44 1764 * @retval None
lypinator 0:bb348c97df44 1765 */
lypinator 0:bb348c97df44 1766 __weak void HAL_TIMEx_CommutationCallback(TIM_HandleTypeDef *htim)
lypinator 0:bb348c97df44 1767 {
lypinator 0:bb348c97df44 1768 /* Prevent unused argument(s) compilation warning */
lypinator 0:bb348c97df44 1769 UNUSED(htim);
lypinator 0:bb348c97df44 1770 /* NOTE : This function Should not be modified, when the callback is needed,
lypinator 0:bb348c97df44 1771 the HAL_TIMEx_CommutationCallback could be implemented in the user file
lypinator 0:bb348c97df44 1772 */
lypinator 0:bb348c97df44 1773 }
lypinator 0:bb348c97df44 1774
lypinator 0:bb348c97df44 1775 /**
lypinator 0:bb348c97df44 1776 * @brief Hall Break detection callback in non blocking mode
lypinator 0:bb348c97df44 1777 * @param htim pointer to a TIM_HandleTypeDef structure that contains
lypinator 0:bb348c97df44 1778 * the configuration information for TIM module.
lypinator 0:bb348c97df44 1779 * @retval None
lypinator 0:bb348c97df44 1780 */
lypinator 0:bb348c97df44 1781 __weak void HAL_TIMEx_BreakCallback(TIM_HandleTypeDef *htim)
lypinator 0:bb348c97df44 1782 {
lypinator 0:bb348c97df44 1783 /* Prevent unused argument(s) compilation warning */
lypinator 0:bb348c97df44 1784 UNUSED(htim);
lypinator 0:bb348c97df44 1785 /* NOTE : This function Should not be modified, when the callback is needed,
lypinator 0:bb348c97df44 1786 the HAL_TIMEx_BreakCallback could be implemented in the user file
lypinator 0:bb348c97df44 1787 */
lypinator 0:bb348c97df44 1788 }
lypinator 0:bb348c97df44 1789 /**
lypinator 0:bb348c97df44 1790 * @}
lypinator 0:bb348c97df44 1791 */
lypinator 0:bb348c97df44 1792
lypinator 0:bb348c97df44 1793 /** @defgroup TIMEx_Exported_Functions_Group7 Extension Peripheral State functions
lypinator 0:bb348c97df44 1794 * @brief Extension Peripheral State functions
lypinator 0:bb348c97df44 1795 *
lypinator 0:bb348c97df44 1796 @verbatim
lypinator 0:bb348c97df44 1797 ==============================================================================
lypinator 0:bb348c97df44 1798 ##### Extension Peripheral State functions #####
lypinator 0:bb348c97df44 1799 ==============================================================================
lypinator 0:bb348c97df44 1800 [..]
lypinator 0:bb348c97df44 1801 This subsection permits to get in run-time the status of the peripheral
lypinator 0:bb348c97df44 1802 and the data flow.
lypinator 0:bb348c97df44 1803
lypinator 0:bb348c97df44 1804 @endverbatim
lypinator 0:bb348c97df44 1805 * @{
lypinator 0:bb348c97df44 1806 */
lypinator 0:bb348c97df44 1807
lypinator 0:bb348c97df44 1808 /**
lypinator 0:bb348c97df44 1809 * @brief Return the TIM Hall Sensor interface state
lypinator 0:bb348c97df44 1810 * @param htim pointer to a TIM_HandleTypeDef structure that contains
lypinator 0:bb348c97df44 1811 * the configuration information for TIM module.
lypinator 0:bb348c97df44 1812 * @retval HAL state
lypinator 0:bb348c97df44 1813 */
lypinator 0:bb348c97df44 1814 HAL_TIM_StateTypeDef HAL_TIMEx_HallSensor_GetState(TIM_HandleTypeDef *htim)
lypinator 0:bb348c97df44 1815 {
lypinator 0:bb348c97df44 1816 return htim->State;
lypinator 0:bb348c97df44 1817 }
lypinator 0:bb348c97df44 1818
lypinator 0:bb348c97df44 1819 /**
lypinator 0:bb348c97df44 1820 * @}
lypinator 0:bb348c97df44 1821 */
lypinator 0:bb348c97df44 1822
lypinator 0:bb348c97df44 1823 /**
lypinator 0:bb348c97df44 1824 * @brief TIM DMA Commutation callback.
lypinator 0:bb348c97df44 1825 * @param hdma pointer to a DMA_HandleTypeDef structure that contains
lypinator 0:bb348c97df44 1826 * the configuration information for the specified DMA module.
lypinator 0:bb348c97df44 1827 * @retval None
lypinator 0:bb348c97df44 1828 */
lypinator 0:bb348c97df44 1829 void TIMEx_DMACommutationCplt(DMA_HandleTypeDef *hdma)
lypinator 0:bb348c97df44 1830 {
lypinator 0:bb348c97df44 1831 TIM_HandleTypeDef* htim = ( TIM_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
lypinator 0:bb348c97df44 1832
lypinator 0:bb348c97df44 1833 htim->State= HAL_TIM_STATE_READY;
lypinator 0:bb348c97df44 1834
lypinator 0:bb348c97df44 1835 HAL_TIMEx_CommutationCallback(htim);
lypinator 0:bb348c97df44 1836 }
lypinator 0:bb348c97df44 1837 /**
lypinator 0:bb348c97df44 1838 * @}
lypinator 0:bb348c97df44 1839 */
lypinator 0:bb348c97df44 1840
lypinator 0:bb348c97df44 1841 /**
lypinator 0:bb348c97df44 1842 * @brief Enables or disables the TIM Capture Compare Channel xN.
lypinator 0:bb348c97df44 1843 * @param TIMx to select the TIM peripheral
lypinator 0:bb348c97df44 1844 * @param Channel specifies the TIM Channel
lypinator 0:bb348c97df44 1845 * This parameter can be one of the following values:
lypinator 0:bb348c97df44 1846 * @arg TIM_Channel_1: TIM Channel 1
lypinator 0:bb348c97df44 1847 * @arg TIM_Channel_2: TIM Channel 2
lypinator 0:bb348c97df44 1848 * @arg TIM_Channel_3: TIM Channel 3
lypinator 0:bb348c97df44 1849 * @param ChannelNState specifies the TIM Channel CCxNE bit new state.
lypinator 0:bb348c97df44 1850 * This parameter can be: TIM_CCxN_ENABLE or TIM_CCxN_Disable.
lypinator 0:bb348c97df44 1851 * @retval None
lypinator 0:bb348c97df44 1852 */
lypinator 0:bb348c97df44 1853 static void TIM_CCxNChannelCmd(TIM_TypeDef* TIMx, uint32_t Channel, uint32_t ChannelNState)
lypinator 0:bb348c97df44 1854 {
lypinator 0:bb348c97df44 1855 uint32_t tmp = 0U;
lypinator 0:bb348c97df44 1856
lypinator 0:bb348c97df44 1857 /* Check the parameters */
lypinator 0:bb348c97df44 1858 assert_param(IS_TIM_CC4_INSTANCE(TIMx));
lypinator 0:bb348c97df44 1859 assert_param(IS_TIM_COMPLEMENTARY_CHANNELS(Channel));
lypinator 0:bb348c97df44 1860
lypinator 0:bb348c97df44 1861 tmp = TIM_CCER_CC1NE << Channel;
lypinator 0:bb348c97df44 1862
lypinator 0:bb348c97df44 1863 /* Reset the CCxNE Bit */
lypinator 0:bb348c97df44 1864 TIMx->CCER &= ~tmp;
lypinator 0:bb348c97df44 1865
lypinator 0:bb348c97df44 1866 /* Set or reset the CCxNE Bit */
lypinator 0:bb348c97df44 1867 TIMx->CCER |= (uint32_t)(ChannelNState << Channel);
lypinator 0:bb348c97df44 1868 }
lypinator 0:bb348c97df44 1869
lypinator 0:bb348c97df44 1870 /**
lypinator 0:bb348c97df44 1871 * @}
lypinator 0:bb348c97df44 1872 */
lypinator 0:bb348c97df44 1873
lypinator 0:bb348c97df44 1874 #endif /* HAL_TIM_MODULE_ENABLED */
lypinator 0:bb348c97df44 1875 /**
lypinator 0:bb348c97df44 1876 * @}
lypinator 0:bb348c97df44 1877 */
lypinator 0:bb348c97df44 1878
lypinator 0:bb348c97df44 1879 /**
lypinator 0:bb348c97df44 1880 * @}
lypinator 0:bb348c97df44 1881 */
lypinator 0:bb348c97df44 1882 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/