Expansion SW library to control high power stepper motor(s) using IHM03A1 expansion board(s) with Powerstep01 driver.

Dependencies:   X_NUCLEO_COMMON ST_INTERFACES

Dependents:   IHM03A1_ExampleFor1Motor HelloWorld_IHM03A1 IHM03A1_ExampleFor3Motors KYPHOS_Stepper_Motor_Control

Fork of X_NUCLEO_IHM03A1 by ST Expansion SW Team

Motor Control Library

Library to handle the X-NUCLEO-IHM03A1 Motor Control Expansion Board based on the Powerstep01 component.

It features the:

  • read and write of Powerstep01 registers
  • Nucleo and expansion board configuration (GPIOs, PWMs, IRQs, etc.)
  • Powerstep01 application commands handling
  • FLAG and BUSY interrupt handling (alarm reporting)
  • Daisy chain handling

The API allows to easily:

  • perform various positioning, moves and stops
  • get/set or monitor the motor positions
  • set home position and mark another position
  • get/set minimum and maximum speed
  • get current speed
  • get/set acceleration and deceleration
  • get/set the step mode (up to 1/128)
  • get/set the control method
  • get/set parameters for voltage mode driving
  • get/set parameters for current mode driving
  • get/set parameters for gate driving
  • configure various protections such as overcurrent detection
  • enable/disable alarms
  • handle step-clock
  • get system status

Daisy-Chain Configuration

The IHM03A1 board can be stacked up to three times so that the Powerstep01 components will be connected in daisy-chain configuration. For this purpose, some resistors must be correctly connected on the boards as depicted here below:

/media/uploads/nucleosam/driving1steppermotor.png /media/uploads/nucleosam/driving2steppermotors.png /media/uploads/nucleosam/driving3steppermotors.png

Platform compatibility

Compatible platforms have been tested with the default configuration provided by the HelloWorld_IHM03A1 example.

Committer:
davide.aliprandi@st.com
Date:
Fri Mar 24 10:58:48 2017 +0100
Revision:
4:f48e8d87553e
Aligning to ARM mbed coding style.

Who changed what in which revision?

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