Diff: lib_L6470_def.h
- Revision:
- 6:7ca2eef852fd
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib_L6470_def.h Fri Apr 01 11:38:25 2022 +0000
@@ -0,0 +1,494 @@
+/* Define to prevent recursive inclusion -------------------------------------*/
+
+#ifndef __L6470_H
+#define __L6470_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Includes ------------------------------------------------------------------*/
+
+
+//#include <stdint.h>
+//#include "component_def.h"
+
+
+typedef enum {
+ L6470_ABS_POS_ID = 0, //!< Current position
+ L6470_EL_POS_ID, //!< Electrical position
+ L6470_MARK_ID, //!< Mark position
+ L6470_SPEED_ID, //!< Current speed
+ L6470_ACC_ID, //!< Acceleration
+ L6470_DEC_ID, //!< Deceleration
+ L6470_MAX_SPEED_ID, //!< Maximum speed
+ L6470_MIN_SPEED_ID, //!< Minimum speed
+ L6470_FS_SPD_ID, //!< Full-step speed
+ L6470_KVAL_HOLD_ID, //!< Holding KVAL
+ L6470_KVAL_RUN_ID, //!< Constant speed KVAL
+ L6470_KVAL_ACC_ID, //!< Acceleration starting KVAL
+ L6470_KVAL_DEC_ID, //!< Deceleration starting KVAL
+ L6470_INT_SPEED_ID, //!< Intersect speed
+ L6470_ST_SLP_ID, //!< Start slope
+ L6470_FN_SLP_ACC_ID, //!< Acceleration final slope
+ L6470_FN_SLP_DEC_ID, //!< Deceleration final slope
+ L6470_K_THERM_ID, //!< Thermal compensation factor
+ L6470_ADC_OUT_ID, //!< ADC output, (the reset value is according to startup conditions)
+ L6470_OCD_TH_ID, //!< OCD threshold
+ L6470_STALL_TH_ID, //!< STALL threshold
+ L6470_STEP_MODE_ID, //!< Step mode
+ L6470_ALARM_EN_ID, //!< Alarm enable
+ L6470_CONFIG_ID, //!< IC configuration
+ L6470_STATUS_ID //!< Status, (the reset value is according to startup conditions)
+} eL6470_RegId_t;
+
+
+typedef enum {
+ L6470_NOP_ID = 0, //!< Nothing
+ L6470_SETPARAM_ID, //!< Writes VALUE in PARAM register
+ L6470_GETPARAM_ID, //!< Returns the stored value in PARAM register
+ L6470_RUN_ID, //!< Sets the target speed and the motor direction
+ L6470_STEPCLOCK_ID, //!< Puts the device into Step-clock mode and imposes DIR direction
+ L6470_MOVE_ID, //!< Makes N_STEP (micro)steps in DIR direction (Not performable when motor is running)
+ L6470_GOTO_ID, //!< Brings motor into ABS_POS position (minimum path)
+ L6470_GOTODIR_ID, //!< Brings motor into ABS_POS position forcing DIR direction
+ L6470_GOUNTIL_ID, //!< Performs a motion in DIR direction with speed SPD until SW is closed, the ACT action is executed then a SoftStop takes place
+ L6470_RELEASESW_ID, //!< Performs a motion in DIR direction at minimum speed until the SW is released (open), the ACT action is executed then a HardStop takes place
+ L6470_GOHOME_ID, //!< Brings the motor into HOME position
+ L6470_GOMARK_ID, //!< Brings the motor into MARK position
+ L6470_RESETPOS_ID, //!< Resets the ABS_POS register (set HOME position)
+ L6470_RESETDEVICE_ID, //!< Device is reset to power-up conditions
+ L6470_SOFTSTOP_ID, //!< Stops motor with a deceleration phase
+ L6470_HARDSTOP_ID, //!< Stops motor immediately
+ L6470_SOFTHIZ_ID, //!< Puts the bridges into high impedance status after a deceleration phase
+ L6470_HARDHIZ_ID, //!< Puts the bridges into high impedance status immediately
+ L6470_GETSTATUS_ID //!< Returns the STATUS register value
+} eL6470_AppCmdId_t;
+
+
+typedef enum {
+ HiZ_ID = 0, //!< HiZ flag identifier inside the L6470 Status Register
+ BUSY_ID, //!< BUSY flag identifier inside the L6470 Status Register
+ SW_F_ID, //!< SW_F flag identifier inside the L6470 Status Register
+ SW_EVN_ID, //!< SW_EVN flag identifier inside the L6470 Status Register
+ DIR_ID, //!< DIR flag identifier inside the L6470 Status Register
+ MOT_STATUS_ID, //!< MOT_STATUS flag identifier inside the L6470 Status Register
+ NOTPERF_CMD_ID, //!< NOTPERF_CMD flag identifier inside the L6470 Status Register
+ WRONG_CMD_ID, //!< WRONG_CMD flag identifier inside the L6470 Status Register
+ UVLO_ID, //!< UVLO flag identifier inside the L6470 Status Register
+ TH_WRN_ID, //!< TH_WRN flag identifier inside the L6470 Status Register
+ TH_SD_ID, //!< TH_SD flag identifier inside the L6470 Status Register
+ OCD_ID, //!< OCD flag identifier inside the L6470 Status Register
+ STEP_LOSS_A_ID, //!< STEP_LOSS_A flag identifier inside the L6470 Status Register
+ STEP_LOSS_B_ID, //!< STEP_LOSS_B flag identifier inside the L6470 Status Register
+ SCK_MOD_ID //!< SCK_MOD flag identifier inside the L6470 Status Register
+} eL6470_StatusRegisterFlagId_t;
+
+/
+typedef enum {
+ //L6470 Direction identifiers.
+ L6470_DIR_REV_ID = 0, //!< Reverse direction
+ L6470_DIR_FWD_ID //!< Forward direction
+} eL6470_DirId_t;
+
+
+typedef enum {
+//L6470 Action identifiers about ABS_POS register.
+ L6470_ACT_RST_ID = 0, //!< ABS_POS register is reset
+ L6470_ACT_CPY_ID //!< ABS_POS register value is copied into the MARK register
+} eL6470_ActId_t;
+
+
+typedef enum {
+// L6470 Status Register Flag states.
+ ZERO_F = 0, //!< The flag is '0'
+ ONE_F = !ZERO_F //!< The flag is '1'
+} eFlagStatus_t;
+
+
+typedef enum {
+//L6470 Motor Directions
+ REVERSE_F = 0, //!< Reverse motor direction
+ FORWARD_F = !REVERSE_F //!< Forward motor direction
+} eMotorDirection_t;
+
+
+typedef enum {
+ //L6470 Motor Status.
+ STOPPED_F = 0, //!< Stopped
+ ACCELERATION_F = 1, //!< Acceleration
+ DECELERATION_F = 2, //!< Deceleration
+ CONSTANTSPEED_F = 3 //!< Constant speed
+} eMotorStatus_t;
+
+
+typedef enum {
+ //L6470 stepping modes.
+ FULL_STEP = 0x00, //!< Full-step
+ HALF_STEP = 0x01, //!< Half-step
+ MICROSTEP_1_4 = 0x02, //!< 1/4 microstep
+ MICROSTEP_1_8 = 0x03, //!< 1/8 microstep
+ MICROSTEP_1_16 = 0x04, //!< 1/16 microstep
+ MICROSTEP_1_32 = 0x05, //!< 1/32 microstep
+ MICROSTEP_1_64 = 0x06, //!< 1/64 microstep
+ MICROSTEP_1_128 = 0x07 //!< 1/128 microstep
+} eMotorStepMode_t;
+
+
+typedef enum {
+ //L6470 alarm conditions
+ L6470_OVERCURRENT = 0x01, //!< Overcurrent
+ L6470_THERMAL_SHUTDOWN = 0x02, //!< Thermal shutdown
+ L6470_THERMAL_WARNING = 0x04, //!< Thermal warning
+ L6470_UNDERVOLTAGE = 0x08, //!< Undervoltage
+ L6470_STALL_DETECTION_A = 0x10, //!< Stall detection (Bridge A)
+ L6470_STALL_DETECTION_B = 0x20, //!< Stall detection (Bridge B)
+ L6470_SWITCH_TURN_ON_EVENT = 0x40, //!< Switch turn-on event
+ L6470_WRONG_OR_NON_PERFORMABLE_COMMAND = 0x80 //!< Wrong or non-performable command
+} eL6470_AlarmCondition_t;
+
+
+typedef struct {
+//L6470 STEP_MODE Register
+ uint8_t STEP_SEL: 3; //!< Step mode
+ uint8_t WRT: 1; //!< When the register is written, this bit should be set to 0.
+ uint8_t SYNC_SEL: 3; //!< Synchronization selection
+ uint8_t SYNC_EN: 1; //!< Synchronization enable
+} sL6470_StepModeRegister_t;
+
+
+typedef struct {
+ //L6470 ALARM_EN Register
+ uint8_t OCD_EN: 1; //!< Overcurrent
+ uint8_t TH_SD_EN: 1; //!< Thermal shutdown
+ uint8_t TH_WRN_EN: 1; //!< Thermal warning
+ uint8_t UVLO_EN: 1; //!< Undervoltage
+ uint8_t STEP_LOSS_A_EN: 1; //!< Stall detection (Bridge A)
+ uint8_t STEP_LOSS_B_EN: 1; //!< Stall detection (Bridge B)
+ uint8_t SW_EVN_EN: 1; //!< Switch turn-on event
+ uint8_t WRONG_NOTPERF_CMD_EN: 1; //!< Wrong or non-performable command
+} sL6470_AlarmEnRegister_t;
+
+
+typedef struct {
+ //L6470 CONFIG Register
+ uint8_t OSC_SEL: 3; //!< Oscillator Selection
+ uint8_t EXT_CLK: 1; //!< External Clock
+ uint8_t SW_MODE: 1; //!< Switch mode
+ uint8_t EN_VSCOMP: 1; //!< Motor supply voltage compensation
+ uint8_t RESERVED: 1; //!< RESERVED
+ uint8_t OC_SD: 1; //!< Overcurrent event
+ uint8_t POW_SR: 2; //!< Output slew rate
+ uint8_t F_PWM_DEC: 3; //!< Multiplication factor
+ uint8_t F_PWM_INT: 3; //!< Integer division factor
+} sL6470_ConfigRegister_t;
+
+
+typedef struct {
+//L6470 STATUS Register
+ uint8_t HiZ: 1; //!< The bridges are in high impedance state (the flag is active high)
+ uint8_t BUSY: 1; //!< BUSY pin status (the flag is active low)
+ uint8_t SW_F: 1; //!< SW input status (the flag is low for open and high for closed)
+ uint8_t SW_EVN: 1; //!< Switch turn-on event (the flag is active high)
+ uint8_t DIR: 1; //!< The current motor direction (1 as forward, 0 as reverse)
+ uint8_t MOT_STATUS: 2; //!< The current motor status (0 as stopped, 1 as acceleration, 2 as deceleration, 3 as constant speed)
+ uint8_t NOTPERF_CMD: 1; //!< The command received by SPI cannot be performed (the flag is active high)
+ uint8_t WRONG_CMD: 1; //!< The command received by SPI does not exist at all (the flag is active high)
+ uint8_t UVLO: 1; //!< Undervoltage lockout or reset events (the flag is active low)
+ uint8_t TH_WRN: 1; //!< Thermal warning event (the flag is active low)
+ uint8_t TH_SD: 1; //!< Thermal shutdown event (the flag is active low)
+ uint8_t OCD: 1; //!< Overcurrent detection event (the flag is active low)
+ uint8_t STEP_LOSS_A: 1; //!< Stall detection on bridge A (the flag is active low)
+ uint8_t STEP_LOSS_B: 1; //!< Stall detection on bridge B (the flag is active low)
+ uint8_t SCK_MOD: 1; //!< Step-clock mode (the flag is active high)
+} sL6470_StatusRegister_t;
+
+
+typedef struct {
+ //Stepper Motor Registers
+ uint32_t ABS_POS; //!< CurrentPosition Register
+ uint16_t EL_POS; //!< ElectricalPosition Register
+ uint32_t MARK; //!< MarkPosition Register
+ uint32_t SPEED; //!< CurrentSpeed Register
+ uint16_t ACC; //!< Acceleration Register
+ uint16_t DEC; //!< Deceleration Register
+ uint16_t MAX_SPEED; //!< MaximumSpeed Register
+ uint16_t MIN_SPEED; //!< MinimumSpeed Register
+ uint16_t FS_SPD; //!< FullStepSpeed Register
+ uint8_t KVAL_HOLD; //!< HoldingKval Register
+ uint8_t KVAL_RUN; //!< ConstantSpeedKval Register
+ uint8_t KVAL_ACC; //!< AccelerationStartingKval Register
+ uint8_t KVAL_DEC; //!< DecelerationStartingKval Register
+ uint16_t INT_SPEED; //!< IntersectSpeed Register
+ uint8_t ST_SLP; //!< StartSlope Register
+ uint8_t FN_SLP_ACC; //!< AccelerationFinalSlope Register
+ uint8_t FN_SLP_DEC; //!< DecelerationFinalSlope Register
+ uint8_t K_THERM; //!< ThermalCompensationFactor Register
+ uint8_t ADC_OUT; //!< AdcOutput Register
+ uint8_t OCD_TH; //!< OcdThreshold Register
+ uint8_t STALL_TH; //!< StallThreshold Register
+ uint8_t STEP_MODE; //!< StepMode Register
+ uint8_t ALARM_EN; //!< AlarmEnable Register
+ uint16_t CONFIG; //!< Config Register
+ uint16_t STATUS; //!< Status Register
+} StepperMotorRegister_t;
+
+/**
+ * @brief
+ */
+typedef struct {
+ //MICROSTEPPING_MOTOR driver virtual table structure definition.
+
+ status_t (*Init)(void *handle, void *init);
+ status_t (*ReadID)(void *handle, uint8_t *id);
+
+ void (*SetParam)(void *handle, eL6470_RegId_t L6470_RegId, uint32_t Value);
+ uint32_t (*GetParam)(void *handle, eL6470_RegId_t L6470_RegId);
+ void (*Run)(void *handle, eL6470_DirId_t L6470_DirId, uint32_t Speed);
+ void (*StepClock)(void *handle, eL6470_DirId_t L6470_DirId);
+ void (*Move)(void *handle, eL6470_DirId_t L6470_DirId, uint32_t N_Step);
+ void (*GoTo)(void *handle, uint32_t AbsPos);
+ void (*GoToDir)(void *handle, eL6470_DirId_t L6470_DirId, uint32_t AbsPos);
+ void (*GoUntil)(void *handle, eL6470_ActId_t L6470_ActId, eL6470_DirId_t L6470_DirId, uint32_t Speed);
+ void (*ReleaseSW)(void *handle, eL6470_ActId_t L6470_ActId, eL6470_DirId_t L6470_DirId);
+ void (*GoHome)(void *handle);
+ void (*GoMark)(void *handle);
+ void (*ResetPos)(void *handle);
+ void (*ResetDevice)(void *handle);
+ void (*SoftStop)(void *handle);
+ void (*HardStop)(void *handle);
+ void (*SoftHiZ)(void *handle);
+ void (*HardHiZ)(void *handle);
+ uint16_t (*GetStatus)(void *handle);
+ void (*PrepareSetParam)(void *handle, eL6470_RegId_t L6470_RegId, uint32_t Value);
+ void (*PrepareGetParam)(void *handle, eL6470_RegId_t L6470_RegId);
+ void (*PrepareRun)(void *handle, eL6470_DirId_t L6470_DirId, uint32_t Speed);
+ void (*PrepareStepClock)(void *handle, eL6470_DirId_t L6470_DirId);
+ void (*PrepareMove)(void *handle, eL6470_DirId_t L6470_DirId, uint32_t N_Step);
+ void (*PrepareGoTo)(void *handle, uint32_t AbsPos);
+ void (*PrepareGoToDir)(void *handle, eL6470_DirId_t L6470_DirId, uint32_t AbsPos);
+ void (*PrepareGoUntil)(void *handle, eL6470_ActId_t L6470_ActId, eL6470_DirId_t L6470_DirId, uint32_t Speed);
+ void (*PrepareReleaseSW)(void *handle, eL6470_ActId_t L6470_ActId, eL6470_DirId_t L6470_DirId);
+ void (*PrepareGoHome)(void *handle);
+ void (*PrepareGoMark)(void *handle);
+ void (*PrepareResetPos)(void *handle);
+ void (*PrepareResetDevice)(void *handle);
+ void (*PrepareSoftStop)(void *handle);
+ void (*PrepareHardStop)(void *handle);
+ void (*PrepareSoftHiZ)(void *handle);
+ void (*PrepareHardHiZ)(void *handle);
+ void (*PrepareGetStatus)(void *handle);
+ uint8_t (*CheckStatusRegisterFlag)(void *handle, uint8_t L6470_StatusRegisterFlagId);
+ uint8_t* (*PerformPreparedApplicationCommand)(void *handle);
+ uint8_t* (*GetRegisterName)(void *handle, uint8_t id);
+ int32_t (*AbsPos_2_Position)(void *handle, uint32_t AbsPos);
+ uint32_t (*Position_2_AbsPos)(void *handle, int32_t Position);
+ float (*Speed_2_Step_s)(void *handle, uint32_t Speed);
+ uint32_t (*Step_s_2_Speed)(void *handle, float Step_s);
+ float (*Acc_2_Step_s2)(void *handle, uint16_t Acc);
+ uint16_t (*Step_s2_2_Acc)(void *handle, float Step_s2);
+ float (*Dec_2_Step_s2)(void *handle, uint16_t Dec);
+ uint16_t (*Step_s2_2_Dec)(void *handle, float Step_s2);
+ float (*MaxSpeed_2_Step_s)(void *handle, uint16_t MaxSpeed);
+ uint16_t (*Step_s_2_MaxSpeed)(void *handle, float Step_s);
+ float (*MinSpeed_2_Step_s)(void *handle, uint16_t MinSpeed);
+ uint16_t (*Step_s_2_MinSpeed)(void *handle, float Step_s);
+ float (*FsSpd_2_Step_s)(void *handle, uint16_t FsSpd);
+ uint16_t (*Step_s_2_FsSpd)(void *handle, float Step_s);
+ float (*IntSpeed_2_Step_s)(void *handle, uint16_t IntSpeed);
+ uint16_t (*Step_s_2_IntSpeed)(void *handle, float Step_s);
+ float (*StSlp_2_s_Step)(void *handle, uint8_t StSlp);
+ uint8_t (*s_Step_2_StSlp)(void *handle, float s_Step);
+ float (*FnSlpAcc_2_s_Step)(void *handle, uint8_t FnSlpAcc);
+ uint8_t (*s_Step_2_FnSlpAcc)(void *handle, float s_Step);
+ float (*FnSlpDec_2_s_Step)(void *handle, uint8_t FnSlpDec);
+ uint8_t (*s_Step_2_FnSlpDec)(void *handle, float s_Step);
+ float (*OcdTh_2_mA)(void *handle, uint8_t OcdTh);
+ uint8_t (*mA_2_OcdTh)(void *handle, float mA);
+ float (*StallTh_2_mA)(void *handle, uint8_t StallTh);
+ uint8_t (*mA_2_StallTh)(void *handle, float mA);
+ uint32_t (*ExtractReturnedData)(void *handle, uint8_t* pL6470_DaisyChainSpiRxStruct, uint8_t LengthByte);
+} MICROSTEPPING_MOTOR_VTable_t;
+
+typedef struct {
+ //Stepper Motor Board Driver Structure
+ void (*SetParam)(uint8_t, uint8_t, eL6470_RegId_t, uint32_t);
+ uint32_t (*GetParam)(uint8_t, uint8_t, eL6470_RegId_t);
+ void (*Run)(uint8_t, uint8_t, eL6470_DirId_t, uint32_t);
+ void (*StepClock)(uint8_t, uint8_t, eL6470_DirId_t);
+ void (*Move)(uint8_t, uint8_t, eL6470_DirId_t, uint32_t);
+ void (*GoTo)(uint8_t, uint8_t L6470_Id, uint32_t AbsPos);
+ void (*GoToDir)(uint8_t, uint8_t, eL6470_DirId_t, uint32_t);
+ void (*GoUntil)(uint8_t, uint8_t, eL6470_ActId_t, eL6470_DirId_t, uint32_t);
+ void (*ReleaseSW)(uint8_t, uint8_t, eL6470_ActId_t, eL6470_DirId_t);
+ void (*GoHome)(uint8_t, uint8_t);
+ void (*GoMark)(uint8_t, uint8_t);
+ void (*ResetPos)(uint8_t, uint8_t);
+ void (*ResetDevice)(uint8_t, uint8_t);
+ void (*SoftStop)(uint8_t, uint8_t);
+ void (*HardStop)(uint8_t, uint8_t);
+ void (*SoftHiZ)(uint8_t, uint8_t);
+ void (*HardHiZ)(uint8_t, uint8_t);
+ uint16_t (*GetStatus)(uint8_t, uint8_t);
+ uint8_t (*CheckStatusRegisterFlag)(uint8_t, uint8_t, uint8_t);
+ uint8_t* (*PerformPreparedApplicationCommand)(uint8_t);
+} MICROSTEPPING_MOTOR_EB_VTable_t;
+
+
+typedef struct __StepperMotorDriver_HandleTypeDef {
+ // Stepper Motor Handle Structure
+ uint8_t DaisyChainPosition;
+ void (*Config)(void*);
+ MICROSTEPPING_MOTOR_VTable_t *Command;
+} StepperMotorDriverHandle_t;
+
+
+typedef struct __StepperMotorBoard_HandleTypeDef {
+ //Stepper Motor Handle Structure
+ uint8_t StackedPosition;
+ void (*Config)(void*);
+ MICROSTEPPING_MOTOR_EB_VTable_t *Command;
+ StepperMotorDriverHandle_t *StepperMotorDriverHandle[2];
+ uint8_t (*Select)(uint8_t);
+} StepperMotorBoardHandle_t;
+
+
+#define L6470_MAX_POSITION (0x1FFFFF) //!< Max position
+#define L6470_MIN_POSITION (-(0x200000)) //!< Min position
+#define L6470_POSITION_RANGE ((uint32_t)(L6470_MAX_POSITION - L6470_MIN_POSITION)) //!< Position range
+#define L6470_MAX_SPEED (0xFFFFF) //!< max value of SPEED
+#define L6470_MAX_ACC (0xFFF) //!< max value of ACC
+#define L6470_MAX_DEC (0xFFF) //!< max value of DEC
+#define L6470_MAX_MAX_SPEED (0x3FF) //!< max value of MAX_SPEED
+#define L6470_MAX_MIN_SPEED (0xFFF) //!< max value of MIN_SPEED
+#define L6470_MAX_FS_SPD (0x3FF) //!< max value of FS_SPD
+#define L6470_MAX_INT_SPEED (0x3FFF) //!< max value of INT_SPEED
+#define L6470_MAX_ST_SLP (0xFF) //!< max value of ST_SLP
+#define L6470_MAX_FN_SLP_ACC (0xFF) //!< max value of FN_SLP_ACC
+#define L6470_MAX_FN_SLP_DEC (0xFF) //!< max value of FN_SLP_DEC
+#define L6470_MAX_OCD_TH (0xF) //!< max value of OCD_TH
+#define L6470_MAX_STALL_TH (0x7F) //!< max value of STALL_TH
+
+#define L6470REGIDSIZE 25 //!< Max number of identifiers of L6470 Registers
+#define L6470APPCMDIDSIZE 19 //!< Max number of identifiers of L6470 Application Commands
+#define L6470DIRIDSIZE 2 //!< Max number of identifiers of L6470 directions
+#define L6470ACTIDSIZE 2 //!< Max number of identifiers of actions to perform about ABS_POS register
+#define L6470MAXSPICMDBYTESIZE 4 //!< Max number of byte to send via SPI to perform an application command
+#define L6470DAISYCHAINSIZE 2 //!< Max number of identifiers of L6470 in daisy chain configuration
+
+#define L6470_MAX_SPEED_VALUE ((float)15610) //!< max value for the speed in step/s
+#define L6470_MAX_ACC_VALUE ((float)59590) //!< max value for the acceleration in step/s^2
+#define L6470_MAX_DEC_VALUE ((float)59590) //!< max value for the acceleration in step/s^2
+#define L6470_MAX_DEC_VALUE ((float)59590) //!< max value for the acceleration in step/s^2
+
+#define OCD_TH_STEP ((float)375) //!< Minimum step for OCD_TH register in mAmpere
+#define STALL_TH_STEP ((float)31.25) //!< Minimum step for STALL_TH register in mAmpere
+
+#define L6470_ACC_CONV ((float)0.068719) //!< Conversion factor for acceleration value from step/s^2 to the right value
+#define L6470_DEC_CONV ((float)0.068719) //!< Conversion factor for deceleration value from step/s^2 to the right value
+#define L6470_MAXSPEED_CONV ((float)0.065536) //!< Conversion factor for max speed value from step/s to the right value
+#define L6470_MINSPEED_CONV ((float)4.194304) //!< Conversion factor for min speed value from step/s to the right value
+#define L6470_SPEED_CONV ((float)67.108864) //!< Conversion factor for speed value from step/s to the right value
+
+
+typedef struct {
+ //Structure to store some features of the L6470 Registers
+ uint8_t Address; //!< Register Address
+ uint8_t Name[12]; //!< Register Name
+ uint8_t LengthBit; //!< Register Length in bits
+ uint8_t LengthByte; //!< Register Length in bytes
+ uint32_t ResetValue; //!< Register Reset Value
+} sL6470_Register_t;
+
+
+typedef struct {
+//Structure to store some features of the L6470 Application Commands.
+ uint8_t Mnemonic[12]; //!< AppCmd Mnemonic
+ uint8_t BinaryCode; //!< AppCmd Binary Code
+ uint8_t NrOfParameters; //!< AppCmd number of needed parameters
+} sL6470_ApplicationCommand_t;
+
+
+typedef struct {
+ //Structure to store some features about the L6470 Motor Direction
+ uint8_t Mnemonic[8]; //!< L6470 Direction Mnemonic
+ uint8_t BinaryCode; //!< L6470 Direction Binary Code
+} sL6470_Direction_t;
+
+
+typedef struct {
+ //Structure to store some features about the action taken with the L6470 ABS_POS register.
+ uint8_t Mnemonic[4]; //!< ACT Mnemonic
+ uint8_t BinaryCode; //!< ACT Binary Code
+} sL6470_ACT_t;
+
+
+typedef struct {
+ //Structure used to store the identifier of the L6470 application
+ * command and its the needed parameters.
+ eL6470_AppCmdId_t L6470_AppCmdId; //!< The identifier of the actual L6470 Application Command
+ uint32_t p1; //!< The 1st parameter if needed
+ uint32_t p2; //!< The 2nd parameter if needed
+ uint32_t p3; //!< The 3rd parameter if needed
+} sL6470_AppCmdPkg_t;
+
+
+typedef struct
+// L6470 driver initialization structure definition.
+{
+ float motorvoltage; //!< motor supply voltage in V
+ float fullstepsperrevolution; //!< min number of steps per revolution for the motor
+ float phasecurrent; //!< max motor phase voltage in A
+ float phasevoltage; //!< max motor phase voltage in V
+ float speed; //!< motor initial speed [step/s]
+ float acc; //!< motor acceleration [step/s^2] (comment for infinite acceleration mode)
+ float dec; //!< motor deceleration [step/s^2] (comment for infinite deceleration mode)
+ float maxspeed; //!< motor maximum speed [step/s]
+ float minspeed; //!< motor minimum speed [step/s]
+ float fsspd; //!< motor full-step speed threshold [step/s]
+ float kvalhold; //!< holding kval [V]
+ float kvalrun; //!< constant speed kval [V]
+ float kvalacc; //!< acceleration starting kval [V]
+ float kvaldec; //!< deceleration starting kval [V]
+ float intspeed; //!< intersect speed for bemf compensation curve slope changing [step/s]
+ float stslp; //!< start slope [s/step]
+ float fnslpacc; //!< acceleration final slope [s/step]
+ float fnslpdec; //!< deceleration final slope [s/step]
+ uint8_t kterm; //!< thermal compensation factor (range [0, 15])
+ float ocdth; //!< ocd threshold [ma] (range [375 ma, 6000 ma])
+ float stallth; //!< stall threshold [ma] (range [31.25 ma, 4000 ma])
+ uint8_t step_sel; //!< step mode selection
+ uint8_t alarmen; //!< alarm conditions enable
+ uint16_t config; //!< ic configuration
+} L6470_init_t;
+
+
+typedef struct {
+ //L6470 driver data structure definition
+ uint8_t L6470_Id; //!< The L6470 identifier inside the daisy chain
+ sL6470_Register_t *L6470_Register; //[L6470REGIDSIZE]; //!< Array whose elements are a structure in which store information about the L6470 Registers (the address, the names, the length in bits, the reset value)
+ sL6470_ApplicationCommand_t *L6470_ApplicationCommand; //[L6470APPCMDIDSIZE]; //!< Array whose elements are a structure in which store information about the L6470 Application Commands (the mnemonic name, the number of needed parameters, the related funtion to call)
+ sL6470_Direction_t *L6470_Direction; //[L6470DIRIDSIZE]; //!< The mnemonic names for the L6470 direction
+ sL6470_ACT_t *L6470_ACT; //[L6470ACTIDSIZE]; //!< Action taken about ABS_POS register
+ sL6470_AppCmdPkg_t L6470_AppCmdPkg[L6470DAISYCHAINSIZE]; //!< To store the identifier of the actual L6470 application command and its the needed parameters
+ uint8_t L6470_DaisyChainSpiTxStruct[L6470MAXSPICMDBYTESIZE][L6470DAISYCHAINSIZE]; //!< To store the matrix that contains the command data that are going to be sent by SPI to the L6470 daisy chain
+ uint8_t L6470_DaisyChainSpiRxStruct[L6470MAXSPICMDBYTESIZE][L6470DAISYCHAINSIZE]; //!< To store the matrix that contains the received data by SPI from the L6470 daisy chain
+ eFlagStatus_t L6470_DaisyChain_HalfPrepared; /* = ZERO_F; */ //!< Boolean variable used when more than one L6470 into the daisy chain is going to be addressed for commanding
+ sL6470_StatusRegister_t L6470_StatusRegister; //!< To store the received L6470_StatusRegister
+ sL6470_StatusRegister_t *pL6470_StatusRegister; /* = &L6470_StatusRegister; */ //!< Pointer to the L6470_StatusRegister variable
+} L6470_Data_t;
+
+
+extern void L6470_DISABLE(void);
+extern void L6470_ENABLE(void);
+extern void L6470_nCS_LOW(void);
+extern void L6470_nCS_HIGH(void);
+extern void L6470_SPI_Communication(uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, uint32_t Timeout);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __L6470_H */
+