silentstep2 2.1.0.0
silentstep2.h File Reference

This file contains API for Silent Step 2 Click Driver. More...

#include "drv_digital_out.h"
#include "drv_digital_in.h"
#include "drv_i2c_master.h"
#include "drv_spi_master.h"
#include "spi_specifics.h"

Go to the source code of this file.

Data Structures

struct  silentstep2_t
 Silent Step 2 Click context object. More...
 
struct  silentstep2_cfg_t
 Silent Step 2 Click configuration object. More...
 
struct  silentstep2_gconf_t
 Silent Step 2 Click global configuration object. More...
 
struct  silentstep2_coolconf_t
 Silent Step 2 Click smart energy control coolStep and stallGuard2 object. More...
 
struct  silentstep2_pwmconf_t
 Silent Step 2 Click voltage mode pwm stealthChop object. More...
 
struct  silentstep2_drv_status_t
 Silent Step 2 Click stallGuard2 value and driver error flags object. More...
 

Macros

#define SILENTSTEP2_REG_GCONF   0x00
 Silent Step 2 description register.
 
#define SILENTSTEP2_REG_GSTAT   0x01
 
#define SILENTSTEP2_REG_IOIN   0x04
 
#define SILENTSTEP2_REG_IHOLD_IRUN   0x10
 
#define SILENTSTEP2_REG_TPOWERDOWN   0x11
 
#define SILENTSTEP2_REG_TSTEP   0x12
 
#define SILENTSTEP2_REG_TPWMTHRS   0x13
 
#define SILENTSTEP2_REG_TCOOLTHRS   0x14
 
#define SILENTSTEP2_REG_THIGH   0x15
 
#define SILENTSTEP2_REG_XDIRECT   0x2D
 
#define SILENTSTEP2_REG_VDCMIN   0x33
 
#define SILENTSTEP2_REG_MSLUT0   0x60
 
#define SILENTSTEP2_REG_MSLUT1   0x61
 
#define SILENTSTEP2_REG_MSLUT2   0x62
 
#define SILENTSTEP2_REG_MSLUT3   0x63
 
#define SILENTSTEP2_REG_MSLUT4   0x64
 
#define SILENTSTEP2_REG_MSLUT5   0x65
 
#define SILENTSTEP2_REG_MSLUT6   0x66
 
#define SILENTSTEP2_REG_MSLUT7   0x67
 
#define SILENTSTEP2_REG_MSLUTSEL   0x68
 
#define SILENTSTEP2_REG_MSLUTSTART   0x69
 
#define SILENTSTEP2_REG_MSCNT   0x6A
 
#define SILENTSTEP2_REG_MSCURACT   0x6B
 
#define SILENTSTEP2_REG_CHOPCONF   0x6C
 
#define SILENTSTEP2_REG_COOLCONF   0x6D
 
#define SILENTSTEP2_REG_DCCTRL   0x6E
 
#define SILENTSTEP2_REG_DRV_STATUS   0x6F
 
#define SILENTSTEP2_REG_PWMCONF   0x70
 
#define SILENTSTEP2_REG_PWM_SCALE   0x71
 
#define SILENTSTEP2_REG_ENCM_CTRL   0x72
 
#define SILENTSTEP2_REG_LOST_STEPS   0x73
 
#define SILENTSTEP2_REG_EXP_IN_PORT   0x00
 
#define SILENTSTEP2_REG_EXP_OUT_PORT   0x01
 
#define SILENTSTEP2_REG_EXP_POL_INV   0x02
 
#define SILENTSTEP2_REG_EXP_CONFIG   0x03
 
#define SILENTSTEP2_GSTAT_RESET   0x00000001ul
 Silent Step 2 global status flags.
 
#define SILENTSTEP2_GSTAT_DRV_ERR   0x00000002ul
 
#define SILENTSTEP2_GSTAT_UV_CP   0x00000004ul
 
#define SILENTSTEP2_GCONF_I_SC_AN_OP_NORMAL   0x00
 Silent Step 2 global configuration flags.
 
#define SILENTSTEP2_GCONF_I_SC_AN_AIN   0x01
 
#define SILENTSTEP2_GCONF_INT_RSE_OP_NORMAL   0x00
 
#define SILENTSTEP2_GCONF_INT_RSE_INT_RSE   0x01
 
#define SILENTSTEP2_GCONF_DISABLE   0x00
 
#define SILENTSTEP2_GCONF_ENABLE   0x01
 
