annotate Common/Drivers/STM32F4xx_HAL_DRIVER_v120/Src/stm32f4xx_hal_tim.c @ 55:a7683f9765da

Italian activated (needs some fine tuning), special characters (?,?,?,?,? and others) currently not working...
author heinrichsweikamp
date Tue, 07 Aug 2018 00:24:05 +0200
parents 5f11787b4f42
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.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 (TIM) peripheral:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
10 * + Time Base Initialization
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
11 * + Time Base Start
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
12 * + Time Base Start Interruption
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
13 * + Time Base Start DMA
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
14 * + Time Output Compare/PWM Initialization
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
15 * + Time Output Compare/PWM Channel Configuration
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
16 * + Time Output Compare/PWM Start
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
17 * + Time Output Compare/PWM Start Interruption
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
18 * + Time Output Compare/PWM Start DMA
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
19 * + Time Input Capture Initialization
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
20 * + Time Input Capture Channel Configuration
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
21 * + Time Input Capture Start
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
22 * + Time Input Capture Start Interruption
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
23 * + Time Input Capture Start DMA
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
24 * + Time One Pulse Initialization
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
25 * + Time One Pulse Channel Configuration
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
26 * + Time One Pulse Start
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
27 * + Time Encoder Interface Initialization
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28 * + Time Encoder Interface Start
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29 * + Time Encoder Interface Start Interruption
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30 * + Time Encoder Interface Start DMA
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31 * + Commutation Event configuration with Interruption and DMA
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32 * + Time OCRef clear configuration
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33 * + Time External Clock configuration
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36 ##### TIMER Generic features #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38 [..] The Timer features include:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39 (#) 16-bit up, down, up/down auto-reload counter.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40 (#) 16-bit programmable prescaler allowing dividing (also on the fly) the
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41 counter clock frequency either by any factor between 1 and 65536.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
42 (#) Up to 4 independent channels for:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43 (++) Input Capture
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
44 (++) Output Compare
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
45 (++) PWM generation (Edge and Center-aligned Mode)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
46 (++) One-pulse mode output
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
47
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
48 ##### How to use this driver #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
49 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
50 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
51 (#) Initialize the TIM low level resources by implementing the following functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
52 depending from feature used :
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
53 (++) Time Base : HAL_TIM_Base_MspInit()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54 (++) Input Capture : HAL_TIM_IC_MspInit()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
55 (++) Output Compare : HAL_TIM_OC_MspInit()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
56 (++) PWM generation : HAL_TIM_PWM_MspInit()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
57 (++) One-pulse mode output : HAL_TIM_OnePulse_MspInit()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
58 (++) Encoder mode output : HAL_TIM_Encoder_MspInit()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
59
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
60 (#) Initialize the TIM low level resources :
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61 (##) Enable the TIM interface clock using __TIMx_CLK_ENABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62 (##) TIM pins configuration
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63 (+++) Enable the clock for the TIM GPIOs using the following function:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64 __GPIOx_CLK_ENABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65 (+++) Configure these TIM pins in Alternate function mode using HAL_GPIO_Init();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67 (#) The external Clock can be configured, if needed (the default clock is the
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68 internal clock from the APBx), using the following function:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69 HAL_TIM_ConfigClockSource, the clock configuration should be done before
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70 any start function.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72 (#) Configure the TIM in the desired functioning mode using one of the
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73 initialization function of this driver:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
74 (++) HAL_TIM_Base_Init: to use the Timer to generate a simple time base
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75 (++) HAL_TIM_OC_Init and HAL_TIM_OC_ConfigChannel: to use the Timer to generate an
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76 Output Compare signal.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77 (++) HAL_TIM_PWM_Init and HAL_TIM_PWM_ConfigChannel: to use the Timer to generate a
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 PWM signal.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79 (++) HAL_TIM_IC_Init and HAL_TIM_IC_ConfigChannel: to use the Timer to measure an
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80 external signal.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81 (++) HAL_TIM_OnePulse_Init and HAL_TIM_OnePulse_ConfigChannel: to use the Timer
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82 in One Pulse Mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83 (++) HAL_TIM_Encoder_Init: to use the Timer Encoder Interface.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85 (#) Activate the TIM peripheral using one of the start functions depending from the feature used:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
86 (++) Time Base : HAL_TIM_Base_Start(), HAL_TIM_Base_Start_DMA(), HAL_TIM_Base_Start_IT()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87 (++) Input Capture : HAL_TIM_IC_Start(), HAL_TIM_IC_Start_DMA(), HAL_TIM_IC_Start_IT()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88 (++) Output Compare : HAL_TIM_OC_Start(), HAL_TIM_OC_Start_DMA(), HAL_TIM_OC_Start_IT()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89 (++) PWM generation : HAL_TIM_PWM_Start(), HAL_TIM_PWM_Start_DMA(), HAL_TIM_PWM_Start_IT()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90 (++) One-pulse mode output : HAL_TIM_OnePulse_Start(), HAL_TIM_OnePulse_Start_IT()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91 (++) Encoder mode output : HAL_TIM_Encoder_Start(), HAL_TIM_Encoder_Start_DMA(), HAL_TIM_Encoder_Start_IT().
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93 (#) The DMA Burst is managed with the two following functions:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94 HAL_TIM_DMABurst_WriteStart()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95 HAL_TIM_DMABurst_ReadStart()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99 * @attention
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
100 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103 * Redistribution and use in source and binary forms, with or without modification,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104 * are permitted provided that the following conditions are met:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105 * 1. Redistributions of source code must retain the above copyright notice,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106 * this list of conditions and the following disclaimer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107 * 2. Redistributions in binary form must reproduce the above copyright notice,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108 * this list of conditions and the following disclaimer in the documentation
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109 * and/or other materials provided with the distribution.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110 * 3. Neither the name of STMicroelectronics nor the names of its contributors
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
111 * may be used to endorse or promote products derived from this software
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112 * without specific prior written permission.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
116 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
118 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
119 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
120 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
121 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
122 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
127
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128 /* Includes ------------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129 #include "stm32f4xx_hal.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131 /** @addtogroup STM32F4xx_HAL_Driver
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
133 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
135 /** @defgroup TIM TIM
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
136 * @brief TIM HAL module driver
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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140 #ifdef HAL_TIM_MODULE_ENABLED
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142 /* Private typedef -----------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143 /* Private define ------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144 /* Private macro -------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145 /* Private variables ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146 /** @addtogroup TIM_Private_Functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
148 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149 /* Private function prototypes -----------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150 static void TIM_OC1_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151 static void TIM_OC3_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152 static void TIM_OC4_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154 static void TIM_TI1_ConfigInputStage(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICFilter);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155 static void TIM_TI2_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156 uint32_t TIM_ICFilter);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157 static void TIM_TI2_ConfigInputStage(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICFilter);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158 static void TIM_TI3_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159 uint32_t TIM_ICFilter);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160 static void TIM_TI4_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161 uint32_t TIM_ICFilter);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163 static void TIM_ETR_SetConfig(TIM_TypeDef* TIMx, uint32_t TIM_ExtTRGPrescaler,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164 uint32_t TIM_ExtTRGPolarity, uint32_t ExtTRGFilter);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166 static void TIM_ITRx_SetConfig(TIM_TypeDef* TIMx, uint16_t TIM_ITRx);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
167 static void TIM_DMAPeriodElapsedCplt(DMA_HandleTypeDef *hdma);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168 static void TIM_DMATriggerCplt(DMA_HandleTypeDef *hdma);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169 static void TIM_SlaveTimer_SetConfig(TIM_HandleTypeDef *htim,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170 TIM_SlaveConfigTypeDef * sSlaveConfig);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
171 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
172 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
173 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
174
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175 /* Exported functions --------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
176 /** @defgroup TIM_Exported_Functions TIM Exported Functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
177 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
178 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
179
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
180 /** @defgroup TIM_Exported_Functions_Group1 Time Base functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
181 * @brief Time Base functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
182 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
183 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
184 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
185 ##### Time Base functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
186 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
187 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
188 This section provides functions allowing to:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
189 (+) Initialize and configure the TIM base.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
190 (+) De-initialize the TIM base.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
191 (+) Start the Time Base.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
192 (+) Stop the Time Base.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
193 (+) Start the Time Base and enable interrupt.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
194 (+) Stop the Time Base and disable interrupt.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
195 (+) Start the Time Base and enable DMA transfer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
196 (+) Stop the Time Base and disable DMA transfer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
197
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
198 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
199 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
200 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
201 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
202 * @brief Initializes the TIM Time base Unit according to the specified
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
203 * parameters in the TIM_HandleTypeDef and create the associated handle.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
204 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
205 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
206 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
207 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
208 HAL_StatusTypeDef HAL_TIM_Base_Init(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
209 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
210 /* Check the TIM handle allocation */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
211 if(htim == NULL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
212 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
213 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
214 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
215
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
216 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
217 assert_param(IS_TIM_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
218 assert_param(IS_TIM_COUNTER_MODE(htim->Init.CounterMode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
219 assert_param(IS_TIM_CLOCKDIVISION_DIV(htim->Init.ClockDivision));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
220
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
221 if(htim->State == HAL_TIM_STATE_RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
222 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
223 /* Init the low level hardware : GPIO, CLOCK, NVIC */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
224 HAL_TIM_Base_MspInit(htim);
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 /* Set the TIM state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
228 htim->State= HAL_TIM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
229
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
230 /* Set the Time Base configuration */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
231 TIM_Base_SetConfig(htim->Instance, &htim->Init);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
232
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
233 /* Initialize the TIM state*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
234 htim->State= HAL_TIM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
235
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
236 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
237 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
238
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
239 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
240 * @brief DeInitializes the TIM Base peripheral
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
241 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
242 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
243 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
244 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
245 HAL_StatusTypeDef HAL_TIM_Base_DeInit(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
246 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
247 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
248 assert_param(IS_TIM_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
249
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
250 htim->State = HAL_TIM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
251
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
252 /* Disable the TIM Peripheral Clock */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
253 __HAL_TIM_DISABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
254
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
255 /* DeInit the low level hardware: GPIO, CLOCK, NVIC */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
256 HAL_TIM_Base_MspDeInit(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
257
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
258 /* Change TIM state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
259 htim->State = HAL_TIM_STATE_RESET;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
260
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
261 /* Release Lock */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
262 __HAL_UNLOCK(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
263
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
264 return HAL_OK;
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 Initializes the TIM Base 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_TIM_Base_MspInit(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_TIM_Base_MspInit 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 DeInitializes TIM Base MSP.
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 None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
285 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
286 __weak void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
287 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
288 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
289 the HAL_TIM_Base_MspDeInit could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
290 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
291 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
292
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
293 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
294 * @brief Starts the TIM Base generation.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
295 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
296 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
297 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
298 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
299 HAL_StatusTypeDef HAL_TIM_Base_Start(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
300 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
301 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
302 assert_param(IS_TIM_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
303
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
304 /* Set the TIM state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
305 htim->State= HAL_TIM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
306
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
307 /* Enable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
308 __HAL_TIM_ENABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
309
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
310 /* Change the TIM state*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
311 htim->State= HAL_TIM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
312
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
313 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
314 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
315 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
316
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
317 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
318 * @brief Stops the TIM Base generation.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
319 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
320 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
321 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
322 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
323 HAL_StatusTypeDef HAL_TIM_Base_Stop(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
324 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
325 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
326 assert_param(IS_TIM_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
327
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
328 /* Set the TIM state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
329 htim->State= HAL_TIM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
330
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
331 /* Disable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
332 __HAL_TIM_DISABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
333
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
334 /* Change the TIM state*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
335 htim->State= HAL_TIM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
336
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
337 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
338 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
339 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
340
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
341 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
342 * @brief Starts the TIM Base generation in interrupt mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
343 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
344 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
345 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
346 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
347 HAL_StatusTypeDef HAL_TIM_Base_Start_IT(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
348 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
349 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
350 assert_param(IS_TIM_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
351
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
352 /* Enable the TIM Update interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
353 __HAL_TIM_ENABLE_IT(htim, TIM_IT_UPDATE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
354
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
355 /* Enable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
356 __HAL_TIM_ENABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
357
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
358 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
359 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
360 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
361
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
362 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
363 * @brief Stops the TIM Base generation in interrupt mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
364 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
365 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
366 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
367 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
368 HAL_StatusTypeDef HAL_TIM_Base_Stop_IT(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
369 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
370 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
371 assert_param(IS_TIM_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
372 /* Disable the TIM Update interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
373 __HAL_TIM_DISABLE_IT(htim, TIM_IT_UPDATE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
374
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
375 /* Disable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
376 __HAL_TIM_DISABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
377
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
378 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
379 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
380 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
381
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
382 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
383 * @brief Starts the TIM Base generation in DMA mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
384 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
385 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
386 * @param pData: The source Buffer address.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
387 * @param Length: The length of data to be transferred from memory to peripheral.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
388 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
389 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
390 HAL_StatusTypeDef HAL_TIM_Base_Start_DMA(TIM_HandleTypeDef *htim, uint32_t *pData, uint16_t Length)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
391 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
392 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
393 assert_param(IS_TIM_DMA_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
394
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
395 if((htim->State == HAL_TIM_STATE_BUSY))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
396 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
397 return HAL_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
398 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
399 else if((htim->State == HAL_TIM_STATE_READY))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
400 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
401 if((pData == 0 ) && (Length > 0))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
402 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
403 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
404 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
405 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
406 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
407 htim->State = HAL_TIM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
408 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
409 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
410 /* Set the DMA Period elapsed callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
411 htim->hdma[TIM_DMA_ID_UPDATE]->XferCpltCallback = TIM_DMAPeriodElapsedCplt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
412
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
413 /* Set the DMA error callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
414 htim->hdma[TIM_DMA_ID_UPDATE]->XferErrorCallback = TIM_DMAError ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
415
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
416 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
417 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_UPDATE], (uint32_t)pData, (uint32_t)&htim->Instance->ARR, Length);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
418
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
419 /* Enable the TIM Update DMA request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
420 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_UPDATE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
421
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
422 /* Enable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
423 __HAL_TIM_ENABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
424
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
425 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
426 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
427 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
428
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
429 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
430 * @brief Stops the TIM Base generation in DMA mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
431 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
432 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
433 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
434 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
435 HAL_StatusTypeDef HAL_TIM_Base_Stop_DMA(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
436 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
437 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
438 assert_param(IS_TIM_DMA_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
439
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
440 /* Disable the TIM Update DMA request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
441 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_UPDATE);
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 /* Change the htim state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
447 htim->State = HAL_TIM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
448
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
449 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
450 return HAL_OK;
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 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
454 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
455
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
456 /** @defgroup TIM_Exported_Functions_Group2 Time Output Compare functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
457 * @brief Time Output Compare functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
458 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
459 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
460 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
461 ##### Time Output Compare functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
462 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
463 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
464 This section provides functions allowing to:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
465 (+) Initialize and configure the TIM Output Compare.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
466 (+) De-initialize the TIM Output Compare.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
467 (+) Start the Time Output Compare.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
468 (+) Stop the Time Output Compare.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
469 (+) Start the Time Output Compare and enable interrupt.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
470 (+) Stop the Time Output Compare and disable interrupt.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
471 (+) Start the Time Output Compare and enable DMA transfer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
472 (+) Stop the Time Output Compare and disable DMA transfer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
473
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
474 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
475 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
476 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
477 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
478 * @brief Initializes the TIM Output Compare according to the specified
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
479 * parameters in the TIM_HandleTypeDef and create the associated handle.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
480 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
481 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
482 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
483 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
484 HAL_StatusTypeDef HAL_TIM_OC_Init(TIM_HandleTypeDef* htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
485 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
486 /* Check the TIM handle allocation */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
487 if(htim == NULL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
488 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
489 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
490 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
491
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
492 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
493 assert_param(IS_TIM_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
494 assert_param(IS_TIM_COUNTER_MODE(htim->Init.CounterMode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
495 assert_param(IS_TIM_CLOCKDIVISION_DIV(htim->Init.ClockDivision));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
496
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
497 if(htim->State == HAL_TIM_STATE_RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
498 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
499 /* Init the low level hardware : GPIO, CLOCK, NVIC and DMA */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
500 HAL_TIM_OC_MspInit(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
501 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
502
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
503 /* Set the TIM state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
504 htim->State= HAL_TIM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
505
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
506 /* Init the base time for the Output Compare */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
507 TIM_Base_SetConfig(htim->Instance, &htim->Init);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
508
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
509 /* Initialize the TIM state*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
510 htim->State= HAL_TIM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
511
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
512 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
513 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
514
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
515 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
516 * @brief DeInitializes the TIM peripheral
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
517 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
518 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
519 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
520 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
521 HAL_StatusTypeDef HAL_TIM_OC_DeInit(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
522 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
523 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
524 assert_param(IS_TIM_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
525
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
526 htim->State = HAL_TIM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
527
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
528 /* Disable the TIM Peripheral Clock */
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 /* DeInit the low level hardware: GPIO, CLOCK, NVIC and DMA */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
532 HAL_TIM_OC_MspDeInit(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
533
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
534 /* Change TIM state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
535 htim->State = HAL_TIM_STATE_RESET;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
536
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
537 /* Release Lock */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
538 __HAL_UNLOCK(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
539
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
540 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
541 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
542
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
543 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
544 * @brief Initializes the TIM Output Compare MSP.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
545 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
546 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
547 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
548 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
549 __weak void HAL_TIM_OC_MspInit(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
550 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
551 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
552 the HAL_TIM_OC_MspInit could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
553 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
554 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
555
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
556 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
557 * @brief DeInitializes TIM Output Compare MSP.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
558 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
559 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
560 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
561 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
562 __weak void HAL_TIM_OC_MspDeInit(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
563 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
564 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
565 the HAL_TIM_OC_MspDeInit could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
566 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
567 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
568
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
569 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
570 * @brief Starts the TIM Output Compare signal generation.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
571 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
572 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
573 * @param Channel: TIM Channel to be enabled.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
574 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
575 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
576 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
577 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
578 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
579 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
580 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
581 HAL_StatusTypeDef HAL_TIM_OC_Start(TIM_HandleTypeDef *htim, uint32_t Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
582 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
583 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
584 assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
585
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
586 /* Enable the Output compare channel */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
587 TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
588
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
589 if(IS_TIM_ADVANCED_INSTANCE(htim->Instance) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
590 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
591 /* Enable the main output */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
592 __HAL_TIM_MOE_ENABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
593 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
594
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
595 /* Enable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
596 __HAL_TIM_ENABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
597
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
598 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
599 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
600 }
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 * @brief Stops the TIM Output Compare signal generation.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
604 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
605 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
606 * @param Channel: TIM Channel to be disabled.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
607 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
608 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
609 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
610 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
611 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
612 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
613 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
614 HAL_StatusTypeDef HAL_TIM_OC_Stop(TIM_HandleTypeDef *htim, uint32_t Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
615 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
616 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
617 assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
618
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
619 /* Disable the Output compare channel */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
620 TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
621
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
622 if(IS_TIM_ADVANCED_INSTANCE(htim->Instance) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
623 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
624 /* Disable the Main Output */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
625 __HAL_TIM_MOE_DISABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
626 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
627
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
628 /* Disable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
629 __HAL_TIM_DISABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
630
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
631 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
632 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
633 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
634
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
635 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
636 * @brief Starts the TIM Output Compare signal generation in interrupt mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
637 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
638 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
639 * @param Channel: TIM Channel to be enabled.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
640 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
641 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
642 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
643 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
644 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
645 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
646 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
647 HAL_StatusTypeDef HAL_TIM_OC_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
648 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
649 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
650 assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
651
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
652 switch (Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
653 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
654 case TIM_CHANNEL_1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
655 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
656 /* Enable the TIM Capture/Compare 1 interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
657 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
658 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
659 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
660
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
661 case TIM_CHANNEL_2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
662 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
663 /* Enable the TIM Capture/Compare 2 interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
664 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
665 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
666 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
667
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
668 case TIM_CHANNEL_3:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
669 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
670 /* Enable the TIM Capture/Compare 3 interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
671 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC3);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
672 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
673 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
674
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
675 case TIM_CHANNEL_4:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
676 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
677 /* Enable the TIM Capture/Compare 4 interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
678 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC4);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
679 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
680 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
681
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
682 default:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
683 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
684 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
685
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
686 /* Enable the Output compare channel */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
687 TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
688
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
689 if(IS_TIM_ADVANCED_INSTANCE(htim->Instance) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
690 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
691 /* Enable the main output */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
692 __HAL_TIM_MOE_ENABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
693 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
694
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
695 /* Enable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
696 __HAL_TIM_ENABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
697
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
698 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
699 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
700 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
701
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
702 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
703 * @brief Stops the TIM Output Compare signal generation in interrupt mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
704 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
705 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
706 * @param Channel: TIM Channel to be disabled.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
707 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
708 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
709 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
710 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
711 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
712 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
713 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
714 HAL_StatusTypeDef HAL_TIM_OC_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
715 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
716 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
717 assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
718
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
719 switch (Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
720 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
721 case TIM_CHANNEL_1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
722 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
723 /* Disable the TIM Capture/Compare 1 interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
724 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
725 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
726 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
727
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
728 case TIM_CHANNEL_2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
729 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
730 /* Disable the TIM Capture/Compare 2 interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
731 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
732 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
733 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
734
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
735 case TIM_CHANNEL_3:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
736 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
737 /* Disable the TIM Capture/Compare 3 interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
738 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC3);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
739 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
740 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
741
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
742 case TIM_CHANNEL_4:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
743 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
744 /* Disable the TIM Capture/Compare 4 interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
745 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC4);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
746 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
747 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
748
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
749 default:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
750 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
751 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
752
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
753 /* Disable the Output compare channel */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
754 TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
755
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
756 if(IS_TIM_ADVANCED_INSTANCE(htim->Instance) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
757 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
758 /* Disable the Main Output */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
759 __HAL_TIM_MOE_DISABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
760 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
761
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
762 /* Disable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
763 __HAL_TIM_DISABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
764
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
765 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
766 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
767 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
768
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
769 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
770 * @brief Starts the TIM Output Compare signal generation in DMA mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
771 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
772 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
773 * @param Channel: TIM Channel to be enabled.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
774 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
775 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
776 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
777 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
778 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
779 * @param pData: The source Buffer address.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
780 * @param Length: The length of data to be transferred from memory to TIM peripheral
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
781 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
782 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
783 HAL_StatusTypeDef HAL_TIM_OC_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
784 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
785 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
786 assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
787
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
788 if((htim->State == HAL_TIM_STATE_BUSY))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
789 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
790 return HAL_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
791 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
792 else if((htim->State == HAL_TIM_STATE_READY))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
793 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
794 if(((uint32_t)pData == 0 ) && (Length > 0))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
795 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
796 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
797 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
798 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
799 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
800 htim->State = HAL_TIM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
801 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
802 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
803 switch (Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
804 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
805 case TIM_CHANNEL_1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
806 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
807 /* Set the DMA Period elapsed callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
808 htim->hdma[TIM_DMA_ID_CC1]->XferCpltCallback = TIM_DMADelayPulseCplt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
809
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
810 /* Set the DMA error callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
811 htim->hdma[TIM_DMA_ID_CC1]->XferErrorCallback = TIM_DMAError ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
812
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
813 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
814 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
815
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
816 /* Enable the TIM Capture/Compare 1 DMA request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
817 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
818 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
819 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
820
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
821 case TIM_CHANNEL_2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
822 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
823 /* Set the DMA Period elapsed callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
824 htim->hdma[TIM_DMA_ID_CC2]->XferCpltCallback = TIM_DMADelayPulseCplt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
825
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
826 /* Set the DMA error callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
827 htim->hdma[TIM_DMA_ID_CC2]->XferErrorCallback = TIM_DMAError ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
828
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
829 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
830 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
831
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
832 /* Enable the TIM Capture/Compare 2 DMA request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
833 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
834 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
835 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
836
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
837 case TIM_CHANNEL_3:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
838 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
839 /* Set the DMA Period elapsed callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
840 htim->hdma[TIM_DMA_ID_CC3]->XferCpltCallback = TIM_DMADelayPulseCplt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
841
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
842 /* Set the DMA error callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
843 htim->hdma[TIM_DMA_ID_CC3]->XferErrorCallback = TIM_DMAError ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
844
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
845 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
846 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
847
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
848 /* Enable the TIM Capture/Compare 3 DMA request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
849 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC3);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
850 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
851 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
852
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
853 case TIM_CHANNEL_4:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
854 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
855 /* Set the DMA Period elapsed callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
856 htim->hdma[TIM_DMA_ID_CC4]->XferCpltCallback = TIM_DMADelayPulseCplt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
857
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
858 /* Set the DMA error callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
859 htim->hdma[TIM_DMA_ID_CC4]->XferErrorCallback = TIM_DMAError ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
860
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
861 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
862 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
863
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
864 /* Enable the TIM Capture/Compare 4 DMA request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
865 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC4);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
866 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
867 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
868
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
869 default:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
870 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
871 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
872
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
873 /* Enable the Output compare channel */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
874 TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
875
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
876 if(IS_TIM_ADVANCED_INSTANCE(htim->Instance) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
877 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
878 /* Enable the main output */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
879 __HAL_TIM_MOE_ENABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
880 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
881
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
882 /* Enable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
883 __HAL_TIM_ENABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
884
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
885 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
886 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
887 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
888
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
889 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
890 * @brief Stops the TIM Output Compare signal generation in DMA mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
891 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
892 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
893 * @param Channel: TIM Channel to be disabled.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
894 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
895 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
896 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
897 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
898 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
899 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
900 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
901 HAL_StatusTypeDef HAL_TIM_OC_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
902 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
903 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
904 assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
905
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
906 switch (Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
907 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
908 case TIM_CHANNEL_1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
909 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
910 /* Disable the TIM Capture/Compare 1 DMA request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
911 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
912 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
913 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
914
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
915 case TIM_CHANNEL_2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
916 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
917 /* Disable the TIM Capture/Compare 2 DMA request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
918 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
919 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
920 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
921
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
922 case TIM_CHANNEL_3:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
923 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
924 /* Disable the TIM Capture/Compare 3 DMA request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
925 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC3);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
926 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
927 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
928
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
929 case TIM_CHANNEL_4:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
930 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
931 /* Disable the TIM Capture/Compare 4 interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
932 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC4);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
933 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
934 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
935
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
936 default:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
937 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
938 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
939
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
940 /* Disable the Output compare channel */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
941 TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
942
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
943 if(IS_TIM_ADVANCED_INSTANCE(htim->Instance) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
944 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
945 /* Disable the Main Output */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
946 __HAL_TIM_MOE_DISABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
947 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
948
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
949 /* Disable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
950 __HAL_TIM_DISABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
951
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
952 /* Change the htim state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
953 htim->State = HAL_TIM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
954
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
955 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
956 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
957 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
958 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
959 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
960 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
961
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
962 /** @defgroup TIM_Exported_Functions_Group3 Time PWM functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
963 * @brief Time PWM functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
964 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
965 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
966 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
967 ##### Time PWM functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
968 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
969 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
970 This section provides functions allowing to:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
971 (+) Initialize and configure the TIM OPWM.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
972 (+) De-initialize the TIM PWM.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
973 (+) Start the Time PWM.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
974 (+) Stop the Time PWM.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
975 (+) Start the Time PWM and enable interrupt.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
976 (+) Stop the Time PWM and disable interrupt.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
977 (+) Start the Time PWM and enable DMA transfer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
978 (+) Stop the Time PWM and disable DMA transfer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
979
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
980 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
981 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
982 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
983 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
984 * @brief Initializes the TIM PWM Time Base according to the specified
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
985 * parameters in the TIM_HandleTypeDef and create the associated handle.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
986 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
987 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
988 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
989 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
990 HAL_StatusTypeDef HAL_TIM_PWM_Init(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
991 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
992 /* Check the TIM handle allocation */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
993 if(htim == NULL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
994 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
995 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
996 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
997
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
998 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
999 assert_param(IS_TIM_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1000 assert_param(IS_TIM_COUNTER_MODE(htim->Init.CounterMode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1001 assert_param(IS_TIM_CLOCKDIVISION_DIV(htim->Init.ClockDivision));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1002
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1003 if(htim->State == HAL_TIM_STATE_RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1004 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1005 /* Init the low level hardware : GPIO, CLOCK, NVIC and DMA */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1006 HAL_TIM_PWM_MspInit(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1007 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1008
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1009 /* Set the TIM state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1010 htim->State= HAL_TIM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1011
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1012 /* Init the base time for the PWM */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1013 TIM_Base_SetConfig(htim->Instance, &htim->Init);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1014
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1015 /* Initialize the TIM state*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1016 htim->State= HAL_TIM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1017
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 DeInitializes the TIM peripheral
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1023 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1024 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1025 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1026 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1027 HAL_StatusTypeDef HAL_TIM_PWM_DeInit(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1028 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1029 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1030 assert_param(IS_TIM_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1031
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1032 htim->State = HAL_TIM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1033
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1034 /* Disable the TIM Peripheral Clock */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1035 __HAL_TIM_DISABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1036
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1037 /* DeInit the low level hardware: GPIO, CLOCK, NVIC and DMA */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1038 HAL_TIM_PWM_MspDeInit(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1039
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1040 /* Change TIM state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1041 htim->State = HAL_TIM_STATE_RESET;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1042
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1043 /* Release Lock */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1044 __HAL_UNLOCK(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1045
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1046 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1047 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1048
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1049 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1050 * @brief Initializes the TIM PWM MSP.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1051 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1052 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1053 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1054 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1055 __weak void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1056 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1057 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1058 the HAL_TIM_PWM_MspInit could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1059 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1060 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1061
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1062 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1063 * @brief DeInitializes TIM PWM MSP.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1064 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1065 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1066 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1067 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1068 __weak void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1069 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1070 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1071 the HAL_TIM_PWM_MspDeInit could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1072 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1073 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1074
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1075 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1076 * @brief Starts the PWM signal generation.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1077 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1078 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1079 * @param Channel: TIM Channels to be enabled.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1080 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1081 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1082 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1083 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1084 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1085 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1086 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1087 HAL_StatusTypeDef HAL_TIM_PWM_Start(TIM_HandleTypeDef *htim, uint32_t Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1088 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1089 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1090 assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1091
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1092 /* Enable the Capture compare channel */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1093 TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1094
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1095 if(IS_TIM_ADVANCED_INSTANCE(htim->Instance) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1096 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1097 /* Enable the main output */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1098 __HAL_TIM_MOE_ENABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1099 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1100
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1101 /* Enable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1102 __HAL_TIM_ENABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1103
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1104 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1105 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1106 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1107
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1108 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1109 * @brief Stops the PWM signal generation.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1110 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1111 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1112 * @param Channel: TIM Channels to be disabled.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1113 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1114 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1115 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1116 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1117 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1118 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1119 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1120 HAL_StatusTypeDef HAL_TIM_PWM_Stop(TIM_HandleTypeDef *htim, uint32_t Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1121 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1122 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1123 assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1124
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1125 /* Disable the Capture compare channel */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1126 TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1127
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1128 if(IS_TIM_ADVANCED_INSTANCE(htim->Instance) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1129 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1130 /* Disable the Main Output */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1131 __HAL_TIM_MOE_DISABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1132 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1133
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1134 /* Disable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1135 __HAL_TIM_DISABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1136
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1137 /* Change the htim state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1138 htim->State = HAL_TIM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1139
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1140 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1141 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1142 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1143
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1144 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1145 * @brief Starts the PWM signal generation in interrupt mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1146 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1147 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1148 * @param Channel: TIM Channel to be disabled.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1149 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1150 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1151 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1152 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1153 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1154 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1155 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1156 HAL_StatusTypeDef HAL_TIM_PWM_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1157 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1158 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1159 assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1160
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1161 switch (Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1162 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1163 case TIM_CHANNEL_1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1164 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1165 /* Enable the TIM Capture/Compare 1 interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1166 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1167 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1168 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1169
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1170 case TIM_CHANNEL_2:
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 2 interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1173 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC2);
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_3:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1178 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1179 /* Enable the TIM Capture/Compare 3 interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1180 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC3);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1181 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1182 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1183
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1184 case TIM_CHANNEL_4:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1185 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1186 /* Enable the TIM Capture/Compare 4 interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1187 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC4);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1188 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1189 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1190
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1191 default:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1192 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1193 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1194
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1195 /* Enable the Capture compare channel */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1196 TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1197
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1198 if(IS_TIM_ADVANCED_INSTANCE(htim->Instance) != RESET)
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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1204 /* Enable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1205 __HAL_TIM_ENABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1206
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1207 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1208 return HAL_OK;
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 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1212 * @brief Stops the PWM signal generation in interrupt mode.
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 Channels 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_TIM_PWM_Stop_IT (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_CCX_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 interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1233 __HAL_TIM_DISABLE_IT(htim, TIM_IT_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 interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1240 __HAL_TIM_DISABLE_IT(htim, TIM_IT_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 interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1247 __HAL_TIM_DISABLE_IT(htim, TIM_IT_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 interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1254 __HAL_TIM_DISABLE_IT(htim, TIM_IT_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 Capture compare channel */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1263 TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1264
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1265 if(IS_TIM_ADVANCED_INSTANCE(htim->Instance) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1266 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1267 /* Disable the Main Output */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1268 __HAL_TIM_MOE_DISABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1269 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1270
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1271 /* Disable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1272 __HAL_TIM_DISABLE(htim);
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 * @brief Starts the TIM PWM signal generation in DMA mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1280 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1281 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1282 * @param Channel: TIM Channels to be enabled.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1283 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1284 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1285 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1286 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1287 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1288 * @param pData: The source Buffer address.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1289 * @param Length: The length of data to be transferred from memory to TIM peripheral
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1290 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1291 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1292 HAL_StatusTypeDef HAL_TIM_PWM_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1293 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1294 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1295 assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1296
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1297 if((htim->State == HAL_TIM_STATE_BUSY))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1298 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1299 return HAL_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1300 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1301 else if((htim->State == HAL_TIM_STATE_READY))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1302 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1303 if(((uint32_t)pData == 0 ) && (Length > 0))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1304 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1305 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1306 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1307 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1308 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1309 htim->State = HAL_TIM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1310 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1311 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1312 switch (Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1313 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1314 case TIM_CHANNEL_1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1315 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1316 /* Set the DMA Period elapsed callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1317 htim->hdma[TIM_DMA_ID_CC1]->XferCpltCallback = TIM_DMADelayPulseCplt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1318
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1319 /* Set the DMA error callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1320 htim->hdma[TIM_DMA_ID_CC1]->XferErrorCallback = TIM_DMAError ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1321
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1322 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1323 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
1324
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1325 /* Enable the TIM Capture/Compare 1 DMA request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1326 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1327 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1328 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1329
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1330 case TIM_CHANNEL_2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1331 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1332 /* Set the DMA Period elapsed callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1333 htim->hdma[TIM_DMA_ID_CC2]->XferCpltCallback = TIM_DMADelayPulseCplt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1334
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1335 /* Set the DMA error callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1336 htim->hdma[TIM_DMA_ID_CC2]->XferErrorCallback = TIM_DMAError ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1337
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1338 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1339 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
1340
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1341 /* Enable the TIM Capture/Compare 2 DMA request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1342 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1343 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1344 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1345
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1346 case TIM_CHANNEL_3:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1347 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1348 /* Set the DMA Period elapsed callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1349 htim->hdma[TIM_DMA_ID_CC3]->XferCpltCallback = TIM_DMADelayPulseCplt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1350
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1351 /* Set the DMA error callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1352 htim->hdma[TIM_DMA_ID_CC3]->XferErrorCallback = TIM_DMAError ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1353
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1354 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1355 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
1356
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1357 /* Enable the TIM Output Capture/Compare 3 request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1358 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC3);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1359 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1360 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1361
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1362 case TIM_CHANNEL_4:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1363 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1364 /* Set the DMA Period elapsed callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1365 htim->hdma[TIM_DMA_ID_CC4]->XferCpltCallback = TIM_DMADelayPulseCplt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1366
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1367 /* Set the DMA error callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1368 htim->hdma[TIM_DMA_ID_CC4]->XferErrorCallback = TIM_DMAError ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1369
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1370 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1371 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
1372
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1373 /* Enable the TIM Capture/Compare 4 DMA request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1374 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC4);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1375 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1376 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1377
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1378 default:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1379 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1380 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1381
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1382 /* Enable the Capture compare channel */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1383 TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1384
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1385 if(IS_TIM_ADVANCED_INSTANCE(htim->Instance) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1386 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1387 /* Enable the main output */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1388 __HAL_TIM_MOE_ENABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1389 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1390
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1391 /* Enable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1392 __HAL_TIM_ENABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1393
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1394 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1395 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1396 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1397
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1398 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1399 * @brief Stops the TIM PWM signal generation in DMA mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1400 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1401 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1402 * @param Channel: TIM Channels to be disabled.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1403 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1404 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1405 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1406 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1407 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1408 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1409 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1410 HAL_StatusTypeDef HAL_TIM_PWM_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1411 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1412 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1413 assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1414
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1415 switch (Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1416 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1417 case TIM_CHANNEL_1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1418 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1419 /* Disable the TIM Capture/Compare 1 DMA request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1420 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1421 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1422 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1423
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1424 case TIM_CHANNEL_2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1425 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1426 /* Disable the TIM Capture/Compare 2 DMA request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1427 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1428 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1429 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1430
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1431 case TIM_CHANNEL_3:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1432 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1433 /* Disable the TIM Capture/Compare 3 DMA request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1434 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC3);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1435 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1436 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1437
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1438 case TIM_CHANNEL_4:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1439 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1440 /* Disable the TIM Capture/Compare 4 interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1441 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC4);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1442 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1443 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1444
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1445 default:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1446 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1447 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1448
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1449 /* Disable the Capture compare channel */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1450 TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1451
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1452 if(IS_TIM_ADVANCED_INSTANCE(htim->Instance) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1453 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1454 /* Disable the Main Output */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1455 __HAL_TIM_MOE_DISABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1456 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1457
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1458 /* Disable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1459 __HAL_TIM_DISABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1460
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1461 /* Change the htim state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1462 htim->State = HAL_TIM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1463
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1464 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1465 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1466 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1467 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1468 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1469 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1470
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1471 /** @defgroup TIM_Exported_Functions_Group4 Time Input Capture functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1472 * @brief Time Input Capture functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1473 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1474 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1475 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1476 ##### Time Input Capture functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1477 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1478 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1479 This section provides functions allowing to:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1480 (+) Initialize and configure the TIM Input Capture.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1481 (+) De-initialize the TIM Input Capture.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1482 (+) Start the Time Input Capture.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1483 (+) Stop the Time Input Capture.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1484 (+) Start the Time Input Capture and enable interrupt.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1485 (+) Stop the Time Input Capture and disable interrupt.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1486 (+) Start the Time Input Capture and enable DMA transfer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1487 (+) Stop the Time Input Capture and disable DMA transfer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1488
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1489 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1490 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1491 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1492 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1493 * @brief Initializes the TIM Input Capture Time base according to the specified
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1494 * parameters in the TIM_HandleTypeDef and create the associated handle.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1495 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1496 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1497 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1498 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1499 HAL_StatusTypeDef HAL_TIM_IC_Init(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1500 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1501 /* Check the TIM handle allocation */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1502 if(htim == NULL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1503 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1504 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1505 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1506
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1507 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1508 assert_param(IS_TIM_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1509 assert_param(IS_TIM_COUNTER_MODE(htim->Init.CounterMode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1510 assert_param(IS_TIM_CLOCKDIVISION_DIV(htim->Init.ClockDivision));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1511
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1512 if(htim->State == HAL_TIM_STATE_RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1513 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1514 /* Init the low level hardware : GPIO, CLOCK, NVIC and DMA */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1515 HAL_TIM_IC_MspInit(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1516 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1517
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1518 /* Set the TIM state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1519 htim->State= HAL_TIM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1520
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1521 /* Init the base time for the input capture */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1522 TIM_Base_SetConfig(htim->Instance, &htim->Init);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1523
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1524 /* Initialize the TIM state*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1525 htim->State= HAL_TIM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1526
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1527 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1528 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1529
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1530 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1531 * @brief DeInitializes the TIM peripheral
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1532 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1533 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1534 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1535 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1536 HAL_StatusTypeDef HAL_TIM_IC_DeInit(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1537 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1538 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1539 assert_param(IS_TIM_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1540
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1541 htim->State = HAL_TIM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1542
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1543 /* Disable the TIM Peripheral Clock */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1544 __HAL_TIM_DISABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1545
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1546 /* DeInit the low level hardware: GPIO, CLOCK, NVIC and DMA */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1547 HAL_TIM_IC_MspDeInit(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1548
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1549 /* Change TIM state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1550 htim->State = HAL_TIM_STATE_RESET;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1551
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1552 /* Release Lock */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1553 __HAL_UNLOCK(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1554
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1555 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1556 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1557
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1558 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1559 * @brief Initializes the TIM INput Capture MSP.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1560 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1561 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1562 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1563 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1564 __weak void HAL_TIM_IC_MspInit(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1565 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1566 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1567 the HAL_TIM_IC_MspInit could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1568 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1569 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1570
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1571 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1572 * @brief DeInitializes TIM Input Capture MSP.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1573 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1574 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1575 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1576 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1577 __weak void HAL_TIM_IC_MspDeInit(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1578 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1579 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1580 the HAL_TIM_IC_MspDeInit could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1581 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1582 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1583
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1584 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1585 * @brief Starts the TIM Input Capture measurement.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1586 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1587 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1588 * @param Channel: TIM Channels to be enabled.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1589 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1590 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1591 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1592 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1593 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1594 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1595 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1596 HAL_StatusTypeDef HAL_TIM_IC_Start (TIM_HandleTypeDef *htim, uint32_t Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1597 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1598 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1599 assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1600
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1601 /* Enable the Input Capture channel */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1602 TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1603
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1604 /* Enable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1605 __HAL_TIM_ENABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1606
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1607 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1608 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1609 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1610
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1611 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1612 * @brief Stops the TIM Input Capture measurement.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1613 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1614 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1615 * @param Channel: TIM Channels to be disabled.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1616 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1617 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1618 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1619 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1620 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1621 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1622 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1623 HAL_StatusTypeDef HAL_TIM_IC_Stop(TIM_HandleTypeDef *htim, uint32_t Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1624 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1625 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1626 assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1627
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1628 /* Disable the Input Capture channel */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1629 TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1630
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1631 /* Disable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1632 __HAL_TIM_DISABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1633
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1634 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1635 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1636 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1637
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1638 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1639 * @brief Starts the TIM Input Capture measurement in interrupt mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1640 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1641 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1642 * @param Channel: TIM Channels to be enabled.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1643 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1644 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1645 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1646 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1647 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1648 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1649 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1650 HAL_StatusTypeDef HAL_TIM_IC_Start_IT (TIM_HandleTypeDef *htim, uint32_t Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1651 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1652 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1653 assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1654
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1655 switch (Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1656 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1657 case TIM_CHANNEL_1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1658 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1659 /* Enable the TIM Capture/Compare 1 interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1660 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1661 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1662 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1663
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1664 case TIM_CHANNEL_2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1665 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1666 /* Enable the TIM Capture/Compare 2 interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1667 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1668 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1669 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1670
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1671 case TIM_CHANNEL_3:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1672 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1673 /* Enable the TIM Capture/Compare 3 interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1674 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC3);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1675 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1676 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1677
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1678 case TIM_CHANNEL_4:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1679 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1680 /* Enable the TIM Capture/Compare 4 interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1681 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC4);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1682 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1683 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1684
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1685 default:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1686 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1687 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1688 /* Enable the Input Capture channel */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1689 TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1690
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1691 /* Enable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1692 __HAL_TIM_ENABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1693
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1694 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1695 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1696 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1697
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1698 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1699 * @brief Stops the TIM Input Capture measurement in interrupt mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1700 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1701 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1702 * @param Channel: TIM Channels to be disabled.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1703 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1704 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1705 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1706 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1707 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1708 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1709 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1710 HAL_StatusTypeDef HAL_TIM_IC_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1711 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1712 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1713 assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1714
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1715 switch (Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1716 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1717 case TIM_CHANNEL_1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1718 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1719 /* Disable the TIM Capture/Compare 1 interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1720 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1721 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1722 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1723
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1724 case TIM_CHANNEL_2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1725 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1726 /* Disable the TIM Capture/Compare 2 interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1727 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1728 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1729 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1730
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1731 case TIM_CHANNEL_3:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1732 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1733 /* Disable the TIM Capture/Compare 3 interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1734 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC3);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1735 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1736 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1737
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1738 case TIM_CHANNEL_4:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1739 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1740 /* Disable the TIM Capture/Compare 4 interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1741 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC4);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1742 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1743 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1744
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1745 default:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1746 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1747 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1748
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1749 /* Disable the Input Capture channel */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1750 TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1751
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1752 /* Disable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1753 __HAL_TIM_DISABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1754
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1755 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1756 return HAL_OK;
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 Starts the TIM Input Capture measurement on in DMA 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 * @param Channel: TIM Channels to be enabled.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1764 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1765 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1766 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1767 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1768 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1769 * @param pData: The destination Buffer address.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1770 * @param Length: The length of data to be transferred from TIM peripheral to memory.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1771 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1772 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1773 HAL_StatusTypeDef HAL_TIM_IC_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1774 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1775 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1776 assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1777 assert_param(IS_TIM_DMA_CC_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1778
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1779 if((htim->State == HAL_TIM_STATE_BUSY))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1780 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1781 return HAL_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1782 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1783 else if((htim->State == HAL_TIM_STATE_READY))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1784 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1785 if((pData == 0 ) && (Length > 0))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1786 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1787 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1788 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1789 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1790 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1791 htim->State = HAL_TIM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1792 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1793 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1794
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1795 switch (Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1796 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1797 case TIM_CHANNEL_1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1798 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1799 /* Set the DMA Period elapsed callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1800 htim->hdma[TIM_DMA_ID_CC1]->XferCpltCallback = TIM_DMACaptureCplt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1801
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1802 /* Set the DMA error callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1803 htim->hdma[TIM_DMA_ID_CC1]->XferErrorCallback = TIM_DMAError ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1804
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1805 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1806 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
1807
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1808 /* Enable the TIM Capture/Compare 1 DMA request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1809 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1810 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1811 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1812
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1813 case TIM_CHANNEL_2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1814 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1815 /* Set the DMA Period elapsed callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1816 htim->hdma[TIM_DMA_ID_CC2]->XferCpltCallback = TIM_DMACaptureCplt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1817
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1818 /* Set the DMA error callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1819 htim->hdma[TIM_DMA_ID_CC2]->XferErrorCallback = TIM_DMAError ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1820
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1821 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1822 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)&htim->Instance->CCR2, (uint32_t)pData, Length);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1823
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1824 /* Enable the TIM Capture/Compare 2 DMA request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1825 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1826 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1827 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1828
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1829 case TIM_CHANNEL_3:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1830 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1831 /* Set the DMA Period elapsed callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1832 htim->hdma[TIM_DMA_ID_CC3]->XferCpltCallback = TIM_DMACaptureCplt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1833
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1834 /* Set the DMA error callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1835 htim->hdma[TIM_DMA_ID_CC3]->XferErrorCallback = TIM_DMAError ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1836
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1837 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1838 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC3], (uint32_t)&htim->Instance->CCR3, (uint32_t)pData, Length);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1839
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1840 /* Enable the TIM Capture/Compare 3 DMA request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1841 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC3);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1842 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1843 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1844
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1845 case TIM_CHANNEL_4:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1846 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1847 /* Set the DMA Period elapsed callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1848 htim->hdma[TIM_DMA_ID_CC4]->XferCpltCallback = TIM_DMACaptureCplt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1849
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1850 /* Set the DMA error callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1851 htim->hdma[TIM_DMA_ID_CC4]->XferErrorCallback = TIM_DMAError ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1852
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1853 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1854 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC4], (uint32_t)&htim->Instance->CCR4, (uint32_t)pData, Length);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1855
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1856 /* Enable the TIM Capture/Compare 4 DMA request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1857 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC4);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1858 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1859 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1860
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1861 default:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1862 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1863 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1864
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1865 /* Enable the Input Capture channel */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1866 TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1867
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1868 /* Enable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1869 __HAL_TIM_ENABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1870
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1871 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1872 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1873 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1874
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1875 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1876 * @brief Stops the TIM Input Capture measurement on in DMA mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1877 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1878 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1879 * @param Channel: TIM Channels to be disabled.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1880 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1881 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1882 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1883 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1884 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1885 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1886 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1887 HAL_StatusTypeDef HAL_TIM_IC_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1888 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1889 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1890 assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1891 assert_param(IS_TIM_DMA_CC_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1892
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1893 switch (Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1894 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1895 case TIM_CHANNEL_1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1896 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1897 /* Disable the TIM Capture/Compare 1 DMA request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1898 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1899 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1900 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1901
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1902 case TIM_CHANNEL_2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1903 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1904 /* Disable the TIM Capture/Compare 2 DMA request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1905 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1906 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1907 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1908
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1909 case TIM_CHANNEL_3:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1910 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1911 /* Disable the TIM Capture/Compare 3 DMA request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1912 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC3);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1913 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1914 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1915
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1916 case TIM_CHANNEL_4:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1917 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1918 /* Disable the TIM Capture/Compare 4 DMA request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1919 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC4);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1920 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1921 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1922
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1923 default:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1924 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1925 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1926
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1927 /* Disable the Input Capture channel */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1928 TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1929
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1930 /* Disable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1931 __HAL_TIM_DISABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1932
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1933 /* Change the htim state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1934 htim->State = HAL_TIM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1935
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1936 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1937 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1938 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1939 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1940 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1941 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1942
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1943 /** @defgroup TIM_Exported_Functions_Group5 Time One Pulse functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1944 * @brief Time One Pulse functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1945 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1946 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1947 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1948 ##### Time One Pulse functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1949 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1950 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1951 This section provides functions allowing to:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1952 (+) Initialize and configure the TIM One Pulse.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1953 (+) De-initialize the TIM One Pulse.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1954 (+) Start the Time One Pulse.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1955 (+) Stop the Time One Pulse.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1956 (+) Start the Time One Pulse and enable interrupt.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1957 (+) Stop the Time One Pulse and disable interrupt.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1958 (+) Start the Time One Pulse and enable DMA transfer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1959 (+) Stop the Time One Pulse and disable DMA transfer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1960
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1961 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1962 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1963 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1964 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1965 * @brief Initializes the TIM One Pulse Time Base according to the specified
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1966 * parameters in the TIM_HandleTypeDef and create the associated handle.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1967 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1968 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1969 * @param OnePulseMode: Select the One pulse mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1970 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1971 * @arg TIM_OPMODE_SINGLE: Only one pulse will be generated.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1972 * @arg TIM_OPMODE_REPETITIVE: Repetitive pulses will be generated.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1973 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1974 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1975 HAL_StatusTypeDef HAL_TIM_OnePulse_Init(TIM_HandleTypeDef *htim, uint32_t OnePulseMode)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1976 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1977 /* Check the TIM handle allocation */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1978 if(htim == NULL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1979 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1980 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1981 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1982
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1983 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1984 assert_param(IS_TIM_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1985 assert_param(IS_TIM_COUNTER_MODE(htim->Init.CounterMode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1986 assert_param(IS_TIM_CLOCKDIVISION_DIV(htim->Init.ClockDivision));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1987 assert_param(IS_TIM_OPM_MODE(OnePulseMode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1988
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1989 if(htim->State == HAL_TIM_STATE_RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1990 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1991 /* Init the low level hardware : GPIO, CLOCK, NVIC and DMA */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1992 HAL_TIM_OnePulse_MspInit(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1993 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1994
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1995 /* Set the TIM state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1996 htim->State= HAL_TIM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1997
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1998 /* Configure the Time base in the One Pulse Mode */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1999 TIM_Base_SetConfig(htim->Instance, &htim->Init);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2000
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2001 /* Reset the OPM Bit */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2002 htim->Instance->CR1 &= ~TIM_CR1_OPM;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2003
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2004 /* Configure the OPM Mode */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2005 htim->Instance->CR1 |= OnePulseMode;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2006
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2007 /* Initialize the TIM state*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2008 htim->State= HAL_TIM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2009
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2010 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2011 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2012
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2013 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2014 * @brief DeInitializes the TIM One Pulse
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2015 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2016 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2017 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2018 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2019 HAL_StatusTypeDef HAL_TIM_OnePulse_DeInit(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2020 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2021 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2022 assert_param(IS_TIM_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2023
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2024 htim->State = HAL_TIM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2025
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2026 /* Disable the TIM Peripheral Clock */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2027 __HAL_TIM_DISABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2028
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2029 /* DeInit the low level hardware: GPIO, CLOCK, NVIC */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2030 HAL_TIM_OnePulse_MspDeInit(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2031
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2032 /* Change TIM state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2033 htim->State = HAL_TIM_STATE_RESET;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2034
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2035 /* Release Lock */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2036 __HAL_UNLOCK(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2037
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2038 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2039 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2040
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2041 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2042 * @brief Initializes the TIM One Pulse MSP.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2043 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2044 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2045 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2046 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2047 __weak void HAL_TIM_OnePulse_MspInit(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2048 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2049 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2050 the HAL_TIM_OnePulse_MspInit could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2051 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2052 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2053
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2054 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2055 * @brief DeInitializes TIM One Pulse MSP.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2056 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2057 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2058 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2059 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2060 __weak void HAL_TIM_OnePulse_MspDeInit(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2061 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2062 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2063 the HAL_TIM_OnePulse_MspDeInit could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2064 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2065 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2066
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2067 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2068 * @brief Starts the TIM One Pulse signal generation.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2069 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2070 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2071 * @param OutputChannel : TIM Channels to be enabled.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2072 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2073 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2074 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2075 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2076 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2077 HAL_StatusTypeDef HAL_TIM_OnePulse_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2078 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2079 /* Enable the Capture compare and the Input Capture channels
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2080 (in the OPM Mode the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2081 if TIM_CHANNEL_1 is used as output, the TIM_CHANNEL_2 will be used as input and
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2082 if TIM_CHANNEL_1 is used as input, the TIM_CHANNEL_2 will be used as output
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2083 in all combinations, the TIM_CHANNEL_1 and TIM_CHANNEL_2 should be enabled together
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2084
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2085 No need to enable the counter, it's enabled automatically by hardware
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2086 (the counter starts in response to a stimulus and generate a pulse */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2087
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2088 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_ENABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2089 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_ENABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2090
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2091 if(IS_TIM_ADVANCED_INSTANCE(htim->Instance) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2092 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2093 /* Enable the main output */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2094 __HAL_TIM_MOE_ENABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2095 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2096
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2097 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2098 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2099 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2100
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2101 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2102 * @brief Stops the TIM One Pulse signal generation.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2103 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2104 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2105 * @param OutputChannel : TIM Channels to be disable.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2106 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2107 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2108 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2109 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2110 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2111 HAL_StatusTypeDef HAL_TIM_OnePulse_Stop(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2112 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2113 /* Disable the Capture compare and the Input Capture channels
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2114 (in the OPM Mode the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2115 if TIM_CHANNEL_1 is used as output, the TIM_CHANNEL_2 will be used as input and
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2116 if TIM_CHANNEL_1 is used as input, the TIM_CHANNEL_2 will be used as output
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2117 in all combinations, the TIM_CHANNEL_1 and TIM_CHANNEL_2 should be disabled together */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2118
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2119 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_DISABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2120 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_DISABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2121
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2122 if(IS_TIM_ADVANCED_INSTANCE(htim->Instance) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2123 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2124 /* Disable the Main Output */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2125 __HAL_TIM_MOE_DISABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2126 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2127
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2128 /* Disable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2129 __HAL_TIM_DISABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2130
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2131 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2132 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2133 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2134
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2135 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2136 * @brief Starts the TIM One Pulse signal generation in interrupt mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2137 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2138 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2139 * @param OutputChannel : TIM Channels to be enabled.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2140 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2141 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2142 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2143 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2144 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2145 HAL_StatusTypeDef HAL_TIM_OnePulse_Start_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2146 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2147 /* Enable the Capture compare and the Input Capture channels
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2148 (in the OPM Mode the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2149 if TIM_CHANNEL_1 is used as output, the TIM_CHANNEL_2 will be used as input and
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2150 if TIM_CHANNEL_1 is used as input, the TIM_CHANNEL_2 will be used as output
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2151 in all combinations, the TIM_CHANNEL_1 and TIM_CHANNEL_2 should be enabled together
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2152
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2153 No need to enable the counter, it's enabled automatically by hardware
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2154 (the counter starts in response to a stimulus and generate a pulse */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2155
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2156 /* Enable the TIM Capture/Compare 1 interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2157 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2158
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2159 /* Enable the TIM Capture/Compare 2 interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2160 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2161
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2162 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_ENABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2163 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_ENABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2164
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2165 if(IS_TIM_ADVANCED_INSTANCE(htim->Instance) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2166 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2167 /* Enable the main output */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2168 __HAL_TIM_MOE_ENABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2169 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2170
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2171 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2172 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2173 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2174
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2175 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2176 * @brief Stops the TIM One Pulse signal generation in interrupt mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2177 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2178 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2179 * @param OutputChannel : TIM Channels to be enabled.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2180 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2181 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2182 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2183 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2184 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2185 HAL_StatusTypeDef HAL_TIM_OnePulse_Stop_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2186 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2187 /* Disable the TIM Capture/Compare 1 interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2188 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2189
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2190 /* Disable the TIM Capture/Compare 2 interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2191 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2192
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2193 /* Disable the Capture compare and the Input Capture channels
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2194 (in the OPM Mode the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2195 if TIM_CHANNEL_1 is used as output, the TIM_CHANNEL_2 will be used as input and
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2196 if TIM_CHANNEL_1 is used as input, the TIM_CHANNEL_2 will be used as output
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2197 in all combinations, the TIM_CHANNEL_1 and TIM_CHANNEL_2 should be disabled together */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2198 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_DISABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2199 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_DISABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2200
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2201 if(IS_TIM_ADVANCED_INSTANCE(htim->Instance) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2202 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2203 /* Disable the Main Output */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2204 __HAL_TIM_MOE_DISABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2205 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2206
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2207 /* Disable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2208 __HAL_TIM_DISABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2209
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2210 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2211 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2212 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2213 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2214 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2215 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2216
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2217 /** @defgroup TIM_Exported_Functions_Group6 Time Encoder functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2218 * @brief Time Encoder functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2219 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2220 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2221 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2222 ##### Time Encoder functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2223 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2224 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2225 This section provides functions allowing to:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2226 (+) Initialize and configure the TIM Encoder.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2227 (+) De-initialize the TIM Encoder.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2228 (+) Start the Time Encoder.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2229 (+) Stop the Time Encoder.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2230 (+) Start the Time Encoder and enable interrupt.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2231 (+) Stop the Time Encoder and disable interrupt.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2232 (+) Start the Time Encoder and enable DMA transfer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2233 (+) Stop the Time Encoder and disable DMA transfer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2234
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2235 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2236 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2237 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2238 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2239 * @brief Initializes the TIM Encoder Interface and create the associated handle.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2240 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2241 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2242 * @param sConfig: TIM Encoder Interface configuration structure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2243 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2244 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2245 HAL_StatusTypeDef HAL_TIM_Encoder_Init(TIM_HandleTypeDef *htim, TIM_Encoder_InitTypeDef* sConfig)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2246 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2247 uint32_t tmpsmcr = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2248 uint32_t tmpccmr1 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2249 uint32_t tmpccer = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2250
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2251 /* Check the TIM handle allocation */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2252 if(htim == NULL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2253 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2254 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2255 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2256
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2257 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2258 assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2259 assert_param(IS_TIM_ENCODER_MODE(sConfig->EncoderMode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2260 assert_param(IS_TIM_IC_SELECTION(sConfig->IC1Selection));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2261 assert_param(IS_TIM_IC_SELECTION(sConfig->IC2Selection));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2262 assert_param(IS_TIM_IC_POLARITY(sConfig->IC1Polarity));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2263 assert_param(IS_TIM_IC_POLARITY(sConfig->IC2Polarity));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2264 assert_param(IS_TIM_IC_PRESCALER(sConfig->IC1Prescaler));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2265 assert_param(IS_TIM_IC_PRESCALER(sConfig->IC2Prescaler));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2266 assert_param(IS_TIM_IC_FILTER(sConfig->IC1Filter));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2267 assert_param(IS_TIM_IC_FILTER(sConfig->IC2Filter));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2268
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2269 if(htim->State == HAL_TIM_STATE_RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2270 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2271 /* Init the low level hardware : GPIO, CLOCK, NVIC and DMA */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2272 HAL_TIM_Encoder_MspInit(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2273 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2274
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2275 /* Set the TIM state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2276 htim->State= HAL_TIM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2277
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2278 /* Reset the SMS bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2279 htim->Instance->SMCR &= ~TIM_SMCR_SMS;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2280
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2281 /* Configure the Time base in the Encoder Mode */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2282 TIM_Base_SetConfig(htim->Instance, &htim->Init);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2283
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2284 /* Get the TIMx SMCR register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2285 tmpsmcr = htim->Instance->SMCR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2286
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2287 /* Get the TIMx CCMR1 register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2288 tmpccmr1 = htim->Instance->CCMR1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2289
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2290 /* Get the TIMx CCER register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2291 tmpccer = htim->Instance->CCER;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2292
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2293 /* Set the encoder Mode */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2294 tmpsmcr |= sConfig->EncoderMode;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2295
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2296 /* Select the Capture Compare 1 and the Capture Compare 2 as input */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2297 tmpccmr1 &= ~(TIM_CCMR1_CC1S | TIM_CCMR1_CC2S);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2298 tmpccmr1 |= (sConfig->IC1Selection | (sConfig->IC2Selection << 8));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2299
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2300 /* Set the Capture Compare 1 and the Capture Compare 2 prescalers and filters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2301 tmpccmr1 &= ~(TIM_CCMR1_IC1PSC | TIM_CCMR1_IC2PSC);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2302 tmpccmr1 &= ~(TIM_CCMR1_IC1F | TIM_CCMR1_IC2F);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2303 tmpccmr1 |= sConfig->IC1Prescaler | (sConfig->IC2Prescaler << 8);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2304 tmpccmr1 |= (sConfig->IC1Filter << 4) | (sConfig->IC2Filter << 12);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2305
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2306 /* Set the TI1 and the TI2 Polarities */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2307 tmpccer &= ~(TIM_CCER_CC1P | TIM_CCER_CC2P);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2308 tmpccer &= ~(TIM_CCER_CC1NP | TIM_CCER_CC2NP);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2309 tmpccer |= sConfig->IC1Polarity | (sConfig->IC2Polarity << 4);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2310
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2311 /* Write to TIMx SMCR */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2312 htim->Instance->SMCR = tmpsmcr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2313
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2314 /* Write to TIMx CCMR1 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2315 htim->Instance->CCMR1 = tmpccmr1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2316
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2317 /* Write to TIMx CCER */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2318 htim->Instance->CCER = tmpccer;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2319
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2320 /* Initialize the TIM state*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2321 htim->State= HAL_TIM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2322
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2323 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2324 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2325
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2326 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2327 * @brief DeInitializes the TIM Encoder interface
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2328 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2329 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2330 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2331 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2332 HAL_StatusTypeDef HAL_TIM_Encoder_DeInit(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2333 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2334 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2335 assert_param(IS_TIM_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2336
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2337 htim->State = HAL_TIM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2338
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2339 /* Disable the TIM Peripheral Clock */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2340 __HAL_TIM_DISABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2341
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2342 /* DeInit the low level hardware: GPIO, CLOCK, NVIC */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2343 HAL_TIM_Encoder_MspDeInit(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2344
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2345 /* Change TIM state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2346 htim->State = HAL_TIM_STATE_RESET;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2347
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2348 /* Release Lock */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2349 __HAL_UNLOCK(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2350
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2351 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2352 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2353
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2354 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2355 * @brief Initializes the TIM Encoder Interface MSP.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2356 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2357 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2358 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2359 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2360 __weak void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2361 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2362 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2363 the HAL_TIM_Encoder_MspInit could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2364 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2365 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2366
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2367 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2368 * @brief DeInitializes TIM Encoder Interface MSP.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2369 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2370 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2371 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2372 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2373 __weak void HAL_TIM_Encoder_MspDeInit(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2374 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2375 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2376 the HAL_TIM_Encoder_MspDeInit could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2377 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2378 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2379
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2380 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2381 * @brief Starts the TIM Encoder Interface.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2382 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2383 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2384 * @param Channel: TIM Channels to be enabled.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2385 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2386 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2387 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2388 * @arg TIM_CHANNEL_ALL: TIM Channel 1 and TIM Channel 2 are selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2389 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2390 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2391 HAL_StatusTypeDef HAL_TIM_Encoder_Start(TIM_HandleTypeDef *htim, uint32_t Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2392 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2393 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2394 assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2395
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2396 /* Enable the encoder interface channels */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2397 switch (Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2398 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2399 case TIM_CHANNEL_1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2400 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2401 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_ENABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2402 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2403 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2404 case TIM_CHANNEL_2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2405 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2406 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_ENABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2407 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2408 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2409 default :
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2410 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2411 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_ENABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2412 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_ENABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2413 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2414 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2415 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2416 /* Enable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2417 __HAL_TIM_ENABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2418
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2419 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2420 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2421 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2422
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2423 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2424 * @brief Stops the TIM Encoder Interface.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2425 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2426 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2427 * @param Channel: TIM Channels to be disabled.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2428 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2429 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2430 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2431 * @arg TIM_CHANNEL_ALL: TIM Channel 1 and TIM Channel 2 are selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2432 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2433 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2434 HAL_StatusTypeDef HAL_TIM_Encoder_Stop(TIM_HandleTypeDef *htim, uint32_t Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2435 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2436 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2437 assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2438
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2439 /* Disable the Input Capture channels 1 and 2
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2440 (in the EncoderInterface the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2) */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2441 switch (Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2442 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2443 case TIM_CHANNEL_1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2444 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2445 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_DISABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2446 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2447 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2448 case TIM_CHANNEL_2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2449 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2450 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_DISABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2451 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2452 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2453 default :
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2454 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2455 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_DISABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2456 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_DISABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2457 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2458 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2459 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2460 /* Disable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2461 __HAL_TIM_DISABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2462
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2463 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2464 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2465 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2466
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2467 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2468 * @brief Starts the TIM Encoder Interface in interrupt mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2469 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2470 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2471 * @param Channel: TIM Channels to be enabled.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2472 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2473 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2474 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2475 * @arg TIM_CHANNEL_ALL: TIM Channel 1 and TIM Channel 2 are selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2476 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2477 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2478 HAL_StatusTypeDef HAL_TIM_Encoder_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2479 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2480 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2481 assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2482
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2483 /* Enable the encoder interface channels */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2484 /* Enable the capture compare Interrupts 1 and/or 2 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2485 switch (Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2486 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2487 case TIM_CHANNEL_1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2488 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2489 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_ENABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2490 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2491 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2492 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2493 case TIM_CHANNEL_2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2494 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2495 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_ENABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2496 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2497 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2498 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2499 default :
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2500 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2501 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_ENABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2502 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_ENABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2503 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2504 __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2505 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2506 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2507 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2508
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2509 /* Enable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2510 __HAL_TIM_ENABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2511
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2512 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2513 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2514 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2515
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2516 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2517 * @brief Stops the TIM Encoder Interface in interrupt mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2518 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2519 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2520 * @param Channel: TIM Channels to be disabled.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2521 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2522 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2523 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2524 * @arg TIM_CHANNEL_ALL: TIM Channel 1 and TIM Channel 2 are selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2525 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2526 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2527 HAL_StatusTypeDef HAL_TIM_Encoder_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2528 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2529 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2530 assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2531
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2532 /* Disable the Input Capture channels 1 and 2
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2533 (in the EncoderInterface the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2) */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2534 if(Channel == TIM_CHANNEL_1)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2535 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2536 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_DISABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2537
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2538 /* Disable the capture compare Interrupts 1 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2539 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2540 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2541 else if(Channel == TIM_CHANNEL_2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2542 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2543 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_DISABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2544
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2545 /* Disable the capture compare Interrupts 2 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2546 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2547 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2548 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2549 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2550 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_DISABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2551 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_DISABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2552
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2553 /* Disable the capture compare Interrupts 1 and 2 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2554 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2555 __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2556 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2557
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2558 /* Disable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2559 __HAL_TIM_DISABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2560
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2561 /* Change the htim state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2562 htim->State = HAL_TIM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2563
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2564 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2565 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2566 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2567
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2568 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2569 * @brief Starts the TIM Encoder Interface in DMA mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2570 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2571 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2572 * @param Channel: TIM Channels to be enabled.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2573 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2574 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2575 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2576 * @arg TIM_CHANNEL_ALL: TIM Channel 1 and TIM Channel 2 are selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2577 * @param pData1: The destination Buffer address for IC1.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2578 * @param pData2: The destination Buffer address for IC2.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2579 * @param Length: The length of data to be transferred from TIM peripheral to memory.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2580 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2581 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2582 HAL_StatusTypeDef HAL_TIM_Encoder_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData1, uint32_t *pData2, uint16_t Length)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2583 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2584 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2585 assert_param(IS_TIM_DMA_CC_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2586
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2587 if((htim->State == HAL_TIM_STATE_BUSY))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2588 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2589 return HAL_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2590 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2591 else if((htim->State == HAL_TIM_STATE_READY))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2592 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2593 if((((pData1 == 0) || (pData2 == 0) )) && (Length > 0))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2594 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2595 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2596 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2597 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2598 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2599 htim->State = HAL_TIM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2600 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2601 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2602
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2603 switch (Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2604 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2605 case TIM_CHANNEL_1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2606 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2607 /* Set the DMA Period elapsed callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2608 htim->hdma[TIM_DMA_ID_CC1]->XferCpltCallback = TIM_DMACaptureCplt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2609
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2610 /* Set the DMA error callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2611 htim->hdma[TIM_DMA_ID_CC1]->XferErrorCallback = TIM_DMAError ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2612
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2613 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2614 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)&htim->Instance->CCR1, (uint32_t )pData1, Length);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2615
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2616 /* Enable the TIM Input Capture DMA request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2617 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2618
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2619 /* Enable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2620 __HAL_TIM_ENABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2621
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2622 /* Enable the Capture compare channel */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2623 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_ENABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2624 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2625 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2626
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2627 case TIM_CHANNEL_2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2628 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2629 /* Set the DMA Period elapsed callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2630 htim->hdma[TIM_DMA_ID_CC2]->XferCpltCallback = TIM_DMACaptureCplt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2631
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2632 /* Set the DMA error callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2633 htim->hdma[TIM_DMA_ID_CC2]->XferErrorCallback = TIM_DMAError;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2634 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2635 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)&htim->Instance->CCR2, (uint32_t)pData2, Length);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2636
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2637 /* Enable the TIM Input Capture DMA request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2638 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2639
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2640 /* Enable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2641 __HAL_TIM_ENABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2642
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2643 /* Enable the Capture compare channel */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2644 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_ENABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2645 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2646 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2647
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2648 case TIM_CHANNEL_ALL:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2649 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2650 /* Set the DMA Period elapsed callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2651 htim->hdma[TIM_DMA_ID_CC1]->XferCpltCallback = TIM_DMACaptureCplt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2652
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2653 /* Set the DMA error callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2654 htim->hdma[TIM_DMA_ID_CC1]->XferErrorCallback = TIM_DMAError ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2655
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2656 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2657 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)&htim->Instance->CCR1, (uint32_t)pData1, Length);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2658
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2659 /* Set the DMA Period elapsed callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2660 htim->hdma[TIM_DMA_ID_CC2]->XferCpltCallback = TIM_DMACaptureCplt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2661
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2662 /* Set the DMA error callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2663 htim->hdma[TIM_DMA_ID_CC2]->XferErrorCallback = TIM_DMAError ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2664
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2665 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2666 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)&htim->Instance->CCR2, (uint32_t)pData2, Length);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2667
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2668 /* Enable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2669 __HAL_TIM_ENABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2670
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2671 /* Enable the Capture compare channel */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2672 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_ENABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2673 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_ENABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2674
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2675 /* Enable the TIM Input Capture DMA request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2676 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2677 /* Enable the TIM Input Capture DMA request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2678 __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2679 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2680 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2681
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2682 default:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2683 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2684 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2685 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2686 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2687 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2688
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2689 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2690 * @brief Stops the TIM Encoder Interface in DMA mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2691 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2692 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2693 * @param Channel: TIM Channels to be enabled.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2694 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2695 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2696 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2697 * @arg TIM_CHANNEL_ALL: TIM Channel 1 and TIM Channel 2 are selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2698 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2699 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2700 HAL_StatusTypeDef HAL_TIM_Encoder_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2701 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2702 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2703 assert_param(IS_TIM_DMA_CC_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2704
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2705 /* Disable the Input Capture channels 1 and 2
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2706 (in the EncoderInterface the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2) */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2707 if(Channel == TIM_CHANNEL_1)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2708 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2709 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_DISABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2710
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2711 /* Disable the capture compare DMA Request 1 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2712 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2713 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2714 else if(Channel == TIM_CHANNEL_2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2715 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2716 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_DISABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2717
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2718 /* Disable the capture compare DMA Request 2 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2719 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2720 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2721 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2722 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2723 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_DISABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2724 TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_DISABLE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2725
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2726 /* Disable the capture compare DMA Request 1 and 2 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2727 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2728 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2729 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2730
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2731 /* Disable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2732 __HAL_TIM_DISABLE(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2733
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2734 /* Change the htim state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2735 htim->State = HAL_TIM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2736
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2737 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2738 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2739 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2740 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2741 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2742 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2743
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2744 /** @defgroup TIM_Exported_Functions_Group7 TIM IRQ handler management
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2745 * @brief IRQ handler management
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2746 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2747 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2748 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2749 ##### IRQ handler management #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2750 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2751 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2752 This section provides Timer IRQ handler function.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2753
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2754 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2755 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2756 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2757 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2758 * @brief This function handles TIM interrupts requests.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2759 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2760 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2761 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2762 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2763 void HAL_TIM_IRQHandler(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2764 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2765 /* Capture compare 1 event */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2766 if(__HAL_TIM_GET_FLAG(htim, TIM_FLAG_CC1) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2767 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2768 if(__HAL_TIM_GET_IT_SOURCE(htim, TIM_IT_CC1) !=RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2769 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2770 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2771 __HAL_TIM_CLEAR_IT(htim, TIM_IT_CC1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2772 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2773
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2774 /* Input capture event */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2775 if((htim->Instance->CCMR1 & TIM_CCMR1_CC1S) != 0x00)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2776 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2777 HAL_TIM_IC_CaptureCallback(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2778 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2779 /* Output compare event */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2780 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2781 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2782 HAL_TIM_OC_DelayElapsedCallback(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2783 HAL_TIM_PWM_PulseFinishedCallback(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2784 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2785 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_CLEARED;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2786 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2787 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2788 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2789 /* Capture compare 2 event */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2790 if(__HAL_TIM_GET_FLAG(htim, TIM_FLAG_CC2) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2791 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2792 if(__HAL_TIM_GET_IT_SOURCE(htim, TIM_IT_CC2) !=RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2793 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2794 __HAL_TIM_CLEAR_IT(htim, TIM_IT_CC2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2795 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2796 /* Input capture event */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2797 if((htim->Instance->CCMR1 & TIM_CCMR1_CC2S) != 0x00)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2798 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2799 HAL_TIM_IC_CaptureCallback(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2800 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2801 /* Output compare event */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2802 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2803 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2804 HAL_TIM_OC_DelayElapsedCallback(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2805 HAL_TIM_PWM_PulseFinishedCallback(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2806 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2807 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_CLEARED;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2808 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2809 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2810 /* Capture compare 3 event */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2811 if(__HAL_TIM_GET_FLAG(htim, TIM_FLAG_CC3) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2812 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2813 if(__HAL_TIM_GET_IT_SOURCE(htim, TIM_IT_CC3) !=RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2814 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2815 __HAL_TIM_CLEAR_IT(htim, TIM_IT_CC3);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2816 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_3;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2817 /* Input capture event */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2818 if((htim->Instance->CCMR2 & TIM_CCMR2_CC3S) != 0x00)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2819 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2820 HAL_TIM_IC_CaptureCallback(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2821 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2822 /* Output compare event */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2823 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2824 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2825 HAL_TIM_OC_DelayElapsedCallback(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2826 HAL_TIM_PWM_PulseFinishedCallback(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2827 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2828 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_CLEARED;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2829 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2830 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2831 /* Capture compare 4 event */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2832 if(__HAL_TIM_GET_FLAG(htim, TIM_FLAG_CC4) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2833 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2834 if(__HAL_TIM_GET_IT_SOURCE(htim, TIM_IT_CC4) !=RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2835 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2836 __HAL_TIM_CLEAR_IT(htim, TIM_IT_CC4);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2837 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_4;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2838 /* Input capture event */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2839 if((htim->Instance->CCMR2 & TIM_CCMR2_CC4S) != 0x00)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2840 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2841 HAL_TIM_IC_CaptureCallback(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2842 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2843 /* Output compare event */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2844 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2845 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2846 HAL_TIM_OC_DelayElapsedCallback(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2847 HAL_TIM_PWM_PulseFinishedCallback(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2848 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2849 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_CLEARED;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2850 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2851 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2852 /* TIM Update event */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2853 if(__HAL_TIM_GET_FLAG(htim, TIM_FLAG_UPDATE) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2854 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2855 if(__HAL_TIM_GET_IT_SOURCE(htim, TIM_IT_UPDATE) !=RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2856 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2857 __HAL_TIM_CLEAR_IT(htim, TIM_IT_UPDATE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2858 HAL_TIM_PeriodElapsedCallback(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2859 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2860 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2861 /* TIM Break input event */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2862 if(__HAL_TIM_GET_FLAG(htim, TIM_FLAG_BREAK) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2863 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2864 if(__HAL_TIM_GET_IT_SOURCE(htim, TIM_IT_BREAK) !=RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2865 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2866 __HAL_TIM_CLEAR_IT(htim, TIM_IT_BREAK);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2867 HAL_TIMEx_BreakCallback(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2868 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2869 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2870 /* TIM Trigger detection event */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2871 if(__HAL_TIM_GET_FLAG(htim, TIM_FLAG_TRIGGER) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2872 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2873 if(__HAL_TIM_GET_IT_SOURCE(htim, TIM_IT_TRIGGER) !=RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2874 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2875 __HAL_TIM_CLEAR_IT(htim, TIM_IT_TRIGGER);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2876 HAL_TIM_TriggerCallback(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2877 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2878 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2879 /* TIM commutation event */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2880 if(__HAL_TIM_GET_FLAG(htim, TIM_FLAG_COM) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2881 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2882 if(__HAL_TIM_GET_IT_SOURCE(htim, TIM_IT_COM) !=RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2883 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2884 __HAL_TIM_CLEAR_IT(htim, TIM_FLAG_COM);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2885 HAL_TIMEx_CommutationCallback(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2886 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2887 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2888 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2889 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2890 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2891 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2892
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2893 /** @defgroup TIM_Exported_Functions_Group8 Peripheral Control functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2894 * @brief Peripheral Control functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2895 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2896 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2897 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2898 ##### Peripheral Control functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2899 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2900 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2901 This section provides functions allowing to:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2902 (+) Configure The Input Output channels for OC, PWM, IC or One Pulse mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2903 (+) Configure External Clock source.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2904 (+) Configure Complementary channels, break features and dead time.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2905 (+) Configure Master and the Slave synchronization.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2906 (+) Configure the DMA Burst Mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2907
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2908 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2909 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2910 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2911
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2912 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2913 * @brief Initializes the TIM Output Compare Channels according to the specified
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2914 * parameters in the TIM_OC_InitTypeDef.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2915 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2916 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2917 * @param sConfig: TIM Output Compare configuration structure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2918 * @param Channel: TIM Channels to be enabled.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2919 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2920 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2921 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2922 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2923 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2924 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2925 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2926 HAL_StatusTypeDef HAL_TIM_OC_ConfigChannel(TIM_HandleTypeDef *htim, TIM_OC_InitTypeDef* sConfig, uint32_t Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2927 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2928 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2929 assert_param(IS_TIM_CHANNELS(Channel));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2930 assert_param(IS_TIM_OC_MODE(sConfig->OCMode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2931 assert_param(IS_TIM_OC_POLARITY(sConfig->OCPolarity));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2932 assert_param(IS_TIM_OCN_POLARITY(sConfig->OCNPolarity));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2933 assert_param(IS_TIM_OCNIDLE_STATE(sConfig->OCNIdleState));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2934 assert_param(IS_TIM_OCIDLE_STATE(sConfig->OCIdleState));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2935
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2936 /* Check input state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2937 __HAL_LOCK(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2938
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2939 htim->State = HAL_TIM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2940
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2941 switch (Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2942 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2943 case TIM_CHANNEL_1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2944 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2945 assert_param(IS_TIM_CC1_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2946 /* Configure the TIM Channel 1 in Output Compare */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2947 TIM_OC1_SetConfig(htim->Instance, sConfig);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2948 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2949 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2950
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2951 case TIM_CHANNEL_2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2952 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2953 assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2954 /* Configure the TIM Channel 2 in Output Compare */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2955 TIM_OC2_SetConfig(htim->Instance, sConfig);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2956 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2957 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2958
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2959 case TIM_CHANNEL_3:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2960 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2961 assert_param(IS_TIM_CC3_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2962 /* Configure the TIM Channel 3 in Output Compare */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2963 TIM_OC3_SetConfig(htim->Instance, sConfig);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2964 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2965 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2966
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2967 case TIM_CHANNEL_4:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2968 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2969 assert_param(IS_TIM_CC4_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2970 /* Configure the TIM Channel 4 in Output Compare */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2971 TIM_OC4_SetConfig(htim->Instance, sConfig);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2972 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2973 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2974
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2975 default:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2976 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2977 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2978 htim->State = HAL_TIM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2979
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2980 __HAL_UNLOCK(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2981
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2982 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2983 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2984
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2985 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2986 * @brief Initializes the TIM Input Capture Channels according to the specified
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2987 * parameters in the TIM_IC_InitTypeDef.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2988 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2989 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2990 * @param sConfig: TIM Input Capture configuration structure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2991 * @param Channel: TIM Channels to be enabled.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2992 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2993 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2994 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2995 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2996 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2997 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2998 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2999 HAL_StatusTypeDef HAL_TIM_IC_ConfigChannel(TIM_HandleTypeDef *htim, TIM_IC_InitTypeDef* sConfig, uint32_t Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3000 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3001 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3002 assert_param(IS_TIM_CC1_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3003 assert_param(IS_TIM_IC_POLARITY(sConfig->ICPolarity));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3004 assert_param(IS_TIM_IC_SELECTION(sConfig->ICSelection));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3005 assert_param(IS_TIM_IC_PRESCALER(sConfig->ICPrescaler));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3006 assert_param(IS_TIM_IC_FILTER(sConfig->ICFilter));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3007
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3008 __HAL_LOCK(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3009
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3010 htim->State = HAL_TIM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3011
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3012 if (Channel == TIM_CHANNEL_1)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3013 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3014 /* TI1 Configuration */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3015 TIM_TI1_SetConfig(htim->Instance,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3016 sConfig->ICPolarity,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3017 sConfig->ICSelection,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3018 sConfig->ICFilter);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3019
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3020 /* Reset the IC1PSC Bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3021 htim->Instance->CCMR1 &= ~TIM_CCMR1_IC1PSC;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3022
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3023 /* Set the IC1PSC value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3024 htim->Instance->CCMR1 |= sConfig->ICPrescaler;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3025 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3026 else if (Channel == TIM_CHANNEL_2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3027 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3028 /* TI2 Configuration */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3029 assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3030
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3031 TIM_TI2_SetConfig(htim->Instance,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3032 sConfig->ICPolarity,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3033 sConfig->ICSelection,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3034 sConfig->ICFilter);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3035
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3036 /* Reset the IC2PSC Bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3037 htim->Instance->CCMR1 &= ~TIM_CCMR1_IC2PSC;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3038
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3039 /* Set the IC2PSC value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3040 htim->Instance->CCMR1 |= (sConfig->ICPrescaler << 8);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3041 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3042 else if (Channel == TIM_CHANNEL_3)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3043 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3044 /* TI3 Configuration */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3045 assert_param(IS_TIM_CC3_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3046
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3047 TIM_TI3_SetConfig(htim->Instance,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3048 sConfig->ICPolarity,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3049 sConfig->ICSelection,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3050 sConfig->ICFilter);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3051
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3052 /* Reset the IC3PSC Bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3053 htim->Instance->CCMR2 &= ~TIM_CCMR2_IC3PSC;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3054
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3055 /* Set the IC3PSC value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3056 htim->Instance->CCMR2 |= sConfig->ICPrescaler;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3057 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3058 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3059 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3060 /* TI4 Configuration */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3061 assert_param(IS_TIM_CC4_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3062
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3063 TIM_TI4_SetConfig(htim->Instance,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3064 sConfig->ICPolarity,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3065 sConfig->ICSelection,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3066 sConfig->ICFilter);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3067
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3068 /* Reset the IC4PSC Bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3069 htim->Instance->CCMR2 &= ~TIM_CCMR2_IC4PSC;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3070
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3071 /* Set the IC4PSC value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3072 htim->Instance->CCMR2 |= (sConfig->ICPrescaler << 8);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3073 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3074
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3075 htim->State = HAL_TIM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3076
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3077 __HAL_UNLOCK(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3078
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3079 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3080 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3081
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3082 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3083 * @brief Initializes the TIM PWM channels according to the specified
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3084 * parameters in the TIM_OC_InitTypeDef.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3085 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3086 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3087 * @param sConfig: TIM PWM configuration structure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3088 * @param Channel: TIM Channels to be enabled.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3089 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3090 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3091 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3092 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3093 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3094 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3095 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3096 HAL_StatusTypeDef HAL_TIM_PWM_ConfigChannel(TIM_HandleTypeDef *htim, TIM_OC_InitTypeDef* sConfig, uint32_t Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3097 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3098 __HAL_LOCK(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3099
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3100 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3101 assert_param(IS_TIM_CHANNELS(Channel));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3102 assert_param(IS_TIM_PWM_MODE(sConfig->OCMode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3103 assert_param(IS_TIM_OC_POLARITY(sConfig->OCPolarity));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3104 assert_param(IS_TIM_OCN_POLARITY(sConfig->OCNPolarity));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3105 assert_param(IS_TIM_OCNIDLE_STATE(sConfig->OCNIdleState));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3106 assert_param(IS_TIM_OCIDLE_STATE(sConfig->OCIdleState));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3107 assert_param(IS_TIM_FAST_STATE(sConfig->OCFastMode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3108
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3109 htim->State = HAL_TIM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3110
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3111 switch (Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3112 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3113 case TIM_CHANNEL_1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3114 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3115 assert_param(IS_TIM_CC1_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3116 /* Configure the Channel 1 in PWM mode */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3117 TIM_OC1_SetConfig(htim->Instance, sConfig);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3118
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3119 /* Set the Preload enable bit for channel1 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3120 htim->Instance->CCMR1 |= TIM_CCMR1_OC1PE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3121
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3122 /* Configure the Output Fast mode */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3123 htim->Instance->CCMR1 &= ~TIM_CCMR1_OC1FE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3124 htim->Instance->CCMR1 |= sConfig->OCFastMode;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3125 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3126 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3127
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3128 case TIM_CHANNEL_2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3129 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3130 assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3131 /* Configure the Channel 2 in PWM mode */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3132 TIM_OC2_SetConfig(htim->Instance, sConfig);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3133
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3134 /* Set the Preload enable bit for channel2 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3135 htim->Instance->CCMR1 |= TIM_CCMR1_OC2PE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3136
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3137 /* Configure the Output Fast mode */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3138 htim->Instance->CCMR1 &= ~TIM_CCMR1_OC2FE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3139 htim->Instance->CCMR1 |= sConfig->OCFastMode << 8;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3140 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3141 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3142
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3143 case TIM_CHANNEL_3:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3144 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3145 assert_param(IS_TIM_CC3_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3146 /* Configure the Channel 3 in PWM mode */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3147 TIM_OC3_SetConfig(htim->Instance, sConfig);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3148
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3149 /* Set the Preload enable bit for channel3 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3150 htim->Instance->CCMR2 |= TIM_CCMR2_OC3PE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3151
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3152 /* Configure the Output Fast mode */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3153 htim->Instance->CCMR2 &= ~TIM_CCMR2_OC3FE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3154 htim->Instance->CCMR2 |= sConfig->OCFastMode;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3155 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3156 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3157
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3158 case TIM_CHANNEL_4:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3159 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3160 assert_param(IS_TIM_CC4_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3161 /* Configure the Channel 4 in PWM mode */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3162 TIM_OC4_SetConfig(htim->Instance, sConfig);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3163
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3164 /* Set the Preload enable bit for channel4 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3165 htim->Instance->CCMR2 |= TIM_CCMR2_OC4PE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3166
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3167 /* Configure the Output Fast mode */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3168 htim->Instance->CCMR2 &= ~TIM_CCMR2_OC4FE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3169 htim->Instance->CCMR2 |= sConfig->OCFastMode << 8;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3170 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3171 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3172
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3173 default:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3174 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3175 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3176
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3177 htim->State = HAL_TIM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3178
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3179 __HAL_UNLOCK(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3180
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3181 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3182 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3183
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3184 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3185 * @brief Initializes the TIM One Pulse Channels according to the specified
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3186 * parameters in the TIM_OnePulse_InitTypeDef.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3187 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3188 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3189 * @param sConfig: TIM One Pulse configuration structure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3190 * @param OutputChannel: TIM Channels to be enabled.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3191 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3192 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3193 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3194 * @param InputChannel: TIM Channels to be enabled.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3195 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3196 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3197 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3198 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3199 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3200 HAL_StatusTypeDef HAL_TIM_OnePulse_ConfigChannel(TIM_HandleTypeDef *htim, TIM_OnePulse_InitTypeDef* sConfig, uint32_t OutputChannel, uint32_t InputChannel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3201 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3202 TIM_OC_InitTypeDef temp1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3203
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3204 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3205 assert_param(IS_TIM_OPM_CHANNELS(OutputChannel));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3206 assert_param(IS_TIM_OPM_CHANNELS(InputChannel));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3207
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3208 if(OutputChannel != InputChannel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3209 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3210 __HAL_LOCK(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3211
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3212 htim->State = HAL_TIM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3213
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3214 /* Extract the Output compare configuration from sConfig structure */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3215 temp1.OCMode = sConfig->OCMode;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3216 temp1.Pulse = sConfig->Pulse;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3217 temp1.OCPolarity = sConfig->OCPolarity;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3218 temp1.OCNPolarity = sConfig->OCNPolarity;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3219 temp1.OCIdleState = sConfig->OCIdleState;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3220 temp1.OCNIdleState = sConfig->OCNIdleState;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3221
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3222 switch (OutputChannel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3223 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3224 case TIM_CHANNEL_1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3225 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3226 assert_param(IS_TIM_CC1_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3227
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3228 TIM_OC1_SetConfig(htim->Instance, &temp1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3229 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3230 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3231 case TIM_CHANNEL_2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3232 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3233 assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3234
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3235 TIM_OC2_SetConfig(htim->Instance, &temp1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3236 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3237 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3238 default:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3239 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3240 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3241 switch (InputChannel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3242 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3243 case TIM_CHANNEL_1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3244 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3245 assert_param(IS_TIM_CC1_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3246
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3247 TIM_TI1_SetConfig(htim->Instance, sConfig->ICPolarity,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3248 sConfig->ICSelection, sConfig->ICFilter);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3249
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3250 /* Reset the IC1PSC Bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3251 htim->Instance->CCMR1 &= ~TIM_CCMR1_IC1PSC;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3252
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3253 /* Select the Trigger source */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3254 htim->Instance->SMCR &= ~TIM_SMCR_TS;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3255 htim->Instance->SMCR |= TIM_TS_TI1FP1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3256
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3257 /* Select the Slave Mode */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3258 htim->Instance->SMCR &= ~TIM_SMCR_SMS;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3259 htim->Instance->SMCR |= TIM_SLAVEMODE_TRIGGER;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3260 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3261 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3262 case TIM_CHANNEL_2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3263 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3264 assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3265
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3266 TIM_TI2_SetConfig(htim->Instance, sConfig->ICPolarity,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3267 sConfig->ICSelection, sConfig->ICFilter);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3268
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3269 /* Reset the IC2PSC Bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3270 htim->Instance->CCMR1 &= ~TIM_CCMR1_IC2PSC;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3271
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3272 /* Select the Trigger source */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3273 htim->Instance->SMCR &= ~TIM_SMCR_TS;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3274 htim->Instance->SMCR |= TIM_TS_TI2FP2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3275
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3276 /* Select the Slave Mode */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3277 htim->Instance->SMCR &= ~TIM_SMCR_SMS;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3278 htim->Instance->SMCR |= TIM_SLAVEMODE_TRIGGER;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3279 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3280 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3281
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3282 default:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3283 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3284 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3285
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3286 htim->State = HAL_TIM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3287
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3288 __HAL_UNLOCK(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3289
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3290 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3291 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3292 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3293 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3294 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3295 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3296 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3297
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3298 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3299 * @brief Configure the DMA Burst to transfer Data from the memory to the TIM peripheral
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3300 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3301 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3302 * @param BurstBaseAddress: TIM Base address from when the DMA will starts the Data write.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3303 * This parameters can be on of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3304 * @arg TIM_DMABASE_CR1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3305 * @arg TIM_DMABASE_CR2
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3306 * @arg TIM_DMABASE_SMCR
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3307 * @arg TIM_DMABASE_DIER
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3308 * @arg TIM_DMABASE_SR
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3309 * @arg TIM_DMABASE_EGR
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3310 * @arg TIM_DMABASE_CCMR1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3311 * @arg TIM_DMABASE_CCMR2
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3312 * @arg TIM_DMABASE_CCER
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3313 * @arg TIM_DMABASE_CNT
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3314 * @arg TIM_DMABASE_PSC
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3315 * @arg TIM_DMABASE_ARR
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3316 * @arg TIM_DMABASE_RCR
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3317 * @arg TIM_DMABASE_CCR1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3318 * @arg TIM_DMABASE_CCR2
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3319 * @arg TIM_DMABASE_CCR3
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3320 * @arg TIM_DMABASE_CCR4
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3321 * @arg TIM_DMABASE_BDTR
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3322 * @arg TIM_DMABASE_DCR
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3323 * @param BurstRequestSrc: TIM DMA Request sources.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3324 * This parameters can be on of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3325 * @arg TIM_DMA_UPDATE: TIM update Interrupt source
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3326 * @arg TIM_DMA_CC1: TIM Capture Compare 1 DMA source
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3327 * @arg TIM_DMA_CC2: TIM Capture Compare 2 DMA source
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3328 * @arg TIM_DMA_CC3: TIM Capture Compare 3 DMA source
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3329 * @arg TIM_DMA_CC4: TIM Capture Compare 4 DMA source
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3330 * @arg TIM_DMA_COM: TIM Commutation DMA source
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3331 * @arg TIM_DMA_TRIGGER: TIM Trigger DMA source
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3332 * @param BurstBuffer: The Buffer address.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3333 * @param BurstLength: DMA Burst length. This parameter can be one value
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3334 * between TIM_DMABURSTLENGTH_1TRANSFER and TIM_DMABURSTLENGTH_18TRANSFERS.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3335 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3336 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3337 HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress, uint32_t BurstRequestSrc,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3338 uint32_t* BurstBuffer, uint32_t BurstLength)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3339 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3340 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3341 assert_param(IS_TIM_DMABURST_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3342 assert_param(IS_TIM_DMA_BASE(BurstBaseAddress));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3343 assert_param(IS_TIM_DMA_SOURCE(BurstRequestSrc));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3344 assert_param(IS_TIM_DMA_LENGTH(BurstLength));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3345
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3346 if((htim->State == HAL_TIM_STATE_BUSY))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3347 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3348 return HAL_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3349 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3350 else if((htim->State == HAL_TIM_STATE_READY))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3351 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3352 if((BurstBuffer == 0 ) && (BurstLength > 0))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3353 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3354 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3355 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3356 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3357 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3358 htim->State = HAL_TIM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3359 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3360 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3361 switch(BurstRequestSrc)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3362 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3363 case TIM_DMA_UPDATE:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3364 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3365 /* Set the DMA Period elapsed callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3366 htim->hdma[TIM_DMA_ID_UPDATE]->XferCpltCallback = TIM_DMAPeriodElapsedCplt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3367
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3368 /* Set the DMA error callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3369 htim->hdma[TIM_DMA_ID_UPDATE]->XferErrorCallback = TIM_DMAError ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3370
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3371 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3372 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_UPDATE], (uint32_t)BurstBuffer, (uint32_t)&htim->Instance->DMAR, ((BurstLength) >> 8) + 1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3373 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3374 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3375 case TIM_DMA_CC1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3376 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3377 /* Set the DMA Period elapsed callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3378 htim->hdma[TIM_DMA_ID_CC1]->XferCpltCallback = TIM_DMADelayPulseCplt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3379
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3380 /* Set the DMA error callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3381 htim->hdma[TIM_DMA_ID_CC1]->XferErrorCallback = TIM_DMAError ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3382
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3383 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3384 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)BurstBuffer, (uint32_t)&htim->Instance->DMAR, ((BurstLength) >> 8) + 1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3385 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3386 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3387 case TIM_DMA_CC2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3388 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3389 /* Set the DMA Period elapsed callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3390 htim->hdma[TIM_DMA_ID_CC2]->XferCpltCallback = TIM_DMADelayPulseCplt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3391
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3392 /* Set the DMA error callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3393 htim->hdma[TIM_DMA_ID_CC2]->XferErrorCallback = TIM_DMAError ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3394
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3395 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3396 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)BurstBuffer, (uint32_t)&htim->Instance->DMAR, ((BurstLength) >> 8) + 1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3397 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3398 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3399 case TIM_DMA_CC3:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3400 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3401 /* Set the DMA Period elapsed callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3402 htim->hdma[TIM_DMA_ID_CC3]->XferCpltCallback = TIM_DMADelayPulseCplt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3403
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3404 /* Set the DMA error callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3405 htim->hdma[TIM_DMA_ID_CC3]->XferErrorCallback = TIM_DMAError ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3406
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3407 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3408 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC3], (uint32_t)BurstBuffer, (uint32_t)&htim->Instance->DMAR, ((BurstLength) >> 8) + 1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3409 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3410 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3411 case TIM_DMA_CC4:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3412 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3413 /* Set the DMA Period elapsed callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3414 htim->hdma[TIM_DMA_ID_CC4]->XferCpltCallback = TIM_DMADelayPulseCplt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3415
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3416 /* Set the DMA error callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3417 htim->hdma[TIM_DMA_ID_CC4]->XferErrorCallback = TIM_DMAError ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3418
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3419 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3420 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC4], (uint32_t)BurstBuffer, (uint32_t)&htim->Instance->DMAR, ((BurstLength) >> 8) + 1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3421 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3422 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3423 case TIM_DMA_COM:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3424 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3425 /* Set the DMA Period elapsed callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3426 htim->hdma[TIM_DMA_ID_COMMUTATION]->XferCpltCallback = TIMEx_DMACommutationCplt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3427
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3428 /* Set the DMA error callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3429 htim->hdma[TIM_DMA_ID_COMMUTATION]->XferErrorCallback = TIM_DMAError ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3430
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3431 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3432 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_COMMUTATION], (uint32_t)BurstBuffer, (uint32_t)&htim->Instance->DMAR, ((BurstLength) >> 8) + 1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3433 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3434 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3435 case TIM_DMA_TRIGGER:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3436 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3437 /* Set the DMA Period elapsed callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3438 htim->hdma[TIM_DMA_ID_TRIGGER]->XferCpltCallback = TIM_DMATriggerCplt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3439
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3440 /* Set the DMA error callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3441 htim->hdma[TIM_DMA_ID_TRIGGER]->XferErrorCallback = TIM_DMAError ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3442
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3443 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3444 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_TRIGGER], (uint32_t)BurstBuffer, (uint32_t)&htim->Instance->DMAR, ((BurstLength) >> 8) + 1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3445 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3446 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3447 default:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3448 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3449 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3450 /* configure the DMA Burst Mode */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3451 htim->Instance->DCR = BurstBaseAddress | BurstLength;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3452
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3453 /* Enable the TIM DMA Request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3454 __HAL_TIM_ENABLE_DMA(htim, BurstRequestSrc);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3455
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3456 htim->State = HAL_TIM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3457
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3458 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3459 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3460 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3461
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3462 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3463 * @brief Stops the TIM DMA Burst mode
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3464 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3465 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3466 * @param BurstRequestSrc: TIM DMA Request sources to disable
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3467 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3468 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3469 HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStop(TIM_HandleTypeDef *htim, uint32_t BurstRequestSrc)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3470 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3471 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3472 assert_param(IS_TIM_DMA_SOURCE(BurstRequestSrc));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3473
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3474 /* Abort the DMA transfer (at least disable the DMA channel) */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3475 switch(BurstRequestSrc)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3476 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3477 case TIM_DMA_UPDATE:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3478 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3479 HAL_DMA_Abort(htim->hdma[TIM_DMA_ID_UPDATE]);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3480 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3481 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3482 case TIM_DMA_CC1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3483 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3484 HAL_DMA_Abort(htim->hdma[TIM_DMA_ID_CC1]);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3485 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3486 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3487 case TIM_DMA_CC2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3488 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3489 HAL_DMA_Abort(htim->hdma[TIM_DMA_ID_CC2]);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3490 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3491 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3492 case TIM_DMA_CC3:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3493 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3494 HAL_DMA_Abort(htim->hdma[TIM_DMA_ID_CC3]);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3495 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3496 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3497 case TIM_DMA_CC4:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3498 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3499 HAL_DMA_Abort(htim->hdma[TIM_DMA_ID_CC4]);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3500 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3501 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3502 case TIM_DMA_COM:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3503 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3504 HAL_DMA_Abort(htim->hdma[TIM_DMA_ID_COMMUTATION]);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3505 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3506 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3507 case TIM_DMA_TRIGGER:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3508 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3509 HAL_DMA_Abort(htim->hdma[TIM_DMA_ID_TRIGGER]);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3510 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3511 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3512 default:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3513 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3514 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3515
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3516 /* Disable the TIM Update DMA request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3517 __HAL_TIM_DISABLE_DMA(htim, BurstRequestSrc);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3518
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3519 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3520 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3521 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3522
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3523 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3524 * @brief Configure the DMA Burst to transfer Data from the TIM peripheral to the memory
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3525 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3526 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3527 * @param BurstBaseAddress: TIM Base address from when the DMA will starts the Data read.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3528 * This parameters can be on of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3529 * @arg TIM_DMABASE_CR1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3530 * @arg TIM_DMABASE_CR2
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3531 * @arg TIM_DMABASE_SMCR
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3532 * @arg TIM_DMABASE_DIER
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3533 * @arg TIM_DMABASE_SR
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3534 * @arg TIM_DMABASE_EGR
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3535 * @arg TIM_DMABASE_CCMR1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3536 * @arg TIM_DMABASE_CCMR2
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3537 * @arg TIM_DMABASE_CCER
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3538 * @arg TIM_DMABASE_CNT
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3539 * @arg TIM_DMABASE_PSC
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3540 * @arg TIM_DMABASE_ARR
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3541 * @arg TIM_DMABASE_RCR
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3542 * @arg TIM_DMABASE_CCR1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3543 * @arg TIM_DMABASE_CCR2
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3544 * @arg TIM_DMABASE_CCR3
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3545 * @arg TIM_DMABASE_CCR4
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3546 * @arg TIM_DMABASE_BDTR
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3547 * @arg TIM_DMABASE_DCR
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3548 * @param BurstRequestSrc: TIM DMA Request sources.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3549 * This parameters can be on of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3550 * @arg TIM_DMA_UPDATE: TIM update Interrupt source
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3551 * @arg TIM_DMA_CC1: TIM Capture Compare 1 DMA source
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3552 * @arg TIM_DMA_CC2: TIM Capture Compare 2 DMA source
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3553 * @arg TIM_DMA_CC3: TIM Capture Compare 3 DMA source
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3554 * @arg TIM_DMA_CC4: TIM Capture Compare 4 DMA source
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3555 * @arg TIM_DMA_COM: TIM Commutation DMA source
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3556 * @arg TIM_DMA_TRIGGER: TIM Trigger DMA source
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3557 * @param BurstBuffer: The Buffer address.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3558 * @param BurstLength: DMA Burst length. This parameter can be one value
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3559 * between TIM_DMABURSTLENGTH_1TRANSFER and TIM_DMABURSTLENGTH_18TRANSFERS.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3560 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3561 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3562 HAL_StatusTypeDef HAL_TIM_DMABurst_ReadStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress, uint32_t BurstRequestSrc,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3563 uint32_t *BurstBuffer, uint32_t BurstLength)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3564 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3565 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3566 assert_param(IS_TIM_DMABURST_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3567 assert_param(IS_TIM_DMA_BASE(BurstBaseAddress));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3568 assert_param(IS_TIM_DMA_SOURCE(BurstRequestSrc));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3569 assert_param(IS_TIM_DMA_LENGTH(BurstLength));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3570
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3571 if((htim->State == HAL_TIM_STATE_BUSY))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3572 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3573 return HAL_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3574 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3575 else if((htim->State == HAL_TIM_STATE_READY))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3576 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3577 if((BurstBuffer == 0 ) && (BurstLength > 0))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3578 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3579 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3580 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3581 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3582 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3583 htim->State = HAL_TIM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3584 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3585 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3586 switch(BurstRequestSrc)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3587 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3588 case TIM_DMA_UPDATE:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3589 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3590 /* Set the DMA Period elapsed callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3591 htim->hdma[TIM_DMA_ID_UPDATE]->XferCpltCallback = TIM_DMAPeriodElapsedCplt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3592
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3593 /* Set the DMA error callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3594 htim->hdma[TIM_DMA_ID_UPDATE]->XferErrorCallback = TIM_DMAError ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3595
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3596 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3597 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_UPDATE], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer, ((BurstLength) >> 8) + 1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3598 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3599 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3600 case TIM_DMA_CC1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3601 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3602 /* Set the DMA Period elapsed callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3603 htim->hdma[TIM_DMA_ID_CC1]->XferCpltCallback = TIM_DMACaptureCplt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3604
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3605 /* Set the DMA error callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3606 htim->hdma[TIM_DMA_ID_CC1]->XferErrorCallback = TIM_DMAError ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3607
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3608 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3609 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer, ((BurstLength) >> 8) + 1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3610 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3611 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3612 case TIM_DMA_CC2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3613 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3614 /* Set the DMA Period elapsed callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3615 htim->hdma[TIM_DMA_ID_CC2]->XferCpltCallback = TIM_DMACaptureCplt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3616
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3617 /* Set the DMA error callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3618 htim->hdma[TIM_DMA_ID_CC2]->XferErrorCallback = TIM_DMAError ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3619
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3620 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3621 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer, ((BurstLength) >> 8) + 1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3622 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3623 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3624 case TIM_DMA_CC3:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3625 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3626 /* Set the DMA Period elapsed callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3627 htim->hdma[TIM_DMA_ID_CC3]->XferCpltCallback = TIM_DMACaptureCplt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3628
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3629 /* Set the DMA error callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3630 htim->hdma[TIM_DMA_ID_CC3]->XferErrorCallback = TIM_DMAError ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3631
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3632 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3633 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC3], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer, ((BurstLength) >> 8) + 1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3634 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3635 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3636 case TIM_DMA_CC4:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3637 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3638 /* Set the DMA Period elapsed callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3639 htim->hdma[TIM_DMA_ID_CC4]->XferCpltCallback = TIM_DMACaptureCplt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3640
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3641 /* Set the DMA error callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3642 htim->hdma[TIM_DMA_ID_CC4]->XferErrorCallback = TIM_DMAError ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3643
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3644 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3645 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC4], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer, ((BurstLength) >> 8) + 1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3646 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3647 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3648 case TIM_DMA_COM:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3649 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3650 /* Set the DMA Period elapsed callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3651 htim->hdma[TIM_DMA_ID_COMMUTATION]->XferCpltCallback = TIMEx_DMACommutationCplt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3652
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3653 /* Set the DMA error callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3654 htim->hdma[TIM_DMA_ID_COMMUTATION]->XferErrorCallback = TIM_DMAError ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3655
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3656 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3657 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_COMMUTATION], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer, ((BurstLength) >> 8) + 1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3658 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3659 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3660 case TIM_DMA_TRIGGER:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3661 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3662 /* Set the DMA Period elapsed callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3663 htim->hdma[TIM_DMA_ID_TRIGGER]->XferCpltCallback = TIM_DMATriggerCplt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3664
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3665 /* Set the DMA error callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3666 htim->hdma[TIM_DMA_ID_TRIGGER]->XferErrorCallback = TIM_DMAError ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3667
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3668 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3669 HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_TRIGGER], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer, ((BurstLength) >> 8) + 1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3670 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3671 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3672 default:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3673 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3674 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3675
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3676 /* configure the DMA Burst Mode */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3677 htim->Instance->DCR = BurstBaseAddress | BurstLength;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3678
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3679 /* Enable the TIM DMA Request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3680 __HAL_TIM_ENABLE_DMA(htim, BurstRequestSrc);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3681
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3682 htim->State = HAL_TIM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3683
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3684 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3685 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3686 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3687
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3688 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3689 * @brief Stop the DMA burst reading
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3690 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3691 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3692 * @param BurstRequestSrc: TIM DMA Request sources to disable.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3693 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3694 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3695 HAL_StatusTypeDef HAL_TIM_DMABurst_ReadStop(TIM_HandleTypeDef *htim, uint32_t BurstRequestSrc)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3696 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3697 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3698 assert_param(IS_TIM_DMA_SOURCE(BurstRequestSrc));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3699
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3700 /* Abort the DMA transfer (at least disable the DMA channel) */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3701 switch(BurstRequestSrc)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3702 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3703 case TIM_DMA_UPDATE:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3704 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3705 HAL_DMA_Abort(htim->hdma[TIM_DMA_ID_UPDATE]);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3706 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3707 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3708 case TIM_DMA_CC1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3709 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3710 HAL_DMA_Abort(htim->hdma[TIM_DMA_ID_CC1]);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3711 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3712 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3713 case TIM_DMA_CC2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3714 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3715 HAL_DMA_Abort(htim->hdma[TIM_DMA_ID_CC2]);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3716 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3717 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3718 case TIM_DMA_CC3:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3719 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3720 HAL_DMA_Abort(htim->hdma[TIM_DMA_ID_CC3]);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3721 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3722 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3723 case TIM_DMA_CC4:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3724 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3725 HAL_DMA_Abort(htim->hdma[TIM_DMA_ID_CC4]);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3726 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3727 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3728 case TIM_DMA_COM:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3729 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3730 HAL_DMA_Abort(htim->hdma[TIM_DMA_ID_COMMUTATION]);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3731 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3732 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3733 case TIM_DMA_TRIGGER:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3734 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3735 HAL_DMA_Abort(htim->hdma[TIM_DMA_ID_TRIGGER]);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3736 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3737 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3738 default:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3739 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3740 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3741
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3742 /* Disable the TIM Update DMA request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3743 __HAL_TIM_DISABLE_DMA(htim, BurstRequestSrc);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3744
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3745 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3746 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3747 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3748
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3749 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3750 * @brief Generate a software event
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3751 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3752 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3753 * @param EventSource: specifies the event source.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3754 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3755 * @arg TIM_EVENTSOURCE_UPDATE: Timer update Event source
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3756 * @arg TIM_EVENTSOURCE_CC1: Timer Capture Compare 1 Event source
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3757 * @arg TIM_EVENTSOURCE_CC2: Timer Capture Compare 2 Event source
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3758 * @arg TIM_EVENTSOURCE_CC3: Timer Capture Compare 3 Event source
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3759 * @arg TIM_EVENTSOURCE_CC4: Timer Capture Compare 4 Event source
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3760 * @arg TIM_EVENTSOURCE_COM: Timer COM event source
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3761 * @arg TIM_EVENTSOURCE_TRIGGER: Timer Trigger Event source
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3762 * @arg TIM_EVENTSOURCE_BREAK: Timer Break event source
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3763 * @note TIM6 and TIM7 can only generate an update event.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3764 * @note TIM_EVENTSOURCE_COM and TIM_EVENTSOURCE_BREAK are used only with TIM1 and TIM8.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3765 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3766 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3767
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3768 HAL_StatusTypeDef HAL_TIM_GenerateEvent(TIM_HandleTypeDef *htim, uint32_t EventSource)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3769 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3770 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3771 assert_param(IS_TIM_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3772 assert_param(IS_TIM_EVENT_SOURCE(EventSource));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3773
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3774 /* Process Locked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3775 __HAL_LOCK(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3776
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3777 /* Change the TIM state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3778 htim->State = HAL_TIM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3779
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3780 /* Set the event sources */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3781 htim->Instance->EGR = EventSource;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3782
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3783 /* Change the TIM state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3784 htim->State = HAL_TIM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3785
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3786 __HAL_UNLOCK(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3787
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3788 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3789 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3790 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3791
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3792 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3793 * @brief Configures the OCRef clear feature
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3794 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3795 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3796 * @param sClearInputConfig: pointer to a TIM_ClearInputConfigTypeDef structure that
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3797 * contains the OCREF clear feature and parameters for the TIM peripheral.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3798 * @param Channel: specifies the TIM Channel.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3799 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3800 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3801 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3802 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3803 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3804 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3805 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3806 HAL_StatusTypeDef HAL_TIM_ConfigOCrefClear(TIM_HandleTypeDef *htim, TIM_ClearInputConfigTypeDef * sClearInputConfig, uint32_t Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3807 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3808 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3809 assert_param(IS_TIM_CC1_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3810 assert_param(IS_TIM_CHANNELS(Channel));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3811 assert_param(IS_TIM_CLEARINPUT_SOURCE(sClearInputConfig->ClearInputSource));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3812 assert_param(IS_TIM_CLEARINPUT_POLARITY(sClearInputConfig->ClearInputPolarity));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3813 assert_param(IS_TIM_CLEARINPUT_PRESCALER(sClearInputConfig->ClearInputPrescaler));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3814 assert_param(IS_TIM_CLEARINPUT_FILTER(sClearInputConfig->ClearInputFilter));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3815
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3816 /* Process Locked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3817 __HAL_LOCK(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3818
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3819 htim->State = HAL_TIM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3820
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3821 if(sClearInputConfig->ClearInputSource == TIM_CLEARINPUTSOURCE_ETR)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3822 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3823 TIM_ETR_SetConfig(htim->Instance,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3824 sClearInputConfig->ClearInputPrescaler,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3825 sClearInputConfig->ClearInputPolarity,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3826 sClearInputConfig->ClearInputFilter);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3827 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3828
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3829 switch (Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3830 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3831 case TIM_CHANNEL_1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3832 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3833 if(sClearInputConfig->ClearInputState != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3834 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3835 /* Enable the Ocref clear feature for Channel 1 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3836 htim->Instance->CCMR1 |= TIM_CCMR1_OC1CE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3837 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3838 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3839 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3840 /* Disable the Ocref clear feature for Channel 1 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3841 htim->Instance->CCMR1 &= ~TIM_CCMR1_OC1CE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3842 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3843 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3844 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3845 case TIM_CHANNEL_2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3846 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3847 assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3848 if(sClearInputConfig->ClearInputState != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3849 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3850 /* Enable the Ocref clear feature for Channel 2 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3851 htim->Instance->CCMR1 |= TIM_CCMR1_OC2CE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3852 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3853 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3854 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3855 /* Disable the Ocref clear feature for Channel 2 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3856 htim->Instance->CCMR1 &= ~TIM_CCMR1_OC2CE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3857 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3858 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3859 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3860 case TIM_CHANNEL_3:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3861 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3862 assert_param(IS_TIM_CC3_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3863 if(sClearInputConfig->ClearInputState != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3864 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3865 /* Enable the Ocref clear feature for Channel 3 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3866 htim->Instance->CCMR2 |= TIM_CCMR2_OC3CE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3867 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3868 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3869 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3870 /* Disable the Ocref clear feature for Channel 3 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3871 htim->Instance->CCMR2 &= ~TIM_CCMR2_OC3CE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3872 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3873 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3874 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3875 case TIM_CHANNEL_4:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3876 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3877 assert_param(IS_TIM_CC4_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3878 if(sClearInputConfig->ClearInputState != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3879 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3880 /* Enable the Ocref clear feature for Channel 4 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3881 htim->Instance->CCMR2 |= TIM_CCMR2_OC4CE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3882 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3883 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3884 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3885 /* Disable the Ocref clear feature for Channel 4 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3886 htim->Instance->CCMR2 &= ~TIM_CCMR2_OC4CE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3887 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3888 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3889 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3890 default:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3891 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3892 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3893
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3894 htim->State = HAL_TIM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3895
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3896 __HAL_UNLOCK(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3897
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3898 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3899 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3900
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3901 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3902 * @brief Configures the clock source to be used
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3903 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3904 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3905 * @param sClockSourceConfig: pointer to a TIM_ClockConfigTypeDef structure that
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3906 * contains the clock source information for the TIM peripheral.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3907 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3908 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3909 HAL_StatusTypeDef HAL_TIM_ConfigClockSource(TIM_HandleTypeDef *htim, TIM_ClockConfigTypeDef * sClockSourceConfig)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3910 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3911 uint32_t tmpsmcr = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3912
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3913 /* Process Locked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3914 __HAL_LOCK(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3915
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3916 htim->State = HAL_TIM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3917
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3918 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3919 assert_param(IS_TIM_CLOCKSOURCE(sClockSourceConfig->ClockSource));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3920 assert_param(IS_TIM_CLOCKPOLARITY(sClockSourceConfig->ClockPolarity));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3921 assert_param(IS_TIM_CLOCKPRESCALER(sClockSourceConfig->ClockPrescaler));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3922 assert_param(IS_TIM_CLOCKFILTER(sClockSourceConfig->ClockFilter));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3923
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3924 /* Reset the SMS, TS, ECE, ETPS and ETRF bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3925 tmpsmcr = htim->Instance->SMCR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3926 tmpsmcr &= ~(TIM_SMCR_SMS | TIM_SMCR_TS);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3927 tmpsmcr &= ~(TIM_SMCR_ETF | TIM_SMCR_ETPS | TIM_SMCR_ECE | TIM_SMCR_ETP);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3928 htim->Instance->SMCR = tmpsmcr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3929
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3930 switch (sClockSourceConfig->ClockSource)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3931 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3932 case TIM_CLOCKSOURCE_INTERNAL:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3933 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3934 assert_param(IS_TIM_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3935 /* Disable slave mode to clock the prescaler directly with the internal clock */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3936 htim->Instance->SMCR &= ~TIM_SMCR_SMS;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3937 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3938 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3939
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3940 case TIM_CLOCKSOURCE_ETRMODE1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3941 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3942 assert_param(IS_TIM_ETR_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3943 /* Configure the ETR Clock source */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3944 TIM_ETR_SetConfig(htim->Instance,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3945 sClockSourceConfig->ClockPrescaler,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3946 sClockSourceConfig->ClockPolarity,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3947 sClockSourceConfig->ClockFilter);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3948 /* Get the TIMx SMCR register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3949 tmpsmcr = htim->Instance->SMCR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3950 /* Reset the SMS and TS Bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3951 tmpsmcr &= ~(TIM_SMCR_SMS | TIM_SMCR_TS);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3952 /* Select the External clock mode1 and the ETRF trigger */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3953 tmpsmcr |= (TIM_SLAVEMODE_EXTERNAL1 | TIM_CLOCKSOURCE_ETRMODE1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3954 /* Write to TIMx SMCR */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3955 htim->Instance->SMCR = tmpsmcr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3956 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3957 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3958
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3959 case TIM_CLOCKSOURCE_ETRMODE2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3960 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3961 assert_param(IS_TIM_ETR_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3962 /* Configure the ETR Clock source */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3963 TIM_ETR_SetConfig(htim->Instance,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3964 sClockSourceConfig->ClockPrescaler,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3965 sClockSourceConfig->ClockPolarity,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3966 sClockSourceConfig->ClockFilter);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3967 /* Enable the External clock mode2 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3968 htim->Instance->SMCR |= TIM_SMCR_ECE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3969 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3970 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3971
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3972 case TIM_CLOCKSOURCE_TI1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3973 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3974 assert_param(IS_TIM_CC1_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3975 TIM_TI1_ConfigInputStage(htim->Instance,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3976 sClockSourceConfig->ClockPolarity,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3977 sClockSourceConfig->ClockFilter);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3978 TIM_ITRx_SetConfig(htim->Instance, TIM_CLOCKSOURCE_TI1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3979 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3980 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3981 case TIM_CLOCKSOURCE_TI2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3982 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3983 assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3984 TIM_TI2_ConfigInputStage(htim->Instance,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3985 sClockSourceConfig->ClockPolarity,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3986 sClockSourceConfig->ClockFilter);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3987 TIM_ITRx_SetConfig(htim->Instance, TIM_CLOCKSOURCE_TI2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3988 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3989 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3990 case TIM_CLOCKSOURCE_TI1ED:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3991 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3992 assert_param(IS_TIM_CC1_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3993 TIM_TI1_ConfigInputStage(htim->Instance,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3994 sClockSourceConfig->ClockPolarity,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3995 sClockSourceConfig->ClockFilter);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3996 TIM_ITRx_SetConfig(htim->Instance, TIM_CLOCKSOURCE_TI1ED);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3997 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3998 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3999 case TIM_CLOCKSOURCE_ITR0:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4000 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4001 assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4002 TIM_ITRx_SetConfig(htim->Instance, TIM_CLOCKSOURCE_ITR0);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4003 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4004 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4005 case TIM_CLOCKSOURCE_ITR1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4006 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4007 assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4008 TIM_ITRx_SetConfig(htim->Instance, TIM_CLOCKSOURCE_ITR1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4009 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4010 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4011 case TIM_CLOCKSOURCE_ITR2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4012 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4013 assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4014 TIM_ITRx_SetConfig(htim->Instance, TIM_CLOCKSOURCE_ITR2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4015 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4016 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4017 case TIM_CLOCKSOURCE_ITR3:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4018 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4019 assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4020 TIM_ITRx_SetConfig(htim->Instance, TIM_CLOCKSOURCE_ITR3);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4021 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4022 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4023
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4024 default:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4025 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4026 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4027 htim->State = HAL_TIM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4028
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4029 __HAL_UNLOCK(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4030
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4031 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4032 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4033
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4034 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4035 * @brief Selects the signal connected to the TI1 input: direct from CH1_input
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4036 * or a XOR combination between CH1_input, CH2_input & CH3_input
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4037 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4038 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4039 * @param TI1_Selection: Indicate whether or not channel 1 is connected to the
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4040 * output of a XOR gate.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4041 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4042 * @arg TIM_TI1SELECTION_CH1: The TIMx_CH1 pin is connected to TI1 input
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4043 * @arg TIM_TI1SELECTION_XORCOMBINATION: The TIMx_CH1, CH2 and CH3
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4044 * pins are connected to the TI1 input (XOR combination)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4045 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4046 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4047 HAL_StatusTypeDef HAL_TIM_ConfigTI1Input(TIM_HandleTypeDef *htim, uint32_t TI1_Selection)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4048 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4049 uint32_t tmpcr2 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4050
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4051 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4052 assert_param(IS_TIM_XOR_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4053 assert_param(IS_TIM_TI1SELECTION(TI1_Selection));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4054
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4055 /* Get the TIMx CR2 register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4056 tmpcr2 = htim->Instance->CR2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4057
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4058 /* Reset the TI1 selection */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4059 tmpcr2 &= ~TIM_CR2_TI1S;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4060
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4061 /* Set the TI1 selection */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4062 tmpcr2 |= TI1_Selection;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4063
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4064 /* Write to TIMxCR2 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4065 htim->Instance->CR2 = tmpcr2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4066
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4067 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4068 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4069
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4070 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4071 * @brief Configures the TIM in Slave mode
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4072 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4073 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4074 * @param sSlaveConfig: pointer to a TIM_SlaveConfigTypeDef structure that
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4075 * contains the selected trigger (internal trigger input, filtered
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4076 * timer input or external trigger input) and the ) and the Slave
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4077 * mode (Disable, Reset, Gated, Trigger, External clock mode 1).
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4078 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4079 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4080 HAL_StatusTypeDef HAL_TIM_SlaveConfigSynchronization(TIM_HandleTypeDef *htim, TIM_SlaveConfigTypeDef * sSlaveConfig)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4081 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4082 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4083 assert_param(IS_TIM_SLAVE_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4084 assert_param(IS_TIM_SLAVE_MODE(sSlaveConfig->SlaveMode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4085 assert_param(IS_TIM_TRIGGER_SELECTION(sSlaveConfig->InputTrigger));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4086
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4087 __HAL_LOCK(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4088
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4089 htim->State = HAL_TIM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4090
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4091 TIM_SlaveTimer_SetConfig(htim, sSlaveConfig);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4092
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4093 /* Disable Trigger Interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4094 __HAL_TIM_DISABLE_IT(htim, TIM_IT_TRIGGER);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4095
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4096 /* Disable Trigger DMA request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4097 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_TRIGGER);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4098
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4099 htim->State = HAL_TIM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4100
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4101 __HAL_UNLOCK(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4102
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4103 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4104 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4105
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4106 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4107 * @brief Configures the TIM in Slave mode in interrupt mode
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4108 * @param htim: TIM handle.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4109 * @param sSlaveConfig: pointer to a TIM_SlaveConfigTypeDef structure that
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4110 * contains the selected trigger (internal trigger input, filtered
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4111 * timer input or external trigger input) and the ) and the Slave
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4112 * mode (Disable, Reset, Gated, Trigger, External clock mode 1).
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4113 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4114 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4115 HAL_StatusTypeDef HAL_TIM_SlaveConfigSynchronization_IT(TIM_HandleTypeDef *htim,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4116 TIM_SlaveConfigTypeDef * sSlaveConfig)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4117 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4118 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4119 assert_param(IS_TIM_SLAVE_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4120 assert_param(IS_TIM_SLAVE_MODE(sSlaveConfig->SlaveMode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4121 assert_param(IS_TIM_TRIGGER_SELECTION(sSlaveConfig->InputTrigger));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4122
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4123 __HAL_LOCK(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4124
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4125 htim->State = HAL_TIM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4126
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4127 TIM_SlaveTimer_SetConfig(htim, sSlaveConfig);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4128
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4129 /* Enable Trigger Interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4130 __HAL_TIM_ENABLE_IT(htim, TIM_IT_TRIGGER);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4131
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4132 /* Disable Trigger DMA request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4133 __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_TRIGGER);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4134
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4135 htim->State = HAL_TIM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4136
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4137 __HAL_UNLOCK(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4138
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4139 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4140 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4141
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4142 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4143 * @brief Read the captured value from Capture Compare unit
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4144 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4145 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4146 * @param Channel: TIM Channels to be enabled.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4147 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4148 * @arg TIM_CHANNEL_1: TIM Channel 1 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4149 * @arg TIM_CHANNEL_2: TIM Channel 2 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4150 * @arg TIM_CHANNEL_3: TIM Channel 3 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4151 * @arg TIM_CHANNEL_4: TIM Channel 4 selected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4152 * @retval Captured value
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4153 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4154 uint32_t HAL_TIM_ReadCapturedValue(TIM_HandleTypeDef *htim, uint32_t Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4155 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4156 uint32_t tmpreg = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4157
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4158 __HAL_LOCK(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4159
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4160 switch (Channel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4161 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4162 case TIM_CHANNEL_1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4163 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4164 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4165 assert_param(IS_TIM_CC1_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4166
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4167 /* Return the capture 1 value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4168 tmpreg = htim->Instance->CCR1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4169
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4170 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4171 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4172 case TIM_CHANNEL_2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4173 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4174 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4175 assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4176
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4177 /* Return the capture 2 value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4178 tmpreg = htim->Instance->CCR2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4179
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4180 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4181 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4182
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4183 case TIM_CHANNEL_3:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4184 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4185 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4186 assert_param(IS_TIM_CC3_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4187
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4188 /* Return the capture 3 value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4189 tmpreg = htim->Instance->CCR3;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4190
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4191 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4192 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4193
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4194 case TIM_CHANNEL_4:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4195 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4196 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4197 assert_param(IS_TIM_CC4_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4198
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4199 /* Return the capture 4 value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4200 tmpreg = htim->Instance->CCR4;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4201
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4202 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4203 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4204
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4205 default:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4206 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4207 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4208
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4209 __HAL_UNLOCK(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4210 return tmpreg;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4211 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4212 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4213 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4214 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4215
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4216 /** @defgroup TIM_Exported_Functions_Group9 TIM Callbacks functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4217 * @brief TIM Callbacks functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4218 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4219 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4220 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4221 ##### TIM Callbacks functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4222 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4223 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4224 This section provides TIM callback functions:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4225 (+) Timer Period elapsed callback
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4226 (+) Timer Output Compare callback
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4227 (+) Timer Input capture callback
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4228 (+) Timer Trigger callback
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4229 (+) Timer Error callback
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4230
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4231 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4232 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4233 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4234
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4235 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4236 * @brief Period elapsed callback in non blocking mode
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4237 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4238 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4239 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4240 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4241 __weak void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4242 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4243 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4244 the __HAL_TIM_PeriodElapsedCallback could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4245 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4246
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4247 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4248 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4249 * @brief Output Compare callback in non blocking mode
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4250 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4251 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4252 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4253 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4254 __weak void HAL_TIM_OC_DelayElapsedCallback(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4255 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4256 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4257 the __HAL_TIM_OC_DelayElapsedCallback could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4258 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4259 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4260 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4261 * @brief Input Capture callback in non blocking mode
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4262 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4263 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4264 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4265 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4266 __weak void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4267 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4268 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4269 the __HAL_TIM_IC_CaptureCallback could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4270 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4271 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4272
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4273 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4274 * @brief PWM Pulse finished callback in non blocking mode
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4275 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4276 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4277 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4278 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4279 __weak void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4280 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4281 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4282 the __HAL_TIM_PWM_PulseFinishedCallback could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4283 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4284 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4285
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4286 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4287 * @brief Hall Trigger detection callback in non blocking mode
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4288 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4289 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4290 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4291 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4292 __weak void HAL_TIM_TriggerCallback(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4293 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4294 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4295 the HAL_TIM_TriggerCallback could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4296 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4297 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4298
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4299 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4300 * @brief Timer error callback in non blocking mode
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4301 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4302 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4303 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4304 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4305 __weak void HAL_TIM_ErrorCallback(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4306 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4307 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4308 the HAL_TIM_ErrorCallback could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4309 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4310 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4311 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4312 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4313 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4314
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4315 /** @defgroup TIM_Exported_Functions_Group10 Peripheral State functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4316 * @brief Peripheral State functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4317 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4318 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4319 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4320 ##### Peripheral State functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4321 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4322 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4323 This subsection permits to get in run-time the status of the peripheral
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4324 and the data flow.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4325
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4326 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4327 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4328 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4329
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4330 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4331 * @brief Return the TIM Base state
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4332 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4333 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4334 * @retval HAL state
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4335 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4336 HAL_TIM_StateTypeDef HAL_TIM_Base_GetState(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4337 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4338 return htim->State;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4339 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4340
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4341 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4342 * @brief Return the TIM OC state
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4343 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4344 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4345 * @retval HAL state
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4346 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4347 HAL_TIM_StateTypeDef HAL_TIM_OC_GetState(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4348 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4349 return htim->State;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4350 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4351
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4352 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4353 * @brief Return the TIM PWM state
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4354 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4355 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4356 * @retval HAL state
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4357 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4358 HAL_TIM_StateTypeDef HAL_TIM_PWM_GetState(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4359 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4360 return htim->State;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4361 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4362
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4363 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4364 * @brief Return the TIM Input Capture state
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4365 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4366 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4367 * @retval HAL state
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4368 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4369 HAL_TIM_StateTypeDef HAL_TIM_IC_GetState(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4370 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4371 return htim->State;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4372 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4373
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4374 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4375 * @brief Return the TIM One Pulse Mode state
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4376 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4377 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4378 * @retval HAL state
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4379 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4380 HAL_TIM_StateTypeDef HAL_TIM_OnePulse_GetState(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4381 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4382 return htim->State;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4383 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4384
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4385 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4386 * @brief Return the TIM Encoder Mode state
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4387 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4388 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4389 * @retval HAL state
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4390 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4391 HAL_TIM_StateTypeDef HAL_TIM_Encoder_GetState(TIM_HandleTypeDef *htim)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4392 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4393 return htim->State;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4394 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4395 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4396 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4397 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4398
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4399 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4400 * @brief Time Base configuration
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4401 * @param TIMx: TIM peripheral
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4402 * @param Structure: pointer on TIM Time Base required parameters
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4403 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4404 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4405 void TIM_Base_SetConfig(TIM_TypeDef *TIMx, TIM_Base_InitTypeDef *Structure)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4406 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4407 uint32_t tmpcr1 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4408 tmpcr1 = TIMx->CR1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4409
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4410 /* Set TIM Time Base Unit parameters ---------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4411 if(IS_TIM_CC3_INSTANCE(TIMx) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4412 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4413 /* Select the Counter Mode */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4414 tmpcr1 &= ~(TIM_CR1_DIR | TIM_CR1_CMS);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4415 tmpcr1 |= Structure->CounterMode;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4416 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4417
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4418 if(IS_TIM_CC1_INSTANCE(TIMx) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4419 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4420 /* Set the clock division */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4421 tmpcr1 &= ~TIM_CR1_CKD;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4422 tmpcr1 |= (uint32_t)Structure->ClockDivision;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4423 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4424
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4425 TIMx->CR1 = tmpcr1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4426
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4427 /* Set the Auto-reload value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4428 TIMx->ARR = (uint32_t)Structure->Period ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4429
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4430 /* Set the Prescaler value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4431 TIMx->PSC = (uint32_t)Structure->Prescaler;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4432
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4433 if(IS_TIM_ADVANCED_INSTANCE(TIMx) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4434 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4435 /* Set the Repetition Counter value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4436 TIMx->RCR = Structure->RepetitionCounter;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4437 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4438
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4439 /* Generate an update event to reload the Prescaler
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4440 and the repetition counter(only for TIM1 and TIM8) value immediately */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4441 TIMx->EGR = TIM_EGR_UG;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4442 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4443
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4444 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4445 * @brief Configure the TI1 as Input.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4446 * @param TIMx to select the TIM peripheral.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4447 * @param TIM_ICPolarity : The Input Polarity.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4448 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4449 * @arg TIM_ICPolarity_Rising
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4450 * @arg TIM_ICPolarity_Falling
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4451 * @arg TIM_ICPolarity_BothEdge
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4452 * @param TIM_ICSelection: specifies the input to be used.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4453 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4454 * @arg TIM_ICSelection_DirectTI: TIM Input 1 is selected to be connected to IC1.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4455 * @arg TIM_ICSelection_IndirectTI: TIM Input 1 is selected to be connected to IC2.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4456 * @arg TIM_ICSelection_TRC: TIM Input 1 is selected to be connected to TRC.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4457 * @param TIM_ICFilter: Specifies the Input Capture Filter.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4458 * This parameter must be a value between 0x00 and 0x0F.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4459 * @note TIM_ICFilter and TIM_ICPolarity are not used in INDIRECT mode as TI2FP1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4460 * (on channel2 path) is used as the input signal. Therefore CCMR1 must be
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4461 * protected against un-initialized filter and polarity values.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4462 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4463 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4464 void TIM_TI1_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4465 uint32_t TIM_ICFilter)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4466 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4467 uint32_t tmpccmr1 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4468 uint32_t tmpccer = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4469
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4470 /* Disable the Channel 1: Reset the CC1E Bit */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4471 TIMx->CCER &= ~TIM_CCER_CC1E;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4472 tmpccmr1 = TIMx->CCMR1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4473 tmpccer = TIMx->CCER;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4474
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4475 /* Select the Input */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4476 if(IS_TIM_CC2_INSTANCE(TIMx) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4477 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4478 tmpccmr1 &= ~TIM_CCMR1_CC1S;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4479 tmpccmr1 |= TIM_ICSelection;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4480 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4481 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4482 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4483 tmpccmr1 &= ~TIM_CCMR1_CC1S;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4484 tmpccmr1 |= TIM_CCMR1_CC1S_0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4485 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4486
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4487 /* Set the filter */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4488 tmpccmr1 &= ~TIM_CCMR1_IC1F;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4489 tmpccmr1 |= ((TIM_ICFilter << 4) & TIM_CCMR1_IC1F);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4490
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4491 /* Select the Polarity and set the CC1E Bit */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4492 tmpccer &= ~(TIM_CCER_CC1P | TIM_CCER_CC1NP);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4493 tmpccer |= (TIM_ICPolarity & (TIM_CCER_CC1P | TIM_CCER_CC1NP));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4494
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4495 /* Write to TIMx CCMR1 and CCER registers */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4496 TIMx->CCMR1 = tmpccmr1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4497 TIMx->CCER = tmpccer;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4498 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4499
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4500 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4501 * @brief Time Output Compare 2 configuration
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4502 * @param TIMx to select the TIM peripheral
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4503 * @param OC_Config: The output configuration structure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4504 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4505 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4506 void TIM_OC2_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4507 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4508 uint32_t tmpccmrx = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4509 uint32_t tmpccer = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4510 uint32_t tmpcr2 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4511
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4512 /* Disable the Channel 2: Reset the CC2E Bit */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4513 TIMx->CCER &= ~TIM_CCER_CC2E;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4514
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4515 /* Get the TIMx CCER register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4516 tmpccer = TIMx->CCER;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4517 /* Get the TIMx CR2 register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4518 tmpcr2 = TIMx->CR2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4519
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4520 /* Get the TIMx CCMR1 register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4521 tmpccmrx = TIMx->CCMR1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4522
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4523 /* Reset the Output Compare mode and Capture/Compare selection Bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4524 tmpccmrx &= ~TIM_CCMR1_OC2M;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4525 tmpccmrx &= ~TIM_CCMR1_CC2S;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4526
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4527 /* Select the Output Compare Mode */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4528 tmpccmrx |= (OC_Config->OCMode << 8);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4529
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4530 /* Reset the Output Polarity level */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4531 tmpccer &= ~TIM_CCER_CC2P;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4532 /* Set the Output Compare Polarity */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4533 tmpccer |= (OC_Config->OCPolarity << 4);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4534
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4535 if(IS_TIM_ADVANCED_INSTANCE(TIMx) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4536 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4537 assert_param(IS_TIM_OCN_POLARITY(OC_Config->OCNPolarity));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4538 assert_param(IS_TIM_OCNIDLE_STATE(OC_Config->OCNIdleState));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4539 assert_param(IS_TIM_OCIDLE_STATE(OC_Config->OCIdleState));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4540
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4541 /* Reset the Output N Polarity level */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4542 tmpccer &= ~TIM_CCER_CC2NP;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4543 /* Set the Output N Polarity */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4544 tmpccer |= (OC_Config->OCNPolarity << 4);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4545 /* Reset the Output N State */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4546 tmpccer &= ~TIM_CCER_CC2NE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4547
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4548 /* Reset the Output Compare and Output Compare N IDLE State */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4549 tmpcr2 &= ~TIM_CR2_OIS2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4550 tmpcr2 &= ~TIM_CR2_OIS2N;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4551 /* Set the Output Idle state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4552 tmpcr2 |= (OC_Config->OCIdleState << 2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4553 /* Set the Output N Idle state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4554 tmpcr2 |= (OC_Config->OCNIdleState << 2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4555 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4556 /* Write to TIMx CR2 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4557 TIMx->CR2 = tmpcr2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4558
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4559 /* Write to TIMx CCMR1 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4560 TIMx->CCMR1 = tmpccmrx;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4561
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4562 /* Set the Capture Compare Register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4563 TIMx->CCR2 = OC_Config->Pulse;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4564
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4565 /* Write to TIMx CCER */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4566 TIMx->CCER = tmpccer;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4567 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4568
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4569 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4570 * @brief TIM DMA Delay Pulse complete callback.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4571 * @param hdma: pointer to a DMA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4572 * the configuration information for the specified DMA module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4573 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4574 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4575 void TIM_DMADelayPulseCplt(DMA_HandleTypeDef *hdma)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4576 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4577 TIM_HandleTypeDef* htim = ( TIM_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4578
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4579 htim->State= HAL_TIM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4580
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4581 if(hdma == htim->hdma[TIM_DMA_ID_CC1])
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4582 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4583 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4584 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4585 else if(hdma == htim->hdma[TIM_DMA_ID_CC2])
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4586 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4587 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4588 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4589 else if(hdma == htim->hdma[TIM_DMA_ID_CC3])
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4590 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4591 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_3;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4592 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4593 else if(hdma == htim->hdma[TIM_DMA_ID_CC4])
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4594 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4595 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_4;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4596 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4597
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4598 HAL_TIM_PWM_PulseFinishedCallback(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4599
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4600 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_CLEARED;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4601 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4602
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4603 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4604 * @brief TIM DMA error callback
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4605 * @param hdma: pointer to a DMA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4606 * the configuration information for the specified DMA module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4607 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4608 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4609 void TIM_DMAError(DMA_HandleTypeDef *hdma)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4610 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4611 TIM_HandleTypeDef* htim = ( TIM_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4612
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4613 htim->State= HAL_TIM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4614
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4615 HAL_TIM_ErrorCallback(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4616 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4617
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4618 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4619 * @brief TIM DMA Capture complete callback.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4620 * @param hdma: pointer to a DMA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4621 * the configuration information for the specified DMA module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4622 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4623 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4624 void TIM_DMACaptureCplt(DMA_HandleTypeDef *hdma)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4625 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4626 TIM_HandleTypeDef* htim = ( TIM_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4627
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4628 htim->State= HAL_TIM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4629
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4630 if(hdma == htim->hdma[TIM_DMA_ID_CC1])
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4631 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4632 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4633 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4634 else if(hdma == htim->hdma[TIM_DMA_ID_CC2])
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4635 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4636 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4637 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4638 else if(hdma == htim->hdma[TIM_DMA_ID_CC3])
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4639 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4640 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_3;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4641 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4642 else if(hdma == htim->hdma[TIM_DMA_ID_CC4])
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4643 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4644 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_4;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4645 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4646
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4647 HAL_TIM_IC_CaptureCallback(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4648
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4649 htim->Channel = HAL_TIM_ACTIVE_CHANNEL_CLEARED;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4650 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4651
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4652 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4653 * @brief Enables or disables the TIM Capture Compare Channel x.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4654 * @param TIMx to select the TIM peripheral
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4655 * @param Channel: specifies the TIM Channel
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4656 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4657 * @arg TIM_Channel_1: TIM Channel 1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4658 * @arg TIM_Channel_2: TIM Channel 2
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4659 * @arg TIM_Channel_3: TIM Channel 3
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4660 * @arg TIM_Channel_4: TIM Channel 4
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4661 * @param ChannelState: specifies the TIM Channel CCxE bit new state.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4662 * This parameter can be: TIM_CCx_ENABLE or TIM_CCx_Disable.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4663 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4664 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4665 void TIM_CCxChannelCmd(TIM_TypeDef* TIMx, uint32_t Channel, uint32_t ChannelState)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4666 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4667 uint32_t tmp = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4668
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4669 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4670 assert_param(IS_TIM_CC1_INSTANCE(TIMx));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4671 assert_param(IS_TIM_CHANNELS(Channel));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4672
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4673 tmp = TIM_CCER_CC1E << Channel;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4674
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4675 /* Reset the CCxE Bit */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4676 TIMx->CCER &= ~tmp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4677
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4678 /* Set or reset the CCxE Bit */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4679 TIMx->CCER |= (uint32_t)(ChannelState << Channel);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4680 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4681
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4682 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4683 * @brief TIM DMA Period Elapse complete callback.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4684 * @param hdma: pointer to a DMA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4685 * the configuration information for the specified DMA module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4686 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4687 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4688 static void TIM_DMAPeriodElapsedCplt(DMA_HandleTypeDef *hdma)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4689 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4690 TIM_HandleTypeDef* htim = ( TIM_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4691
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4692 htim->State= HAL_TIM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4693
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4694 HAL_TIM_PeriodElapsedCallback(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4695 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4696
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4697 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4698 * @brief TIM DMA Trigger callback.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4699 * @param hdma: pointer to a DMA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4700 * the configuration information for the specified DMA module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4701 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4702 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4703 static void TIM_DMATriggerCplt(DMA_HandleTypeDef *hdma)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4704 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4705 TIM_HandleTypeDef* htim = ( TIM_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4706
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4707 htim->State= HAL_TIM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4708
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4709 HAL_TIM_TriggerCallback(htim);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4710 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4711
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4712 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4713 * @brief Time Output Compare 1 configuration
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4714 * @param TIMx to select the TIM peripheral
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4715 * @param OC_Config: The output configuration structure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4716 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4717 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4718 static void TIM_OC1_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4719 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4720 uint32_t tmpccmrx = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4721 uint32_t tmpccer = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4722 uint32_t tmpcr2 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4723
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4724 /* Disable the Channel 1: Reset the CC1E Bit */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4725 TIMx->CCER &= ~TIM_CCER_CC1E;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4726
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4727 /* Get the TIMx CCER register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4728 tmpccer = TIMx->CCER;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4729 /* Get the TIMx CR2 register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4730 tmpcr2 = TIMx->CR2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4731
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4732 /* Get the TIMx CCMR1 register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4733 tmpccmrx = TIMx->CCMR1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4734
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4735 /* Reset the Output Compare Mode Bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4736 tmpccmrx &= ~TIM_CCMR1_OC1M;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4737 tmpccmrx &= ~TIM_CCMR1_CC1S;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4738 /* Select the Output Compare Mode */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4739 tmpccmrx |= OC_Config->OCMode;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4740
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4741 /* Reset the Output Polarity level */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4742 tmpccer &= ~TIM_CCER_CC1P;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4743 /* Set the Output Compare Polarity */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4744 tmpccer |= OC_Config->OCPolarity;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4745
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4746
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4747 if(IS_TIM_ADVANCED_INSTANCE(TIMx) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4748 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4749 /* Reset the Output N Polarity level */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4750 tmpccer &= ~TIM_CCER_CC1NP;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4751 /* Set the Output N Polarity */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4752 tmpccer |= OC_Config->OCNPolarity;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4753 /* Reset the Output N State */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4754 tmpccer &= ~TIM_CCER_CC1NE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4755
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4756 /* Reset the Output Compare and Output Compare N IDLE State */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4757 tmpcr2 &= ~TIM_CR2_OIS1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4758 tmpcr2 &= ~TIM_CR2_OIS1N;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4759 /* Set the Output Idle state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4760 tmpcr2 |= OC_Config->OCIdleState;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4761 /* Set the Output N Idle state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4762 tmpcr2 |= OC_Config->OCNIdleState;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4763 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4764 /* Write to TIMx CR2 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4765 TIMx->CR2 = tmpcr2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4766
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4767 /* Write to TIMx CCMR1 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4768 TIMx->CCMR1 = tmpccmrx;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4769
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4770 /* Set the Capture Compare Register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4771 TIMx->CCR1 = OC_Config->Pulse;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4772
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4773 /* Write to TIMx CCER */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4774 TIMx->CCER = tmpccer;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4775 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4776
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4777 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4778 * @brief Time Output Compare 3 configuration
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4779 * @param TIMx to select the TIM peripheral
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4780 * @param OC_Config: The output configuration structure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4781 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4782 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4783 static void TIM_OC3_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4784 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4785 uint32_t tmpccmrx = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4786 uint32_t tmpccer = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4787 uint32_t tmpcr2 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4788
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4789 /* Disable the Channel 3: Reset the CC2E Bit */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4790 TIMx->CCER &= ~TIM_CCER_CC3E;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4791
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4792 /* Get the TIMx CCER register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4793 tmpccer = TIMx->CCER;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4794 /* Get the TIMx CR2 register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4795 tmpcr2 = TIMx->CR2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4796
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4797 /* Get the TIMx CCMR2 register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4798 tmpccmrx = TIMx->CCMR2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4799
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4800 /* Reset the Output Compare mode and Capture/Compare selection Bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4801 tmpccmrx &= ~TIM_CCMR2_OC3M;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4802 tmpccmrx &= ~TIM_CCMR2_CC3S;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4803 /* Select the Output Compare Mode */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4804 tmpccmrx |= OC_Config->OCMode;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4805
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4806 /* Reset the Output Polarity level */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4807 tmpccer &= ~TIM_CCER_CC3P;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4808 /* Set the Output Compare Polarity */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4809 tmpccer |= (OC_Config->OCPolarity << 8);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4810
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4811 if(IS_TIM_ADVANCED_INSTANCE(TIMx) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4812 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4813 assert_param(IS_TIM_OCN_POLARITY(OC_Config->OCNPolarity));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4814 assert_param(IS_TIM_OCNIDLE_STATE(OC_Config->OCNIdleState));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4815 assert_param(IS_TIM_OCIDLE_STATE(OC_Config->OCIdleState));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4816
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4817 /* Reset the Output N Polarity level */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4818 tmpccer &= ~TIM_CCER_CC3NP;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4819 /* Set the Output N Polarity */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4820 tmpccer |= (OC_Config->OCNPolarity << 8);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4821 /* Reset the Output N State */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4822 tmpccer &= ~TIM_CCER_CC3NE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4823
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4824 /* Reset the Output Compare and Output Compare N IDLE State */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4825 tmpcr2 &= ~TIM_CR2_OIS3;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4826 tmpcr2 &= ~TIM_CR2_OIS3N;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4827 /* Set the Output Idle state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4828 tmpcr2 |= (OC_Config->OCIdleState << 4);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4829 /* Set the Output N Idle state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4830 tmpcr2 |= (OC_Config->OCNIdleState << 4);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4831 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4832 /* Write to TIMx CR2 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4833 TIMx->CR2 = tmpcr2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4834
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4835 /* Write to TIMx CCMR2 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4836 TIMx->CCMR2 = tmpccmrx;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4837
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4838 /* Set the Capture Compare Register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4839 TIMx->CCR3 = OC_Config->Pulse;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4840
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4841 /* Write to TIMx CCER */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4842 TIMx->CCER = tmpccer;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4843 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4844
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4845 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4846 * @brief Time Output Compare 4 configuration
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4847 * @param TIMx to select the TIM peripheral
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4848 * @param OC_Config: The output configuration structure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4849 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4850 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4851 static void TIM_OC4_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4852 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4853 uint32_t tmpccmrx = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4854 uint32_t tmpccer = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4855 uint32_t tmpcr2 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4856
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4857 /* Disable the Channel 4: Reset the CC4E Bit */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4858 TIMx->CCER &= ~TIM_CCER_CC4E;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4859
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4860 /* Get the TIMx CCER register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4861 tmpccer = TIMx->CCER;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4862 /* Get the TIMx CR2 register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4863 tmpcr2 = TIMx->CR2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4864
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4865 /* Get the TIMx CCMR2 register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4866 tmpccmrx = TIMx->CCMR2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4867
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4868 /* Reset the Output Compare mode and Capture/Compare selection Bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4869 tmpccmrx &= ~TIM_CCMR2_OC4M;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4870 tmpccmrx &= ~TIM_CCMR2_CC4S;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4871
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4872 /* Select the Output Compare Mode */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4873 tmpccmrx |= (OC_Config->OCMode << 8);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4874
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4875 /* Reset the Output Polarity level */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4876 tmpccer &= ~TIM_CCER_CC4P;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4877 /* Set the Output Compare Polarity */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4878 tmpccer |= (OC_Config->OCPolarity << 12);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4879
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4880 /*if((TIMx == TIM1) || (TIMx == TIM8))*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4881 if(IS_TIM_ADVANCED_INSTANCE(TIMx) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4882 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4883 assert_param(IS_TIM_OCIDLE_STATE(OC_Config->OCIdleState));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4884 /* Reset the Output Compare IDLE State */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4885 tmpcr2 &= ~TIM_CR2_OIS4;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4886 /* Set the Output Idle state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4887 tmpcr2 |= (OC_Config->OCIdleState << 6);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4888 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4889 /* Write to TIMx CR2 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4890 TIMx->CR2 = tmpcr2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4891
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4892 /* Write to TIMx CCMR2 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4893 TIMx->CCMR2 = tmpccmrx;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4894
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4895 /* Set the Capture Compare Register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4896 TIMx->CCR4 = OC_Config->Pulse;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4897
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4898 /* Write to TIMx CCER */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4899 TIMx->CCER = tmpccer;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4900 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4901
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4902 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4903 * @brief Time Output Compare 4 configuration
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4904 * @param htim: pointer to a TIM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4905 * the configuration information for TIM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4906 * @param sSlaveConfig: The slave configuration structure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4907 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4908 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4909 static void TIM_SlaveTimer_SetConfig(TIM_HandleTypeDef *htim,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4910 TIM_SlaveConfigTypeDef * sSlaveConfig)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4911 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4912 uint32_t tmpsmcr = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4913 uint32_t tmpccmr1 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4914 uint32_t tmpccer = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4915
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4916 /* Get the TIMx SMCR register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4917 tmpsmcr = htim->Instance->SMCR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4918
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4919 /* Reset the Trigger Selection Bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4920 tmpsmcr &= ~TIM_SMCR_TS;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4921 /* Set the Input Trigger source */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4922 tmpsmcr |= sSlaveConfig->InputTrigger;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4923
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4924 /* Reset the slave mode Bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4925 tmpsmcr &= ~TIM_SMCR_SMS;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4926 /* Set the slave mode */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4927 tmpsmcr |= sSlaveConfig->SlaveMode;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4928
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4929 /* Write to TIMx SMCR */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4930 htim->Instance->SMCR = tmpsmcr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4931
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4932 /* Configure the trigger prescaler, filter, and polarity */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4933 switch (sSlaveConfig->InputTrigger)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4934 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4935 case TIM_TS_ETRF:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4936 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4937 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4938 assert_param(IS_TIM_ETR_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4939 assert_param(IS_TIM_TRIGGERPRESCALER(sSlaveConfig->TriggerPrescaler));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4940 assert_param(IS_TIM_TRIGGERPOLARITY(sSlaveConfig->TriggerPolarity));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4941 assert_param(IS_TIM_TRIGGERFILTER(sSlaveConfig->TriggerFilter));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4942 /* Configure the ETR Trigger source */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4943 TIM_ETR_SetConfig(htim->Instance,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4944 sSlaveConfig->TriggerPrescaler,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4945 sSlaveConfig->TriggerPolarity,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4946 sSlaveConfig->TriggerFilter);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4947 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4948 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4949
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4950 case TIM_TS_TI1F_ED:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4951 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4952 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4953 assert_param(IS_TIM_CC1_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4954 assert_param(IS_TIM_TRIGGERFILTER(sSlaveConfig->TriggerFilter));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4955
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4956 /* Disable the Channel 1: Reset the CC1E Bit */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4957 tmpccer = htim->Instance->CCER;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4958 htim->Instance->CCER &= ~TIM_CCER_CC1E;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4959 tmpccmr1 = htim->Instance->CCMR1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4960
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4961 /* Set the filter */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4962 tmpccmr1 &= ~TIM_CCMR1_IC1F;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4963 tmpccmr1 |= ((sSlaveConfig->TriggerFilter) << 4);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4964
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4965 /* Write to TIMx CCMR1 and CCER registers */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4966 htim->Instance->CCMR1 = tmpccmr1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4967 htim->Instance->CCER = tmpccer;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4968
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4969 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4970 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4971
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4972 case TIM_TS_TI1FP1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4973 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4974 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4975 assert_param(IS_TIM_CC1_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4976 assert_param(IS_TIM_TRIGGERPOLARITY(sSlaveConfig->TriggerPolarity));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4977 assert_param(IS_TIM_TRIGGERFILTER(sSlaveConfig->TriggerFilter));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4978
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4979 /* Configure TI1 Filter and Polarity */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4980 TIM_TI1_ConfigInputStage(htim->Instance,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4981 sSlaveConfig->TriggerPolarity,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4982 sSlaveConfig->TriggerFilter);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4983 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4984 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4985
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4986 case TIM_TS_TI2FP2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4987 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4988 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4989 assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4990 assert_param(IS_TIM_TRIGGERPOLARITY(sSlaveConfig->TriggerPolarity));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4991 assert_param(IS_TIM_TRIGGERFILTER(sSlaveConfig->TriggerFilter));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4992
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4993 /* Configure TI2 Filter and Polarity */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4994 TIM_TI2_ConfigInputStage(htim->Instance,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4995 sSlaveConfig->TriggerPolarity,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4996 sSlaveConfig->TriggerFilter);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4997 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4998 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4999
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5000 case TIM_TS_ITR0:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5001 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5002 /* Check the parameter */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5003 assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5004 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5005 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5006
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5007 case TIM_TS_ITR1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5008 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5009 /* Check the parameter */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5010 assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5011 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5012 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5013
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5014 case TIM_TS_ITR2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5015 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5016 /* Check the parameter */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5017 assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5018 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5019 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5020
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5021 case TIM_TS_ITR3:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5022 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5023 /* Check the parameter */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5024 assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5025 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5026 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5027
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5028 default:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5029 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5030 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5031 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5032
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5033
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5034 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5035 * @brief Configure the Polarity and Filter for TI1.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5036 * @param TIMx to select the TIM peripheral.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5037 * @param TIM_ICPolarity : The Input Polarity.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5038 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5039 * @arg TIM_ICPolarity_Rising
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5040 * @arg TIM_ICPolarity_Falling
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5041 * @arg TIM_ICPolarity_BothEdge
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5042 * @param TIM_ICFilter: Specifies the Input Capture Filter.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5043 * This parameter must be a value between 0x00 and 0x0F.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5044 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5045 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5046 static void TIM_TI1_ConfigInputStage(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICFilter)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5047 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5048 uint32_t tmpccmr1 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5049 uint32_t tmpccer = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5050
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5051 /* Disable the Channel 1: Reset the CC1E Bit */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5052 tmpccer = TIMx->CCER;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5053 TIMx->CCER &= ~TIM_CCER_CC1E;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5054 tmpccmr1 = TIMx->CCMR1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5055
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5056 /* Set the filter */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5057 tmpccmr1 &= ~TIM_CCMR1_IC1F;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5058 tmpccmr1 |= (TIM_ICFilter << 4);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5059
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5060 /* Select the Polarity and set the CC1E Bit */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5061 tmpccer &= ~(TIM_CCER_CC1P | TIM_CCER_CC1NP);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5062 tmpccer |= TIM_ICPolarity;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5063
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5064 /* Write to TIMx CCMR1 and CCER registers */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5065 TIMx->CCMR1 = tmpccmr1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5066 TIMx->CCER = tmpccer;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5067 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5068
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5069 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5070 * @brief Configure the TI2 as Input.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5071 * @param TIMx to select the TIM peripheral
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5072 * @param TIM_ICPolarity : The Input Polarity.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5073 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5074 * @arg TIM_ICPolarity_Rising
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5075 * @arg TIM_ICPolarity_Falling
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5076 * @arg TIM_ICPolarity_BothEdge
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5077 * @param TIM_ICSelection: specifies the input to be used.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5078 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5079 * @arg TIM_ICSelection_DirectTI: TIM Input 2 is selected to be connected to IC2.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5080 * @arg TIM_ICSelection_IndirectTI: TIM Input 2 is selected to be connected to IC1.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5081 * @arg TIM_ICSelection_TRC: TIM Input 2 is selected to be connected to TRC.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5082 * @param TIM_ICFilter: Specifies the Input Capture Filter.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5083 * This parameter must be a value between 0x00 and 0x0F.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5084 * @note TIM_ICFilter and TIM_ICPolarity are not used in INDIRECT mode as TI1FP2
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5085 * (on channel1 path) is used as the input signal. Therefore CCMR1 must be
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5086 * protected against un-initialized filter and polarity values.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5087 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5088 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5089 static void TIM_TI2_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5090 uint32_t TIM_ICFilter)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5091 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5092 uint32_t tmpccmr1 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5093 uint32_t tmpccer = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5094
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5095 /* Disable the Channel 2: Reset the CC2E Bit */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5096 TIMx->CCER &= ~TIM_CCER_CC2E;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5097 tmpccmr1 = TIMx->CCMR1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5098 tmpccer = TIMx->CCER;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5099
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5100 /* Select the Input */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5101 tmpccmr1 &= ~TIM_CCMR1_CC2S;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5102 tmpccmr1 |= (TIM_ICSelection << 8);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5103
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5104 /* Set the filter */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5105 tmpccmr1 &= ~TIM_CCMR1_IC2F;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5106 tmpccmr1 |= ((TIM_ICFilter << 12) & TIM_CCMR1_IC2F);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5107
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5108 /* Select the Polarity and set the CC2E Bit */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5109 tmpccer &= ~(TIM_CCER_CC2P | TIM_CCER_CC2NP);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5110 tmpccer |= ((TIM_ICPolarity << 4) & (TIM_CCER_CC2P | TIM_CCER_CC2NP));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5111
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5112 /* Write to TIMx CCMR1 and CCER registers */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5113 TIMx->CCMR1 = tmpccmr1 ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5114 TIMx->CCER = tmpccer;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5115 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5116
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5117 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5118 * @brief Configure the Polarity and Filter for TI2.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5119 * @param TIMx to select the TIM peripheral.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5120 * @param TIM_ICPolarity : The Input Polarity.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5121 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5122 * @arg TIM_ICPolarity_Rising
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5123 * @arg TIM_ICPolarity_Falling
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5124 * @arg TIM_ICPolarity_BothEdge
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5125 * @param TIM_ICFilter: Specifies the Input Capture Filter.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5126 * This parameter must be a value between 0x00 and 0x0F.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5127 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5128 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5129 static void TIM_TI2_ConfigInputStage(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICFilter)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5130 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5131 uint32_t tmpccmr1 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5132 uint32_t tmpccer = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5133
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5134 /* Disable the Channel 2: Reset the CC2E Bit */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5135 TIMx->CCER &= ~TIM_CCER_CC2E;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5136 tmpccmr1 = TIMx->CCMR1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5137 tmpccer = TIMx->CCER;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5138
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5139 /* Set the filter */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5140 tmpccmr1 &= ~TIM_CCMR1_IC2F;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5141 tmpccmr1 |= (TIM_ICFilter << 12);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5142
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5143 /* Select the Polarity and set the CC2E Bit */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5144 tmpccer &= ~(TIM_CCER_CC2P | TIM_CCER_CC2NP);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5145 tmpccer |= (TIM_ICPolarity << 4);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5146
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5147 /* Write to TIMx CCMR1 and CCER registers */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5148 TIMx->CCMR1 = tmpccmr1 ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5149 TIMx->CCER = tmpccer;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5150 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5151
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5152 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5153 * @brief Configure the TI3 as Input.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5154 * @param TIMx to select the TIM peripheral
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5155 * @param TIM_ICPolarity : The Input Polarity.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5156 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5157 * @arg TIM_ICPolarity_Rising
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5158 * @arg TIM_ICPolarity_Falling
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5159 * @arg TIM_ICPolarity_BothEdge
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5160 * @param TIM_ICSelection: specifies the input to be used.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5161 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5162 * @arg TIM_ICSelection_DirectTI: TIM Input 3 is selected to be connected to IC3.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5163 * @arg TIM_ICSelection_IndirectTI: TIM Input 3 is selected to be connected to IC4.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5164 * @arg TIM_ICSelection_TRC: TIM Input 3 is selected to be connected to TRC.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5165 * @param TIM_ICFilter: Specifies the Input Capture Filter.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5166 * This parameter must be a value between 0x00 and 0x0F.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5167 * @note TIM_ICFilter and TIM_ICPolarity are not used in INDIRECT mode as TI4FP3
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5168 * (on channel4 path) is used as the input signal. Therefore CCMR2 must be
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5169 * protected against un-initialized filter and polarity values.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5170 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5171 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5172 static void TIM_TI3_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5173 uint32_t TIM_ICFilter)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5174 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5175 uint32_t tmpccmr2 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5176 uint32_t tmpccer = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5177
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5178 /* Disable the Channel 3: Reset the CC3E Bit */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5179 TIMx->CCER &= ~TIM_CCER_CC3E;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5180 tmpccmr2 = TIMx->CCMR2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5181 tmpccer = TIMx->CCER;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5182
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5183 /* Select the Input */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5184 tmpccmr2 &= ~TIM_CCMR2_CC3S;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5185 tmpccmr2 |= TIM_ICSelection;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5186
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5187 /* Set the filter */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5188 tmpccmr2 &= ~TIM_CCMR2_IC3F;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5189 tmpccmr2 |= ((TIM_ICFilter << 4) & TIM_CCMR2_IC3F);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5190
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5191 /* Select the Polarity and set the CC3E Bit */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5192 tmpccer &= ~(TIM_CCER_CC3P | TIM_CCER_CC3NP);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5193 tmpccer |= ((TIM_ICPolarity << 8) & (TIM_CCER_CC3P | TIM_CCER_CC3NP));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5194
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5195 /* Write to TIMx CCMR2 and CCER registers */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5196 TIMx->CCMR2 = tmpccmr2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5197 TIMx->CCER = tmpccer;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5198 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5199
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5200 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5201 * @brief Configure the TI4 as Input.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5202 * @param TIMx to select the TIM peripheral
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5203 * @param TIM_ICPolarity : The Input Polarity.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5204 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5205 * @arg TIM_ICPolarity_Rising
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5206 * @arg TIM_ICPolarity_Falling
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5207 * @arg TIM_ICPolarity_BothEdge
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5208 * @param TIM_ICSelection: specifies the input to be used.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5209 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5210 * @arg TIM_ICSelection_DirectTI: TIM Input 4 is selected to be connected to IC4.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5211 * @arg TIM_ICSelection_IndirectTI: TIM Input 4 is selected to be connected to IC3.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5212 * @arg TIM_ICSelection_TRC: TIM Input 4 is selected to be connected to TRC.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5213 * @param TIM_ICFilter: Specifies the Input Capture Filter.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5214 * This parameter must be a value between 0x00 and 0x0F.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5215 * @note TIM_ICFilter and TIM_ICPolarity are not used in INDIRECT mode as TI3FP4
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5216 * (on channel3 path) is used as the input signal. Therefore CCMR2 must be
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5217 * protected against un-initialized filter and polarity values.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5218 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5219 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5220 static void TIM_TI4_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5221 uint32_t TIM_ICFilter)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5222 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5223 uint32_t tmpccmr2 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5224 uint32_t tmpccer = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5225
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5226 /* Disable the Channel 4: Reset the CC4E Bit */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5227 TIMx->CCER &= ~TIM_CCER_CC4E;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5228 tmpccmr2 = TIMx->CCMR2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5229 tmpccer = TIMx->CCER;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5230
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5231 /* Select the Input */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5232 tmpccmr2 &= ~TIM_CCMR2_CC4S;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5233 tmpccmr2 |= (TIM_ICSelection << 8);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5234
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5235 /* Set the filter */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5236 tmpccmr2 &= ~TIM_CCMR2_IC4F;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5237 tmpccmr2 |= ((TIM_ICFilter << 12) & TIM_CCMR2_IC4F);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5238
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5239 /* Select the Polarity and set the CC4E Bit */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5240 tmpccer &= ~(TIM_CCER_CC4P | TIM_CCER_CC4NP);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5241 tmpccer |= ((TIM_ICPolarity << 12) & (TIM_CCER_CC4P | TIM_CCER_CC4NP));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5242
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5243 /* Write to TIMx CCMR2 and CCER registers */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5244 TIMx->CCMR2 = tmpccmr2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5245 TIMx->CCER = tmpccer ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5246 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5247
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5248 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5249 * @brief Selects the Input Trigger source
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5250 * @param TIMx to select the TIM peripheral
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5251 * @param TIM_ITRx: The Input Trigger source.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5252 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5253 * @arg TIM_TS_ITR0: Internal Trigger 0
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5254 * @arg TIM_TS_ITR1: Internal Trigger 1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5255 * @arg TIM_TS_ITR2: Internal Trigger 2
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5256 * @arg TIM_TS_ITR3: Internal Trigger 3
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5257 * @arg TIM_TS_TI1F_ED: TI1 Edge Detector
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5258 * @arg TIM_TS_TI1FP1: Filtered Timer Input 1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5259 * @arg TIM_TS_TI2FP2: Filtered Timer Input 2
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5260 * @arg TIM_TS_ETRF: External Trigger input
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5261 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5262 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5263 static void TIM_ITRx_SetConfig(TIM_TypeDef *TIMx, uint16_t TIM_ITRx)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5264 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5265 uint32_t tmpsmcr = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5266
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5267 /* Get the TIMx SMCR register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5268 tmpsmcr = TIMx->SMCR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5269 /* Reset the TS Bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5270 tmpsmcr &= ~TIM_SMCR_TS;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5271 /* Set the Input Trigger source and the slave mode*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5272 tmpsmcr |= TIM_ITRx | TIM_SLAVEMODE_EXTERNAL1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5273 /* Write to TIMx SMCR */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5274 TIMx->SMCR = tmpsmcr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5275 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5276
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5277 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5278 * @brief Configures the TIMx External Trigger (ETR).
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5279 * @param TIMx to select the TIM peripheral
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5280 * @param TIM_ExtTRGPrescaler: The external Trigger Prescaler.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5281 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5282 * @arg TIM_ExtTRGPSC_DIV1: ETRP Prescaler OFF.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5283 * @arg TIM_ExtTRGPSC_DIV2: ETRP frequency divided by 2.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5284 * @arg TIM_ExtTRGPSC_DIV4: ETRP frequency divided by 4.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5285 * @arg TIM_ExtTRGPSC_DIV8: ETRP frequency divided by 8.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5286 * @param TIM_ExtTRGPolarity: The external Trigger Polarity.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5287 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5288 * @arg TIM_ExtTRGPolarity_Inverted: active low or falling edge active.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5289 * @arg TIM_ExtTRGPolarity_NonInverted: active high or rising edge active.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5290 * @param ExtTRGFilter: External Trigger Filter.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5291 * This parameter must be a value between 0x00 and 0x0F
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5292 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5293 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5294 static void TIM_ETR_SetConfig(TIM_TypeDef* TIMx, uint32_t TIM_ExtTRGPrescaler,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5295 uint32_t TIM_ExtTRGPolarity, uint32_t ExtTRGFilter)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5296 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5297 uint32_t tmpsmcr = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5298
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5299 tmpsmcr = TIMx->SMCR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5300
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5301 /* Reset the ETR Bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5302 tmpsmcr &= ~(TIM_SMCR_ETF | TIM_SMCR_ETPS | TIM_SMCR_ECE | TIM_SMCR_ETP);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5303
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5304 /* Set the Prescaler, the Filter value and the Polarity */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5305 tmpsmcr |= (uint32_t)(TIM_ExtTRGPrescaler | (TIM_ExtTRGPolarity | (ExtTRGFilter << 8)));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5306
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5307 /* Write to TIMx SMCR */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5308 TIMx->SMCR = tmpsmcr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5309 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5310
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5311 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5312 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5313 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5314
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5315 #endif /* HAL_TIM_MODULE_ENABLED */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5316 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5317 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5318 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5319
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5320 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5321 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5322 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5323 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/