Davide Aliprandi / X-NUCLEO-IHM06A1

Dependencies:   ST_INTERFACES

Fork of X_NUCLEO_IHM06A1 by ST

Embed: (wiki syntax)

« Back to documentation index

STSPIN220 Class Reference

Class representing a STSPIN220 component. More...

#include <stspin220_class.h>

Public Member Functions

 STSPIN220 (PinName fault_and_enable_pin, PinName stby_reset_pin, PinName direction_mode4_pin, PinName mode1_pin, PinName mode2_pin, PinName stck_mode3_pin, PinName pwm_ref_pin, PinName monitor_pin=NC)
 Constructor.
virtual ~STSPIN220 (void)
 Destructor.
virtual int Init (void *init=NULL)
 Public functions inherited from the Component Class.
virtual int ReadID (uint8_t *id=NULL)
 Getting the ID of the component.
virtual unsigned int GetStatus (void)
 Public functions inherited from the StepperMotor Class.
virtual signed int GetPosition (void)
 Getting the position.
virtual signed int GetMark (void)
 Getting the marked position.
virtual unsigned int GetSpeed (void)
 Getting the current speed in pps.
virtual unsigned int GetMaxSpeed (void)
 Getting the maximum speed in pps.
virtual unsigned int GetMinSpeed (void)
 Getting the minimum speed in pps.
virtual unsigned int GetAcceleration (void)
 Getting the acceleration in pps^2.
virtual unsigned int GetDeceleration (void)
 Getting the deceleration in pps^2.
virtual direction_t GetDirection (void)
 Getting the direction of rotation.
virtual void SetHome (void)
 Setting the current position to be the home position.
virtual void SetMark (void)
 Setting the current position to be the marked position.
virtual bool SetMaxSpeed (unsigned int speed)
 Setting the maximum speed in pps.
virtual bool SetMinSpeed (unsigned int speed)
 Setting the minimum speed in pps.
virtual bool SetAcceleration (unsigned int acceleration)
 Setting the acceleration in pps^2.
virtual bool SetDeceleration (unsigned int deceleration)
 Setting the deceleration in pps^2.
virtual bool SetStepMode (step_mode_t step_mode)
 Setting the Step Mode.
virtual void GoTo (signed int position)
 Going to a specified position.
virtual void GoHome (void)
 Going to the home position.
virtual void GoMark (void)
 Going to the marked position.
virtual void Run (direction_t direction)
 Running the motor towards a specified direction.
virtual void Move (direction_t direction, unsigned int steps)
 Moving the motor towards a specified direction for a certain number of steps.
virtual void SoftStop (void)
 Stopping the motor through an immediate deceleration up to zero speed.
virtual void HardStop (void)
 Stopping the motor through an immediate infinite deceleration.
virtual void SoftHiZ (void)
 Disabling the power bridge after performing a deceleration to zero.
virtual void HardHiZ (void)
 Disabling the power bridge immediately.
virtual void WaitWhileActive (void)
 Waiting while the motor is active.
virtual void AttachErrorHandler (void(*fptr)(uint16_t error))
 Public functions NOT inherited.
virtual unsigned int CheckStatusHw (void)
 Checks if the device is disabled or/and has an alarm flag set by reading the EN FAULT pin position.
virtual void Disable (void)
 Disabling the device.
virtual void Enable (void)
 Enabling the device.
virtual void ExitDeviceFromStandby (void)
 Exit STSPIN220 device from standby (low power consumption) by setting STBY pin to high level and changing the motion state to INACTIVE.
virtual uint32_t GetFreqVrefPwm (void)
 Set the frequency of the VREFA and VREFB PWM.
virtual unsigned int GetFwVersion (void)
 Getting the version of the firmware.
virtual step_mode_t GetStepMode (void)
 Getting the motor step mode.
virtual motorStopMode_t GetStopMode (void)
 Getting the motor stop mode.
virtual uint8_t GetTorque (motorTorqueMode_t torqueMode)
 Get the motor torque.
virtual bool GetTorqueBoostEnable (void)
 Get the torque boost feature status.
virtual uint16_t GetTorqueBoostThreshold (void)
 Get the torque boost threshold.
virtual void GoTo (direction_t direction, signed int position)
 Going to a specified position with a specificied direction.
virtual void PutDeviceInStandby (void)
 Put STSPIN220 device in standby (low power consumption) by setting STBY pin to low level and changing the motion state to STANDBY.
virtual void ReleaseReset (void)
 Release the STSPIN220 reset (Reset pin set to high level).
virtual void Reset (void)
 Reset the STSPIN220 (Reset pin set to low level).
virtual void SetDirection (direction_t direction)
 Set the motor direction.
virtual void SetFreqVrefPwm (uint32_t frequency)
 Set the frequency of the PWM for REF pin.
virtual void SetStopMode (motorStopMode_t stopMode)
 Set the motor stop mode.
virtual void SetTorque (motorTorqueMode_t torqueMode, uint8_t torqueValue)
 Set the motor torque.
virtual void SetTorqueBoostEnable (bool enable)
 Enable or disable the motor torque boost feature.
virtual void SetTorqueBoostThreshold (uint16_t speedThreshold)
 Set the torque boost threshold.
void AttachFlagIRQ (void(*fptr)(void))
 Attaching an interrupt handler to the FLAG interrupt.
void EnableFlagIRQ (void)
 Enabling the FLAG interrupt handling.

Protected Member Functions

Status_t Stspin220_Init (void *init)
 Start the STSPIN220 library.
void Stspin220_ApplyTorque (motorTorqueMode_t torqueMode)
 Apply the set torque.
void Stspin220_Disable (void)
 Disable the power bridges (leave the output bridges HiZ)
void Stspin220_ErrorHandler (uint16_t error)
 Error handler which calls the user callback (if defined)