#define SILENTSTEP2_THIGH_DEFAULT   0x00000300ul
 Silent Step 2 velocity setting for different chopper modes and full stepping to maximize torque.
 
#define SILENTSTEP2_THIGH_MAX   0x000FFFFFul
 
#define SILENTSTEP2_TCOOLTHRS_DEFAULT   0x00002700ul
 Silent Step 2 threshold velocity for switching on smart energy.
 
#define SILENTSTEP2_TCOOLTHRS_MAX   0x000FFFFFul
 
#define SILENTSTEP2_CHOPCONF_SEMIN_0   0x00
 Silent Step 2 coolStep smart current control register and stallGuard2 configuration.
 
#define SILENTSTEP2_CHOPCONF_SEMIN_BIT_MASK   0x0F
 
#define SILENTSTEP2_CHOPCONF_SEUP_1   0x00
 
#define SILENTSTEP2_CHOPCONF_SEUP_2   0x01
 
#define SILENTSTEP2_CHOPCONF_SEUP_3   0x02
 
#define SILENTSTEP2_CHOPCONF_SEUP_8   0x03
 
#define SILENTSTEP2_CHOPCONF_SEMAX_0   0x00
 
#define SILENTSTEP2_CHOPCONF_SEMAX_BIT_MASK   0x0F
 
#define SILENTSTEP2_CHOPCONF_SEDN_32   0x00
 
#define SILENTSTEP2_CHOPCONF_SEDN_8   0x01
 
#define SILENTSTEP2_CHOPCONF_SEDN_2   0x02
 
#define SILENTSTEP2_CHOPCONF_SEDN_1   0x03
 
#define SILENTSTEP2_CHOPCONF_SEIMIN_1_2   0x00
 
#define SILENTSTEP2_CHOPCONF_SEIMIN_1_4   0x01
 
#define SILENTSTEP2_CHOPCONF_SGT_M64   0x00
 
#define SILENTSTEP2_CHOPCONF_SGT_P64   0x7F
 
#define SILENTSTEP2_CHOPCONF_SFILT_MODE_STD   0x00
 
#define SILENTSTEP2_CHOPCONF_SFILT_MODE_FLTR   0x01
 
#define SILENTSTEP2_IHOLD_10_32   0x0A
 Silent Step 2 coolStep smart current control register and stallGuard2 configuration.
 
#define SILENTSTEP2_IHOLD_BIT_MASK   0x1F
 
#define SILENTSTEP2_IRUN_10_32   0x0A
 
#define SILENTSTEP2_IRUN_BIT_MASK   0x1F
 
#define SILENTSTEP2_IHOLDDELAY_PWR_DOWN   0x00
 
#define SILENTSTEP2_IHOLDDELAY_32   0x05
 
#define SILENTSTEP2_IHOLDDELAY_BIT_MASK   0x0F
 
#define SILENTSTEP2_TOFF_DIS   0x00
 Silent Step 2 off time setting controls duration of slow decay phase.
 
#define SILENTSTEP2_TOFF_NCLK_140   0x04
 
#define SILENTSTEP2_TOFF_BIT_MASK   0x0F
 
#define SILENTSTEP2_STEP_SPEED_MIN   1
 Silent Step 2 step speed and angle data values.
 
#define SILENTSTEP2_STEP_SPEED_MAX   100
 
#define SILENTSTEP2_ANGLE_360_DEGREES   360.0f
 
#define SILENTSTEP2_CHOPCONF_CHM_MODE_STND   0x00
 Silent Step 2 chopper and driver configuration.
 
#define SILENTSTEP2_CHOPCONF_CHM_CONST_OFF_TIME   0x01
 
#define SILENTSTEP2_CHOPCONF_CHM_BIT_MASK   0x00004000ul
 
#define SILENTSTEP2_CHOPCONF_HE_OS_M3   0x00
 
#define SILENTSTEP2_CHOPCONF_HE_OS_M2   0x01
 
#define SILENTSTEP2_CHOPCONF_HE_OS_M1   0x02
 
#define SILENTSTEP2_CHOPCONF_HE_OS_0   0x03
 
#define SILENTSTEP2_CHOPCONF_HE_OS_1   0x04
 
#define SILENTSTEP2_CHOPCONF_HE_OS_2   0x05
 
#define SILENTSTEP2_CHOPCONF_HE_OS_3   0x06
 
#define SILENTSTEP2_CHOPCONF_HE_OS_4   0x07
 
#define SILENTSTEP2_CHOPCONF_HE_OS_5   0x08
 
