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 STEPPER6_PCA9538A_REG_INPUT 0x00
76#define STEPPER6_PCA9538A_REG_OUTPUT 0x01
77#define STEPPER6_PCA9538A_REG_POLARITY 0x02
78#define STEPPER6_PCA9538A_REG_CONFIG 0x03
96#define STEPPER6_PIN_TRQ 0x01
97#define STEPPER6_PIN_M1 0x02
98#define STEPPER6_PIN_M0 0x04
99#define STEPPER6_PIN_SLEEP 0x08
100#define STEPPER6_PIN_FAULT 0x10
106#define STEPPER6_PCA9538A_DEFAULT_CONFIG 0xF0
112#define STEPPER6_DIR_CW 0
113#define STEPPER6_DIR_CCW 1
119#define STEPPER6_PIN_STATE_LOW 0
120#define STEPPER6_PIN_STATE_HIGH 1
121#define STEPPER6_PIN_STATE_OPEN 2
127#define STEPPER6_SPEED_VERY_SLOW 0
128#define STEPPER6_SPEED_SLOW 1
129#define STEPPER6_SPEED_MEDIUM 2
130#define STEPPER6_SPEED_FAST 3
131#define STEPPER6_SPEED_VERY_FAST 4
137#define STEPPER6_MODE_FULL_STEP 0
138#define STEPPER6_MODE_1_OVER_16 1
139#define STEPPER6_MODE_HALF_STEP 2
140#define STEPPER6_MODE_QUARTER_STEP 3
141#define STEPPER6_MODE_1_OVER_8 4
142#define STEPPER6_MODE_HALF_NON_CIRC_STEP 5
148#define STEPPER6_DAC_DEFAULT_CONFIG 0x7FFFu
155#define STEPPER6_DEVICE_ADDRESS_A1A0_00 0x70
156#define STEPPER6_DEVICE_ADDRESS_A1A0_01 0x71
157#define STEPPER6_DEVICE_ADDRESS_A1A0_10 0x72
158#define STEPPER6_DEVICE_ADDRESS_A1A0_11 0x73
168#define STEPPER6_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
169#define STEPPER6_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
187#define STEPPER6_MAP_MIKROBUS( cfg, mikrobus ) \
188 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
189 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
190 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
191 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
192 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
193 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
194 cfg.step = MIKROBUS( mikrobus, MIKROBUS_AN ); \
195 cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST ); \
196 cfg.dir = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
197 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_INT )
void stepper6_reset_pca(stepper6_t *ctx)
Stepper 6 reset device function.
err_t stepper6_set_step_mode(stepper6_t *ctx, uint8_t mode)
Stepper 6 set step mode function.
err_t stepper6_set_sleep_pin(stepper6_t *ctx, uint8_t state)
Stepper 6 set sleep pin function.
err_t stepper6_get_trq_pin(stepper6_t *ctx, uint8_t *state)
Stepper 6 get trq pin function.
err_t stepper6_set_trq_pin(stepper6_t *ctx, uint8_t state)
Stepper 6 set trq pin function.
err_t stepper6_get_m0_pin(stepper6_t *ctx, uint8_t *state)
Stepper 6 get M0 pin function.
err_t stepper6_set_dac(stepper6_t *ctx, uint16_t dac_cmd)
Stepper 6 set dac function.
err_t stepper6_set_m1_pin(stepper6_t *ctx, uint8_t state)
Stepper 6 set M1 pin function.
err_t stepper6_get_fault_pin(stepper6_t *ctx, uint8_t *state)
Stepper 6 get fault pin function.
err_t stepper6_pca_write_reg(stepper6_t *ctx, uint8_t reg, uint8_t data_in)
Stepper 6 pca write reg function.
err_t stepper6_get_sleep_pin(stepper6_t *ctx, uint8_t *state)
Stepper 6 get sleep pin function.
err_t stepper6_init(stepper6_t *ctx, stepper6_cfg_t *cfg)
Stepper 6 initialization function.
void stepper6_cfg_setup(stepper6_cfg_t *cfg)
Stepper 6 configuration object setup function.
void stepper6_switch_direction(stepper6_t *ctx)
Stepper 6 switch direction function.
void stepper6_set_step_pin(stepper6_t *ctx, uint8_t state)
Stepper 6 set step pin function.
err_t stepper6_get_m1_pin(stepper6_t *ctx, uint8_t *state)
Stepper 6 get M1 pin function.
err_t stepper6_default_cfg(stepper6_t *ctx)
Stepper 6 default configuration function.
void stepper6_enable_device(stepper6_t *ctx)
Stepper 6 enable device function.
err_t stepper6_set_m0_pin(stepper6_t *ctx, uint8_t state)
Stepper 6 set M0 pin function.
void stepper6_disable_device(stepper6_t *ctx)
Stepper 6 disable device function.
void stepper6_set_direction(stepper6_t *ctx, uint8_t dir)
Stepper 6 set direction function.
err_t stepper6_pca_read_reg(stepper6_t *ctx, uint8_t reg, uint8_t *data_out)
Stepper 6 pca read reg function.
err_t stepper6_get_step_mode(stepper6_t *ctx, uint8_t *mode)
Stepper 6 get step mode function.
void stepper6_drive_motor(stepper6_t *ctx, uint32_t steps, uint8_t speed)
Stepper 6 driver motor function.
void stepper6_set_rst_pin(stepper6_t *ctx, uint8_t state)
Stepper 6 set rst pin function.
This file contains SPI specific macros, functions, etc.
struct stepper6_s stepper6_t
Stepper 6 Click context object.
stepper6_return_value_t
Stepper 6 Click return value data.
Definition stepper6.h:252
@ STEPPER6_ERROR
Definition stepper6.h:254
@ STEPPER6_OK
Definition stepper6.h:253
Stepper 6 Click configuration object.
Definition stepper6.h:226
pin_name_t step
Definition stepper6.h:233
uint32_t i2c_speed
Definition stepper6.h:238
spi_master_chip_select_polarity_t cs_polarity
Definition stepper6.h:243
pin_name_t sck
Definition stepper6.h:231
spi_master_mode_t spi_mode
Definition stepper6.h:242
pin_name_t mosi
Definition stepper6.h:230
uint32_t spi_speed
Definition stepper6.h:241
pin_name_t dir
Definition stepper6.h:235
pin_name_t scl
Definition stepper6.h:227
pin_name_t en
Definition stepper6.h:234
pin_name_t miso
Definition stepper6.h:229
pin_name_t sda
Definition stepper6.h:228
pin_name_t rst
Definition stepper6.h:236
pin_name_t cs
Definition stepper6.h:232
uint8_t i2c_address
Definition stepper6.h:239
Stepper 6 Click context object.
Definition stepper6.h:207
spi_master_t spi
Definition stepper6.h:214
digital_out_t step
Definition stepper6.h:208
i2c_master_t i2c
Definition stepper6.h:213
digital_out_t en
Definition stepper6.h:209
digital_out_t rst
Definition stepper6.h:211
uint8_t slave_address
Definition stepper6.h:216
pin_name_t chip_select
Definition stepper6.h:217
digital_out_t dir
Definition stepper6.h:210