mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
mbed_official
Date:
Thu Aug 20 10:45:13 2015 +0100
Revision:
613:bc40b8d2aec4
Parent:
532:fe11edbda85c
Synchronized with git revision 92ca8c7b60a283b6bb60eb65b183dac1599f0ade

Full URL: https://github.com/mbedmicro/mbed/commit/92ca8c7b60a283b6bb60eb65b183dac1599f0ade/

Nordic: update application start address in GCC linker script

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