#define SILENTSTEP2_CHOPCONF_HE_OS_6   0x09
 
#define SILENTSTEP2_CHOPCONF_HE_OS_7   0x0A
 
#define SILENTSTEP2_CHOPCONF_HE_OS_8   0x0B
 
#define SILENTSTEP2_CHOPCONF_HE_OS_9   0x0C
 
#define SILENTSTEP2_CHOPCONF_HE_OS_10   0x0D
 
#define SILENTSTEP2_CHOPCONF_HE_OS_11   0x0E
 
#define SILENTSTEP2_CHOPCONF_HE_OS_12   0x0F
 
#define SILENTSTEP2_CHOPCONF_HE_OS_BIT_MASK   0x00000780ul
 
#define SILENTSTEP2_CHOPCONF_HSTRT_TFD_0   0x00
 
#define SILENTSTEP2_CHOPCONF_HSTRT_TFD_1   0x01
 
#define SILENTSTEP2_CHOPCONF_HSTRT_TFD_2   0x02
 
#define SILENTSTEP2_CHOPCONF_HSTRT_TFD_3   0x03
 
#define SILENTSTEP2_CHOPCONF_HSTRT_TFD_4   0x04
 
#define SILENTSTEP2_CHOPCONF_HSTRT_TFD_5   0x05
 
#define SILENTSTEP2_CHOPCONF_HSTRT_TFD_6   0x06
 
#define SILENTSTEP2_CHOPCONF_HSTRT_TFD_7   0x07
 
#define SILENTSTEP2_CHOPCONF_HSTRT_TFD_BIT_MASK   0x00000070ul
 
#define SILENTSTEP2_MSLUT_SEL_0   0x00
 Silent Step 2 microstep table entries and defines four segments values.
 
#define SILENTSTEP2_MSLUT_SEL_1   0x01
 
#define SILENTSTEP2_MSLUT_SEL_2   0x02
 
#define SILENTSTEP2_MSLUT_SEL_3   0x03
 
#define SILENTSTEP2_MSLUT_SEL_4   0x04
 
#define SILENTSTEP2_MSLUT_SEL_5   0x05
 
#define SILENTSTEP2_MSLUT_SEL_6   0x06
 
#define SILENTSTEP2_MSLUT_SEL_7   0x07
 
#define SILENTSTEP2_MSLUTSEL_WIDTH_BIT_MASK   0x000000FFul
 
#define SILENTSTEP2_MSLUTSEL_SEG_BIT_MASK   0x00FFFFFFul
 
#define SILENTSTEP2_MSLUTSTART_SIN_BIT_MASK   0x000000FFul
 Silent Step 2 absolute current at microstep table entry values.
 
#define SILENTSTEP2_MSLUTSTART_SIN90_BIT_MASK   0x000000FFul
 
#define SILENTSTEP2_CHOPCONF_MRES_BIT_MASK   0xF0FFFFFFul
 Silent Step 2 chopper configuration bit masks values.
 
#define SILENTSTEP2_CHOPCONF_DEDGE_BIT_MASK   0xDFFFFFFFul
 
#define SILENTSTEP2_CHOPCONF_INTPOL_BIT_MASK   0xEFFFFFFFul
 
#define SILENTSTEP2_CHOPCONF_TBL_BIT_MASK   0xFFFE7FFFul
 
#define SILENTSTEP2_CHOPCONF_TOFF_BIT_MASK   0xFFFFFFF0ul
 
#define SILENTSTEP2_PIN_NONE   0x00
 Silent Step 2 GPIO expander pin setting.
 
#define SILENTSTEP2_PIN_EN   0x01
 
#define SILENTSTEP2_PIN_FT1   0x02
 
#define SILENTSTEP2_PIN_FT2   0x04
 
#define SILENTSTEP2_PIN_ALL   0x07
 
#define SILENTSTEP2_DIRECTION_COUNTERCLOCKWISE   0
 Silent Step 2 step/direction driver mode.
 
#define SILENTSTEP2_DIRECTION_CLOCKWISE   1
 
#define SILENTSTEP2_STEP_DELAY_DEFAULT_100US   100ul
 Silent Step 2 step delay default value.
 
#define SILENTSTEP2_DEVICE_ADDRESS_0   0x70
 Silent Step 2 device address setting.
 
#define SILENTSTEP2_DEVICE_ADDRESS_1   0x72
 
#define SILENTSTEP2_DEVICE_ADDRESS_2   0x74
 
