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