void Stspin220_Enable (void)
 Enable the power bridges.
void Stspin220_ExitDeviceFromStandby (void)
 Exit STSPIN220 device from standby (low power consumption)
uint16_t Stspin220_GetAcceleration (void)
 Return the acceleration.
uint16_t Stspin220_GetCurrentSpeed (void)
 Return the current speed.
uint16_t Stspin220_GetDeceleration (void)
 Return the deceleration.
motorState_t Stspin220_GetDeviceState (void)
 Return the device state.
motorDir_t Stspin220_GetDirection (void)
 Get the motor current direction.
uint32_t Stspin220_GetFwVersion (void)
 Return the FW version.
int32_t Stspin220_GetMark (void)
 Get the mark position (32b signed)
uint16_t Stspin220_GetMaxSpeed (void)
 Return the max speed.
uint16_t Stspin220_GetMinSpeed (void)
 Get the min speed in step/s for full, half and wave modes in microsteps/s for microstep modes.
int32_t Stspin220_GetPosition (void)
 Get the current position (32b signed)
motorStepMode_t Stspin220_GetStepMode (void)
 Get the motor step mode.
motorStopMode_t Stspin220_GetStopMode (void)
 Get the selected stop mode.
uint8_t Stspin220_GetTorque (motorTorqueMode_t torqueMode)
 Get the torque.
bool Stspin220_GetTorqueBoostEnable (void)
 Get the torque boost feature status.
uint16_t Stspin220_GetTorqueBoostThreshold (void)
 Get the torque boost threshold.
void Stspin220_GoHome (void)
 Go to the home position.
void Stspin220_GoMark (void)
 Go to the Mark position.
void Stspin220_GoTo (int32_t targetPosition)
 Request the motor to move to the specified position.
void Stspin220_GoToDir (motorDir_t direction, int32_t targetPosition)
 Move the motor to the absolute position.
void Stspin220_HardHiZ (void)
 Immediately stop the motor and disables the power bridges.
void Stspin220_HardStop (void)
 Immediatly stop the motor and either set holding torque when stop mode is HOLD_MODE, or call Stspin220_HardHiz function when stop mode is HIZ_MODE, or call Stspin220_PutDeviceInStandby function when stop mode is STANDBY_MODE.
void Stspin220_Move (motorDir_t direction, uint32_t stepCount)
 Moves the motor of the specified number of steps.
void Stspin220_PutDeviceInStandby (void)
 Put STSPIN220 device in standby (low power consumption)
void Stspin220_Run (motorDir_t direction)
 Runs the motor.
bool Stspin220_SetAcceleration (uint16_t newAcc)
 Changes the acceleration.
bool Stspin220_SetDeceleration (uint16_t newDec)
 Changes the deceleration.
void Stspin220_SetDirection (motorDir_t direction)
 Specifies the direction.
void Stspin220_SetHome (void)
 Set current position to be the Home position (current position set to 0)
void Stspin220_SetMark (void)
 Set current position to be the Mark position.
bool Stspin220_SetMaxSpeed (uint16_t volatile newSpeed)
 Changes the max speed.
bool Stspin220_SetMinSpeed (uint16_t volatile newSpeed)
 Changes the min speed.
bool Stspin220_SetStepMode (motorStepMode_t stepMode)
 Set the stepping mode.
void Stspin220_SetStopMode (motorStopMode_t stopMode)
 Select the mode to stop the motor.
bool Stspin220_SoftStop (void)
 Stops the motor by using the device deceleration.
void Stspin220_SetTorque (motorTorqueMode_t torqueMode, uint8_t torqueValue)
 Set the torque.
void Stspin220_SetTorqueBoostEnable (bool enable)
 Enable or disable the torque boost feature.
void Stspin220_SetTorqueBoostThreshold (uint16_t speedThreshold)
 Set the torque boost threshold.
uint32_t Stspin220_VrefPwmGetFreq (void)
 Get the frequency of REF PWM.
void Stspin220_VrefPwmSetFreq (uint32_t newFreq)
 Set the frequency of REF PWM.
void Stspin220_WaitWhileActive (void)
 Locks until the device state becomes Inactive.
void Stspin220_ApplySpeed (uint16_t newSpeed)
 Updates the current speed of the device.
void Stspin220_ComputeSpeedProfile (uint32_t nbSteps)
 Computes the speed profile according to the number of steps to move.
void Stspin220_SetDeviceParamsToGivenValues (Stspin220_Init_t *pInitDevicePrm)
 Set the parameters of the device to values of the structure pointed by pInitDevicePrm.
void Stspin220_SetDeviceParamsOtherValues (void)
 Set the parameters of the device whose values are not defined in stspin220_target_config.h.
void Stspin220_SetDeviceParamsToPredefinedValues (void)
 Sets the parameters of the device to predefined values from stspin220_target_config.h.
bool Stspin220_SetStepModeWithoutReset (motorStepMode_t stepMode)
 Set the stepping mode without reset.
void Stspin220_StartMovement (void)
 Initialises the bridge parameters to start the movement and enable the power bridge.
void Stspin220_StepClockHandler (void)
 Handles the device state machine at each pulse.
void Stspin220_Board_Delay (uint32_t delay)
 Making the CPU wait.
void Stspin220_Board_Disable (void)
 Disable the power bridges (leave the output bridges HiZ).
void Stspin220_Board_DisableIrq (void)
 Disabling interrupts.
void Stspin220_Board_Enable (void)
 Enable the power bridges (leave the output bridges HiZ).
void Stspin220_Board_EnableIrq (void)
 Enabling interrupts.
void Stspin220_Board_PwmRefSetDutyCycle (uint8_t dutyCycle)
 Set the duty cycle of the PwmOut used for the REF reference voltage generation and actually start the pwm if the duty cycle is not zero.
