Library used to control ST Nucleo Evaluation board IHM12A1, based on STSPIN240 low voltage dual brush DC motor control driver.

Dependencies:   ST_INTERFACES

Dependents:   motori prova_motore SchedamotoriIHM12A1 prova_motore_duck ... more

Fork of X-NUCLEO-IHM12A1 by ST Expansion SW Team

Brush DC Motor Control Library

Library to handle the X-NUCLEO-IHM12A1 Motor Control Expansion Board based on the STSPIN240 component.

It allows a complete management of the STSPIN240, a low voltage dual brush DC driver, by providing a complete APIs.

The key features of the library are :

  • Configuration of the STSPIN240 (bridges input and enabling signals)
  • Flag interrupt handling (overcurrent and thermal alarms reporting)
  • Handling of up to two bidirectional Brush DC motors
  • Nucleo and expansion board configuration (GPIOs, PWMs, IRQs…)

To use the STSPIN240 driver library, the user first has to call its initialization method which:

  • Setups the required GPIOs to handle the bridges enable pins, the FLAG interrupt which reports overcurrent detection or thermal protection.
  • Loads the driver parameters with initial values configured by the user or with their predefined values from “stspin240_250_target_config.h”, in order to program the PWMs frequency of the bridges inputs, the number of brush DC motors.

Once the initialization is done, the user can modify the driver parameters by calling specific functions to change the numbers of motors or the PWMs frequency.

The user can also write callback functions and attach them to:

  • The flag interrupt handler depending on the actions he wants to perform when an overcurrent or a thermal alarm is reported.
  • The Error handler which is called by the library when it reports an error.

Then, the user can drive the different brush DC motors by requesting to run in a specified direction and by changing the maximal speed. When a motor is requested to run, the corresponding bridge is automatically enabled.

A motion command can be stopped at any moment:

  • Either by a hard stop which immediately stops the motor.
  • Or by a hardHiz command which immediately stops the motor and disables the bridge which is used by the motor.

The library also provides functions to disable or enable the bridges independently from the run or stop commands.

Arduino Connector Compatibility Warning

Using the X-NUCLEO-IHM12A1 expansion board with the NUCLEO-F429ZI requires adopting the following patch:

  • to connect with a wire the PB_3 Nucleo pin to the PWMB expansion board pin.


Board configuration for HelloWorld_IHM12A1 example

/media/uploads/Manu_L/x_nucleo_ihm12a1.jpg

Committer:
Davidroid
Date:
Thu Aug 09 15:00:43 2018 +0000
Revision:
7:6efcc9b4d810
Parent:
3:b0128df93d26
Update comment of STSpin240_250's class constructor

Who changed what in which revision?