#define SILENTSTEP2_DEVICE_ADDRESS_3   0x76
 
#define SILENTSTEP2_SET_DATA_SAMPLE_EDGE   SET_SPI_DATA_SAMPLE_EDGE
 Data sample selection.
 
#define SILENTSTEP2_SET_DATA_SAMPLE_MIDDLE   SET_SPI_DATA_SAMPLE_MIDDLE
 
#define SILENTSTEP2_MAP_MIKROBUS(cfg, mikrobus)
 MikroBUS pin mapping.
 

Enumerations

enum  silentstep2_drv_t { SILENTSTEP2_DRV_SEL_SPI , SILENTSTEP2_DRV_SEL_I2C }
 Silent Step 2 Click driver selector. More...
 
enum  silentstep2_return_value_t { SILENTSTEP2_OK = 0 , SILENTSTEP2_ERROR = -1 }
 Silent Step 2 Click return value data. More...
 
enum  silentstep2_mres_t {
  SILENTSTEP2_MRES_256 = 0 , SILENTSTEP2_MRES_128 , SILENTSTEP2_MRES_64 , SILENTSTEP2_MRES_32 ,
  SILENTSTEP2_MRES_16 , SILENTSTEP2_MRES_8 , SILENTSTEP2_MRES_4 , SILENTSTEP2_MRES_2 ,
  SILENTSTEP2_MRES_NATIVE
}
 Silent Step 2 Click reduced microstep resolution value data. More...
 
enum  silentstep2_tbl_t { SILENTSTEP2_TBL_CLOCKS_16 = 0 , SILENTSTEP2_TBL_CLOCKS_24 , SILENTSTEP2_TBL_CLOCKS_36 , SILENTSTEP2_TBL_CLOCKS_54 }
 Silent Step 2 Click comparator blank time value data. More...
 

Functions

void silentstep2_cfg_setup (silentstep2_cfg_t *cfg)
 Silent Step 2 configuration object setup function.
 
err_t silentstep2_init (silentstep2_t *ctx, silentstep2_cfg_t *cfg)
 Silent Step 2 initialization function.
 
err_t silentstep2_default_cfg (silentstep2_t *ctx)
 Silent Step 2 default configuration function.
 
err_t silentstep2_reg_write (silentstep2_t *ctx, uint8_t reg, uint32_t data_in)
 Silent Step 2 data writing function.
 
err_t silentstep2_reg_read (silentstep2_t *ctx, uint8_t reg, uint32_t *data_in)
 Silent Step 2 data reading function.
 
err_t silentstep2_set_gconf (silentstep2_t *ctx, silentstep2_gconf_t gconf)
 Silent Step 2 sets global configuration function.
 
err_t silentstep2_get_gstat (silentstep2_t *ctx, uint32_t *gstat)
 Silent Step 2 get global status function.
 
err_t silentstep2_set_ihold_irun (silentstep2_t *ctx, uint8_t ihold, uint8_t irun, uint8_t ihold_delay)
 Silent Step 2 sets driver current control function.
 
err_t silentstep2_set_tcoolthrs (silentstep2_t *ctx, uint32_t tcoolthrs)
 Silent Step 2 sets lower threshold velocity for switching on smart energy function.
 
err_t silentstep2_set_thigh (silentstep2_t *ctx, uint32_t thigh)
 Silent Step 2 sets the velocity setting function.
 
err_t silentstep2_set_mslut (silentstep2_t *ctx, uint8_t mslut_sel, uint32_t mslut)
 Silent Step 2 sets the microstep table entries function.
 
err_t silentstep2_set_mslutsel (silentstep2_t *ctx, uint32_t lut_seg_str, uint32_t lut_width_sel)
 Silent Step 2 sets the microstep segments function.
 
err_t silentstep2_set_mslutstart (silentstep2_t *ctx, uint32_t start_sin, uint32_t start_sin90)
 Silent Step 2 sets the absolute current microstep table function.
 
err_t silentstep2_set_mstep_res (silentstep2_t *ctx, silentstep2_mres_t step_width)
 Silent Step 2 sets the micro step resolution function.
 
err_t silentstep2_set_dedge (silentstep2_t *ctx, uint8_t dedge_en)
 Silent Step 2 sets the step impulsen function.
 
err_t silentstep2_set_intpol (silentstep2_t *ctx, uint8_t intpol_en)
 Silent Step 2 enable the actual microstep resolution function.
 