void Stspin220_Board_PwmRefSetFreq (uint32_t newFreq)
 Set the frequency of the PwmOut used for the REF reference voltage generation.
void Stspin220_Board_PwmRefStart (uint32_t frequency, motorTorqueMode_t torqueMode)
 Start the PwmOut for the REF pin.
void Stspin220_Board_ReleaseReset (void)
 Exit the device from standby reset mode.
void Stspin220_Board_Reset (void)
 Put the device in standby reset mode.
void Stspin220_Board_SetDirectionGpio (motorDir_t dir)
 Set the DIR pin.
void Stspin220_Board_SetFullStep (void)
 Select Full Step mode.
uint8_t Stspin220_Board_SetModePins (uint8_t modePin1Level,\uint8_t modePin2Level,\uint8_t modePin3Level,\uint8_t modePin4Level)
 Select the STSPIN220 mode1, mode2, mode3 and mode4 pins levels.
void Stspin220_Board_StckMode3_Reset (void)
 Reset the STCK pin.
void Stspin220_Board_StckMode3_Set (void)
 Set the STCK pin.
void Stspin220_Board_TimStckInit (bool check)
 Initialises the step clock pin level.
void Stspin220_Board_TimStckSetFreq (uint16_t newFreq)
 Setting the Stck Timeout delay and attaching a callback function to it.
uint8_t Stspin220_Board_TimStckStop (volatile uint8_t *pToggleOdd)
 Stopping the Timeout.
void Stspin220_Board_UnsetFullStep (void)
 Unselect Full Step mode.

Detailed Description

Class representing a STSPIN220 component.

Definition at line 72 of file stspin220_class.h.


Constructor & Destructor Documentation

STSPIN220 ( PinName  fault_and_enable_pin,
PinName  stby_reset_pin,
PinName  direction_mode4_pin,
PinName  mode1_pin,
PinName  mode2_pin,
PinName  stck_mode3_pin,
PinName  pwm_ref_pin,
PinName  monitor_pin = NC 
)

Constructor.

Parameters:
fault_and_enable_pinpin name of the EN pin of the component.
stby_reset_pinpin name of the STBY pin of the component.
direction_mode4_pinpin name of the MODE4 pin of the component.
mode1_pinpin name of the MODE1 pin of the component.
mode2_pinpin name of the MODE2 pin of the component.
stck_mode3_pinpin name of the MODE3 pin of the component.
pwm_ref_pinpin name of the PWM connected to the REF pin of the component.
Monitor_pinpin name for the step clock handler duration Monitoring.

Definition at line 87 of file stspin220_class.h.

virtual ~STSPIN220 ( void   ) [virtual]

Destructor.

Definition at line 126 of file stspin220_class.h.


Member Function Documentation

virtual void AttachErrorHandler ( void(*)(uint16_t error)  fptr ) [virtual]

Public functions NOT inherited.

Attaching an error handler.

Parameters:
fptrAn error handler.
Return values:
None.

Definition at line 493 of file stspin220_class.h.

void AttachFlagIRQ ( void(*)(void)  fptr )

Attaching an interrupt handler to the FLAG interrupt.

Parameters:
fptrAn interrupt handler.
Return values:
None.

Definition at line 756 of file stspin220_class.h.

virtual unsigned int CheckStatusHw ( void   ) [virtual]

Checks if the device is disabled or/and has an alarm flag set by reading the EN FAULT pin position.

Parameters:
None.
Return values:
Oneif the EN FAULT pin is low (the device is disabled or/and has an alarm flag set), otherwise zero.

Definition at line 505 of file stspin220_class.h.

virtual void Disable ( void   ) [virtual]

Disabling the device.

Parameters:
None.
Return values:
None.

Definition at line 516 of file stspin220_class.h.

virtual void Enable ( void   ) [virtual]

Enabling the device.

Parameters:
None.
Return values:
None.

Definition at line 526 of file stspin220_class.h.

void EnableFlagIRQ ( void   )

Enabling the FLAG interrupt handling.

Parameters:
None.
Return values:
None.

Definition at line 769 of file stspin220_class.h.

virtual void ExitDeviceFromStandby ( void   ) [virtual]

Exit STSPIN220 device from standby (low power consumption) by setting STBY pin to high level and changing the motion state to INACTIVE.

Parameters:
None.
Return values:
None.

Definition at line 538 of file stspin220_class.h.

virtual unsigned int GetAcceleration ( void   ) [virtual]

Getting the acceleration in pps^2.

Parameters:
None.
Return values:
Theacceleration in pps^2.

Definition at line 245 of file stspin220_class.h.

virtual unsigned int GetDeceleration ( void   ) [virtual]

Getting the deceleration in pps^2.

Parameters:
None.
Return values:
Thedeceleration in pps^2.

Definition at line 255 of file stspin220_class.h.

virtual direction_t GetDirection ( void   ) [virtual]

Getting the direction of rotation.

Parameters:
None.
Return values:
Thedirection of rotation.

Definition at line 265 of file stspin220_class.h.

virtual uint32_t GetFreqVrefPwm ( void   ) [virtual]

Set the frequency of the VREFA and VREFB PWM.

Parameters:
frequencyin Hz
Return values:
None.

Definition at line 548 of file stspin220_class.h.

virtual unsigned int GetFwVersion ( void   ) [virtual]

Getting the version of the firmware.

Parameters:
None.
Return values:
Theversion of the firmware.

Definition at line 558 of file stspin220_class.h.

virtual signed int GetMark ( void   ) [virtual]

Getting the marked position.

Parameters:
None.
Return values:
Themarked position.

Definition at line 205 of file stspin220_class.h.

virtual unsigned int GetMaxSpeed ( void   ) [virtual]

