39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_spi_master.h"
74#define SILENTSTEP_REG_GCONF 0x00
75#define SILENTSTEP_REG_GSTAT 0x01
76#define SILENTSTEP_REG_IFCNT 0x02
77#define SILENTSTEP_REG_SLAVECONF 0x03
78#define SILENTSTEP_REG_IOIN 0x04
79#define SILENTSTEP_REG_X_COMPARE 0x05
80#define SILENTSTEP_REG_IHOLD_IRUN 0x10
81#define SILENTSTEP_REG_TPOWERDOWN 0x11
82#define SILENTSTEP_REG_TSTEP 0x12
83#define SILENTSTEP_REG_TPWMTHRS 0x13
84#define SILENTSTEP_REG_TCOOLTHRS 0x14
85#define SILENTSTEP_REG_THIGH 0x15
86#define SILENTSTEP_REG_RAMP_MODE 0x20
87#define SILENTSTEP_REG_XACTUAL 0x21
88#define SILENTSTEP_REG_VACTUAL 0x22
89#define SILENTSTEP_REG_VSTART 0x23
90#define SILENTSTEP_REG_A1 0x24
91#define SILENTSTEP_REG_V1 0x25
92#define SILENTSTEP_REG_AMAX 0x26
93#define SILENTSTEP_REG_VMAX 0x27
94#define SILENTSTEP_REG_DMAX 0x28
95#define SILENTSTEP_REG_D1 0x2A
96#define SILENTSTEP_REG_VSTOP 0x2B
97#define SILENTSTEP_REG_TZEROWAIT 0x2C
98#define SILENTSTEP_REG_XTARGET 0x2D
99#define SILENTSTEP_REG_VDCMIN 0x33
100#define SILENTSTEP_REG_SW_MODE 0x34
101#define SILENTSTEP_REG_RAMP_STAT 0x35
102#define SILENTSTEP_REG_XLATCH 0x36
103#define SILENTSTEP_REG_ENCMODE 0x38
104#define SILENTSTEP_REG_X_ENC 0x39
105#define SILENTSTEP_REG_ENC_CONST 0x3A
106#define SILENTSTEP_REG_ENC_STATUS 0x3B
107#define SILENTSTEP_REG_ENC_LATCH 0x3C
108#define SILENTSTEP_REG_MSLUT_0 0x60
109#define SILENTSTEP_REG_MSLUT_1 0x61
110#define SILENTSTEP_REG_MSLUT_2 0x62
111#define SILENTSTEP_REG_MSLUT_3 0x63
112#define SILENTSTEP_REG_MSLUT_4 0x64
113#define SILENTSTEP_REG_MSLUT_5 0x65
114#define SILENTSTEP_REG_MSLUT_6 0x66
115#define SILENTSTEP_REG_MSLUT_7 0x67
116#define SILENTSTEP_REG_MSLUTSEL 0x68
117#define SILENTSTEP_REG_MSLUTSTART 0x69
118#define SILENTSTEP_REG_MSCNT 0x6A
119#define SILENTSTEP_REG_MSCURACT 0x6B
120#define SILENTSTEP_REG_CHOPCONF 0x6C
121#define SILENTSTEP_REG_COOLCONF 0x6D
122#define SILENTSTEP_REG_DCCTRL 0x6E
123#define SILENTSTEP_REG_DRV_STATUS 0x6F
124#define SILENTSTEP_REG_PWMCONF 0x70
125#define SILENTSTEP_REG_PWM_SCALE 0x71
126#define SILENTSTEP_REG_ENCM_CTRL 0x72
127#define SILENTSTEP_REG_LOST_STEPS 0x73
145#define SILENTSTEP_IOIN_VERSION_MASK 0xFF000000ul
146#define SILENTSTEP_IOIN_VERSION_DEFAULT 0x11000000ul
152#define SILENTSTEP_DIR_CW 0
153#define SILENTSTEP_DIR_CCW 1
159#define SILENTSTEP_PIN_STATE_LOW 0
160#define SILENTSTEP_PIN_STATE_HIGH 1
166#define SILENTSTEP_SPEED_VERY_SLOW 0
167#define SILENTSTEP_SPEED_SLOW 1
168#define SILENTSTEP_SPEED_MEDIUM 2
169#define SILENTSTEP_SPEED_FAST 3
170#define SILENTSTEP_SPEED_VERY_FAST 4
176#define SILENTSTEP_TOFF_MASK 0x0000000Ful
177#define SILENTSTEP_TOFF_SHIFT 0
178#define SILENTSTEP_TOFF_DRIVER_DISABLE 0
179#define SILENTSTEP_TOFF_MIN 1
180#define SILENTSTEP_TOFF_DEFAULT 4
181#define SILENTSTEP_TOFF_MAX 15
187#define SILENTSTEP_MRES_MASK 0x0F000000ul
188#define SILENTSTEP_MRES_SHIFT 24
189#define SILENTSTEP_MRES_256 0
190#define SILENTSTEP_MRES_128 1
191#define SILENTSTEP_MRES_64 2
192#define SILENTSTEP_MRES_32 3
193#define SILENTSTEP_MRES_16 4
194#define SILENTSTEP_MRES_8 5
195#define SILENTSTEP_MRES_4 6
196#define SILENTSTEP_MRES_2 7
197#define SILENTSTEP_MRES_FULLSTEP 8
203#define SILENTSTEP_IRUN_MASK 0x00000F00ul
204#define SILENTSTEP_IRUN_SHIFT 8
205#define SILENTSTEP_IRUN_MIN 0
206#define SILENTSTEP_IRUN_DEFAULT 2
207#define SILENTSTEP_IRUN_MAX 31
217#define SILENTSTEP_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
218#define SILENTSTEP_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
236#define SILENTSTEP_MAP_MIKROBUS( cfg, mikrobus ) \
237 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
238 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
239 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
240 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
241 cfg.spm = MIKROBUS( mikrobus, MIKROBUS_AN ); \
242 cfg.sdm = MIKROBUS( mikrobus, MIKROBUS_RST ); \
243 cfg.step = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
244 cfg.dir = MIKROBUS( mikrobus, MIKROBUS_INT )
err_t silentstep_set_step_res(silentstep_t *ctx, uint8_t mres)
Silent Step set step res function.
err_t silentstep_write_reg(silentstep_t *ctx, uint8_t reg, uint32_t data_in)
Silent Step write reg function.
void silentstep_set_step_pin(silentstep_t *ctx, uint8_t state)
Silent Step set step pin function.
void silentstep_set_sdm_pin(silentstep_t *ctx, uint8_t state)
Silent Step set sdm pin function.
void silentstep_set_spm_pin(silentstep_t *ctx, uint8_t state)
Silent Step set spm pin function.
void silentstep_drive_motor(silentstep_t *ctx, uint32_t steps, uint8_t speed)
Silent Step driver motor function.
err_t silentstep_set_toff(silentstep_t *ctx, uint8_t toff)
Silent Step set toff function.
err_t silentstep_default_cfg(silentstep_t *ctx)
Silent Step default configuration function.
err_t silentstep_check_com(silentstep_t *ctx)
Silent Step check com function.
void silentstep_cfg_setup(silentstep_cfg_t *cfg)
Silent Step configuration object setup function.
err_t silentstep_set_run_current(silentstep_t *ctx, uint8_t irun)
Silent Step set run current function.
void silentstep_set_direction(silentstep_t *ctx, uint8_t dir)
Silent Step set direction function.
err_t silentstep_init(silentstep_t *ctx, silentstep_cfg_t *cfg)
Silent Step initialization function.
err_t silentstep_read_reg(silentstep_t *ctx, uint8_t reg, uint32_t *data_out)
Silent Step read reg function.
void silentstep_switch_direction(silentstep_t *ctx)
Silent Step switch direction function.
silentstep_return_value_t
Silent Step Click return value data.
Definition silentstep.h:298
@ SILENTSTEP_OK
Definition silentstep.h:299
@ SILENTSTEP_ERROR
Definition silentstep.h:300
This file contains SPI specific macros, functions, etc.
Silent Step Click configuration object.
Definition silentstep.h:273
pin_name_t spm
Definition silentstep.h:281
pin_name_t step
Definition silentstep.h:283
spi_master_chip_select_polarity_t cs_polarity
Definition silentstep.h:289
pin_name_t sdm
Definition silentstep.h:282
pin_name_t sck
Definition silentstep.h:277
spi_master_mode_t spi_mode
Definition silentstep.h:288
pin_name_t mosi
Definition silentstep.h:276
uint32_t spi_speed
Definition silentstep.h:287
pin_name_t dir
Definition silentstep.h:284
pin_name_t miso
Definition silentstep.h:275
pin_name_t cs
Definition silentstep.h:278
Silent Step Click context object.
Definition silentstep.h:254
spi_master_t spi
Definition silentstep.h:262
digital_out_t sdm
Definition silentstep.h:257
digital_out_t spm
Definition silentstep.h:256
digital_out_t step
Definition silentstep.h:258
pin_name_t chip_select
Definition silentstep.h:264
digital_out_t dir
Definition silentstep.h:259