Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: ST_INTERFACES
Dependents: motori prova_motore SchedamotoriIHM12A1 prova_motore_duck ... more
Fork of X-NUCLEO-IHM12A1 by
STSpin240_250_def.h
00001 /** 00002 ****************************************************************************** 00003 * @file STSpin240_250_def.h 00004 * @author IPC Rennes 00005 * @version V1.0.0 00006 * @date February 10, 2016 00007 * @brief Header for STSpin240 (low voltage dual brush DC motor driver) and 00008 * STSpin250 driver (low voltage brush DC motor driver) 00009 * @note (C) COPYRIGHT 2016 STMicroelectronics 00010 ****************************************************************************** 00011 * @attention 00012 * 00013 * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> 00014 * 00015 * Redistribution and use in source and binary forms, with or without modification, 00016 * are permitted provided that the following conditions are met: 00017 * 1. Redistributions of source code must retain the above copyright notice, 00018 * this list of conditions and the following disclaimer. 00019 * 2. Redistributions in binary form must reproduce the above copyright notice, 00020 * this list of conditions and the following disclaimer in the documentation 00021 * and/or other materials provided with the distribution. 00022 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00023 * may be used to endorse or promote products derived from this software 00024 * without specific prior written permission. 00025 * 00026 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00027 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00028 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00029 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00030 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00031 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00032 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00033 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00034 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00035 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00036 * 00037 ****************************************************************************** 00038 */ 00039 00040 /* Define to prevent recursive inclusion -------------------------------------*/ 00041 #ifndef __STSPIN240_250_H 00042 #define __STSPIN240_250_H 00043 00044 #ifdef __cplusplus 00045 extern "C" { 00046 #endif 00047 00048 /* Includes ------------------------------------------------------------------*/ 00049 #include "STSpin240_250_config.h" 00050 #include "motor_def.h" 00051 00052 /* Definitions ---------------------------------------------------------------*/ 00053 00054 /** @addtogroup Components 00055 * @{ 00056 */ 00057 00058 /** @defgroup STSPIN240_250 STSPIN240_250 00059 * @{ 00060 */ 00061 00062 /** @defgroup STSPIN240_250_Exported_Defines STSPIN240_250 Exported Defines 00063 * @{ 00064 */ 00065 00066 /// Current FW version 00067 00068 /// Current FW major version 00069 #define STSPIN240_250_FW_MAJOR_VERSION (uint8_t)(1) 00070 /// Current FW minor version 00071 #define STSPIN240_250_FW_MINOR_VERSION (uint8_t)(0) 00072 /// Current FW patch version 00073 #define STSPIN240_250_FW_PATCH_VERSION (uint8_t)(0) 00074 /// Current FW version 00075 #define STSPIN240_250_FW_VERSION (uint32_t)((STSPIN240_250_FW_MAJOR_VERSION<<16)|\ 00076 (STSPIN240_250_FW_MINOR_VERSION<<8)|\ 00077 (STSPIN240_250_FW_PATCH_VERSION)) 00078 00079 ///Max number of Brush DC motors 00080 #define STSPIN240_250_NB_MAX_MOTORS (2) 00081 ///Number of Bridges 00082 #define STSPIN240_250_NB_BRIDGES (2) 00083 00084 /** 00085 * @} 00086 */ 00087 00088 /* Types ---------------------------------------------------------------------*/ 00089 00090 /** @defgroup STSPIN240_250_Exported_Types STSPIN240_250 Exported Types 00091 * @{ 00092 */ 00093 00094 00095 /** @defgroup Device_Parameters Device Parameters 00096 * @{ 00097 */ 00098 00099 /// Device Parameters Structure Type 00100 typedef struct { 00101 /// Pwm frequency of the bridge input 00102 uint32_t bridgePwmFreq[STSPIN240_250_NB_BRIDGES]; 00103 /// Pwm frequency of the ref pin 00104 uint32_t refPwmFreq; 00105 /// Pwm Duty Cycle of the ref pin 00106 uint8_t refPwmDc; 00107 /// Speed% (from 0 to 100) of the corresponding motor 00108 uint16_t speed[STSPIN240_250_NB_MAX_MOTORS]; 00109 /// FORWARD or BACKWARD direction of the motors 00110 motorDir_t direction[STSPIN240_250_NB_MAX_MOTORS]; 00111 /// Current State of the motors 00112 motorState_t motionState[STSPIN240_250_NB_MAX_MOTORS]; 00113 /// Current State of the bridges 00114 bool bridgeEnabled[STSPIN240_250_NB_BRIDGES]; 00115 /// Enabling of a dual bridge configuration 00116 bool dualBridgeEnabled; 00117 }deviceParams_t; 00118 00119 /** 00120 * @} 00121 */ 00122 00123 00124 00125 /** @defgroup STSpin240_250_Initialization_Structure STSpin240_250 Initialization Structure 00126 * @{ 00127 */ 00128 /* ACTION --------------------------------------------------------------------* 00129 * Declare here the component's initialization structure, if any, one * 00130 * variable per line without initialization. * 00131 * * 00132 * Example: * 00133 * typedef struct * 00134 * { * 00135 * int frequency; * 00136 * int update_mode; * 00137 * } COMPONENT_init_t; * 00138 *----------------------------------------------------------------------------*/ 00139 typedef struct { 00140 /* Frequency of the bridge PWMs in Hz up to 100000Hz */ 00141 uint32_t bridgePwmFreq[STSPIN240_250_NB_BRIDGES]; 00142 /* Frequency of the PWM used for Ref pin in Hz up to 100000Hz */ 00143 uint32_t refPwmFreq; 00144 /* Duty cycle of the PWM used for Ref pin in % (0..100) */ 00145 uint8_t refPwmDc; 00146 /* Dual Bridge configuration (0 for mono, 1 for dual brush dc (STSPIN240 only) */ 00147 bool dualBridgeEnabled; 00148 } STSpin240_250_init_t; 00149 00150 /** 00151 * @} 00152 */ 00153 00154 /** 00155 * @brief Powerstep01 driver data structure definition. 00156 */ 00157 /* ACTION --------------------------------------------------------------------* 00158 * Declare here the structure of component's data, if any, one variable per * 00159 * line without initialization. * 00160 * * 00161 * Example: * 00162 * typedef struct * 00163 * { * 00164 * int T0_out; * 00165 * int T1_out; * 00166 * float T0_degC; * 00167 * float T1_degC; * 00168 * } COMPONENT_Data_t; * 00169 *----------------------------------------------------------------------------*/ 00170 00171 /** 00172 * @} 00173 */ 00174 00175 /** 00176 * @} 00177 */ 00178 00179 /* Functions -----------------------------------------------------------------*/ 00180 00181 00182 /** @defgroup STSPIN240_250_Board_Linked_Functions STSPIN240_250 Board Linked Functions 00183 * @{ 00184 */ 00185 00186 /* ACTION --------------------------------------------------------------------* 00187 * Declare here extern platform-dependent APIs you might need (e.g.: I/O and * 00188 * interrupt related functions), and implement them in a glue-logic file on * 00189 * the target environment, for example within the "x_nucleo_board.c" file. * 00190 * E.g.: * 00191 * extern status_t COMPONENT_IO_Init (void *handle); * 00192 * extern status_t COMPONENT_IO_Read (handle, buf, regadd, bytes); * 00193 * extern status_t COMPONENT_IO_Write(handle, buf, regadd, bytes); * 00194 * extern void COMPONENT_IO_ITConfig(void); * 00195 *----------------------------------------------------------------------------*/ 00196 00197 ///Delay of the requested number of milliseconds 00198 extern void STSpin240_250_Board_Delay(void *handle, uint32_t delay); 00199 ///Disable the bridges 00200 extern void STSpin240_250_Board_DisableBridge(void *handle); 00201 ///Enable the specified bridge 00202 extern void STSpin240_250_Board_EnableBridge(void *handle, uint8_t addDelay); 00203 //Get the status of the flag and enable Pin 00204 extern uint8_t STSpin240_250_Board_GetFaultPinState(void *handle); 00205 //Get the status of the reset Pin 00206 extern uint8_t STSpin240_250_Board_GetResetPinState(void *handle); 00207 ///Set Briges Inputs PWM frequency and start it 00208 extern void STSpin240_250_Board_PwmSetFreq(void *handle, uint8_t pwmId, uint32_t newFreq, uint8_t duty); 00209 ///Deinitialise the PWM of the specified bridge input 00210 extern void STSpin240_250_Board_PwmDeInit(void *handle, uint8_t pwmId); 00211 ///init the PWM of the specified bridge input 00212 extern void STSpin240_250_Board_PwmInit(void *handle, uint8_t pwmId, uint8_t onlyChannel); 00213 ///Stop the PWM of the specified brigde input 00214 extern void STSpin240_250_Board_PwmStop(void *handle, uint8_t pwmId); 00215 ///Release the reset pin of the STSpin240 or STSpin250 00216 extern void STSpin240_250_Board_ReleaseReset(void *handle, uint8_t deviceId); 00217 ///Reset the STSpin240 or STSpin250 00218 extern void STSpin240_250_Board_Reset(void *handle, uint8_t deviceId); 00219 ///Set direction of the specified bridge 00220 extern void STSpin240_250_Board_SetDirectionGpio(void *handle, uint8_t bridgeId, uint8_t gpioState); 00221 00222 00223 /** 00224 * @} 00225 */ 00226 00227 00228 /** 00229 * @} 00230 */ 00231 00232 /** 00233 * @} 00234 */ 00235 00236 #ifdef __cplusplus 00237 } 00238 #endif 00239 00240 #endif /* #ifndef __STSPIN240_250_H */ 00241 00242 00243 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Generated on Wed Jul 13 2022 07:47:18 by
1.7.2

X-NUCLEO-IHM12A1 Low Voltage Dual Brush DC Motor Driver