39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
73#define STEPPER5_REG_GCONF 0x00
74#define STEPPER5_REG_GSTAT 0x01
75#define STEPPER5_REG_IFCNT 0x02
76#define STEPPER5_REG_SLAVECONF 0x03
77#define STEPPER5_REG_OTP_PROG 0x04
78#define STEPPER5_REG_OTP_READ 0x05
79#define STEPPER5_REG_IOIN 0x06
80#define STEPPER5_REG_FACTORY_CONF 0x07
81#define STEPPER5_REG_IHOLD_IRUN 0x10
82#define STEPPER5_REG_TPOWERDOWN 0x11
83#define STEPPER5_REG_TSTEP 0x12
84#define STEPPER5_REG_TPWMTHRS 0x13
85#define STEPPER5_REG_VACTUAL 0x22
86#define STEPPER5_REG_MSCNT 0x6A
87#define STEPPER5_REG_MSCURACT 0x6B
88#define STEPPER5_REG_CHOPCONF 0x6C
89#define STEPPER5_REG_COOLCONF 0x6D
90#define STEPPER5_REG_DRV_STATUS 0x6F
91#define STEPPER5_REG_PWMCONF 0x70
92#define STEPPER5_REG_PWM_SCALE 0x71
93#define STEPPER5_REG_PWM_AUTO 0x72
111#define STEPPER5_IOIN_VERSION_MASK 0xFF000000ul
112#define STEPPER5_IOIN_VERSION_DEFAULT 0x20000000ul
118#define STEPPER5_DIR_CW 0
119#define STEPPER5_DIR_CCW 1
125#define STEPPER5_PIN_STATE_LOW 0
126#define STEPPER5_PIN_STATE_HIGH 1
132#define STEPPER5_SPEED_VERY_SLOW 0
133#define STEPPER5_SPEED_SLOW 1
134#define STEPPER5_SPEED_MEDIUM 2
135#define STEPPER5_SPEED_FAST 3
136#define STEPPER5_SPEED_VERY_FAST 4
142#define STEPPER5_GCONF_I_SCALE_ANALOG_INT_5V 0x00000000ul
143#define STEPPER5_GCONF_I_SCALE_ANALOG_EXT_VREF 0x00000001ul
144#define STEPPER5_GCONF_INTERNAL_RSENSE_EXT 0x00000000ul
145#define STEPPER5_GCONF_INTERNAL_RSENSE_INT 0x00000002ul
146#define STEPPER5_GCONF_EN_SPREAD_CYCLE_SCHOP 0x00000000ul
147#define STEPPER5_GCONF_EN_SPREAD_CYCLE_SCYCLE 0x00000004ul
148#define STEPPER5_GCONF_SHAFT_INVERSE 0x00000008ul
149#define STEPPER5_GCONF_INDEX_OTPW_FIRST_MSTEP 0x00000000ul
150#define STEPPER5_GCONF_INDEX_OTPW_OVERTEMP 0x00000010ul
151#define STEPPER5_GCONF_INDEX_STEP_OTPW 0x00000000ul
152#define STEPPER5_GCONF_INDEX_STEP_INT 0x00000020ul
153#define STEPPER5_GCONF_PDN_DISABLE_SSC_REDUCT 0x00000000ul
154#define STEPPER5_GCONF_PDN_DISABLE_UART_EN 0x00000040ul
155#define STEPPER5_GCONF_MSTEP_REG_SELECT_MS_PINS 0x00000000ul
156#define STEPPER5_GCONF_MSTEP_REG_SELECT_MSTEP 0x00000080ul
157#define STEPPER5_GCONF_MULTISTEP_FILT_DIS 0x00000000ul
158#define STEPPER5_GCONF_MULTISTEP_FILT_EN 0x00000100ul
159#define STEPPER5_GCONF_TEST_MODE_NORMAL 0x00000000ul
160#define STEPPER5_GCONF_TEST_MODE_ENN 0x00000200ul
166#define STEPPER5_TOFF_MASK 0x0000000Ful
167#define STEPPER5_TOFF_SHIFT 0
168#define STEPPER5_TOFF_DRIVER_DISABLE 0
169#define STEPPER5_TOFF_MIN 1
170#define STEPPER5_TOFF_DEFAULT 4
171#define STEPPER5_TOFF_MAX 15
177#define STEPPER5_MRES_MASK 0x0F000000ul
178#define STEPPER5_MRES_SHIFT 24
179#define STEPPER5_MRES_256 0
180#define STEPPER5_MRES_128 1
181#define STEPPER5_MRES_64 2
182#define STEPPER5_MRES_32 3
183#define STEPPER5_MRES_16 4
184#define STEPPER5_MRES_8 5
185#define STEPPER5_MRES_4 6
186#define STEPPER5_MRES_2 7
187#define STEPPER5_MRES_FULLSTEP 8
193#define STEPPER5_IRUN_MASK 0x00000F00ul
194#define STEPPER5_IRUN_SHIFT 8
195#define STEPPER5_IRUN_MIN 0
196#define STEPPER5_IRUN_DEFAULT 16
197#define STEPPER5_IRUN_MAX 31
203#define STEPPER5_UART_SYNC_BYTE 0x05
204#define STEPPER5_UART_SLAVE_ADDRESS 0x00
205#define STEPPER5_UART_WRITE_BIT 0x80
212#define STEPPER5_TX_DRV_BUFFER_SIZE 100
213#define STEPPER5_RX_DRV_BUFFER_SIZE 300
231#define STEPPER5_MAP_MIKROBUS( cfg, mikrobus ) \
232 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
233 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
234 cfg.diag = MIKROBUS( mikrobus, MIKROBUS_AN ); \
235 cfg.dir = MIKROBUS( mikrobus, MIKROBUS_RST ); \
236 cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
237 cfg.step = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
238 cfg.ind = MIKROBUS( mikrobus, MIKROBUS_INT );
#define STEPPER5_RX_DRV_BUFFER_SIZE
Definition stepper5.h:213
#define STEPPER5_TX_DRV_BUFFER_SIZE
Stepper 5 driver buffer size.
Definition stepper5.h:212
err_t stepper5_read_reg(stepper5_t *ctx, uint8_t reg, uint32_t *data_out)
Stepper 5 read reg function.
void stepper5_disable_device(stepper5_t *ctx)
Stepper 5 disable device function.
err_t stepper5_default_cfg(stepper5_t *ctx)
Stepper 5 default configuration function.
void stepper5_switch_direction(stepper5_t *ctx)
Stepper 5 switch direction function.
err_t stepper5_set_run_current(stepper5_t *ctx, uint8_t irun)
Stepper 5 set run current function.
err_t stepper5_set_toff(stepper5_t *ctx, uint8_t toff)
Stepper 5 set toff function.
void stepper5_cfg_setup(stepper5_cfg_t *cfg)
Stepper 5 configuration object setup function.
uint8_t stepper5_get_index_pin(stepper5_t *ctx)
Stepper 5 get index pin function.
uint8_t stepper5_get_diag_pin(stepper5_t *ctx)
Stepper 5 get diag pin function.
err_t stepper5_set_step_res(stepper5_t *ctx, uint8_t mres)
Stepper 5 set step res function.
void stepper5_set_direction(stepper5_t *ctx, uint8_t dir)
Stepper 5 set direction function.
void stepper5_set_step_pin(stepper5_t *ctx, uint8_t state)
Stepper 5 set step pin function.
void stepper5_drive_motor(stepper5_t *ctx, uint32_t steps, uint8_t speed)
Stepper 5 driver motor function.
void stepper5_enable_device(stepper5_t *ctx)
Stepper 5 enable device function.
err_t stepper5_init(stepper5_t *ctx, stepper5_cfg_t *cfg)
Stepper 5 initialization function.
void stepper5_write_reg(stepper5_t *ctx, uint8_t reg, uint32_t data_in)
Stepper 5 write reg function.
err_t stepper5_check_com(stepper5_t *ctx)
Stepper 5 check com function.
stepper5_return_value_t
Stepper 5 Click return value data.
Definition stepper5.h:298
@ STEPPER5_ERROR
Definition stepper5.h:300
@ STEPPER5_OK
Definition stepper5.h:299
Stepper 5 Click configuration object.
Definition stepper5.h:272
pin_name_t diag
Definition stepper5.h:278
uint32_t baud_rate
Definition stepper5.h:285
pin_name_t step
Definition stepper5.h:281
bool uart_blocking
Definition stepper5.h:286
uart_data_bits_t data_bit
Definition stepper5.h:287
pin_name_t tx_pin
Definition stepper5.h:275
pin_name_t rx_pin
Definition stepper5.h:274
uart_stop_bits_t stop_bit
Definition stepper5.h:289
pin_name_t dir
Definition stepper5.h:279
pin_name_t en
Definition stepper5.h:280
uart_parity_t parity_bit
Definition stepper5.h:288
pin_name_t ind
Definition stepper5.h:282
Stepper 5 Click context object.
Definition stepper5.h:248
uart_t uart
Definition stepper5.h:259
digital_out_t step
Definition stepper5.h:252
digital_out_t en
Definition stepper5.h:251
digital_in_t ind
Definition stepper5.h:256
digital_in_t diag
Definition stepper5.h:255
digital_out_t dir
Definition stepper5.h:250