mbed library sources

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Sat Feb 08 19:45:06 2014 +0000
Revision:
87:085cde657901
Child:
106:ced8cbb51063
Synchronized with git revision 9272cdeb45ec7e6077641536509413da8fd2ebc2

Full URL: https://github.com/mbedmicro/mbed/commit/9272cdeb45ec7e6077641536509413da8fd2ebc2/

Add NUCLEO_F401RE, improvements

Who changed what in which revision?

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