err_t silentstep2_set_tbl_blank_time (silentstep2_t *ctx, silentstep2_tbl_t tbl)
 Silent Step 2 enable the blank time select function.
 
err_t silentstep2_set_h_end_strt (silentstep2_t *ctx, uint8_t chm, uint8_t h_end_offset, uint8_t hstrt_tfd)
 Silent Step 2 sets the chopper mode config function.
 
err_t silentstep2_set_toff (silentstep2_t *ctx, uint8_t off_time)
 Silent Step 2 sets the off time and driver enable function.
 
err_t silentstep2_set_coolconf (silentstep2_t *ctx, silentstep2_coolconf_t coolconf)
 Silent Step 2 sets the coolStep smart current control function.
 
err_t silentstep2_set_pwmconf (silentstep2_t *ctx, silentstep2_pwmconf_t pwmconf)
 Silent Step 2 sets the voltage PWM Mode stealthChop function.
 
err_t silentstep2_get_drv_status (silentstep2_t *ctx, silentstep2_drv_status_t *drv_status)
 Silent Step 2 get driver status error flags function.
 
err_t silentstep2_port_exp_write (silentstep2_t *ctx, uint8_t reg, uint8_t data_in)
 Silent Step 2 port expander data writing function.
 
err_t silentstep2_port_exp_read (silentstep2_t *ctx, uint8_t reg, uint8_t *data_out)
 Silent Step 2 port expander data reading function.
 
err_t silentstep2_set_pins (silentstep2_t *ctx, uint8_t set_mask, uint8_t clr_mask)
 Silent Step 2 sets the pin states function.
 
err_t silentstep2_get_diag0 (silentstep2_t *ctx, uint8_t *diag0)
 Silent Step 2 get the diagnostics output DIAG0 function.
 
err_t silentstep2_get_diag1 (silentstep2_t *ctx, uint8_t *diag1)
 Silent Step 2 get the diagnostics output DIAG1 function.
 
err_t silentstep2_switch_off (silentstep2_t *ctx)
 Silent Step 2 sets the power OFF function.
 
err_t silentstep2_input_enable (silentstep2_t *ctx)
 Silent Step 2 enable input function.
 
void silentstep2_set_direction (silentstep2_t *ctx, uint8_t dir)
 Silent Step 2 sets the clockwise or counterclockwise direction movement function.
 
void silentstep2_set_step (silentstep2_t *ctx, uint8_t step)
 Silent Step 2 set the step pin state function.
 
err_t silentstep2_make_one_step (silentstep2_t *ctx, uint8_t step_speed)
 Silent Step 2 make the one step function.
 
err_t silentstep2_rotate_by_angle (silentstep2_t *ctx, uint8_t step_speed, float angle, uint16_t res_360)
 Silent Step 2 rotates the shaft through a desired angle function.
 
uint8_t silentstep2_get_interrupt (silentstep2_t *ctx)
 Silent Step 2 get the interrupt function.
 

Detailed Description

This file contains API for Silent Step 2 Click Driver.

Enumeration Type Documentation

◆ silentstep2_drv_t

Silent Step 2 Click driver selector.

Selects target driver interface of Silent Step 2 Click driver.

Enumerator
SILENTSTEP2_DRV_SEL_SPI 

SPI driver descriptor.

SILENTSTEP2_DRV_SEL_I2C 

I2C driver descriptor.

◆ silentstep2_mres_t

Silent Step 2 Click reduced microstep resolution value data.

Predefined enum values for driver reduced microstep resolution values.

Enumerator
SILENTSTEP2_MRES_256 
SILENTSTEP2_MRES_128 
SILENTSTEP2_MRES_64 
SILENTSTEP2_MRES_32 
SILENTSTEP2_MRES_16 
SILENTSTEP2_MRES_8 
SILENTSTEP2_MRES_4 
SILENTSTEP2_MRES_2 
SILENTSTEP2_MRES_NATIVE 

◆ silentstep2_return_value_t

Silent Step 2 Click return value data.

Predefined enum values for driver return values.

Enumerator
SILENTSTEP2_OK 
SILENTSTEP2_ERROR 

◆ silentstep2_tbl_t

Silent Step 2 Click comparator blank time value data.

Predefined enum values for driver comparator blank time values.

Enumerator
SILENTSTEP2_TBL_CLOCKS_16 
SILENTSTEP2_TBL_CLOCKS_24 
SILENTSTEP2_TBL_CLOCKS_36 
SILENTSTEP2_TBL_CLOCKS_54