Getting the maximum speed in pps.

Parameters:
None.
Return values:
Themaximum speed in pps.

Definition at line 225 of file stspin220_class.h.

virtual unsigned int GetMinSpeed ( void   ) [virtual]

Getting the minimum speed in pps.

Parameters:
None.
Return values:
Theminimum speed in pps.

Definition at line 235 of file stspin220_class.h.

virtual signed int GetPosition ( void   ) [virtual]

Getting the position.

Parameters:
None.
Return values:
Theposition.

Definition at line 195 of file stspin220_class.h.

virtual unsigned int GetSpeed ( void   ) [virtual]

Getting the current speed in pps.

Parameters:
None.
Return values:
Thecurrent speed in pps.

Definition at line 215 of file stspin220_class.h.

virtual unsigned int GetStatus ( void   ) [virtual]

Public functions inherited from the StepperMotor Class.

Getting the value of the motor state .

Parameters:
None.
Return values:
Themotor state accoring to motorState_t in motor.h

Definition at line 185 of file stspin220_class.h.

virtual step_mode_t GetStepMode ( void   ) [virtual]

Getting the motor step mode.

Parameters:
None.
Return values:
Themotor step mode.

Definition at line 568 of file stspin220_class.h.

virtual motorStopMode_t GetStopMode ( void   ) [virtual]

Getting the motor stop mode.

Parameters:
None.
Return values:
Themotor stop mode.

Definition at line 578 of file stspin220_class.h.

virtual uint8_t GetTorque ( motorTorqueMode_t  torqueMode ) [virtual]

Get the motor torque.

Parameters:
torqueModeTorque mode as specified in enum motorTorqueMode_t
Return values:
thetorqueValue in % (from 0 to 100)

Definition at line 588 of file stspin220_class.h.

virtual bool GetTorqueBoostEnable ( void   ) [virtual]

Get the torque boost feature status.

Parameters:
None.
Return values:
trueif enabled, false if disabled

Definition at line 598 of file stspin220_class.h.

virtual uint16_t GetTorqueBoostThreshold ( void   ) [virtual]

Get the torque boost threshold.

Return values:
Thetorque boost threshold above which the step mode is changed to full step

Definition at line 608 of file stspin220_class.h.

virtual void GoHome ( void   ) [virtual]

Going to the home position.

Parameters:
None.
Return values:
None.

Definition at line 397 of file stspin220_class.h.

virtual void GoMark ( void   ) [virtual]

Going to the marked position.

Parameters:
None.
Return values:
None.

Definition at line 407 of file stspin220_class.h.

virtual void GoTo ( signed int  position ) [virtual]

Going to a specified position.

Parameters:
positionThe desired position.
Return values:
None.

Definition at line 387 of file stspin220_class.h.

virtual void GoTo ( direction_t  direction,
signed int  position 
) [virtual]

Going to a specified position with a specificied direction.

Parameters:
directionThe desired direction.
positionThe desired position.
Return values:
None.

Definition at line 619 of file stspin220_class.h.

virtual void HardHiZ ( void   ) [virtual]

Disabling the power bridge immediately.

Parameters:
None.
Return values:
None.

Definition at line 469 of file stspin220_class.h.

virtual void HardStop ( void   ) [virtual]

Stopping the motor through an immediate infinite deceleration.

Parameters:
None.
Return values:
None.

Definition at line 448 of file stspin220_class.h.

virtual int Init ( void *  init = NULL ) [virtual]

Public functions inherited from the Component Class.

Initialize the component.

Parameters:
initPointer to device specific initalization structure.
Return values:
0in case of success, an error code otherwise.

Definition at line 161 of file stspin220_class.h.

virtual void Move ( direction_t  direction,
unsigned int  steps 
) [virtual]

Moving the motor towards a specified direction for a certain number of steps.

Parameters:
directionThe direction of rotation.
stepsThe desired number of steps.
Return values:
None.

Definition at line 428 of file stspin220_class.h.

virtual void PutDeviceInStandby ( void   ) [virtual]

Put STSPIN220 device in standby (low power consumption) by setting STBY pin to low level and changing the motion state to STANDBY.

Parameters:
None.
Return values:
None.

Definition at line 631 of file stspin220_class.h.

virtual int ReadID ( uint8_t *  id = NULL ) [virtual]

Getting the ID of the component.

Parameters:
idPointer to an allocated variable to store the ID into.
Return values:
0in case of success, an error code otherwise.

Definition at line 171 of file stspin220_class.h.

virtual void ReleaseReset ( void   ) [virtual]

Release the STSPIN220 reset (Reset pin set to high level).

Parameters:
None.
Return values:
None.

Definition at line 641 of file stspin220_class.h.

virtual void Reset ( void   ) [virtual]

Reset the STSPIN220 (Reset pin set to low level).

Parameters:
None.
Return values:
None.

Definition at line 651 of file stspin220_class.h.

virtual void Run ( direction_t  direction ) [virtual]

Running the motor towards a specified direction.

Parameters:
directionThe direction of rotation.
Return values:
None.

Definition at line 417 of file stspin220_class.h.

virtual bool SetAcceleration ( unsigned int  acceleration ) [virtual]

Setting the acceleration in pps^2.

Parameters:
accelerationThe acceleration in pps/s^2.
Return values:
truein case of success, "false" otherwise.

Definition at line 336 of file stspin220_class.h.

virtual bool SetDeceleration ( unsigned int  deceleration ) [virtual]

Setting the deceleration in pps^2.

Parameters:
decelerationThe deceleration in pps^2.
Return values:
truein case of success, "false" otherwise.

Definition at line 353 of file stspin220_class.h.

virtual void SetDirection ( direction_t  direction ) [virtual]

Set the motor direction.

Parameters:
directionThe desired direction.
Return values:
None.

