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 STEPPER21_REG_INPUT 0x00
74#define STEPPER21_REG_OUTPUT 0x01
75#define STEPPER21_REG_POLARITY 0x02
76#define STEPPER21_REG_CONFIG 0x03
94#define STEPPER21_PIN_SLEEP 0x01
95#define STEPPER21_PIN_FAULT 0x02
96#define STEPPER21_PIN_DECAY 0x04
97#define STEPPER21_PIN_ENABLE 0x08
98#define STEPPER21_PIN_HOME 0x10
99#define STEPPER21_PIN_MODE0 0x20
100#define STEPPER21_PIN_MODE1 0x40
101#define STEPPER21_PIN_MODE2 0x80
107#define STEPPER21_DEFAULT_CONFIG 0x16
113#define STEPPER21_DIR_CCW 0
114#define STEPPER21_DIR_CW 1
120#define STEPPER21_PIN_STATE_LOW 0
121#define STEPPER21_PIN_STATE_HIGH 1
122#define STEPPER21_PIN_STATE_OPEN 2
128#define STEPPER21_MODE_FULL_STEP 0x00
129#define STEPPER21_MODE_HALF_STEP 0x01
130#define STEPPER21_MODE_QUARTER_STEP 0x02
131#define STEPPER21_MODE_1_OVER_8 0x03
132#define STEPPER21_MODE_1_OVER_16 0x04
133#define STEPPER21_MODE_1_OVER_32 0x05
134#define STEPPER21_MODE_MASK 0x07
140#define STEPPER21_SPEED_VERY_SLOW 0
141#define STEPPER21_SPEED_SLOW 1
142#define STEPPER21_SPEED_MEDIUM 2
143#define STEPPER21_SPEED_FAST 3
144#define STEPPER21_SPEED_VERY_FAST 4
151#define STEPPER21_DEVICE_ADDRESS_A1A0_00 0x70
152#define STEPPER21_DEVICE_ADDRESS_A1A0_01 0x71
153#define STEPPER21_DEVICE_ADDRESS_A1A0_10 0x72
154#define STEPPER21_DEVICE_ADDRESS_A1A0_11 0x73
172#define STEPPER21_MAP_MIKROBUS( cfg, mikrobus ) \
173 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
174 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
175 cfg.dir = MIKROBUS( mikrobus, MIKROBUS_AN ); \
176 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
177 cfg.step = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
178 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
err_t stepper21_default_cfg(stepper21_t *ctx)
Stepper 21 default configuration function.
void stepper21_set_direction(stepper21_t *ctx, uint8_t dir)
Stepper 21 set direction function.
err_t stepper21_set_sleep_pin(stepper21_t *ctx, uint8_t state)
Stepper 21 set sleep pin function.
err_t stepper21_get_step_mode(stepper21_t *ctx, uint8_t *mode)
Stepper 21 get step mode function.
err_t stepper21_get_decay_pin(stepper21_t *ctx, uint8_t *state)
Stepper 21 get decay pin function.
err_t stepper21_get_sleep_pin(stepper21_t *ctx, uint8_t *state)
Stepper 21 get sleep pin function.
void stepper21_set_rst_pin(stepper21_t *ctx, uint8_t state)
Stepper 21 set rst pin function.
void stepper21_set_step_pin(stepper21_t *ctx, uint8_t state)
Stepper 21 set step pin function.
uint8_t stepper21_get_int_pin(stepper21_t *ctx)
Stepper 21 get int pin function.
err_t stepper21_set_decay_pin(stepper21_t *ctx, uint8_t state)
Stepper 21 set decay pin function.
void stepper21_switch_direction(stepper21_t *ctx)
Stepper 21 switch direction function.
err_t stepper21_set_enable_pin(stepper21_t *ctx, uint8_t state)
Stepper 21 set enable pin function.
void stepper21_cfg_setup(stepper21_cfg_t *cfg)
Stepper 21 configuration object setup function.
err_t stepper21_init(stepper21_t *ctx, stepper21_cfg_t *cfg)
Stepper 21 initialization function.
err_t stepper21_enable_device(stepper21_t *ctx)
Stepper 21 enable device function.
void stepper21_reset_device(stepper21_t *ctx)
Stepper 21 reset device function.
err_t stepper21_write_register(stepper21_t *ctx, uint8_t reg, uint8_t data_in)
Stepper 21 write register function.
err_t stepper21_get_home_pin(stepper21_t *ctx, uint8_t *state)
Stepper 21 get home pin function.
err_t stepper21_set_step_mode(stepper21_t *ctx, uint8_t mode)
Stepper 21 set step mode function.
err_t stepper21_get_fault_pin(stepper21_t *ctx, uint8_t *state)
Stepper 21 get fault pin function.
void stepper21_drive_motor(stepper21_t *ctx, uint32_t steps, uint8_t speed)
Stepper 21 driver motor function.
err_t stepper21_disable_device(stepper21_t *ctx)
Stepper 21 disable device function.
err_t stepper21_read_register(stepper21_t *ctx, uint8_t reg, uint8_t *data_out)
Stepper 21 read register function.
err_t stepper21_get_enable_pin(stepper21_t *ctx, uint8_t *state)
Stepper 21 get enable pin function.
stepper21_return_value_t
Stepper 21 Click return value data.
Definition stepper21.h:229
@ STEPPER21_OK
Definition stepper21.h:230
@ STEPPER21_ERROR
Definition stepper21.h:231
Stepper 21 Click configuration object.
Definition stepper21.h:210
pin_name_t step
Definition stepper21.h:216
uint32_t i2c_speed
Definition stepper21.h:219
pin_name_t dir
Definition stepper21.h:214
pin_name_t scl
Definition stepper21.h:211
pin_name_t int_pin
Definition stepper21.h:217
pin_name_t sda
Definition stepper21.h:212
pin_name_t rst
Definition stepper21.h:215
uint8_t i2c_address
Definition stepper21.h:220
Stepper 21 Click context object.
Definition stepper21.h:188
digital_in_t int_pin
Definition stepper21.h:195
digital_out_t step
Definition stepper21.h:192
i2c_master_t i2c
Definition stepper21.h:198
digital_out_t rst
Definition stepper21.h:191
uint8_t slave_address
Definition stepper21.h:201
digital_out_t dir
Definition stepper21.h:190