annotate f103c8/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c @ 6:ca42336826bd default tip

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