UserRevisionLine numberNew contents of line
davide.aliprandi@st.com 3:b0128df93d26 1 /**
davide.aliprandi@st.com 3:b0128df93d26 2 ******************************************************************************
davide.aliprandi@st.com 3:b0128df93d26 3 * @file motor_def.h
davide.aliprandi@st.com 3:b0128df93d26 4 * @author IPC Rennes
davide.aliprandi@st.com 3:b0128df93d26 5 * @version V1.6.0
davide.aliprandi@st.com 3:b0128df93d26 6 * @date April 7th, 2016
davide.aliprandi@st.com 3:b0128df93d26 7 * @brief This file contains all the functions prototypes for motor drivers.
davide.aliprandi@st.com 3:b0128df93d26 8 ******************************************************************************
davide.aliprandi@st.com 3:b0128df93d26 9 * @attention
davide.aliprandi@st.com 3:b0128df93d26 10 *
davide.aliprandi@st.com 3:b0128df93d26 11 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
davide.aliprandi@st.com 3:b0128df93d26 12 *
davide.aliprandi@st.com 3:b0128df93d26 13 * Redistribution and use in source and binary forms, with or without modification,
davide.aliprandi@st.com 3:b0128df93d26 14 * are permitted provided that the following conditions are met:
davide.aliprandi@st.com 3:b0128df93d26 15 * 1. Redistributions of source code must retain the above copyright notice,
davide.aliprandi@st.com 3:b0128df93d26 16 * this list of conditions and the following disclaimer.
davide.aliprandi@st.com 3:b0128df93d26 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
davide.aliprandi@st.com 3:b0128df93d26 18 * this list of conditions and the following disclaimer in the documentation
davide.aliprandi@st.com 3:b0128df93d26 19 * and/or other materials provided with the distribution.
davide.aliprandi@st.com 3:b0128df93d26 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
davide.aliprandi@st.com 3:b0128df93d26 21 * may be used to endorse or promote products derived from this software
davide.aliprandi@st.com 3:b0128df93d26 22 * without specific prior written permission.
davide.aliprandi@st.com 3:b0128df93d26 23 *
davide.aliprandi@st.com 3:b0128df93d26 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
davide.aliprandi@st.com 3:b0128df93d26 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
davide.aliprandi@st.com 3:b0128df93d26 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
davide.aliprandi@st.com 3:b0128df93d26 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
davide.aliprandi@st.com 3:b0128df93d26 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
davide.aliprandi@st.com 3:b0128df93d26 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
davide.aliprandi@st.com 3:b0128df93d26 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
davide.aliprandi@st.com 3:b0128df93d26 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
davide.aliprandi@st.com 3:b0128df93d26 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
davide.aliprandi@st.com 3:b0128df93d26 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
davide.aliprandi@st.com 3:b0128df93d26 34 *
davide.aliprandi@st.com 3:b0128df93d26 35 ******************************************************************************
davide.aliprandi@st.com 3:b0128df93d26 36 */
davide.aliprandi@st.com 3:b0128df93d26 37
davide.aliprandi@st.com 3:b0128df93d26 38 /* Define to prevent recursive inclusion -------------------------------------*/
davide.aliprandi@st.com 3:b0128df93d26 39 #ifndef __MOTOR_H
davide.aliprandi@st.com 3:b0128df93d26 40 #define __MOTOR_H
davide.aliprandi@st.com 3:b0128df93d26 41
davide.aliprandi@st.com 3:b0128df93d26 42 #ifdef __cplusplus
davide.aliprandi@st.com 3:b0128df93d26 43 extern "C" {
davide.aliprandi@st.com 3:b0128df93d26 44 #endif
davide.aliprandi@st.com 3:b0128df93d26 45
davide.aliprandi@st.com 3:b0128df93d26 46 /* Includes ------------------------------------------------------------------*/
davide.aliprandi@st.com 3:b0128df93d26 47 #include <stdint.h>
davide.aliprandi@st.com 3:b0128df93d26 48 #include "component_def.h"
davide.aliprandi@st.com 3:b0128df93d26 49
davide.aliprandi@st.com 3:b0128df93d26 50 /* Definitions ---------------------------------------------------------------*/
davide.aliprandi@st.com 3:b0128df93d26 51 /// boolean for false condition
davide.aliprandi@st.com 3:b0128df93d26 52 #ifndef FALSE
davide.aliprandi@st.com 3:b0128df93d26 53 #define FALSE (0)
davide.aliprandi@st.com 3:b0128df93d26 54 #endif
davide.aliprandi@st.com 3:b0128df93d26 55 /// boolean for true condition
davide.aliprandi@st.com 3:b0128df93d26 56 #ifndef TRUE
davide.aliprandi@st.com 3:b0128df93d26 57 #define TRUE (1)
davide.aliprandi@st.com 3:b0128df93d26 58 #endif
davide.aliprandi@st.com 3:b0128df93d26 59
davide.aliprandi@st.com 3:b0128df93d26 60 /* Types ---------------------------------------------------------------------*/
davide.aliprandi@st.com 3:b0128df93d26 61 /** @addtogroup BSP
davide.aliprandi@st.com 3:b0128df93d26 62 * @{
davide.aliprandi@st.com 3:b0128df93d26 63 */
davide.aliprandi@st.com 3:b0128df93d26 64
davide.aliprandi@st.com 3:b0128df93d26 65 /** @addtogroup Components
davide.aliprandi@st.com 3:b0128df93d26 66 * @{
davide.aliprandi@st.com 3:b0128df93d26 67 */
davide.aliprandi@st.com 3:b0128df93d26 68
davide.aliprandi@st.com 3:b0128df93d26 69 /** @defgroup Motor Motor
davide.aliprandi@st.com 3:b0128df93d26 70 * @{
davide.aliprandi@st.com 3:b0128df93d26 71 */
davide.aliprandi@st.com 3:b0128df93d26 72
davide.aliprandi@st.com 3:b0128df93d26 73 /** @defgroup Motor_Exported_Types Motor Exported Types
davide.aliprandi@st.com 3:b0128df93d26 74 * @{
davide.aliprandi@st.com 3:b0128df93d26 75 */
davide.aliprandi@st.com 3:b0128df93d26 76
davide.aliprandi@st.com 3:b0128df93d26 77 /** @defgroup Device_Direction_Options Device Direction Options
davide.aliprandi@st.com 3:b0128df93d26 78 * @{
davide.aliprandi@st.com 3:b0128df93d26 79 */
davide.aliprandi@st.com 3:b0128df93d26 80 /// Direction options
davide.aliprandi@st.com 3:b0128df93d26 81 typedef enum {
davide.aliprandi@st.com 3:b0128df93d26 82 BACKWARD = 0,
davide.aliprandi@st.com 3:b0128df93d26 83 FORWARD = 1,
davide.aliprandi@st.com 3:b0128df93d26 84 UNKNOW_DIR = ((uint8_t)0xFF)
davide.aliprandi@st.com 3:b0128df93d26 85 } motorDir_t;
davide.aliprandi@st.com 3:b0128df93d26 86 /**
davide.aliprandi@st.com 3:b0128df93d26 87 * @}
davide.aliprandi@st.com 3:b0128df93d26 88 */
davide.aliprandi@st.com 3:b0128df93d26 89
davide.aliprandi@st.com 3:b0128df93d26 90 /** @defgroup Device_Action_Options Device Action Options
davide.aliprandi@st.com 3:b0128df93d26 91 * @{
davide.aliprandi@st.com 3:b0128df93d26 92 */
davide.aliprandi@st.com 3:b0128df93d26 93 /// Action options
davide.aliprandi@st.com 3:b0128df93d26 94 typedef enum {
davide.aliprandi@st.com 3:b0128df93d26 95 ACTION_RESET = ((uint8_t)0x00),
davide.aliprandi@st.com 3:b0128df93d26 96 ACTION_COPY = ((uint8_t)0x08)
davide.aliprandi@st.com 3:b0128df93d26 97 } motorAction_t;
davide.aliprandi@st.com 3:b0128df93d26 98 /**
davide.aliprandi@st.com 3:b0128df93d26 99 * @}
davide.aliprandi@st.com 3:b0128df93d26 100 */
davide.aliprandi@st.com 3:b0128df93d26 101
davide.aliprandi@st.com 3:b0128df93d26 102 /** @defgroup Device_States Device States
davide.aliprandi@st.com 3:b0128df93d26 103 * @{
davide.aliprandi@st.com 3:b0128df93d26 104 */
davide.aliprandi@st.com 3:b0128df93d26 105 /// Device states
davide.aliprandi@st.com 3:b0128df93d26 106 typedef enum {
davide.aliprandi@st.com 3:b0128df93d26 107 ACCELERATING = 0,
davide.aliprandi@st.com 3:b0128df93d26 108 DECELERATINGTOSTOP = 1,
davide.aliprandi@st.com 3:b0128df93d26 109 DECELERATING = 2,
davide.aliprandi@st.com 3:b0128df93d26 110 STEADY = 3,
davide.aliprandi@st.com 3:b0128df93d26 111 INDEX_ACCEL = 4,
davide.aliprandi@st.com 3:b0128df93d26 112 INDEX_RUN = 5,
davide.aliprandi@st.com 3:b0128df93d26 113 INDEX_DECEL = 6,
davide.aliprandi@st.com 3:b0128df93d26 114 INDEX_DWELL = 7,
davide.aliprandi@st.com 3:b0128df93d26 115 INACTIVE = 8,
davide.aliprandi@st.com 3:b0128df93d26 116 STANDBY = 9,
davide.aliprandi@st.com 3:b0128df93d26 117 STANDBYTOINACTIVE = 10
davide.aliprandi@st.com 3:b0128df93d26 118 } motorState_t;
davide.aliprandi@st.com 3:b0128df93d26 119 /**
davide.aliprandi@st.com 3:b0128df93d26 120 * @}
davide.aliprandi@st.com 3:b0128df93d26 121 */
davide.aliprandi@st.com 3:b0128df93d26 122
davide.aliprandi@st.com 3:b0128df93d26 123 /** @defgroup Device_Step_mode Device Step mode
davide.aliprandi@st.com 3:b0128df93d26 124 * @{
davide.aliprandi@st.com 3:b0128df93d26 125 */
davide.aliprandi@st.com 3:b0128df93d26 126 /// Stepping options
davide.aliprandi@st.com 3:b0128df93d26 127 typedef enum {
davide.aliprandi@st.com 3:b0128df93d26 128 STEP_MODE_FULL = ((uint8_t)0x00),
davide.aliprandi@st.com 3:b0128df93d26 129 STEP_MODE_HALF = ((uint8_t)0x01),
davide.aliprandi@st.com 3:b0128df93d26 130 STEP_MODE_1_4 = ((uint8_t)0x02),
davide.aliprandi@st.com 3:b0128df93d26 131 STEP_MODE_1_8 = ((uint8_t)0x03),
davide.aliprandi@st.com 3:b0128df93d26 132 STEP_MODE_1_16 = ((uint8_t)0x04),
davide.aliprandi@st.com 3:b0128df93d26 133 STEP_MODE_1_32 = ((uint8_t)0x05),
davide.aliprandi@st.com 3:b0128df93d26 134 STEP_MODE_1_64 = ((uint8_t)0x06),
davide.aliprandi@st.com 3:b0128df93d26 135 STEP_MODE_1_128 = ((uint8_t)0x07),
davide.aliprandi@st.com 3:b0128df93d26 136 STEP_MODE_1_256 = ((uint8_t)0x08),
davide.aliprandi@st.com 3:b0128df93d26 137 STEP_MODE_UNKNOW = ((uint8_t)0xFE),
davide.aliprandi@st.com 3:b0128df93d26 138 STEP_MODE_WAVE = ((uint8_t)0xFF)
davide.aliprandi@st.com 3:b0128df93d26 139 } motorStepMode_t;
davide.aliprandi@st.com 3:b0128df93d26 140
davide.aliprandi@st.com 3:b0128df93d26 141 /**
davide.aliprandi@st.com 3:b0128df93d26 142 * @}
davide.aliprandi@st.com 3:b0128df93d26 143 */
davide.aliprandi@st.com 3:b0128df93d26 144
davide.aliprandi@st.com 3:b0128df93d26 145 /** @defgroup Decay_mode Decay mode
davide.aliprandi@st.com 3:b0128df93d26 146 * @{
davide.aliprandi@st.com 3:b0128df93d26 147 */
davide.aliprandi@st.com 3:b0128df93d26 148 /// Decay Mode
davide.aliprandi@st.com 3:b0128df93d26 149 typedef enum {
davide.aliprandi@st.com 3:b0128df93d26 150 SLOW_DECAY = 0,
davide.aliprandi@st.com 3:b0128df93d26 151 FAST_DECAY = 1,
davide.aliprandi@st.com 3:b0128df93d26 152 UNKNOW_DECAY = ((uint8_t)0xFF)
davide.aliprandi@st.com 3:b0128df93d26 153 } motorDecayMode_t;
davide.aliprandi@st.com 3:b0128df93d26 154 /**
davide.aliprandi@st.com 3:b0128df93d26 155 * @}
davide.aliprandi@st.com 3:b0128df93d26 156 */
davide.aliprandi@st.com 3:b0128df93d26 157
davide.aliprandi@st.com 3:b0128df93d26 158 /** @defgroup Stop_mode Stop mode
davide.aliprandi@st.com 3:b0128df93d26 159 * @{
davide.aliprandi@st.com 3:b0128df93d26 160 */
davide.aliprandi@st.com 3:b0128df93d26 161 /// Stop mode
davide.aliprandi@st.com 3:b0128df93d26 162 typedef enum
davide.aliprandi@st.com 3:b0128df93d26 163 {
davide.aliprandi@st.com 3:b0128df93d26 164 HOLD_MODE = 0,
davide.aliprandi@st.com 3:b0128df93d26 165 HIZ_MODE = 1,
davide.aliprandi@st.com 3:b0128df93d26 166 STANDBY_MODE = 2,
davide.aliprandi@st.com 3:b0128df93d26 167 UNKNOW_STOP_MODE = ((uint8_t)0xFF)
davide.aliprandi@st.com 3:b0128df93d26 168 } motorStopMode_t;
davide.aliprandi@st.com 3:b0128df93d26 169 /**
davide.aliprandi@st.com 3:b0128df93d26 170 * @}
davide.aliprandi@st.com 3:b0128df93d26 171 */
davide.aliprandi@st.com 3:b0128df93d26 172
davide.aliprandi@st.com 3:b0128df93d26 173 /** @defgroup Torque_mode Torque mode
davide.aliprandi@st.com 3:b0128df93d26 174 * @{
davide.aliprandi@st.com 3:b0128df93d26 175 */
davide.aliprandi@st.com 3:b0128df93d26 176 /// Torque mode
davide.aliprandi@st.com 3:b0128df93d26 177 typedef enum
davide.aliprandi@st.com 3:b0128df93d26 178 {
davide.aliprandi@st.com 3:b0128df93d26 179 ACC_TORQUE = 0,
davide.aliprandi@st.com 3:b0128df93d26 180 DEC_TORQUE = 1,
davide.aliprandi@st.com 3:b0128df93d26 181 RUN_TORQUE = 2,
davide.aliprandi@st.com 3:b0128df93d26 182 HOLD_TORQUE = 3,
davide.aliprandi@st.com 3:b0128df93d26 183 CURRENT_TORQUE = 4,
davide.aliprandi@st.com 3:b0128df93d26 184 UNKNOW_TORQUE = ((uint8_t)0xFF)
davide.aliprandi@st.com 3:b0128df93d26 185 } motorTorqueMode_t;
davide.aliprandi@st.com 3:b0128df93d26 186 /**
davide.aliprandi@st.com 3:b0128df93d26 187 * @}
davide.aliprandi@st.com 3:b0128df93d26 188 */
davide.aliprandi@st.com 3:b0128df93d26 189
davide.aliprandi@st.com 3:b0128df93d26 190 /** @defgroup Dual_Full_Bridge_Configuration Dual Full Bridge Configuration
davide.aliprandi@st.com 3:b0128df93d26 191 * @{
davide.aliprandi@st.com 3:b0128df93d26 192 */
davide.aliprandi@st.com 3:b0128df93d26 193 ///Dual full bridge configurations for brush DC motors
davide.aliprandi@st.com 3:b0128df93d26 194 typedef enum {
davide.aliprandi@st.com 3:b0128df93d26 195 PARALLELING_NONE___1_BIDIR_MOTOR_BRIDGE_A__1_BIDIR_MOTOR_BRIDGE_B = 0,
davide.aliprandi@st.com 3:b0128df93d26 196 PARALLELING_NONE___1_BIDIR_MOTOR_BRIDGE_A__2_UNDIR_MOTOR_BRIDGE_B = 1,
davide.aliprandi@st.com 3:b0128df93d26 197 PARALLELING_NONE___2_UNDIR_MOTOR_BRIDGE_A__1_BIDIR_MOTOR_BRIDGE_B = 2,
davide.aliprandi@st.com 3:b0128df93d26 198 PARALLELING_NONE___2_UNDIR_MOTOR_BRIDGE_A__2_UNDIR_MOTOR_BRIDGE_B = 3,
davide.aliprandi@st.com 3:b0128df93d26 199 PARALLELING_IN1A_IN2A__1_UNDIR_MOTOR_BRIDGE_A__1_BIDIR_MOTOR_BRIDGE_B = 4,
davide.aliprandi@st.com 3:b0128df93d26 200 PARALLELING_IN1A_IN2A__1_UNDIR_MOTOR_BRIDGE_A__2_UNDIR_MOTOR_BRIDGE_B = 5,
davide.aliprandi@st.com 3:b0128df93d26 201 PARALLELING_IN1B_IN2B__1_BIDIR_MOTOR_BRIDGE_A__1_UNDIR_MOTOR_BRIDGE_B = 6,
davide.aliprandi@st.com 3:b0128df93d26 202 PARALLELING_IN1B_IN2B__2_UNDIR_MOTOR_BRIDGE_A__1_UNDIR_MOTOR_BRIDGE_B = 7,
davide.aliprandi@st.com 3:b0128df93d26 203 PARALLELING_IN1A_IN2A__IN1B_IN2B__1_UNDIR_MOTOR_BRIDGE_A__1_UNDIR_MOTOR_BRIDGE_B = 8,
davide.aliprandi@st.com 3:b0128df93d26 204 PARALLELING_IN1A_IN2A__IN1B_IN2B__1_BIDIR_MOTOR = 9,
davide.aliprandi@st.com 3:b0128df93d26 205 PARALLELING_IN1A_IN1B__IN2A_IN2B__1_UNDIR_MOTOR_BRIDGE_1A__1_UNDIR_MOTOR_BRIDGE_2A = 10,
davide.aliprandi@st.com 3:b0128df93d26 206 PARALLELING_IN1A_IN1B__IN2A_IN2B__1_BIDIR_MOTOR = 11,
davide.aliprandi@st.com 3:b0128df93d26 207 PARALLELING_ALL_WITH_IN1A___1_UNDIR_MOTOR = 12,
davide.aliprandi@st.com 3:b0128df93d26 208 PARALLELING_END_ENUM = 13
davide.aliprandi@st.com 3:b0128df93d26 209 } dualFullBridgeConfig_t;
davide.aliprandi@st.com 3:b0128df93d26 210 /**
davide.aliprandi@st.com 3:b0128df93d26 211 * @}
davide.aliprandi@st.com 3:b0128df93d26 212 */
davide.aliprandi@st.com 3:b0128df93d26 213
davide.aliprandi@st.com 3:b0128df93d26 214 /** @defgroup Motor_Driver_Structure Motor Driver Structure
davide.aliprandi@st.com 3:b0128df93d26 215 * @{
davide.aliprandi@st.com 3:b0128df93d26 216 */
davide.aliprandi@st.com 3:b0128df93d26 217 /**
davide.aliprandi@st.com 3:b0128df93d26 218 * @brief MOTOR driver virtual table structure definition.
davide.aliprandi@st.com 3:b0128df93d26 219 */
davide.aliprandi@st.com 3:b0128df93d26 220 typedef struct
davide.aliprandi@st.com 3:b0128df93d26 221 {
davide.aliprandi@st.com 3:b0128df93d26 222 /* ACTION ----------------------------------------------------------------*
davide.aliprandi@st.com 3:b0128df93d26 223 * Declare here the component's generic functions. *
davide.aliprandi@st.com 3:b0128df93d26 224 * Tag this group of functions with the " Generic " C-style comment. *
davide.aliprandi@st.com 3:b0128df93d26 225 * A component's interface has to define at least the two generic *
davide.aliprandi@st.com 3:b0128df93d26 226 * functions provided here below within the "Example" section, as the *
davide.aliprandi@st.com 3:b0128df93d26 227 * first and second functions of its Virtual Table. They have to be *
davide.aliprandi@st.com 3:b0128df93d26 228 * specified exactly in the given way. *
davide.aliprandi@st.com 3:b0128df93d26 229 * *
davide.aliprandi@st.com 3:b0128df93d26 230 * Example: *
davide.aliprandi@st.com 3:b0128df93d26 231 * status_t (*init) (void *handle, void *init); *
davide.aliprandi@st.com 3:b0128df93d26 232 * status_t (*read_id) (void *handle, uint8_t *id); *
davide.aliprandi@st.com 3:b0128df93d26 233 *------------------------------------------------------------------------*/
davide.aliprandi@st.com 3:b0128df93d26 234 /* Generic */
davide.aliprandi@st.com 3:b0128df93d26 235 status_t (*init)(void *handle, void *init);
davide.aliprandi@st.com 3:b0128df93d26 236 status_t (*read_id)(void *handle, uint8_t *id);
davide.aliprandi@st.com 3:b0128df93d26 237 /* ACTION ----------------------------------------------------------------*
davide.aliprandi@st.com 3:b0128df93d26 238 * Declare here the component's interrupts related functions. *
davide.aliprandi@st.com 3:b0128df93d26 239 * Tag this group of functions with the " Interrupts " C-style comment. *
davide.aliprandi@st.com 3:b0128df93d26 240 * Do not specify any function if not required. *
davide.aliprandi@st.com 3:b0128df93d26 241 * *
davide.aliprandi@st.com 3:b0128df93d26 242 * Example: *
davide.aliprandi@st.com 3:b0128df93d26 243 * void (*ConfigIT) (void *handle, int a); *
davide.aliprandi@st.com 3:b0128df93d26 244 *------------------------------------------------------------------------*/
davide.aliprandi@st.com 3:b0128df93d26 245 /* Interrupts */
davide.aliprandi@st.com 3:b0128df93d26 246 /// Function pointer to attach_error_handler
davide.aliprandi@st.com 3:b0128df93d26 247 void (*attach_error_handler)(void *handle, void (*callback)(void *handle, uint16_t error));
davide.aliprandi@st.com 3:b0128df93d26 248 /// Function pointer to attach_flag_interrupt
davide.aliprandi@st.com 3:b0128df93d26 249 void (*attach_flag_interrupt)(void *handle, void (*callback)(void *handle));
davide.aliprandi@st.com 3:b0128df93d26 250 /// Function pointer to AttachBusyInterrupt
davide.aliprandi@st.com 3:b0128df93d26 251 void (*AttachBusyInterrupt)(void *handle, void (*callback)(void *handle));
davide.aliprandi@st.com 3:b0128df93d26 252 /// Function pointer to FlagInterruptHandler
davide.aliprandi@st.com 3:b0128df93d26 253 void (*FlagInterruptHandler)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 254 /* ACTION ----------------------------------------------------------------*
davide.aliprandi@st.com 3:b0128df93d26 255 * Declare here the component's specific functions. *
davide.aliprandi@st.com 3:b0128df93d26 256 * Tag this group of functions with the " Specific " C-style comment. *
davide.aliprandi@st.com 3:b0128df93d26 257 * Do not specify any function if not required. *
davide.aliprandi@st.com 3:b0128df93d26 258 * *
davide.aliprandi@st.com 3:b0128df93d26 259 * Example: *
davide.aliprandi@st.com 3:b0128df93d26 260 * status_t (*GetValue) (void *handle, float *f); *
davide.aliprandi@st.com 3:b0128df93d26 261 *------------------------------------------------------------------------*/
davide.aliprandi@st.com 3:b0128df93d26 262 /* Specific */
davide.aliprandi@st.com 3:b0128df93d26 263 /// Function pointer to get_acceleration
davide.aliprandi@st.com 3:b0128df93d26 264 uint16_t (*get_acceleration)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 265 /// Function pointer to GetCurrentSpeed
davide.aliprandi@st.com 3:b0128df93d26 266 uint16_t (*GetCurrentSpeed)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 267 /// Function pointer to get_deceleration
davide.aliprandi@st.com 3:b0128df93d26 268 uint16_t (*get_deceleration)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 269 /// Function pointer to get_device_state
davide.aliprandi@st.com 3:b0128df93d26 270 motorState_t(*get_device_state)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 271 /// Function pointer to get_fw_version
davide.aliprandi@st.com 3:b0128df93d26 272 uint32_t (*get_fw_version)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 273 /// Function pointer to get_mark
davide.aliprandi@st.com 3:b0128df93d26 274 int32_t (*get_mark)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 275 /// Function pointer to get_max_speed
davide.aliprandi@st.com 3:b0128df93d26 276 uint16_t (*get_max_speed)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 277 /// Function pointer to get_min_speed
davide.aliprandi@st.com 3:b0128df93d26 278 uint16_t (*get_min_speed)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 279 /// Function pointer to get_position
davide.aliprandi@st.com 3:b0128df93d26 280 int32_t (*get_position)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 281 /// Function pointer to go_home
davide.aliprandi@st.com 3:b0128df93d26 282 void (*go_home)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 283 /// Function pointer to go_mark
davide.aliprandi@st.com 3:b0128df93d26 284 void (*go_mark)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 285 /// Function pointer to go_to
davide.aliprandi@st.com 3:b0128df93d26 286 void (*go_to)(void *handle, int32_t targetPosition);
davide.aliprandi@st.com 3:b0128df93d26 287 /// Function pointer to hard_stop
davide.aliprandi@st.com 3:b0128df93d26 288 void (*hard_stop)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 289 /// Function pointer to move
davide.aliprandi@st.com 3:b0128df93d26 290 void (*move)(void *handle, motorDir_t direction, uint32_t stepCount);
davide.aliprandi@st.com 3:b0128df93d26 291 /// Function pointer to ResetAllDevices
davide.aliprandi@st.com 3:b0128df93d26 292 //void (*ResetAllDevices)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 293 /// Function pointer to run
davide.aliprandi@st.com 3:b0128df93d26 294 void (*run)(void *handle, motorDir_t direction);
davide.aliprandi@st.com 3:b0128df93d26 295 /// Function pointer to set_acceleration
davide.aliprandi@st.com 3:b0128df93d26 296 bool (*set_acceleration)(void *handle, uint16_t newAcc);
davide.aliprandi@st.com 3:b0128df93d26 297 /// Function pointer to set_deceleration
davide.aliprandi@st.com 3:b0128df93d26 298 bool (*set_deceleration)(void *handle, uint16_t newDec);
davide.aliprandi@st.com 3:b0128df93d26 299 /// Function pointer to set_home
davide.aliprandi@st.com 3:b0128df93d26 300 void (*set_home)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 301 /// Function pointer to set_mark
davide.aliprandi@st.com 3:b0128df93d26 302 void (*set_mark)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 303 /// Function pointer to set_max_speed
davide.aliprandi@st.com 3:b0128df93d26 304 bool (*set_max_speed)(void *handle, uint16_t newMaxSpeed);
davide.aliprandi@st.com 3:b0128df93d26 305 /// Function pointer to set_min_speed
davide.aliprandi@st.com 3:b0128df93d26 306 bool (*set_min_speed)(void *handle, uint16_t newMinSpeed);
davide.aliprandi@st.com 3:b0128df93d26 307 /// Function pointer to soft_stop
davide.aliprandi@st.com 3:b0128df93d26 308 bool (*soft_stop)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 309 /// Function pointer to StepClockHandler
davide.aliprandi@st.com 3:b0128df93d26 310 void (*StepClockHandler)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 311 /// Function pointer to wait_while_active
davide.aliprandi@st.com 3:b0128df93d26 312 void (*wait_while_active)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 313 /// Function pointer to CmdDisable
davide.aliprandi@st.com 3:b0128df93d26 314 void (*CmdDisable)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 315 /// Function pointer to CmdEnable
davide.aliprandi@st.com 3:b0128df93d26 316 void (*CmdEnable)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 317 /// Function pointer to CmdGetParam
davide.aliprandi@st.com 3:b0128df93d26 318 uint32_t (*CmdGetParam)(void *handle, uint32_t param);
davide.aliprandi@st.com 3:b0128df93d26 319 /// Function pointer to CmdGetStatus
davide.aliprandi@st.com 3:b0128df93d26 320 uint16_t (*CmdGetStatus)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 321 /// Function pointer to CmdNop
davide.aliprandi@st.com 3:b0128df93d26 322 void (*CmdNop)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 323 /// Function pointer to CmdSetParam
davide.aliprandi@st.com 3:b0128df93d26 324 void (*CmdSetParam)(void *handle, uint32_t param, uint32_t value);
davide.aliprandi@st.com 3:b0128df93d26 325 /// Function pointer to read_status_register
davide.aliprandi@st.com 3:b0128df93d26 326 uint16_t (*read_status_register)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 327 /// Function pointer to release_reset
davide.aliprandi@st.com 3:b0128df93d26 328 void (*release_reset)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 329 /// Function pointer to Reset
davide.aliprandi@st.com 3:b0128df93d26 330 void (*Reset)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 331 /// Function pointer to SelectStepMode
davide.aliprandi@st.com 3:b0128df93d26 332 bool (*SelectStepMode)(void *handle, motorStepMode_t);
davide.aliprandi@st.com 3:b0128df93d26 333 /// Function pointer to set_direction
davide.aliprandi@st.com 3:b0128df93d26 334 void (*set_direction)(void *handle, motorDir_t direction);
davide.aliprandi@st.com 3:b0128df93d26 335 /// Function pointer to CmdGoToDir
davide.aliprandi@st.com 3:b0128df93d26 336 void (*CmdGoToDir)(void *handle, motorDir_t direction, int32_t targetPosition);
davide.aliprandi@st.com 3:b0128df93d26 337 /// Function pointer to check_busy_hw
davide.aliprandi@st.com 3:b0128df93d26 338 uint8_t (*check_busy_hw)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 339 /// Function pointer to check_status_hw
davide.aliprandi@st.com 3:b0128df93d26 340 uint8_t (*check_status_hw)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 341 /// Function pointer to CmdGoUntil
davide.aliprandi@st.com 3:b0128df93d26 342 void (*CmdGoUntil)(void *handle, motorAction_t action, motorDir_t direction, uint32_t targetPosition);
davide.aliprandi@st.com 3:b0128df93d26 343 /// Function pointer to CmdHardHiZ
davide.aliprandi@st.com 3:b0128df93d26 344 void (*CmdHardHiZ)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 345 /// Function pointer to CmdReleaseSw
davide.aliprandi@st.com 3:b0128df93d26 346 void (*CmdReleaseSw)(void *handle, motorAction_t action, motorDir_t direction);
davide.aliprandi@st.com 3:b0128df93d26 347 /// Function pointer to CmdResetDevice
davide.aliprandi@st.com 3:b0128df93d26 348 void (*CmdResetDevice)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 349 /// Function pointer to CmdResetPos
davide.aliprandi@st.com 3:b0128df93d26 350 void (*CmdResetPos)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 351 /// Function pointer to CmdRun
davide.aliprandi@st.com 3:b0128df93d26 352 void (*CmdRun)(void *handle, motorDir_t direction, uint32_t targetPosition);
davide.aliprandi@st.com 3:b0128df93d26 353 /// Function pointer to CmdSoftHiZ
davide.aliprandi@st.com 3:b0128df93d26 354 void (*CmdSoftHiZ)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 355 /// Function pointer to CmdStepClock
davide.aliprandi@st.com 3:b0128df93d26 356 void (*CmdStepClock)(void *handle, motorDir_t direction);
davide.aliprandi@st.com 3:b0128df93d26 357 /// Function pointer to fetch_and_clear_all_status
davide.aliprandi@st.com 3:b0128df93d26 358 void (*fetch_and_clear_all_status)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 359 /// Function pointer to get_fetched_status
davide.aliprandi@st.com 3:b0128df93d26 360 uint16_t (*get_fetched_status)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 361 /// Function pointer to get_nb_devices
davide.aliprandi@st.com 3:b0128df93d26 362 uint8_t (*get_nb_devices)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 363 /// Function pointer to is_device_busy
davide.aliprandi@st.com 3:b0128df93d26 364 bool (*is_device_busy)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 365 /// Function pointer to send_queued_commands
davide.aliprandi@st.com 3:b0128df93d26 366 void (*send_queued_commands)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 367 /// Function pointer to queue_commands
davide.aliprandi@st.com 3:b0128df93d26 368 void (*queue_commands)(void *handle, uint8_t command, int32_t value);
davide.aliprandi@st.com 3:b0128df93d26 369 /// Function pointer to WaitForAllDevicesNotBusy
davide.aliprandi@st.com 3:b0128df93d26 370 void (*WaitForAllDevicesNotBusy)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 371 /// Function pointer to error_handler
davide.aliprandi@st.com 3:b0128df93d26 372 void (*error_handler)(void *handle, uint16_t error);
davide.aliprandi@st.com 3:b0128df93d26 373 /// Function pointer to BusyInterruptHandler
davide.aliprandi@st.com 3:b0128df93d26 374 void (*BusyInterruptHandler)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 375 /// Function pointer to CmdSoftStop
davide.aliprandi@st.com 3:b0128df93d26 376 void (*CmdSoftStop)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 377 /// Function pointer to StartStepClock
davide.aliprandi@st.com 3:b0128df93d26 378 void (*StartStepClock)(void *handle, uint16_t newFreq);
davide.aliprandi@st.com 3:b0128df93d26 379 /// Function pointer to StopStepClock
davide.aliprandi@st.com 3:b0128df93d26 380 void (*StopStepClock)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 381 /// Function pointer to set_dual_full_bridge_config
davide.aliprandi@st.com 3:b0128df93d26 382 void (*set_dual_full_bridge_config)(void *handle, uint8_t config);
davide.aliprandi@st.com 3:b0128df93d26 383 /// Function pointer to get_bridge_input_pwm_freq
davide.aliprandi@st.com 3:b0128df93d26 384 uint32_t (*get_bridge_input_pwm_freq)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 385 /// Function pointer to set_bridge_input_pwm_freq
davide.aliprandi@st.com 3:b0128df93d26 386 void (*set_bridge_input_pwm_freq)(void *handle, uint32_t newFreq);
davide.aliprandi@st.com 3:b0128df93d26 387 /// Function pointer to set_stop_mode
davide.aliprandi@st.com 3:b0128df93d26 388 void (*set_stop_mode)(void *handle, motorStopMode_t stopMode);
davide.aliprandi@st.com 3:b0128df93d26 389 /// Function pointer to get_stop_mode
davide.aliprandi@st.com 3:b0128df93d26 390 motorStopMode_t (*get_stop_mode)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 391 /// Function pointer to set_decay_mode
davide.aliprandi@st.com 3:b0128df93d26 392 void (*set_decay_mode)(void *handle, motorDecayMode_t decayMode);
davide.aliprandi@st.com 3:b0128df93d26 393 /// Function pointer to get_decay_mode
davide.aliprandi@st.com 3:b0128df93d26 394 motorDecayMode_t (*get_decay_mode)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 395 /// Function pointer to get_step_mode
davide.aliprandi@st.com 3:b0128df93d26 396 motorStepMode_t (*get_step_mode)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 397 /// Function pointer to get_direction
davide.aliprandi@st.com 3:b0128df93d26 398 motorDir_t (*get_direction)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 399 /// Function pointer to ExitDeviceFromReset
davide.aliprandi@st.com 3:b0128df93d26 400 void (*ExitDeviceFromReset)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 401 /// Function pointer to set_torque
davide.aliprandi@st.com 3:b0128df93d26 402 void (*set_torque)(void *handle, motorTorqueMode_t torqueMode, uint8_t torqueValue);
davide.aliprandi@st.com 3:b0128df93d26 403 /// Function pointer to get_torque
davide.aliprandi@st.com 3:b0128df93d26 404 uint8_t (*get_torque)(void *handle, motorTorqueMode_t torqueMode);
davide.aliprandi@st.com 3:b0128df93d26 405 /// Function pointer to SetVRefFreq
davide.aliprandi@st.com 3:b0128df93d26 406 void (*SetRefFreq)(void *handle, uint32_t newFreq);
davide.aliprandi@st.com 3:b0128df93d26 407 /// Function pointer to GetVRefFreq
davide.aliprandi@st.com 3:b0128df93d26 408 uint32_t (*GetRefFreq)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 409 /// Function pointer to SetVRefDc
davide.aliprandi@st.com 3:b0128df93d26 410 void (*SetRefDc)(void *handle, uint8_t newDc);
davide.aliprandi@st.com 3:b0128df93d26 411 /// Function pointer to GetVRefDc
davide.aliprandi@st.com 3:b0128df93d26 412 uint8_t (*GetRefDc)(void *handle);
davide.aliprandi@st.com 3:b0128df93d26 413 /// Function pointer to set_nb_devices
davide.aliprandi@st.com 3:b0128df93d26 414 bool (*set_nb_devices)(void *handle, uint8_t nbDevices);
davide.aliprandi@st.com 3:b0128df93d26 415 /// Function pointer to set a parameter
davide.aliprandi@st.com 3:b0128df93d26 416 bool (*set_analog_value)(void *handle, uint32_t param, float value);
davide.aliprandi@st.com 3:b0128df93d26 417 /// Function pointer to get a parameter
davide.aliprandi@st.com 3:b0128df93d26 418 float (*get_analog_value)(void *handle, uint32_t param);
davide.aliprandi@st.com 3:b0128df93d26 419 } MOTOR_VTable_t;
davide.aliprandi@st.com 3:b0128df93d26 420 /**
davide.aliprandi@st.com 3:b0128df93d26 421 * @}
davide.aliprandi@st.com 3:b0128df93d26 422 */
davide.aliprandi@st.com 3:b0128df93d26 423
davide.aliprandi@st.com 3:b0128df93d26 424 /**
davide.aliprandi@st.com 3:b0128df93d26 425 * @}
davide.aliprandi@st.com 3:b0128df93d26 426 */
davide.aliprandi@st.com 3:b0128df93d26 427
davide.aliprandi@st.com 3:b0128df93d26 428 /**
davide.aliprandi@st.com 3:b0128df93d26 429 * @}
davide.aliprandi@st.com 3:b0128df93d26 430 */
davide.aliprandi@st.com 3:b0128df93d26 431
davide.aliprandi@st.com 3:b0128df93d26 432 /**
davide.aliprandi@st.com 3:b0128df93d26 433 * @}
davide.aliprandi@st.com 3:b0128df93d26 434 */
davide.aliprandi@st.com 3:b0128df93d26 435
davide.aliprandi@st.com 3:b0128df93d26 436 /**
davide.aliprandi@st.com 3:b0128df93d26 437 * @}
davide.aliprandi@st.com 3:b0128df93d26 438 */
davide.aliprandi@st.com 3:b0128df93d26 439
davide.aliprandi@st.com 3:b0128df93d26 440 #ifdef __cplusplus
davide.aliprandi@st.com 3:b0128df93d26 441 }
davide.aliprandi@st.com 3:b0128df93d26 442 #endif
davide.aliprandi@st.com 3:b0128df93d26 443
davide.aliprandi@st.com 3:b0128df93d26 444 #endif /* __MOTOR_H */
davide.aliprandi@st.com 3:b0128df93d26 445
davide.aliprandi@st.com 3:b0128df93d26 446 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/