Definition at line 661 of file stspin220_class.h.

virtual void SetFreqVrefPwm ( uint32_t  frequency ) [virtual]

Set the frequency of the PWM for REF pin.

Parameters:
frequencyin Hz
Return values:
None.

Definition at line 671 of file stspin220_class.h.

virtual void SetHome ( void   ) [virtual]

Setting the current position to be the home position.

Parameters:
None.
Return values:
None.

Definition at line 282 of file stspin220_class.h.

virtual void SetMark ( void   ) [virtual]

Setting the current position to be the marked position.

Parameters:
None.
Return values:
None.

Definition at line 292 of file stspin220_class.h.

virtual bool SetMaxSpeed ( unsigned int  speed ) [virtual]

Setting the maximum speed in pps.

Parameters:
speedThe maximum speed in pps.
Return values:
truein case of success, "false" otherwise.

Definition at line 302 of file stspin220_class.h.

virtual bool SetMinSpeed ( unsigned int  speed ) [virtual]

Setting the minimum speed in pps.

Parameters:
speedThe minimum speed in pps.
Return values:
truein case of success, "false" otherwise.

Definition at line 319 of file stspin220_class.h.

virtual bool SetStepMode ( step_mode_t  step_mode ) [virtual]

Setting the Step Mode.

Parameters:
step_modeThe Step Mode.
Return values:
truein case of success, "false" otherwise.
Note:
step_mode can be one of the following: + STEP_MODE_FULL + STEP_MODE_WAVE + STEP_MODE_HALF + STEP_MODE_1_4 + STEP_MODE_1_8 + STEP_MODE_1_16

Definition at line 377 of file stspin220_class.h.

virtual void SetStopMode ( motorStopMode_t  stopMode ) [virtual]

Set the motor stop mode.

Parameters:
stopModeThe desired stop mode (HOLD_MODE, HIZ_MODE or STANDBY_MODE).
Return values:
None.

Definition at line 682 of file stspin220_class.h.

virtual void SetTorque ( motorTorqueMode_t  torqueMode,
uint8_t  torqueValue 
) [virtual]

Set the motor torque.

Parameters:
torqueModeTorque mode as specified in enum motorTorqueMode_t
torqueValuein % (from 0 to 100)
Return values:
None.

Definition at line 693 of file stspin220_class.h.

virtual void SetTorqueBoostEnable ( bool  enable ) [virtual]

Enable or disable the motor torque boost feature.

Parameters:
enableenable true to enable torque boost, false to disable
Return values:
None.

Definition at line 703 of file stspin220_class.h.

virtual void SetTorqueBoostThreshold ( uint16_t  speedThreshold ) [virtual]

Set the torque boost threshold.

Parameters:
[in]speedThresholdspeed threshold above which the step mode is changed to full step
Return values:
None.

Definition at line 714 of file stspin220_class.h.

virtual void SoftHiZ ( void   ) [virtual]

Disabling the power bridge after performing a deceleration to zero.

Parameters:
None.
Return values:
None.

Definition at line 458 of file stspin220_class.h.

virtual void SoftStop ( void   ) [virtual]

Stopping the motor through an immediate deceleration up to zero speed.

Parameters:
None.
Return values:
None.

Definition at line 438 of file stspin220_class.h.

void Stspin220_ApplySpeed ( uint16_t  newSpeed ) [protected]

Updates the current speed of the device.

Parameters:
[in]newSpeedin pps
Return values:
None

Definition at line 966 of file stspin220_class.cpp.

void Stspin220_ApplyTorque ( motorTorqueMode_t  torqueMode ) [protected]

Apply the set torque.

Parameters:
[in]torqueModetorque mode
Return values:
None
Note:

Definition at line 102 of file stspin220_class.cpp.

void Stspin220_Board_Delay ( uint32_t  delay ) [protected]

Making the CPU wait.

Parameters:
None.
Return values:
None.

Definition at line 863 of file stspin220_class.h.

void Stspin220_Board_Disable ( void   ) [protected]

Disable the power bridges (leave the output bridges HiZ).

Parameters:
None.
Return values:
None.

Definition at line 873 of file stspin220_class.h.

void Stspin220_Board_DisableIrq ( void   ) [protected]

Disabling interrupts.

Parameters:
None.
Return values:
None.

Definition at line 885 of file stspin220_class.h.

void Stspin220_Board_Enable ( void   ) [protected]

Enable the power bridges (leave the output bridges HiZ).

Parameters:
None.
Return values:
None.

Definition at line 895 of file stspin220_class.h.

void Stspin220_Board_EnableIrq ( void   ) [protected]

Enabling interrupts.

Parameters:
None.
Return values:
None.

Definition at line 910 of file stspin220_class.h.

void Stspin220_Board_PwmRefSetDutyCycle ( uint8_t  dutyCycle ) [protected]

Set the duty cycle of the PwmOut used for the REF reference voltage generation and actually start the pwm if the duty cycle is not zero.

Parameters:
[in]dutyCycle0 - 100%
Return values:
None

Definition at line 922 of file stspin220_class.h.

void Stspin220_Board_PwmRefSetFreq ( uint32_t  newFreq ) [protected]

Set the frequency of the PwmOut used for the REF reference voltage generation.

Parameters:
[in]newFreqin Hz.
Return values:
None.

Definition at line 933 of file stspin220_class.h.

void Stspin220_Board_PwmRefStart ( uint32_t  frequency,
motorTorqueMode_t  torqueMode 
) [protected]

Start the PwmOut for the REF pin.

Parameters:
[in]frequencyfrequency of the PwmOut used to generate the REF reference voltage for the bridges.
[in]torqueModeTorque mode as specified in enum motorTorqueMode_t
Return values:
None.

Definition at line 945 of file stspin220_class.h.

