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_i2c_master.h"
73#define STEPPER19_REG_IN_PORT 0x00
74#define STEPPER19_REG_OUT_PORT 0x01
75#define STEPPER19_REG_POL_INV 0x02
76#define STEPPER19_REG_CONFIG 0x03
94#define STEPPER19_PIN_STATE_LOW 0
95#define STEPPER19_PIN_STATE_HIGH 1
101#define STEPPER19_DIR_CLOCKWISE 0
102#define STEPPER19_DIR_COUNTERCLOCKWISE 1
108#define STEPPER19_PIN_NONE 0x00
109#define STEPPER19_PIN_M0 0x01
110#define STEPPER19_PIN_M1 0x02
111#define STEPPER19_PIN_DEC0 0x04
112#define STEPPER19_PIN_DEC1 0x08
113#define STEPPER19_PIN_TOFF 0x10
114#define STEPPER19_PIN_STP 0x20
115#define STEPPER19_PIN_DIR 0x40
121#define STEPPER19_CTRL_STEP_DIR_GPIO 0
122#define STEPPER19_CTRL_STEP_DIR_PORT_EXP 1
128#define STEPPER19_PORT_EXP_DEFAULT_CFG 0x03
134#define STEPPER19_MSTEP_MODE_FULL 1
135#define STEPPER19_MSTEP_MODE_HALF 2
136#define STEPPER19_MSTEP_MODE_1_4 4
137#define STEPPER19_MSTEP_MODE_1_8 8
138#define STEPPER19_MSTEP_MODE_1_16 16
139#define STEPPER19_MSTEP_MODE_1_32 32
140#define STEPPER19_MSTEP_MODE_1_64 64
141#define STEPPER19_MSTEP_MODE_1_128 128
142#define STEPPER19_MSTEP_MODE_1_256 256
148#define STEPPER19_DECAY_MODE_DYN 0
149#define STEPPER19_DECAY_MODE_XRP 1
150#define STEPPER19_DECAY_MODE_F_30 2
151#define STEPPER19_DECAY_MODE_SLW 3
157#define STEPPER19_TOFF_7US 0
158#define STEPPER19_TOFF_16US 1
164#define STEPPER19_STEP_DELAY_DEF_100US 2ul
170#define STEPPER19_FULL_STEP 1.0f
171#define STEPPER19_STEP_SPEED_MIN 1
172#define STEPPER19_STEP_SPEED_MAX 100
173#define STEPPER19_ANGLE_360_DEGREES 360.0f
179#define STEPPER19_FULL_CIRCLE 360.0
180#define STEPPER19_RESOLUTION 4096.0
181#define STEPPER19_VREF 3330.0
188#define STEPPER19_DEVICE_ADDRESS_0 0x70
189#define STEPPER19_DEVICE_ADDRESS_1 0x72
190#define STEPPER19_DEVICE_ADDRESS_2 0x74
191#define STEPPER19_DEVICE_ADDRESS_3 0x76
209#define STEPPER19_MAP_MIKROBUS( cfg, mikrobus ) \
210 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
211 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
212 cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
213 cfg.dir = MIKROBUS( mikrobus, MIKROBUS_AN ); \
214 cfg.stp = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
215 cfg.flt = MIKROBUS( mikrobus, MIKROBUS_INT )
err_t stepper19_port_exp_write(stepper19_t *ctx, uint8_t reg, uint8_t data_in)
Stepper 19 port expander data writing function.
void stepper19_cfg_setup(stepper19_cfg_t *cfg)
Stepper 19 configuration object setup function.
void stepper19_disable_device(stepper19_t *ctx)
Stepper 19 disable device function.
err_t stepper19_init(stepper19_t *ctx, stepper19_cfg_t *cfg)
Stepper 19 initialization function.
err_t stepper19_rotate_by_step(stepper19_t *ctx, uint8_t step_speed, uint16_t steps)
Stepper 19 rotates the shaft through a desired step function.
void stepper19_enable_device(stepper19_t *ctx)
Stepper 19 enable device function.
uint8_t stepper19_fault_indication(stepper19_t *ctx)
Stepper 19 fault indication function.
err_t stepper19_port_exp_read(stepper19_t *ctx, uint8_t reg, uint8_t *data_out)
Stepper 19 port expander data reading function.
err_t stepper19_set_step(stepper19_t *ctx, uint8_t step)
Stepper 19 sets the step function.
err_t stepper19_rotate_by_angle(stepper19_t *ctx, uint8_t step_speed, float angle, uint16_t res_360)
Stepper 19 rotates the shaft through a desired angle function.
err_t stepper19_set_direction(stepper19_t *ctx, uint8_t dir)
Stepper 19 sets the direction function.
err_t stepper19_make_one_step(stepper19_t *ctx, uint8_t step_speed)
Stepper 19 make the one step function.
err_t stepper19_set_microstep_mode(stepper19_t *ctx, uint8_t ms_mode)
Stepper 19 sets the microstepping mode function.
err_t stepper19_generic_read(stepper19_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Stepper 19 I2C reading function.
err_t stepper19_set_pins(stepper19_t *ctx, uint8_t set_mask, uint8_t clr_mask)
Stepper 19 sets the pin states function.
err_t stepper19_set_toff(stepper19_t *ctx, uint8_t toff)
Stepper 19 set toff function.
err_t stepper19_generic_write(stepper19_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Stepper 19 I2C writing function.
err_t stepper19_set_decay_mode(stepper19_t *ctx, uint8_t decay_mode)
Stepper 19 sets the decay mode function.
err_t stepper19_default_cfg(stepper19_t *ctx)
Stepper 19 default configuration function.
stepper19_return_value_t
Stepper 19 Click return value data.
Definition stepper19.h:271
@ STEPPER19_OK
Definition stepper19.h:272
@ STEPPER19_ERROR
Definition stepper19.h:273
Stepper 19 Click configuration object.
Definition stepper19.h:252
pin_name_t stp
Definition stepper19.h:258
uint32_t i2c_speed
Definition stepper19.h:261
pin_name_t flt
Definition stepper19.h:259
pin_name_t dir
Definition stepper19.h:257
pin_name_t scl
Definition stepper19.h:253
pin_name_t en
Definition stepper19.h:256
pin_name_t sda
Definition stepper19.h:254
uint8_t i2c_address
Definition stepper19.h:262
Stepper 19 Click context object.
Definition stepper19.h:225
uint8_t step_dir_mode
Definition stepper19.h:243
digital_in_t flt
Definition stepper19.h:232
digital_out_t stp
Definition stepper19.h:229
i2c_master_t i2c
Definition stepper19.h:235
float microstep_mode
Definition stepper19.h:242
digital_out_t en
Definition stepper19.h:227
float step_delay
Definition stepper19.h:241
uint8_t slave_address
Definition stepper19.h:238
digital_out_t dir
Definition stepper19.h:228