X-CUBE-SPN11 for X-NUCLEO-IHM11M1: X-NUCLEO-IHM11M1.c Source File

X-CUBE-SPN11 for X-NUCLEO-IHM11M1

X-NUCLEO-IHM11M1.c
Go to the documentation of this file.
1 /**
2  ******************************************************************************
3  * @file X-NUCLEO-IHM11M1.c
4  * @author IPC
5  * @version V0
6  * @date 10/07/2016
7  * @brief This file provides the set of functions to manage the X-Nucleo expansion board
8  ******************************************************************************
9  * @attention
10  *
11  * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
12  *
13  * Redistribution and use in source and binary forms, with or without modification,
14  * are permitted provided that the following conditions are met:
15  * 1. Redistributions of source code must retain the above copyright notice,
16  * this list of conditions and the following disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright notice,
18  * this list of conditions and the following disclaimer in the documentation
19  * and/or other materials provided with the distribution.
20  * 3. Neither the name of STMicroelectronics nor the names of its contributors
21  * may be used to endorse or promote products derived from this software
22  * without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  *
35  ******************************************************************************
36  */
37 
38 /** @addtogroup DRIVERS DRIVERS
39  * @brief Driver Layer
40  * @{
41  */
42 
43 /** @addtogroup BSP BSP
44  * @brief BSP Layer
45  * @{
46  */
47 
48 /** @addtogroup X-NUCLEO-IHM11M1 X-NUCLEO-IHM11M1
49  * @brief X-Nucleo expansion board
50  * @{
51  */
52 
53 
54 /* Includes ------------------------------------------------------------------*/
55 
56 #include "X-NUCLEO-IHM11M1.h"
57 #include "6Step_Lib.h"
58 
59 #ifdef STM32F030x8
60 #include "stm32f0xx_hal.h"
61 #include "stm32F030_nucleo_ihm11m1.h"
62 #endif
63 #ifdef STM32F401xE
64 #include "stm32f4xx_hal.h"
66 #endif
67 extern SIXSTEP_Base_InitTypeDef SIXSTEP_parameters; /*!< Main SixStep structure*/
68 
69 /** @defgroup STSPIN230_EnableInput_CH1_E_CH2_E_CH3_D STSPIN230_EnableInput_CH1_E_CH2_E_CH3_D
70  * @{
71  * @brief Enable Input channel for STSPIN230
72  */
73 
74 /**
75  * @brief Enable Input channel CH1 and CH2 for STSPIN230
76  * @retval None
77 */
78 
80 {
81  HAL_TIM_PWM_Start(&HF_TIMx,HF_TIMx_CH1); //TIM1_CH1 ENABLE
82  HAL_TIMEx_PWMN_Start(&HF_TIMx,HF_TIMx_CH1) ;
83 
84  HAL_TIM_PWM_Start(&HF_TIMx,HF_TIMx_CH2); //TIM1_CH2 ENABLE
85  HAL_TIMEx_PWMN_Start(&HF_TIMx,HF_TIMx_CH2) ;
86 
87  HAL_TIM_PWM_Stop(&HF_TIMx,HF_TIMx_CH3); //TIM1_CH3 DISABLE
88  HAL_TIMEx_PWMN_Stop(&HF_TIMx,HF_TIMx_CH3) ;
89 }
90 
91 /**
92  * @}
93  */
94 
95  /** @defgroup STSPIN230_EnableInput_CH1_E_CH2_D_CH3_E STSPIN230_EnableInput_CH1_E_CH2_D_CH3_E
96  * @{
97  * @brief Enable Input channel for STSPIN230
98  */
99 /**
100  * @brief Enable Input channel CH1 and CH3 for STSPIN230
101  * @retval None
102 */
103 
105 {
106  HAL_TIM_PWM_Start(&HF_TIMx,HF_TIMx_CH1); //TIM1_CH1 ENABLE
107  HAL_TIMEx_PWMN_Start(&HF_TIMx,HF_TIMx_CH1) ;
108 
109  HAL_TIM_PWM_Stop(&HF_TIMx,HF_TIMx_CH2); //TIM1_CH2 DISABLE
110  HAL_TIMEx_PWMN_Stop(&HF_TIMx,HF_TIMx_CH2) ;
111 
112  HAL_TIM_PWM_Start(&HF_TIMx,HF_TIMx_CH3); //TIM1_CH3 ENABLE
113  HAL_TIMEx_PWMN_Start(&HF_TIMx,HF_TIMx_CH3) ;
114 }
115 
116 /**
117  * @}
118  */
119 
120 /** @defgroup STSPIN230_EnableInput_CH1_D_CH2_E_CH3_E STSPIN230_EnableInput_CH1_D_CH2_E_CH3_E
121  * @{
122  * @brief Enable Input channel for STSPIN230
123  */
124 /**
125  * @brief Enable Input channel CH2 and CH3 for STSPIN230
126  * @retval None
127 */
128 
130 {
131  HAL_TIM_PWM_Stop(&HF_TIMx,HF_TIMx_CH1); //TIM1_CH1 DISABLE
132  HAL_TIMEx_PWMN_Stop(&HF_TIMx,HF_TIMx_CH1) ;
133 
134  HAL_TIM_PWM_Start(&HF_TIMx,HF_TIMx_CH2); //TIM1_CH2 ENABLE
135  HAL_TIMEx_PWMN_Start(&HF_TIMx,HF_TIMx_CH2) ;
136 
137  HAL_TIM_PWM_Start(&HF_TIMx,HF_TIMx_CH3); //TIM1_CH3 ENABLE
138  HAL_TIMEx_PWMN_Start(&HF_TIMx,HF_TIMx_CH3) ;
139 }
140 
141 /**
142  * @}
143  */
144 
145 /** @defgroup STSPIN230_DisableInput_CH1_D_CH2_D_CH3_D STSPIN230_DisableInput_CH1_D_CH2_D_CH3_D
146  * @{
147  * @brief Disable All Input channels for STSPIN230
148  */
149 /**
150  * @brief Enable Input channel CH2 and CH3 for STSPIN230
151  * @retval None
152 */
153 
155 {
156  HAL_TIM_PWM_Stop(&HF_TIMx,HF_TIMx_CH1); //TIM1_CH1 DISABLE
157  HAL_TIMEx_PWMN_Stop(&HF_TIMx,HF_TIMx_CH1) ;
158 
159  HAL_TIM_PWM_Stop(&HF_TIMx,HF_TIMx_CH2); //TIM1_CH2 DISABLE
160  HAL_TIMEx_PWMN_Stop(&HF_TIMx,HF_TIMx_CH2) ;
161 
162  HAL_TIM_PWM_Stop(&HF_TIMx,HF_TIMx_CH3); //TIM1_CH3 DISABLE
163  HAL_TIMEx_PWMN_Stop(&HF_TIMx,HF_TIMx_CH3) ;
164 }
165 
166 /**
167  * @}
168  */
169 
170 /** @defgroup STSPIN230_Start_PWM_driving STSPIN230_Start_PWM_driving
171  * @{
172  * @brief Enable the PWM generation on Input channels for STSPIN230
173  */
174 /**
175  * @brief Enable PWM channels for STSPIN230
176  * @retval None
177 */
178 
180 {
181  HAL_TIM_PWM_Start(&HF_TIMx, HF_TIMx_CH1); //TIM1_CH1 ENABLE
182  HAL_TIMEx_PWMN_Start(&HF_TIMx,HF_TIMx_CH1) ;
183 
184  HAL_TIM_PWM_Start(&HF_TIMx, HF_TIMx_CH2); //TIM1_CH2 ENABLE
185  HAL_TIMEx_PWMN_Start(&HF_TIMx,HF_TIMx_CH2) ;
186 
187  HAL_TIM_PWM_Start(&HF_TIMx, HF_TIMx_CH3); //TIM1_CH3 ENABLE
188  HAL_TIMEx_PWMN_Start(&HF_TIMx,HF_TIMx_CH3) ;
189 }
190 
191 /**
192  * @}
193  */
194 
195 /** @defgroup STSPIN230_Stop_PWM_driving STSPIN230_Stop_PWM_driving
196  * @{
197  * @brief Disable the PWM generation on Input channels for STSPIN230
198  */
199 /**
200  * @brief Disable PWM channels for STSPIN230
201  * @retval None
202 */
203 
205 {
206  HAL_TIM_PWM_Stop(&HF_TIMx, HF_TIMx_CH1); //TIM1_CH1 DISABLE
207  HAL_TIMEx_PWMN_Stop(&HF_TIMx,HF_TIMx_CH1) ;
208 
209  HAL_TIM_PWM_Stop(&HF_TIMx, HF_TIMx_CH2); //TIM1_CH2 DISABLE
210  HAL_TIMEx_PWMN_Stop(&HF_TIMx,HF_TIMx_CH2) ;
211 
212  HAL_TIM_PWM_Stop(&HF_TIMx, HF_TIMx_CH3); //TIM1_CH3 DISABLE
213  HAL_TIMEx_PWMN_Stop(&HF_TIMx,HF_TIMx_CH3) ;
214 
215 }
216 
217 /**
218  * @}
219  */
220 
221 /** @defgroup STSPIN230_HF_TIMx_SetDutyCycle_CH1 STSPIN230_HF_TIMx_SetDutyCycle_CH1
222  * @{
223  * @brief Set the Duty Cycle value for CH1 for STSPIN230
224 */
225 /**
226  * @brief Set the Duty Cycle value for CH1
227  * @retval None
228 */
229 
230 void STSPIN230_HF_TIMx_SetDutyCycle_CH1(uint16_t CCR_value)
231 {
232  HF_TIMx.Instance->HF_TIMx_CCR1 = CCR_value;
233 
234 }
235 
236 
237 /**
238  * @}
239  */
240 
241 /** @defgroup STSPIN230_HF_TIMx_SetDutyCycle_CH2 STSPIN230_HF_TIMx_SetDutyCycle_CH2
242  * @{
243  * @brief Set the Duty Cycle value for CH2 for STSPIN230
244 */
245 /**
246  * @brief Set the Duty Cycle value for CH2
247  * @retval None
248 */
249 
250 void STSPIN230_HF_TIMx_SetDutyCycle_CH2(uint16_t CCR_value)
251 {
252  HF_TIMx.Instance->HF_TIMx_CCR2 = CCR_value;
253 
254 }
255 /**
256  * @}
257  */
258 
259 
260 
261 
262 
263 
264 /** @defgroup STSPIN230_HF_TIMx_SetDutyCycle_CH3 STSPIN230_HF_TIMx_SetDutyCycle_CH3
265  * @{
266  * @brief Set the Duty Cycle value for CH3 for STSPIN230
267 */
268 /**
269  * @brief Set the Duty Cycle value for CH3
270  * @retval None
271 */
272 
273 
274 void STSPIN230_HF_TIMx_SetDutyCycle_CH3(uint16_t CCR_value)
275 {
276  HF_TIMx.Instance->HF_TIMx_CCR3 = CCR_value;
277 
278 }
279 
280 /**
281  * @}
282  */
283 
284 /** @defgroup STSPIN230_Current_Reference_Start STSPIN230_Current_Reference_Start
285  * @{
286  * @brief Enable the Current Reference generation for STSPIN230
287 */
288 /**
289  * @brief Enable the Current Reference generation
290  * @retval None
291 */
292 
294 {
296  SIXSTEP_parameters.pulse_value=STARTUP_DUTY_CYCLE;
297 }
298 
299 /**
300  * @}
301  */
302 
303 
304 /** @defgroup STSPIN230_Current_Reference_Stop STSPIN230_Current_Reference_Stop
305  * @{
306  * @brief Disable the Current Reference generation for STSPIN230
307 */
308 /**
309  * @brief Disable the Current Reference generation
310  * @retval None
311 */
312 
314 {
316  SIXSTEP_parameters.pulse_value=STARTUP_DUTY_CYCLE;
317 
318 }
319 /**
320  * @}
321  */
322 
323 
324 /** @defgroup STSPIN230_Current_Reference_Setvalue STSPIN230_Current_Reference_Setvalue
325  * @{
326  * @brief Set the value for Current Reference for STSPIN230
327 */
328 /**
329  * @brief Set the value for Current Reference
330  * @retval None
331 */
332 
333 
335 {
336  SIXSTEP_parameters.pulse_value=Iref;
337 
338 }
339 
340 /**
341  * @}
342  */
343 
344 
345 /** @defgroup BSP_X_NUCLEO_FAULT_LED_ON BSP_X_NUCLEO_FAULT_LED_ON
346  * @{
347  * @brief Turns selected LED On.
348  * @retval None
349 */
350 
352 {
353 }
354 
355 /**
356  * @}
357  */
358 
359 /** @defgroup BSP_X_NUCLEO_FAULT_LED_OFF BSP_X_NUCLEO_FAULT_LED_OFF
360  * @{
361  * @brief Turns selected LED Off.
362  * @retval None
363 */
365 {
366 }
367 /**
368  * @}
369  */
370 /**
371  * @} end X-NUCLEO-IHM11M1
372  */
373 
374 /**
375  * @} end BSP
376  */
377 
378 /**
379  * @} end DRIVERS
380  */
void STSPIN230_Current_Reference_Start()
Enable the Current Reference generation.
This file provides the set of functions to manage the X-Nucleo board.
void STSPIN230_HF_TIMx_SetDutyCycle_CH3(uint16_t CCR_value)
Set the Duty Cycle value for CH3.
void STSPIN230_EnableInput_CH1_E_CH2_D_CH3_E()
Enable Input channel CH1 and CH3 for STSPIN230.
void BSP_X_NUCLEO_FAULT_LED_OFF()
void BSP_X_NUCLEO_FAULT_LED_ON()
#define HF_TIMx_CH3
void STSPIN230_HF_TIMx_SetDutyCycle_CH2(uint16_t CCR_value)
Set the Duty Cycle value for CH2.
#define HF_TIMx_CH1
void STSPIN230_DisableInput_CH1_D_CH2_D_CH3_D()
Enable Input channel CH2 and CH3 for STSPIN230.
This file provides the interface between the MC-lib and STM Nucleo.
void STSPIN230_EnableInput_CH1_D_CH2_E_CH3_E()
Enable Input channel CH2 and CH3 for STSPIN230.
Six Step parameters.
Definition: 6Step_Lib.h:94
void STSPIN230_HF_TIMx_SetDutyCycle_CH1(uint16_t CCR_value)
Set the Duty Cycle value for CH1.
This header file provides the set of functions for Motor Control library.
void STSPIN230_Current_Reference_Setvalue(uint16_t Iref)
Set the value for Current Reference.
SIXSTEP_Base_InitTypeDef SIXSTEP_parameters
Definition: 6Step_Lib.c:73
#define HF_TIMx
void Stop_PWM_driving()
Definition: STSPIN230.c:173
void Start_PWM_driving()
Definition: STSPIN230.c:158
#define STARTUP_DUTY_CYCLE
#define HF_TIMx_CH2
void STSPIN230_Current_Reference_Stop()
Disable the Current Reference generation.
void STSPIN230_Start_PWM_driving()
Enable PWM channels for STSPIN230.
void STSPIN230_EnableInput_CH1_E_CH2_E_CH3_D()
Enable Input channel CH1 and CH2 for STSPIN230.
void STSPIN230_Stop_PWM_driving()
Disable PWM channels for STSPIN230.
Generated by   doxygen 1.8.11