void Stspin220_Board_ReleaseReset ( void   ) [protected]

Exit the device from standby reset mode.

Parameters:
None.
Return values:
None.

Definition at line 959 of file stspin220_class.h.

void Stspin220_Board_Reset ( void   ) [protected]

Put the device in standby reset mode.

Parameters:
None.
Return values:
None.

Definition at line 969 of file stspin220_class.h.

void Stspin220_Board_SetDirectionGpio ( motorDir_t  dir ) [protected]

Set the DIR pin.

Parameters:
dirmotor direction FORWARD or BACKWARD.
Return values:
None.

Definition at line 979 of file stspin220_class.h.

void Stspin220_Board_SetFullStep ( void   ) [protected]

Select Full Step mode.

Parameters:
None.
Return values:
None

Definition at line 990 of file stspin220_class.h.

uint8_t Stspin220_Board_SetModePins ( uint8_t  modePin1Level,
\uint8_t  modePin2Level,
\uint8_t  modePin3Level,
\uint8_t  modePin4Level 
) [protected]

Select the STSPIN220 mode1, mode2, mode3 and mode4 pins levels.

Parameters:
[in]modePin1Levellevel of the mode1 gpio (0 low, 1+ high)
[in]modePin2Levellevel of the mode2 gpio (0 low, 1+ high)
[in]modePin3Levellevel of the mode3 gpio (0 low, 1+ high)
[in]modePin4Levellevel of the mode4 gpio (0 low, 1+ high)
Return values:
1

Definition at line 1004 of file stspin220_class.h.

void Stspin220_Board_StckMode3_Reset ( void   ) [protected]

Reset the STCK pin.

Parameters:
None.
Return values:
None.

Definition at line 1021 of file stspin220_class.h.

void Stspin220_Board_StckMode3_Set ( void   ) [protected]

Set the STCK pin.

Parameters:
None.
Return values:
None.

Definition at line 1031 of file stspin220_class.h.

void Stspin220_Board_TimStckInit ( bool  check ) [protected]

Initialises the step clock pin level.

Parameters:
None.
Return values:
None

Definition at line 1041 of file stspin220_class.h.

void Stspin220_Board_TimStckSetFreq ( uint16_t  newFreq ) [protected]

Setting the Stck Timeout delay and attaching a callback function to it.

Parameters:
frequencyThe frequency corresponding to the delay.
Return values:
None.

Definition at line 1054 of file stspin220_class.h.

uint8_t Stspin220_Board_TimStckStop ( volatile uint8_t *  pToggleOdd ) [protected]

Stopping the Timeout.

Parameters:
None.
Return values:
None.

Definition at line 1079 of file stspin220_class.h.

void Stspin220_Board_UnsetFullStep ( void   ) [protected]

Unselect Full Step mode.

Parameters:
None.
Return values:
None

Definition at line 1102 of file stspin220_class.h.

void Stspin220_ComputeSpeedProfile ( uint32_t  nbSteps ) [protected]

Computes the speed profile according to the number of steps to move.

