annotate Common/Drivers/STM32F4xx_HAL_DRIVER_v120/Src/stm32f4xx_hal_tim_ex.c @ 38:5f11787b4f42

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