mbed library sources

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Fri May 30 15:30:09 2014 +0100
Revision:
218:44081b78fdc2
Parent:
205:c41fc65bcfb4
Synchronized with git revision d854859072d318241476ccc5f335965444d4c1d8

Full URL: https://github.com/mbedmicro/mbed/commit/d854859072d318241476ccc5f335965444d4c1d8/

[NUCLEO_F072RB] Update CubeF0 HAL driver

Who changed what in which revision?

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