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_spi_master.h"
74#define STEPPER7_REG_IODIR 0x00
75#define STEPPER7_REG_IPOL 0x01
76#define STEPPER7_REG_GPINTEN 0x02
77#define STEPPER7_REG_DEFVAL 0x03
78#define STEPPER7_REG_INTCON 0x04
79#define STEPPER7_REG_IOCON 0x05
80#define STEPPER7_REG_GPPU 0x06
81#define STEPPER7_REG_INTF 0x07
82#define STEPPER7_REG_INTCAP 0x08
83#define STEPPER7_REG_GPIO 0x09
84#define STEPPER7_REG_OLAT 0x0A
102#define STEPPER7_PIN_PHASE2 0x80
103#define STEPPER7_PIN_PHASE1 0x40
104#define STEPPER7_PIN_I12 0x20
105#define STEPPER7_PIN_I02 0x10
106#define STEPPER7_PIN_I11 0x08
107#define STEPPER7_PIN_I01 0x04
113#define STEPPER7_IODIR_DEFAULT 0x03
114#define STEPPER7_IOCON_DEFAULT 0x38
115#define STEPPER7_GPIO_CLEAR 0x00
121#define STEPPER7_DIR_CW 0
122#define STEPPER7_DIR_CCW 1
128#define STEPPER7_PIN_LOW_LEVEL 0
129#define STEPPER7_PIN_HIGH_LEVEL 1
135#define STEPPER7_MODE_FULL_STEP 0
136#define STEPPER7_MODE_HALF_STEP 1
137#define STEPPER7_MODE_1_OVER_8_STEP 2
143#define STEPPER7_SPEED_VERY_SLOW 0
144#define STEPPER7_SPEED_SLOW 1
145#define STEPPER7_SPEED_MEDIUM 2
146#define STEPPER7_SPEED_FAST 3
147#define STEPPER7_SPEED_VERY_FAST 4
153#define STEPPER7_SPI_READ_OPCODE 0x41
154#define STEPPER7_SPI_WRITE_OPCODE 0x40
164#define STEPPER7_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
165#define STEPPER7_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
183#define STEPPER7_MAP_MIKROBUS( cfg, mikrobus ) \
184 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
185 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
186 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
187 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
188 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST );
err_t stepper7_init(stepper7_t *ctx, stepper7_cfg_t *cfg)
Stepper 7 initialization function.
err_t stepper7_set_i12_pin(stepper7_t *ctx, uint8_t state)
Stepper 7 set I12 pin function.
err_t stepper7_disable_device(stepper7_t *ctx)
Stepper 7 disable device function.
err_t stepper7_read_reg(stepper7_t *ctx, uint8_t reg, uint8_t *data_out)
Stepper 7 read reg function.
err_t stepper7_drive_motor(stepper7_t *ctx, uint32_t steps, uint8_t speed)
Stepper 7 driver motor function.
void stepper7_cfg_setup(stepper7_cfg_t *cfg)
Stepper 7 configuration object setup function.
err_t stepper7_write_reg(stepper7_t *ctx, uint8_t reg, uint8_t data_in)
Stepper 7 write reg function.
err_t stepper7_set_i02_pin(stepper7_t *ctx, uint8_t state)
Stepper 7 set I02 pin function.
err_t stepper7_enable_device(stepper7_t *ctx)
Stepper 7 enable device function.
void stepper7_set_direction(stepper7_t *ctx, uint8_t dir)
Stepper 7 set direction function.
err_t stepper7_default_cfg(stepper7_t *ctx)
Stepper 7 default configuration function.
err_t stepper7_set_i01_pin(stepper7_t *ctx, uint8_t state)
Stepper 7 set I01 pin function.
err_t stepper7_set_phase1_pin(stepper7_t *ctx, uint8_t state)
Stepper 7 set PHASE1 pin function.
void stepper7_switch_direction(stepper7_t *ctx)
Stepper 7 switch direction function.
err_t stepper7_set_phase2_pin(stepper7_t *ctx, uint8_t state)
Stepper 7 set PHASE2 pin function.
void stepper7_set_step_mode(stepper7_t *ctx, uint8_t mode)
Stepper 7 set step mode function.
err_t stepper7_set_i11_pin(stepper7_t *ctx, uint8_t state)
Stepper 7 set I11 pin function.
void stepper7_reset_device(stepper7_t *ctx)
Stepper 7 reset device function.
void stepper7_set_rst_pin(stepper7_t *ctx, uint8_t state)
Stepper 7 set rst pin function.
This file contains SPI specific macros, functions, etc.
stepper7_return_value_t
Stepper 7 Click return value data.
Definition stepper7.h:239
@ STEPPER7_OK
Definition stepper7.h:240
@ STEPPER7_ERROR
Definition stepper7.h:241
Stepper 7 Click configuration object.
Definition stepper7.h:217
spi_master_chip_select_polarity_t cs_polarity
Definition stepper7.h:230
pin_name_t sck
Definition stepper7.h:221
spi_master_mode_t spi_mode
Definition stepper7.h:229
pin_name_t mosi
Definition stepper7.h:220
uint32_t spi_speed
Definition stepper7.h:228
pin_name_t miso
Definition stepper7.h:219
pin_name_t rst
Definition stepper7.h:225
pin_name_t cs
Definition stepper7.h:222
Stepper 7 Click context object.
Definition stepper7.h:198
spi_master_t spi
Definition stepper7.h:203
uint8_t step_mode
Definition stepper7.h:207
digital_out_t rst
Definition stepper7.h:200
uint8_t direction
Definition stepper7.h:208
pin_name_t chip_select
Definition stepper7.h:205