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"
52#include "drv_spi_master.h"
75#define STEPPER10_TCA9534A_REG_INPUT 0x00
76#define STEPPER10_TCA9534A_REG_OUTPUT 0x01
77#define STEPPER10_TCA9534A_REG_POLARITY 0x02
78#define STEPPER10_TCA9534A_REG_CONFIG 0x03
96#define STEPPER10_PIN0_MS0 0x01
97#define STEPPER10_PIN0_MS1 0x02
98#define STEPPER10_PIN0_MS2 0x04
99#define STEPPER10_PIN0_MS_MASK 0x07
100#define STEPPER10_PIN0_SLEEP 0x08
101#define STEPPER10_PIN0_MDT0 0x10
102#define STEPPER10_PIN0_MDT1 0x20
103#define STEPPER10_PIN0_MDT_MASK 0x30
104#define STEPPER10_PIN0_AGC 0x40
105#define STEPPER10_PIN0_IF_SEL 0x80
106#define STEPPER10_PIN1_TORQUE0 0x01
107#define STEPPER10_PIN1_TORQUE1 0x02
108#define STEPPER10_PIN1_TORQUE2 0x04
109#define STEPPER10_PIN1_TORQUE_MASK 0x07
110#define STEPPER10_PIN1_CLIM0 0x08
111#define STEPPER10_PIN1_EDG_SEL 0x10
112#define STEPPER10_PIN1_MO 0x20
113#define STEPPER10_PIN1_LO0 0x40
114#define STEPPER10_PIN1_LO1 0x80
115#define STEPPER10_PIN1_LO_MASK 0xC0
121#define STEPPER10_TCA9534A_0_DEFAULT_CONFIG 0x00
122#define STEPPER10_TCA9534A_1_DEFAULT_CONFIG 0xE0
128#define STEPPER10_DIR_CW 0
129#define STEPPER10_DIR_CCW 1
135#define STEPPER10_PIN_STATE_LOW 0
136#define STEPPER10_PIN_STATE_HIGH 1
142#define STEPPER10_SPEED_VERY_SLOW 0
143#define STEPPER10_SPEED_SLOW 1
144#define STEPPER10_SPEED_MEDIUM 2
145#define STEPPER10_SPEED_FAST 3
146#define STEPPER10_SPEED_VERY_FAST 4
152#define STEPPER10_MODE_FULL_STEP 0
153#define STEPPER10_MODE_HALF_STEP 1
154#define STEPPER10_MODE_QUARTER_STEP 2
155#define STEPPER10_MODE_1_OVER_8 3
156#define STEPPER10_MODE_1_OVER_16 4
157#define STEPPER10_MODE_1_OVER_32 5
158#define STEPPER10_MODE_1_OVER_64 6
159#define STEPPER10_MODE_1_OVER_128 7
165#define STEPPER10_MIXED_DECAY_FAST_37_5 0
166#define STEPPER10_MIXED_DECAY_FAST_50 1
167#define STEPPER10_MIXED_DECAY_FAST_ONLY 2
168#define STEPPER10_MIXED_DECAY_ADMD 3
174#define STEPPER10_TORQUE_100 0
175#define STEPPER10_TORQUE_85 1
176#define STEPPER10_TORQUE_70 2
177#define STEPPER10_TORQUE_60 3
178#define STEPPER10_TORQUE_50 4
179#define STEPPER10_TORQUE_40 5
180#define STEPPER10_TORQUE_25 6
181#define STEPPER10_TORQUE_10 7
187#define STEPPER10_LO_THERMAL_SHUTDOWN 0
188#define STEPPER10_LO_MOTOR_LOAD_OPEN 1
189#define STEPPER10_LO_OVER_CURRENT 2
190#define STEPPER10_LO_NORMAL 3
197#define STEPPER10_DEVICE0_ADDRESS_A2A1_00 0x38
198#define STEPPER10_DEVICE0_ADDRESS_A2A1_01 0x3A
199#define STEPPER10_DEVICE0_ADDRESS_A2A1_10 0x3C
200#define STEPPER10_DEVICE0_ADDRESS_A2A1_11 0x3E
201#define STEPPER10_DEVICE1_ADDRESS_A2A1_00 0x39
202#define STEPPER10_DEVICE1_ADDRESS_A2A1_01 0x3B
203#define STEPPER10_DEVICE1_ADDRESS_A2A1_10 0x3D
204#define STEPPER10_DEVICE1_ADDRESS_A2A1_11 0x3F
214#define STEPPER10_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
215#define STEPPER10_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
233#define STEPPER10_MAP_MIKROBUS( cfg, mikrobus ) \
234 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
235 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
236 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
237 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
238 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
239 cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
240 cfg.dir = MIKROBUS( mikrobus, MIKROBUS_AN ); \
241 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
242 cfg.step = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
243 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
err_t stepper10_set_agc_pin(stepper10_t *ctx, uint8_t state)
Stepper 10 set agc pin function.
void stepper10_set_direction(stepper10_t *ctx, uint8_t dir)
Stepper 10 set direction function.
err_t stepper10_get_torque(stepper10_t *ctx, uint8_t *mode)
Stepper 10 get torque function.
err_t stepper10_tca_read_reg(stepper10_t *ctx, uint8_t reg, uint8_t *data_out)
Stepper 10 tca read reg function.
err_t stepper10_select_gpio(stepper10_t *ctx)
Stepper 10 select GPIO function.
err_t stepper10_get_edg_sel_pin(stepper10_t *ctx, uint8_t *state)
Stepper 10 get edg_sel pin function.
err_t stepper10_get_mixed_decay(stepper10_t *ctx, uint8_t *mode)
Stepper 10 get mixed decay function.
void stepper10_set_rst_pin(stepper10_t *ctx, uint8_t state)
Stepper 10 set rst pin function.
err_t stepper10_get_agc_pin(stepper10_t *ctx, uint8_t *state)
Stepper 10 get agc pin function.
err_t stepper10_get_step_mode(stepper10_t *ctx, uint8_t *mode)
Stepper 10 get step mode function.
err_t stepper10_get_lo_state(stepper10_t *ctx, uint8_t *state)
Stepper 10 get LO function.
err_t stepper10_set_edg_sel_pin(stepper10_t *ctx, uint8_t state)
Stepper 10 set edg_sel pin function.
err_t stepper10_set_torque(stepper10_t *ctx, uint8_t mode)
Stepper 10 set torque function.
void stepper10_cfg_setup(stepper10_cfg_t *cfg)
Stepper 10 configuration object setup function.
err_t stepper10_get_sleep_pin(stepper10_t *ctx, uint8_t *state)
Stepper 10 get sleep pin function.
void stepper10_enable_device(stepper10_t *ctx)
Stepper 10 enable device function.
err_t stepper10_get_clim0_pin(stepper10_t *ctx, uint8_t *state)
Stepper 10 get clim0 pin function.
err_t stepper10_set_clim0_pin(stepper10_t *ctx, uint8_t state)
Stepper 10 set clim0 pin function.
err_t stepper10_write_spi_bank0(stepper10_t *ctx, uint32_t data_in)
Stepper 10 write spi bank0 function.
uint8_t stepper10_get_int_pin(stepper10_t *ctx)
Stepper 10 get INT pin function.
err_t stepper10_write_spi_bank1(stepper10_t *ctx, uint32_t data_in)
Stepper 10 write spi bank1 function.
err_t stepper10_set_step_mode(stepper10_t *ctx, uint8_t mode)
Stepper 10 set step mode function.
err_t stepper10_drive_motor(stepper10_t *ctx, uint32_t steps, uint8_t speed)
Stepper 10 driver motor function.
err_t stepper10_tca_write_reg(stepper10_t *ctx, uint8_t reg, uint8_t data_in)
Stepper 10 tca write reg function.
void stepper10_disable_device(stepper10_t *ctx)
Stepper 10 disable device function.
err_t stepper10_select_spi(stepper10_t *ctx)
Stepper 10 select SPI function.
void stepper10_set_step_pin(stepper10_t *ctx, uint8_t state)
Stepper 10 set step pin function.
err_t stepper10_set_sleep_pin(stepper10_t *ctx, uint8_t state)
Stepper 10 set sleep pin function.
err_t stepper10_set_mixed_decay(stepper10_t *ctx, uint8_t mode)
Stepper 10 set mixed decay function.
err_t stepper10_init(stepper10_t *ctx, stepper10_cfg_t *cfg)
Stepper 10 initialization function.
err_t stepper10_default_cfg(stepper10_t *ctx)
Stepper 10 default configuration function.
err_t stepper10_get_mo_pin(stepper10_t *ctx, uint8_t *state)
Stepper 10 get mo pin function.
void stepper10_reset_device(stepper10_t *ctx)
Stepper 10 reset device function.
This file contains SPI specific macros, functions, etc.
stepper10_return_value_t
Stepper 10 Click return value data.
Definition stepper10.h:299
@ STEPPER10_ERROR
Definition stepper10.h:301
@ STEPPER10_OK
Definition stepper10.h:300
struct stepper10_s stepper10_t
Stepper 10 Click context object.
Stepper 10 Click configuration object.
Definition stepper10.h:274
pin_name_t step
Definition stepper10.h:283
uint32_t i2c_speed
Definition stepper10.h:286
pin_name_t sck
Definition stepper10.h:279
spi_master_mode_t spi_mode
Definition stepper10.h:290
pin_name_t mosi
Definition stepper10.h:278
uint32_t spi_speed
Definition stepper10.h:289
pin_name_t dir
Definition stepper10.h:281
pin_name_t scl
Definition stepper10.h:275
pin_name_t en
Definition stepper10.h:280
pin_name_t int_pin
Definition stepper10.h:284
pin_name_t miso
Definition stepper10.h:277
pin_name_t sda
Definition stepper10.h:276
pin_name_t rst
Definition stepper10.h:282
uint8_t i2c_address
Definition stepper10.h:287
Stepper 10 Click context object.
Definition stepper10.h:253
spi_master_t spi
Definition stepper10.h:262
digital_in_t int_pin
Definition stepper10.h:259
digital_out_t step
Definition stepper10.h:256
i2c_master_t i2c
Definition stepper10.h:261
digital_out_t en
Definition stepper10.h:257
digital_out_t rst
Definition stepper10.h:255
uint8_t slave_address
Definition stepper10.h:264
pin_name_t chip_select
Definition stepper10.h:265
digital_out_t dir
Definition stepper10.h:254