Parameters:
[in]nbStepsnumber of steps to perform
Return values:
None
Note:
Using the acceleration and deceleration of the device, this function determines the duration in steps of the acceleration, steady and deceleration phases. If the total number of steps to perform is big enough, a trapezoidal move is performed (i.e. there is a steady phase where the motor runs at the maximum speed. Else, a triangular move is performed (no steady phase: the maximum speed is never reached.

Definition at line 1039 of file stspin220_class.cpp.

void Stspin220_Disable ( void   ) [protected]

Disable the power bridges (leave the output bridges HiZ)

Return values:
None

Definition at line 133 of file stspin220_class.cpp.

void Stspin220_Enable ( void   ) [protected]

Enable the power bridges.

Return values:
None

Definition at line 142 of file stspin220_class.cpp.

void Stspin220_ErrorHandler ( uint16_t  error ) [protected]

Error handler which calls the user callback (if defined)

Parameters:
[in]errorNumber of the error
Return values:
None

Definition at line 152 of file stspin220_class.cpp.

void Stspin220_ExitDeviceFromStandby ( void   ) [protected]

Exit STSPIN220 device from standby (low power consumption)

Return values:
None

Definition at line 171 of file stspin220_class.cpp.

uint16_t Stspin220_GetAcceleration ( void   ) [protected]

Return the acceleration.

Return values:
Accelerationin pps^2

Definition at line 201 of file stspin220_class.cpp.

uint16_t Stspin220_GetCurrentSpeed ( void   ) [protected]

Return the current speed.

Return values:
Speedin pps

Definition at line 210 of file stspin220_class.cpp.

uint16_t Stspin220_GetDeceleration ( void   ) [protected]

Return the deceleration.

Return values:
Decelerationin pps^2

Definition at line 219 of file stspin220_class.cpp.

motorState_t Stspin220_GetDeviceState ( void   ) [protected]

Return the device state.

Return values:
State(ACCELERATING, DECELERATING, STEADY or INACTIVE)

Definition at line 228 of file stspin220_class.cpp.

motorDir_t Stspin220_GetDirection ( void   ) [protected]

Get the motor current direction.

Return values:
direction

Definition at line 237 of file stspin220_class.cpp.

uint32_t Stspin220_GetFwVersion ( void   ) [protected]

Return the FW version.

Return values:
FWversion

Definition at line 246 of file stspin220_class.cpp.

int32_t Stspin220_GetMark ( void   ) [protected]

Get the mark position (32b signed)

Return values:
markposition

Definition at line 255 of file stspin220_class.cpp.

uint16_t Stspin220_GetMaxSpeed ( void   ) [protected]

Return the max speed.

Return values:
maxSpeedin pps

Definition at line 264 of file stspin220_class.cpp.

uint16_t Stspin220_GetMinSpeed ( void   ) [protected]

Get the min speed in step/s for full, half and wave modes in microsteps/s for microstep modes.

Return values:
returnthe min speed in step/s or microstep/s
Note:

Definition at line 276 of file stspin220_class.cpp.

int32_t Stspin220_GetPosition ( void   ) [protected]

Get the current position (32b signed)

Return values:
currentposition value

Definition at line 285 of file stspin220_class.cpp.

motorStepMode_t Stspin220_GetStepMode ( void   ) [protected]

Get the motor step mode.

Return values:
stepmode

Definition at line 294 of file stspin220_class.cpp.

motorStopMode_t Stspin220_GetStopMode ( void   ) [protected]

Get the selected stop mode.

Return values:
theselected stop mode

Definition at line 303 of file stspin220_class.cpp.

uint8_t Stspin220_GetTorque ( motorTorqueMode_t  torqueMode ) [protected]

Get the torque.

Parameters:
[in]torqueModetorque mode
Return values:
thetorqueValue in % (from 0 to 100)
Note:

Definition at line 314 of file stspin220_class.cpp.

bool Stspin220_GetTorqueBoostEnable ( void   ) [protected]

Get the torque boost feature status.

Return values:
TRUEif enabled, FALSE if disabled

Definition at line 344 of file stspin220_class.cpp.

uint16_t Stspin220_GetTorqueBoostThreshold ( void   ) [protected]

Get the torque boost threshold.

Return values:
Thetorque boost threshold above which the step mode is changed to full step

Definition at line 354 of file stspin220_class.cpp.

void Stspin220_GoHome ( void   ) [protected]

Go to the home position.

Return values:
None

Definition at line 363 of file stspin220_class.cpp.

void Stspin220_GoMark ( void   ) [protected]

Go to the Mark position.

Return values:
None

Definition at line 372 of file stspin220_class.cpp.

void Stspin220_GoTo ( int32_t  targetPosition ) [protected]

Request the motor to move to the specified position.

Parameters:
[in]targetPositionabsolute position in steps
Return values:
None
Note:
The position is at the resolution corresponding to the selected step mode. STEP_MODE_FULL : step STEP_MODE_HALF : 1/2 step STEP_MODE_1_4 : 1/4 step STEP_MODE_1_8 : 1/8 step STEP_MODE_1_16 : 1/16 step STEP_MODE_1_32 : 1/32 step STEP_MODE_1_64 : 1/64 step STEP_MODE_1_128 : 1/128 step STEP_MODE_1_256 : 1/256 step

Definition at line 393 of file stspin220_class.cpp.

void Stspin220_GoToDir ( motorDir_t  direction,
int32_t  targetPosition 
) [protected]

Move the motor to the absolute position.

Parameters:
[in]directionFORWARD or BACKWARD
[in]targetPosition32 bit signed value position
Return values:
None
Note:
The position is at the resolution corresponding to the selected step mode. STEP_MODE_FULL : step STEP_MODE_HALF : 1/2 step STEP_MODE_1_4 : 1/4 step STEP_MODE_1_8 : 1/8 step STEP_MODE_1_16 : 1/16 step STEP_MODE_1_32 : 1/32 step STEP_MODE_1_64 : 1/64 step STEP_MODE_1_128 : 1/128 step STEP_MODE_1_256 : 1/256 step

Definition at line 470 of file stspin220_class.cpp.

void Stspin220_HardHiZ ( void   ) [protected]

Immediately stop the motor and disables the power bridges.

Return values:
None

Definition at line 530 of file stspin220_class.cpp.

void Stspin220_HardStop ( void   ) [protected]

Immediatly stop the motor and either set holding torque when stop mode is HOLD_MODE, or call Stspin220_HardHiz function when stop mode is HIZ_MODE, or call Stspin220_PutDeviceInStandby function when stop mode is STANDBY_MODE.

Return values:
None

Definition at line 570 of file stspin220_class.cpp.

Status_t Stspin220_Init ( void *  pInit ) [protected]

Start the STSPIN220 library.

Parameters:
[in]pInitpointer to the initialization data
Return values:
COMPONENT_OKin case of success.

Definition at line 54 of file stspin220_class.cpp.

void Stspin220_Move ( motorDir_t  direction,
uint32_t  stepCount 
) [protected]

Moves the motor of the specified number of steps.

Parameters:
[in]directionFORWARD or BACKWARD
[in]stepCountNumber of steps to perform
Return values:
None

Definition at line 613 of file stspin220_class.cpp.

void Stspin220_PutDeviceInStandby ( void   ) [protected]

Put STSPIN220 device in standby (low power consumption)

Return values:
None

Definition at line 645 of file stspin220_class.cpp.

void Stspin220_Run ( motorDir_t  direction ) [protected]

Runs the motor.

It will accelerate from the min speed up to the max speed by using the device acceleration.

Parameters:
[in]directionFORWARD or BACKWARD
Return values:
None

Definition at line 662 of file stspin220_class.cpp.

bool Stspin220_SetAcceleration ( uint16_t  newAcc ) [protected]

Changes the acceleration.

Parameters:
[in]newAccNew acceleration to apply in pps^2
Return values:
trueif the command is successfully executed, else false
Note:
The command is not performed if the device is executing a MOVE or GOTO command (but it can be used during a RUN command)

Definition at line 689 of file stspin220_class.cpp.

bool Stspin220_SetDeceleration ( uint16_t  newDec ) [protected]

Changes the deceleration.

Parameters:
[in]newDecNew deceleration to apply in pps^2
Return values:
trueif the command is successfully executed, else false
Note:
The command is not performed if the device is executing a MOVE or GOTO command (but it can be used during a RUN command)

Definition at line 709 of file stspin220_class.cpp.

void Stspin220_SetDeviceParamsOtherValues ( void   ) [protected]

Set the parameters of the device whose values are not defined in stspin220_target_config.h.

Return values:
None

Definition at line 1095 of file stspin220_class.cpp.

void Stspin220_SetDeviceParamsToGivenValues ( Stspin220_Init_t *  pInitDevicePrm ) [protected]

Set the parameters of the device to values of the structure pointed by pInitDevicePrm.

Set GPIO according to these values.

Parameters:
pInitDevicePrmpointer onto the structure containing values to initialize the device parameters.
Return values:
None

Definition at line 1126 of file stspin220_class.cpp.

void Stspin220_SetDeviceParamsToPredefinedValues ( void   ) [protected]

Sets the parameters of the device to predefined values from stspin220_target_config.h.

Return values:
None

Definition at line 1156 of file stspin220_class.cpp.

void Stspin220_SetDirection ( motorDir_t  dir ) [protected]

Specifies the direction.

Parameters:
[in]dirFORWARD or BACKWARD
Note:
The direction change is applied if the device is in INACTIVE or STANDBY state or if the device is executing a run command
Return values:
None

Definition at line 730 of file stspin220_class.cpp.

void Stspin220_SetHome ( void   ) [protected]

Set current position to be the Home position (current position set to 0)

Return values:
None

Definition at line 750 of file stspin220_class.cpp.

void Stspin220_SetMark ( void   ) [protected]

Set current position to be the Mark position.

Return values:
None

Definition at line 759 of file stspin220_class.cpp.

bool Stspin220_SetMaxSpeed ( uint16_t volatile  newSpeed ) [protected]

Changes the max speed.

Parameters:
[in]newMaxSpeedNew max speed to apply in pps
Return values:
trueif the command is successfully executed, else false
Note:
The command is not performed is the device is executing a MOVE or GOTO command (but it can be used during a RUN command).

Definition at line 771 of file stspin220_class.cpp.

bool Stspin220_SetMinSpeed ( uint16_t volatile  newSpeed ) [protected]

Changes the min speed.

Parameters:
[in]newMinSpeedNew min speed to apply in pps
Return values:
trueif the command is successfully executed, else false
Note:
The command is not performed is the device is executing a MOVE or GOTO command (but it can be used during a RUN command).

Definition at line 795 of file stspin220_class.cpp.

bool Stspin220_SetStepMode ( motorStepMode_t  stepMode ) [protected]

Set the stepping mode.

Parameters:
[in]stepModefrom full step to 1/256 microstep as specified in enum motorStepMode_t
Return values:
trueif the command is successfully executed, else false

Definition at line 816 of file stspin220_class.cpp.

bool Stspin220_SetStepModeWithoutReset ( motorStepMode_t  stepMode ) [protected]

Set the stepping mode without reset.

Parameters:
[in]stepModefrom full step to 1/256 microstep as specified in enum motorStepMode_t
Return values:
trueif the command is successfully executed, else false

Definition at line 1187 of file stspin220_class.cpp.

void Stspin220_SetStopMode ( motorStopMode_t  stopMode ) [protected]

Select the mode to stop the motor.

Parameters:
[in]stopModeHOLD_MODE to let power bridge enabled
Return values:
None

Definition at line 844 of file stspin220_class.cpp.

void Stspin220_SetTorque ( motorTorqueMode_t  torqueMode,
uint8_t  torqueValue 
) [protected]

Set the torque.

Parameters:
[in]torqueModeTorque mode as specified in enum motorTorqueMode_t
[in]torqueValuein % (from 0 to 100)
Return values:
None
Note:

Definition at line 856 of file stspin220_class.cpp.

void Stspin220_SetTorqueBoostEnable ( bool  enable ) [protected]

Enable or disable the torque boost feature.

Parameters:
[in]enabletrue to enable torque boost, false to disable
Return values:
None

Definition at line 891 of file stspin220_class.cpp.

void Stspin220_SetTorqueBoostThreshold ( uint16_t  speedThreshold ) [protected]

Set the torque boost threshold.

Parameters:
[in]speedThresholdspeed threshold above which the step mode is changed to full step
Return values:
None

Definition at line 902 of file stspin220_class.cpp.

bool Stspin220_SoftStop ( void   ) [protected]

Stops the motor by using the device deceleration.

Return values:
trueif the command is successfully executed, else false
Note:
The command is not performed if the device is in INACTIVE, STANDBYTOINACTIVE or STANDBY state.

Definition at line 913 of file stspin220_class.cpp.

void Stspin220_StartMovement ( void   ) [protected]

Initialises the bridge parameters to start the movement and enable the power bridge.

Return values:
None

Definition at line 1251 of file stspin220_class.cpp.

void Stspin220_StepClockHandler ( void   ) [protected]

Handles the device state machine at each pulse.

Return values:
None
Note:
Must only be called by the timer ISR

Definition at line 1279 of file stspin220_class.cpp.

uint32_t Stspin220_VrefPwmGetFreq ( void   ) [protected]

Get the frequency of REF PWM.

Return values:
thefrequency of REF PWM in Hz
Note:

Definition at line 930 of file stspin220_class.cpp.

void Stspin220_VrefPwmSetFreq ( uint32_t  newFreq ) [protected]

Set the frequency of REF PWM.

Parameters:
[in]newFreqin Hz
Return values:
None
Note:

Definition at line 941 of file stspin220_class.cpp.

void Stspin220_WaitWhileActive ( void   ) [protected]

Locks until the device state becomes Inactive.

Return values:
None

Definition at line 951 of file stspin220_class.cpp.

virtual void WaitWhileActive ( void   ) [virtual]

Waiting while the motor is active.

Parameters:
None.
Return values:
None.

Definition at line 479 of file stspin220_class.h.