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