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"
53#include "drv_i2c_master.h"
75#define DCMOTOR29_REG_DEVICE_ID 0x00
76#define DCMOTOR29_REG_FAULT_SUMMARY 0x01
77#define DCMOTOR29_REG_STATUS1 0x02
78#define DCMOTOR29_REG_STATUS2 0x03
79#define DCMOTOR29_REG_COMMAND 0x08
80#define DCMOTOR29_REG_SPI_IN 0x09
81#define DCMOTOR29_REG_CONFIG1 0x0A
82#define DCMOTOR29_REG_CONFIG2 0x0B
83#define DCMOTOR29_REG_CONFIG3 0x0C
84#define DCMOTOR29_REG_CONFIG4 0x0D
85#define DCMOTOR29_REG_INPUT_PORT 0x00
86#define DCMOTOR29_REG_OUTPUT_PORT 0x01
87#define DCMOTOR29_REG_POLARITY_INV 0x02
88#define DCMOTOR29_REG_CONFIG 0x03
106#define DCMOTOR29_CLR_FLT_CMD 0x80
107#define DCMOTOR29_SPI_IN_UNLOCK_CMD 0x10
108#define DCMOTOR29_SPI_IN_LOCK_CMD 0x08
109#define DCMOTOR29_REG_UNLOCK_CMD 0x01
110#define DCMOTOR29_REG_LOCK_CMD 0x02
117#define DCMOTOR29_NONE_PIN 0x00
118#define DCMOTOR29_IN2_PIN 0x01
119#define DCMOTOR29_DOF_PIN 0x02
120#define DCMOTOR29_FLT_PIN 0x04
121#define DCMOTOR29_ALL_PIN 0x07
128#define DCMOTOR29_READ_REG_MASK 0x40
135#define DCMOTOR29_DRVOFF_ON 0x01
136#define DCMOTOR29_DRVOFF_OFF 0x00
143#define DCMOTOR29_PIN_STATE_HIGH 0x01
144#define DCMOTOR29_PIN_STATE_LOW 0x00
151#define DCMOTOR29_S_EN_DEVOFF_MASK 0x08
152#define DCMOTOR29_S_EN_DEVOFF2_MASK 0x04
153#define DCMOTOR29_S_EN_IN1_MASK 0x02
154#define DCMOTOR29_S_EN_IN2_MASK 0x01
155#define DCMOTOR29_S_EN_NONE 0x00
162#define DCMOTOR29_EN_OLA 0x80
163#define DCMOTOR29_VMOV_SEL_DISABLED 0x60
164#define DCMOTOR29_VMOV_SEL_18V 0x40
165#define DCMOTOR29_VMOV_SEL_28V 0x20
166#define DCMOTOR29_VMOV_SEL_35V 0x00
167#define DCMOTOR29_SSC_DISABLE 0x10
168#define DCMOTOR29_OCP_RETRY 0x08
169#define DCMOTOR29_TSD_RETRY 0x04
170#define DCMOTOR29_VMOV_RETRY 0x02
171#define DCMOTOR29_OLA_RETRY 0x01
178#define DCMOTOR29_TOF_50_US 0xC0
179#define DCMOTOR29_TOF_40_US 0x80
180#define DCMOTOR29_TOF_30_US 0x40
181#define DCMOTOR29_TOF_20_US 0x00
182#define DCMOTOR29_S_SR_50_V_US 0x1C
183#define DCMOTOR29_S_SR_38_V_US 0x18
184#define DCMOTOR29_S_SR_26_V_US 0x14
185#define DCMOTOR29_S_SR_20_V_US 0x10
186#define DCMOTOR29_S_SR_14_V_US 0x0C
187#define DCMOTOR29_S_SR_9_8V_US 0x08
188#define DCMOTOR29_S_SR_5_V_US 0x04
189#define DCMOTOR29_S_SR_1_5V_US 0x00
190#define DCMOTOR29_S_MODE_PWM 0x03
191#define DCMOTOR29_S_MODE_INDEPENDENT 0x01
192#define DCMOTOR29_S_MODE_PH_EN 0x00
199#define DCMOTOR29_DRIVE_MOTOR_CW 0x00
200#define DCMOTOR29_DRIVE_MOTOR_CCW 0x01
201#define DCMOTOR29_DRIVE_MOTOR_BRAKE 0x02
202#define DCMOTOR29_DRIVE_MOTOR_COASTING 0x03
209#define DCMOTOR29_DEVICE_ADDRESS_A1A0_00 0x70
210#define DCMOTOR29_DEVICE_ADDRESS_A1A0_01 0x71
211#define DCMOTOR29_DEVICE_ADDRESS_A1A0_10 0x72
212#define DCMOTOR29_DEVICE_ADDRESS_A1A0_11 0x73
222#define DCMOTOR29_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
223#define DCMOTOR29_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
241#define DCMOTOR29_MAP_MIKROBUS( cfg, mikrobus ) \
242 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
243 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
244 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
245 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
246 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
247 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
248 cfg.ip = MIKROBUS( mikrobus, MIKROBUS_AN ); \
249 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
250 cfg.in1 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
251 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
dcmotor29_return_value_t
DC Motor 29 Click return value data.
Definition dcmotor29.h:315
@ DCMOTOR29_OK
Definition dcmotor29.h:316
@ DCMOTOR29_ERROR
Definition dcmotor29.h:317
err_t dcmotor29_drive_motor(dcmotor29_t *ctx, uint8_t state)
DC Motor 29 drive motor function.
err_t dcmotor29_register_write(dcmotor29_t *ctx, uint8_t reg, uint8_t data_in)
DC Motor 29 data register writing function.
void dcmotor29_cfg_setup(dcmotor29_cfg_t *cfg)
DC Motor 29 configuration object setup function.
err_t dcmotor29_drvoff_state(dcmotor29_t *ctx, uint8_t drvoff_state)
DC Motor 29 control drvoff function.
uint8_t dcmotor29_get_ip_pin(dcmotor29_t *ctx)
DC Motor 29 get IP pin function.
err_t dcmotor29_port_expander_read(dcmotor29_t *ctx, uint8_t reg, uint8_t *data_out)
DC Motor 29 port ecpander read register function.
void dcmotor29_set_in1_pin(dcmotor29_t *ctx, uint8_t pin_state)
DC Motor 29 set IN1 pin function.
err_t dcmotor29_generic_write(dcmotor29_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
DC Motor 29 data writing function.
err_t dcmotor29_default_cfg(dcmotor29_t *ctx)
DC Motor 29 default configuration function.
err_t dcmotor29_set_pins(dcmotor29_t *ctx, uint8_t set_mask, uint8_t clr_mask)
DC Motor 29 set pins function.
err_t dcmotor29_generic_read(dcmotor29_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
DC Motor 29 data reading function.
uint8_t dcmotor29_get_int_pin(dcmotor29_t *ctx)
DC Motor 29 get INT pin function.
void dcmotor29_set_rst_pin(dcmotor29_t *ctx, uint8_t pin_state)
DC Motor 29 set RST pin function.
err_t dcmotor29_port_expander_write(dcmotor29_t *ctx, uint8_t reg, uint8_t data_in)
DC Motor 29 port ecpander write register function.
err_t dcmotor29_init(dcmotor29_t *ctx, dcmotor29_cfg_t *cfg)
DC Motor 29 initialization function.
err_t dcmotor29_register_read(dcmotor29_t *ctx, uint8_t reg, uint8_t *data_out)
DC Motor 29 data register reading function.
This file contains SPI specific macros, functions, etc.
DC Motor 29 Click configuration object.
Definition dcmotor29.h:286
uint32_t i2c_speed
Definition dcmotor29.h:305
pin_name_t ip
Definition dcmotor29.h:296
spi_master_chip_select_polarity_t cs_polarity
Definition dcmotor29.h:304
pin_name_t sck
Definition dcmotor29.h:290
spi_master_mode_t spi_mode
Definition dcmotor29.h:303
pin_name_t mosi
Definition dcmotor29.h:289
uint32_t spi_speed
Definition dcmotor29.h:302
pin_name_t scl
Definition dcmotor29.h:292
pin_name_t in1
Definition dcmotor29.h:298
pin_name_t int_pin
Definition dcmotor29.h:299
pin_name_t miso
Definition dcmotor29.h:288
pin_name_t sda
Definition dcmotor29.h:293
pin_name_t rst
Definition dcmotor29.h:297
pin_name_t cs
Definition dcmotor29.h:291
uint8_t i2c_address
Definition dcmotor29.h:306
DC Motor 29 Click context object.
Definition dcmotor29.h:261
spi_master_t spi
Definition dcmotor29.h:271
digital_in_t int_pin
Definition dcmotor29.h:268
i2c_master_t i2c
Definition dcmotor29.h:272
digital_in_t ip
Definition dcmotor29.h:267
digital_out_t rst
Definition dcmotor29.h:263
uint8_t slave_address
Definition dcmotor29.h:275
pin_name_t chip_select
Definition dcmotor29.h:277
digital_out_t in1
Definition dcmotor29.h:264