X-CUBE-SPN11 for X-NUCLEO-IHM11M1: stm32F401_nucleo_ihm11m1.h Source File

X-CUBE-SPN11 for X-NUCLEO-IHM11M1

stm32F401_nucleo_ihm11m1.h
Go to the documentation of this file.
1 /**
2  ******************************************************************************
3  * @file stm32F401_nucleo_ihm11m1.h
4  * @author IPC
5  * @version V0
6  * @date 10/08/2016
7  * @brief This file provides the interface between the MC-lib and STM Nucleo
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 /* Define to prevent recursive inclusion -------------------------------------*/
39 #ifndef __STM32F401_NUCLEO_IHM11M1_H
40 #define __STM32F401_NUCLEO_IHM11M1_H
41 
42  #include "stm32f4xx_hal.h"
43  #include "main_F401.h"
44 
45  #define HF_TIMx htim1
46  #define LF_TIMx htim4
47  #define HALL_ENCODER_TIMx htim2
48  #define ADCx hadc1
49  #define DACx htim3
50  #define UART huart2
51 
52  #define ADC_CH_1 ADC_CHANNEL_0 /*CURRENT*/
53  #define ADC_CH_2 ADC_CHANNEL_12 /*SPEED*/
54  #define ADC_CH_3 ADC_CHANNEL_1 /*VBUS*/
55  #define ADC_CH_4 ADC_CHANNEL_2 /*TEMP */
56  #define ADC_Bemf_CH1 ADC_CHANNEL_13 /*BEMF1*/
57  #define ADC_Bemf_CH2 ADC_CHANNEL_8 /*BEMF2*/
58  #define ADC_Bemf_CH3 ADC_CHANNEL_7 /*BEMF3*/
59 
60  #define ADC_CH_1_ST ADC_SAMPLETIME_3CYCLES /*CURRENT sampling time */
61  #define ADC_CH_2_ST ADC_SAMPLETIME_84CYCLES /*SPEED sampling time*/
62  #define ADC_CH_3_ST ADC_SAMPLETIME_84CYCLES /*VBUS sampling time*/
63  #define ADC_CH_4_ST ADC_SAMPLETIME_84CYCLES /*TEMP sampling time*/
64  #define ADC_Bemf_CH1_ST ADC_SAMPLETIME_28CYCLES /*BEMF1 sampling time*/
65  #define ADC_Bemf_CH2_ST ADC_SAMPLETIME_28CYCLES /*BEMF2 sampling time*/
66  #define ADC_Bemf_CH3_ST ADC_SAMPLETIME_28CYCLES /*BEMF3 sampling time*/
67 
68  #define HF_TIMx_CH1 TIM_CHANNEL_1
69  #define HF_TIMx_CH2 TIM_CHANNEL_2
70  #define HF_TIMx_CH3 TIM_CHANNEL_3
71  #define HF_TIMx_CCR1 CCR1 /*Channel 1*/
72  #define HF_TIMx_CCR2 CCR2 /*Channel 2*/
73  #define HF_TIMx_CCR3 CCR3 /*Channel 3*/
74 
75  #define DAC_ENABLE 0 /*!< Enable (1) the DAC peripheral */
76 
77  #define GPIO_PORT_ZCR GPIOC /*!< GPIO port name for zero crossing detection */
78  #define GPIO_CH_ZCR GPIO_PIN_12 /*!< GPIO pin name for zero crossing detection */
79  #define GPIO_PORT_COMM GPIOC /*!< GPIO port name for 6Step commutation */
80  #define GPIO_CH_COMM GPIO_PIN_10 /*!< GPIO pin name for 6Step commutation */
81 
82  #define STARTM_CMD 0 /*!< Start Motor command received */
83  #define STOPMT_CMD 1 /*!< Stop Motor command received */
84  #define SETSPD_CMD 2 /*!< Set the new speed value command received */
85  #define GETSPD_CMD 3 /*!< Get Mechanical Motor Speed command received */
86  #define INIREF_CMD 4 /*!< Set the new STARUP_CURRENT_REFERENCE value command received */
87  #define POLESP_CMD 5 /*!< Set the Pole Pairs value command received */
88  #define ACCELE_CMD 6 /*!< Set the Accelleration for Start-up of the motor command received */
89  #define KP_PRM_CMD 7 /*!< Set the KP PI param command received */
90  #define KI_PRM_CMD 8 /*!< Set the KI PI param command received */
91  #define POTENZ_CMD 9 /*!< Enable Potentiometer command received */
92  #define HELP_CMD 10 /*!< Help command received */
93  #define STATUS_CMD 11 /*!< Get the Status of the system command received */
94  #define DIRECT_CMD 12 /*!< Get the motor direction */
95 
96  /** @addtogroup stm32F401_nucleo_ihm11m1 stm32F401_nucleo_ihm11m1
97  * @brief Interface file for STM32F401 and Library configuration
98  * @{
99  */
100 
101  /** @defgroup Exported_function_F401 Exported_function_F401
102  * @{
103  */
104  /**
105  * @brief API function for STM32 instruction
106  */
107  void MC_SixStep_ADC_Channel(uint32_t);
108  void MC_SixStep_Nucleo_Init(void);
109  void START_Ref_Generation(void);
110  void STOP_Ref_Generation(void);
111  void Set_Ref_Generation(uint16_t);
112  void START_DAC(void);
113  void STOP_DAC(void);
114  void SET_DAC_value(uint16_t);
115  void Bemf_delay_calc(void);
116  uint32_t Get_UART_Data(void);
121  void MC_SixStep_Start_PWM_driving(void);
122  void MC_SixStep_Stop_PWM_driving(void);
129  void BSP_X_NUCLEO_FAULT_LED_ON(void);
130  void BSP_X_NUCLEO_FAULT_LED_OFF(void);
131  /**
132  * @}
133  */
134 
135  /**
136  * @}
137  */
138 #endif
void MC_SixStep_HF_TIMx_SetDutyCycle_CH3(uint16_t)
Set the Duty Cycle value for CH3.
void START_DAC(void)
Start DAC for debug.
void MC_SixStep_DisableInput_CH1_D_CH2_D_CH3_D(void)
Enable Input channel CH2 and CH3 for STSPIN230.
void STOP_DAC(void)
Stop DAC for debug.
void Set_Ref_Generation(uint16_t)
void MC_SixStep_EnableInput_CH1_E_CH2_D_CH3_E(void)
Enable Input channel CH1 and CH3 for STSPIN230.
void MC_SixStep_Stop_PWM_driving(void)
Disable PWM channels for STSPIN230.
void STOP_Ref_Generation(void)
void MC_SixStep_Current_Reference_Start(void)
Enable the Current Reference generation.
void MC_SixStep_HF_TIMx_SetDutyCycle_CH2(uint16_t)
Set the Duty Cycle value for CH2.
Main program body for STM32F401xx.
void BSP_X_NUCLEO_FAULT_LED_ON(void)
void Bemf_delay_calc(void)
Bemf delay calculation.
void MC_SixStep_HF_TIMx_SetDutyCycle_CH1(uint16_t)
Set the Duty Cycle value for CH1.
void MC_SixStep_EnableInput_CH1_E_CH2_E_CH3_D(void)
Enable Input channel CH1 and CH2 for STSPIN230.
void MC_SixStep_Nucleo_Init(void)
Init the STM32 register.
void SET_DAC_value(uint16_t)
Set DAC value for debug.
void MC_SixStep_Current_Reference_Stop(void)
Disable the Current Reference generation.
uint32_t Get_UART_Data(void)
Get the UART value from DR register.
void MC_SixStep_Start_PWM_driving(void)
Enable PWM channels for STSPIN230.
void MC_SixStep_EnableInput_CH1_D_CH2_E_CH3_E(void)
Enable Input channel CH2 and CH3 for STSPIN230.
void MC_SixStep_ADC_Channel(uint32_t)
API function for STM32 instruction.
void BSP_X_NUCLEO_FAULT_LED_OFF(void)
void START_Ref_Generation(void)
void MC_SixStep_Current_Reference_Setvalue(uint16_t)
Set the value for Current Reference.
Generated by   doxygen 1.8.11