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 STEPPER17_REG_INPUT_0 0x00
74#define STEPPER17_REG_INPUT_1 0x01
75#define STEPPER17_REG_OUTPUT_0 0x02
76#define STEPPER17_REG_OUTPUT_1 0x03
77#define STEPPER17_REG_POLARITY_0 0x04
78#define STEPPER17_REG_POLARITY_1 0x05
79#define STEPPER17_REG_CONFIG_0 0x06
80#define STEPPER17_REG_CONFIG_1 0x07
98#define STEPPER17_P0_DMODE0_PIN 0x01
99#define STEPPER17_P0_DMODE1_PIN 0x02
100#define STEPPER17_P0_DMODE2_PIN 0x04
101#define STEPPER17_P0_DECAY1_PIN 0x08
102#define STEPPER17_P0_DECAY2_PIN 0x10
103#define STEPPER17_P0_TRQ0_PIN 0x20
104#define STEPPER17_P0_TRQ1_PIN 0x40
105#define STEPPER17_P0_SLEEP_X_PIN 0x80
106#define STEPPER17_P1_LO1_PIN 0x01
107#define STEPPER17_P1_LO2_PIN 0x02
108#define STEPPER17_P1_MO_PIN 0x04
114#define STEPPER17_P0_DEFAULT_CONFIG 0x00
115#define STEPPER17_P1_DEFAULT_CONFIG 0xFF
121#define STEPPER17_DIR_CW 1
122#define STEPPER17_DIR_CCW 0
128#define STEPPER17_PIN_LOW_LEVEL 0
129#define STEPPER17_PIN_HIGH_LEVEL 1
135#define STEPPER17_MODE_FULL_STEP 0x00
136#define STEPPER17_MODE_1_OVER_8 0x01
137#define STEPPER17_MODE_HALF_STEP_TYPE_B 0x02
138#define STEPPER17_MODE_1_OVER_32 0x03
139#define STEPPER17_MODE_HALF_STEP_TYPE_A 0x04
140#define STEPPER17_MODE_1_OVER_16 0x05
141#define STEPPER17_MODE_QUARTER_STEP 0x06
142#define STEPPER17_MODE_MASK 0x07
148#define STEPPER17_TORQUE_100_PCT 0x00
149#define STEPPER17_TORQUE_75_PCT 0x01
150#define STEPPER17_TORQUE_50_PCT 0x02
151#define STEPPER17_TORQUE_25_PCT 0x03
152#define STEPPER17_TORQUE_MASK 0x03
158#define STEPPER17_DECAY_MIXED 0x00
159#define STEPPER17_DECAY_SLOW 0x01
160#define STEPPER17_DECAY_FAST 0x02
161#define STEPPER17_DECAY_ADMD 0x03
162#define STEPPER17_DECAY_MASK 0x03
168#define STEPPER17_SPEED_VERY_SLOW 0
169#define STEPPER17_SPEED_SLOW 1
170#define STEPPER17_SPEED_MEDIUM 2
171#define STEPPER17_SPEED_FAST 3
172#define STEPPER17_SPEED_VERY_FAST 4
179#define STEPPER17_DEVICE_ADDRESS_A2A1A0_000 0x20
180#define STEPPER17_DEVICE_ADDRESS_A2A1A0_001 0x21
181#define STEPPER17_DEVICE_ADDRESS_A2A1A0_010 0x22
182#define STEPPER17_DEVICE_ADDRESS_A2A1A0_011 0x23
183#define STEPPER17_DEVICE_ADDRESS_A2A1A0_100 0x24
184#define STEPPER17_DEVICE_ADDRESS_A2A1A0_101 0x25
185#define STEPPER17_DEVICE_ADDRESS_A2A1A0_110 0x26
186#define STEPPER17_DEVICE_ADDRESS_A2A1A0_111 0x27
204#define STEPPER17_MAP_MIKROBUS( cfg, mikrobus ) \
205 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
206 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
207 cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
208 cfg.dir = MIKROBUS( mikrobus, MIKROBUS_AN ); \
209 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
210 cfg.clk = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
211 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
err_t stepper17_default_cfg(stepper17_t *ctx)
Stepper 17 default configuration function.
err_t stepper17_set_decay(stepper17_t *ctx, uint8_t decay)
Stepper 17 set decay function.
err_t stepper17_get_lo2_pin(stepper17_t *ctx, uint8_t *state)
Stepper 17 get lo2 pin function.
err_t stepper17_get_sleep_x_pin(stepper17_t *ctx, uint8_t *state)
Stepper 17 get sleep x pin function.
void stepper17_cfg_setup(stepper17_cfg_t *cfg)
Stepper 17 configuration object setup function.
err_t stepper17_init(stepper17_t *ctx, stepper17_cfg_t *cfg)
Stepper 17 initialization function.
err_t stepper17_set_step_mode(stepper17_t *ctx, uint8_t mode)
Stepper 17 set step mode function.
err_t stepper17_get_torque(stepper17_t *ctx, uint8_t *torque)
Stepper 17 get torque function.
void stepper17_set_direction(stepper17_t *ctx, uint8_t dir)
Stepper 17 set direction function.
err_t stepper17_get_mo_pin(stepper17_t *ctx, uint8_t *state)
Stepper 17 get mo pin function.
err_t stepper17_get_lo1_pin(stepper17_t *ctx, uint8_t *state)
Stepper 17 get lo1 pin function.
err_t stepper17_read_register(stepper17_t *ctx, uint8_t reg, uint8_t *data_out)
Stepper 17 read register function.
err_t stepper17_get_decay(stepper17_t *ctx, uint8_t *decay)
Stepper 17 get decay function.
void stepper17_reset_device(stepper17_t *ctx)
Stepper 17 reset device function.
void stepper17_switch_direction(stepper17_t *ctx)
Stepper 17 switch direction function.
void stepper17_disable_device(stepper17_t *ctx)
Stepper 17 disable device function.
err_t stepper17_set_torque(stepper17_t *ctx, uint8_t torque)
Stepper 17 set torque function.
err_t stepper17_get_step_mode(stepper17_t *ctx, uint8_t *mode)
Stepper 17 get step mode function.
void stepper17_drive_motor(stepper17_t *ctx, uint32_t steps, uint8_t speed)
Stepper 17 driver motor function.
void stepper17_enable_device(stepper17_t *ctx)
Stepper 17 enable device function.
err_t stepper17_set_sleep_x_pin(stepper17_t *ctx, uint8_t state)
Stepper 17 set sleep x pin function.
void stepper17_set_clk_pin(stepper17_t *ctx, uint8_t state)
Stepper 17 set clk pin function.
uint8_t stepper17_get_int_pin(stepper17_t *ctx)
Stepper 17 get int pin function.
err_t stepper17_write_register(stepper17_t *ctx, uint8_t reg, uint8_t data_in)
Stepper 17 write register function.
stepper17_return_value_t
Stepper 17 Click return value data.
Definition stepper17.h:264
@ STEPPER17_OK
Definition stepper17.h:265
@ STEPPER17_ERROR
Definition stepper17.h:266
Stepper 17 Click configuration object.
Definition stepper17.h:244
pin_name_t clk
Definition stepper17.h:251
uint32_t i2c_speed
Definition stepper17.h:254
pin_name_t dir
Definition stepper17.h:249
pin_name_t scl
Definition stepper17.h:245
pin_name_t en
Definition stepper17.h:248
pin_name_t int_pin
Definition stepper17.h:252
pin_name_t sda
Definition stepper17.h:246
pin_name_t rst
Definition stepper17.h:250
uint8_t i2c_address
Definition stepper17.h:255
Stepper 17 Click context object.
Definition stepper17.h:221
digital_in_t int_pin
Definition stepper17.h:229
i2c_master_t i2c
Definition stepper17.h:232
digital_out_t clk
Definition stepper17.h:226
digital_out_t en
Definition stepper17.h:223
digital_out_t rst
Definition stepper17.h:225
uint8_t slave_address
Definition stepper17.h:235
digital_out_t dir
Definition stepper17.h:224