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 STEPPER8_PCA9538A_REG_INPUT 0x00
76#define STEPPER8_PCA9538A_REG_OUTPUT 0x01
77#define STEPPER8_PCA9538A_REG_POLARITY 0x02
78#define STEPPER8_PCA9538A_REG_CONFIG 0x03
96#define STEPPER8_PIN_STBY 0x01
97#define STEPPER8_PIN_SELECT 0x02
98#define STEPPER8_PIN_EN 0x04
104#define STEPPER8_PCA9538A_DEFAULT_CONFIG 0xF8
110#define STEPPER8_DIR_CW 0
111#define STEPPER8_DIR_CCW 1
117#define STEPPER8_PIN_STATE_LOW 0
118#define STEPPER8_PIN_STATE_HIGH 1
124#define STEPPER8_SPEED_VERY_SLOW 0
125#define STEPPER8_SPEED_SLOW 1
126#define STEPPER8_SPEED_MEDIUM 2
127#define STEPPER8_SPEED_FAST 3
128#define STEPPER8_SPEED_VERY_FAST 4
134#define STEPPER8_MODE_FULL_STEP 0
135#define STEPPER8_MODE_HALF_STEP 1
136#define STEPPER8_MODE_QUARTER_STEP 2
137#define STEPPER8_MODE_1_OVER_8 3
138#define STEPPER8_MODE_1_OVER_16 4
139#define STEPPER8_MODE_1_OVER_32 5
140#define STEPPER8_MODE_1_OVER_64 6
141#define STEPPER8_MODE_1_OVER_128 7
148#define STEPPER8_DEVICE_ADDRESS_A1A0_00 0x70
149#define STEPPER8_DEVICE_ADDRESS_A1A0_01 0x71
150#define STEPPER8_DEVICE_ADDRESS_A1A0_10 0x72
151#define STEPPER8_DEVICE_ADDRESS_A1A0_11 0x73
161#define STEPPER8_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
162#define STEPPER8_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
180#define STEPPER8_MAP_MIKROBUS( cfg, mikrobus ) \
181 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
182 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
183 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
184 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
185 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
186 cfg.md1 = MIKROBUS( mikrobus, MIKROBUS_CS ); \
187 cfg.md3 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
188 cfg.md0 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
189 cfg.md2 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
190 cfg.err = MIKROBUS( mikrobus, MIKROBUS_INT )
err_t stepper8_pca_write_reg(stepper8_t *ctx, uint8_t reg, uint8_t data_in)
Stepper 8 pca write reg function.
uint8_t stepper8_get_err_pin(stepper8_t *ctx)
Stepper 8 get ERR pin function.
err_t stepper8_select_spi(stepper8_t *ctx)
Stepper 8 select SPI function.
void stepper8_cfg_setup(stepper8_cfg_t *cfg)
Stepper 8 configuration object setup function.
void stepper8_set_md2_pin(stepper8_t *ctx, uint8_t state)
Stepper 8 set MD2 pin function.
err_t stepper8_pca_read_reg(stepper8_t *ctx, uint8_t reg, uint8_t *data_out)
Stepper 8 pca read reg function.
void stepper8_set_md0_pin(stepper8_t *ctx, uint8_t state)
Stepper 8 set MD0 pin function.
void stepper8_set_direction(stepper8_t *ctx, uint8_t dir)
Stepper 8 set direction function.
err_t stepper8_set_step_mode(stepper8_t *ctx, uint8_t mode)
Stepper 8 set step mode function.
void stepper8_set_rst_pin(stepper8_t *ctx, uint8_t state)
Stepper 8 set rst pin function.
void stepper8_set_step_pin(stepper8_t *ctx, uint8_t state)
Stepper 8 set step pin function.
err_t stepper8_enable_device(stepper8_t *ctx)
Stepper 8 enable device function.
err_t stepper8_enable_standby(stepper8_t *ctx)
Stepper 8 enable standby function.
err_t stepper8_init(stepper8_t *ctx, stepper8_cfg_t *cfg)
Stepper 8 initialization function.
err_t stepper8_disable_standby(stepper8_t *ctx)
Stepper 8 disable standby function.
void stepper8_set_md1_pin(stepper8_t *ctx, uint8_t state)
Stepper 8 set MD1 pin function.
err_t stepper8_disable_device(stepper8_t *ctx)
Stepper 8 disable device function.
void stepper8_set_md3_pin(stepper8_t *ctx, uint8_t state)
Stepper 8 set MD3 pin function.
err_t stepper8_select_gpio(stepper8_t *ctx)
Stepper 8 select GPIO function.
err_t stepper8_drive_motor(stepper8_t *ctx, uint32_t steps, uint8_t speed)
Stepper 8 driver motor function.
err_t stepper8_default_cfg(stepper8_t *ctx)
Stepper 8 default configuration function.
err_t stepper8_write_spi(stepper8_t *ctx, uint32_t data_in)
Stepper 8 write spi function.
This file contains SPI specific macros, functions, etc.
stepper8_return_value_t
Stepper 8 Click return value data.
Definition stepper8.h:247
@ STEPPER8_OK
Definition stepper8.h:248
@ STEPPER8_ERROR
Definition stepper8.h:249
struct stepper8_s stepper8_t
Stepper 8 Click context object.
Stepper 8 Click configuration object.
Definition stepper8.h:222
pin_name_t md2
Definition stepper8.h:230
uint32_t i2c_speed
Definition stepper8.h:234
pin_name_t md1
Definition stepper8.h:229
pin_name_t sck
Definition stepper8.h:227
pin_name_t err
Definition stepper8.h:232
pin_name_t md3
Definition stepper8.h:231
spi_master_mode_t spi_mode
Definition stepper8.h:238
pin_name_t md0
Definition stepper8.h:228
pin_name_t mosi
Definition stepper8.h:226
uint32_t spi_speed
Definition stepper8.h:237
pin_name_t scl
Definition stepper8.h:223
pin_name_t miso
Definition stepper8.h:225
pin_name_t sda
Definition stepper8.h:224
uint8_t i2c_address
Definition stepper8.h:235
Stepper 8 Click context object.
Definition stepper8.h:200
digital_out_t md0
Definition stepper8.h:201
spi_master_t spi
Definition stepper8.h:209
digital_out_t md3
Definition stepper8.h:204
uint8_t dir
Definition stepper8.h:213
i2c_master_t i2c
Definition stepper8.h:208
uint8_t slave_address
Definition stepper8.h:211
digital_in_t err
Definition stepper8.h:206
digital_out_t md1
Definition stepper8.h:202
digital_out_t md2
Definition stepper8.h:203