Go to the documentation of this file.
35 #include "mikrosdk_version.h"
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_spi_master.h"
49 #include "drv_i2c_master.h"
50 #include "drv_analog_in.h"
72 #define DCMOTOR26_REG_STATUS1 0x01
73 #define DCMOTOR26_REG_STATUS2 0x02
74 #define DCMOTOR26_REG_STATUS3 0x03
75 #define DCMOTOR26_REG_CONFIG1 0x04
76 #define DCMOTOR26_REG_CONFIG2 0x05
77 #define DCMOTOR26_REG_CONFIG3 0x06
78 #define DCMOTOR26_REG_CONFIG4 0x07
79 #define DCMOTOR26_REG_CONFIG5 0x08
80 #define DCMOTOR26_REG_CONFIG6 0x09
81 #define DCMOTOR26_REG_CONFIG7 0x0A
87 #define DCMOTOR26_REG_INPUT 0x00
88 #define DCMOTOR26_REG_OUTPUT 0x01
89 #define DCMOTOR26_REG_POLARITY 0x02
90 #define DCMOTOR26_REG_CONFIG 0x03
108 #define DCMOTOR26_CONFIG12_OPEN_LOAD_NOP_100US 0x000000ul
109 #define DCMOTOR26_CONFIG12_OPEN_LOAD_NOP_50US 0x002000ul
110 #define DCMOTOR26_CONFIG12_OPEN_LOAD_NOP_500US 0x004000ul
111 #define DCMOTOR26_CONFIG12_OPEN_LOAD_NOP_MASK 0x006000ul
112 #define DCMOTOR26_CONFIG12_DUTY_OFF_LOW_SIDE 0x000000ul
113 #define DCMOTOR26_CONFIG12_DUTY_OFF_HIGH_SIDE 0x001000ul
114 #define DCMOTOR26_CONFIG12_DUTY_OFF_MASK 0x001000ul
115 #define DCMOTOR26_CONFIG12_VBAT_UVC_0US 0x000000ul
116 #define DCMOTOR26_CONFIG12_VBAT_UVC_100US 0x000800ul
117 #define DCMOTOR26_CONFIG12_VBAT_UVC_MASK 0x000800ul
118 #define DCMOTOR26_CONFIG12_CLIMIT_UP_6p5A 0x000000ul
119 #define DCMOTOR26_CONFIG12_CLIMIT_UP_4p6A 0x000400ul
120 #define DCMOTOR26_CONFIG12_CLIMIT_UP_MASK 0x000400ul
121 #define DCMOTOR26_CONFIG12_CLIMIT_LOW_0p25A 0x000000ul
122 #define DCMOTOR26_CONFIG12_CLIMIT_LOW_0p5A 0x000200ul
123 #define DCMOTOR26_CONFIG12_CLIMIT_LOW_MASK 0x000200ul
124 #define DCMOTOR26_CONFIG12_CLIMIT_LOW_0p25A 0x000000ul
125 #define DCMOTOR26_CONFIG12_CLIMIT_LOW_0p5A 0x000200ul
126 #define DCMOTOR26_CONFIG12_OPEN_LOAD_OP_200mA 0x000000ul
127 #define DCMOTOR26_CONFIG12_OPEN_LOAD_OP_100mA 0x000080ul
128 #define DCMOTOR26_CONFIG12_OPEN_LOAD_OP_300mA 0x000100ul
129 #define DCMOTOR26_CONFIG12_OPEN_LOAD_OP_MASK 0x000180ul
130 #define DCMOTOR26_CONFIG12_SR_MODE_NORMAL 0x000000ul
131 #define DCMOTOR26_CONFIG12_SR_MODE_SLOW1 0x000010ul
132 #define DCMOTOR26_CONFIG12_SR_MODE_SLOW2 0x000020ul
133 #define DCMOTOR26_CONFIG12_SR_MODE_SLOW3 0x000030ul
134 #define DCMOTOR26_CONFIG12_SR_MODE_SLOW4 0x000040ul
135 #define DCMOTOR26_CONFIG12_SR_MODE_FAST2 0x000050ul
136 #define DCMOTOR26_CONFIG12_SR_MODE_FAST1 0x000060ul
137 #define DCMOTOR26_CONFIG12_SR_MODE_MASK 0x000070ul
138 #define DCMOTOR26_CONFIG12_OC_LATCH 0x000000ul
139 #define DCMOTOR26_CONFIG12_OC_AUTO 0x000008ul
140 #define DCMOTOR26_CONFIG12_OC_MASK 0x000008ul
141 #define DCMOTOR26_CONFIG12_OC_LATCH 0x000000ul
142 #define DCMOTOR26_CONFIG12_OC_AUTO 0x000008ul
143 #define DCMOTOR26_CONFIG12_SPI_DISR_10mS 0x000000ul
144 #define DCMOTOR26_CONFIG12_SPI_DISR_100mS 0x000002ul
145 #define DCMOTOR26_CONFIG12_SPI_DISR_1S 0x000004ul
146 #define DCMOTOR26_CONFIG12_SPI_DISR_DISABLE 0x000006ul
147 #define DCMOTOR26_CONFIG12_SPI_DISR_MASK 0x000006ul
148 #define DCMOTOR26_CONFIG12_OPMODE_DISR_OFF 0x000000ul
149 #define DCMOTOR26_CONFIG12_OPMODE_DISR_CONTINUE 0x000001ul
150 #define DCMOTOR26_CONFIG12_OPMODE_DISR_MASK 0x000001ul
156 #define DCMOTOR26_CONFIG56_MOTOR_OPMODE_MAX 3u
157 #define DCMOTOR26_CONFIG56_MOTOR_OPMODE_SHIFT 22ul
158 #define DCMOTOR26_CONFIG56_MOTOR_OPMODE_MASK 0xC00000ul
159 #define DCMOTOR26_CONFIG56_DRV_FREQ_MAX 2047u
160 #define DCMOTOR26_CONFIG56_DRV_FREQ_SHIFT 11ul
161 #define DCMOTOR26_CONFIG56_DRV_FREQ_MASK 0x3FF800ul
162 #define DCMOTOR26_CONFIG56_DUTY_PERIOD_MAX 2047u
163 #define DCMOTOR26_CONFIG56_DUTY_PERIOD_SHIFT 0ul
164 #define DCMOTOR26_CONFIG56_DUTY_PERIOD_MASK 0x0007FFul
170 #define DCMOTOR26_DIAG1_PIN 0x01
171 #define DCMOTOR26_DIAG2_PIN 0x02
172 #define DCMOTOR26_EN1_PIN 0x04
173 #define DCMOTOR26_EN2_PIN 0x08
174 #define DCMOTOR26_CM_SEL_PIN 0x10
175 #define DCMOTOR26_SLP_PIN 0x20
181 #define DCMOTOR26_DEFAULT_CONFIG 0xE3
187 #define DCMOTOR26_MODE_OUTPUT_OFF 0x00
188 #define DCMOTOR26_MODE_FORWARD 0x01
189 #define DCMOTOR26_MODE_REVERSE 0x02
190 #define DCMOTOR26_MODE_BRAKE 0x03
196 #define DCMOTOR26_PIN_LOW_LEVEL 0
197 #define DCMOTOR26_PIN_HIGH_LEVEL 1
203 #define DCMOTOR26_VREF_3V3 3.3
204 #define DCMOTOR26_VREF_5V 5.0
210 #define DCMOTOR26_NUM_CONVERSIONS 5000
211 #define DCMOTOR26_RSENSE 220.0f
212 #define DCMOTOR26_VOLTAGE_TO_CURRENT 0.00238167f
219 #define DCMOTOR26_DEVICE_ADDRESS_A1A0_00 0x70
220 #define DCMOTOR26_DEVICE_ADDRESS_A1A0_01 0x71
221 #define DCMOTOR26_DEVICE_ADDRESS_A1A0_10 0x72
222 #define DCMOTOR26_DEVICE_ADDRESS_A1A0_11 0x73
232 #define DCMOTOR26_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
233 #define DCMOTOR26_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
251 #define DCMOTOR26_MAP_MIKROBUS( cfg, mikrobus ) \
252 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
253 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
254 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
255 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
256 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
257 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
258 cfg.cm = MIKROBUS( mikrobus, MIKROBUS_AN ); \
259 cfg.slp = MIKROBUS( mikrobus, MIKROBUS_RST ); \
260 cfg.clk = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
261 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
732 #endif // DCMOTOR26_H
uint8_t dcmotor26_get_int_pin(dcmotor26_t *ctx)
DC Motor 26 get int pin function.
err_t dcmotor26_set_ch1_drive_frequency(dcmotor26_t *ctx, uint16_t drv_freq)
DC Motor 26 set ch1 drive frequency function.
err_t dcmotor26_read_register(dcmotor26_t *ctx, uint8_t reg, uint32_t *data_out)
DC Motor 26 read register function.
err_t dcmotor26_get_cm_sel_pin(dcmotor26_t *ctx, uint8_t *state)
DC Motor 26 get cm sel pin function.
void dcmotor26_enter_sleep_mode(dcmotor26_t *ctx)
DC Motor 26 enter sleep mode function.
err_t dcmotor26_set_ch2_operation_mode(dcmotor26_t *ctx, uint8_t mode)
DC Motor 26 set ch2 operation mode function.
err_t dcmotor26_get_motor_current(dcmotor26_t *ctx, float *current)
DC Motor 26 get motor current function.
err_t dcmotor26_pca9538a_write_register(dcmotor26_t *ctx, uint8_t reg, uint8_t data_in)
DC Motor 26 pca9538a write register function.
void dcmotor26_wake_up_device(dcmotor26_t *ctx)
DC Motor 26 wake up device function.
This file contains SPI specific macros, functions, etc.
err_t dcmotor26_read_an_pin_value(dcmotor26_t *ctx, uint16_t *data_out)
DC Motor 26 read AN pin value function.
uint32_t i2c_speed
Definition: dcmotor26.h:314
err_t dcmotor26_set_ch2_drive_frequency(dcmotor26_t *ctx, uint16_t drv_freq)
DC Motor 26 set ch2 drive frequency function.
err_t dcmotor26_pca9538a_read_register(dcmotor26_t *ctx, uint8_t reg, uint8_t *data_out)
DC Motor 26 pca9538a read register function.
analog_in_t adc
Definition: dcmotor26.h:282
pin_name_t sck
Definition: dcmotor26.h:300
digital_out_t slp
Definition: dcmotor26.h:274
pin_name_t int_pin
Definition: dcmotor26.h:307
err_t dcmotor26_set_cm_sel_pin(dcmotor26_t *ctx, uint8_t state)
DC Motor 26 set cm sel pin function.
err_t dcmotor26_get_diag1_pin(dcmotor26_t *ctx, uint8_t *state)
DC Motor 26 get diag1 pin function.
err_t dcmotor26_write_register(dcmotor26_t *ctx, uint8_t reg, uint32_t data_in)
DC Motor 26 write register function.
void dcmotor26_cfg_setup(dcmotor26_cfg_t *cfg)
DC Motor 26 configuration object setup function.
err_t dcmotor26_read_an_pin_voltage(dcmotor26_t *ctx, float *data_out)
DC Motor 26 read AN pin voltage level function.
digital_in_t int_pin
Definition: dcmotor26.h:277
pin_name_t clk
Definition: dcmotor26.h:305
pin_name_t scl
Definition: dcmotor26.h:296
DC Motor 26 Click context object.
Definition: dcmotor26.h:271
void dcmotor26_set_clk_pin(dcmotor26_t *ctx, uint8_t state)
DC Motor 26 set clk pin function.
err_t dcmotor26_get_en1_pin(dcmotor26_t *ctx, uint8_t *state)
DC Motor 26 get en1 pin function.
i2c_master_t i2c
Definition: dcmotor26.h:281
@ DCMOTOR26_OK
Definition: dcmotor26.h:328
err_t dcmotor26_get_en2_pin(dcmotor26_t *ctx, uint8_t *state)
DC Motor 26 get en2 pin function.
err_t dcmotor26_set_en1_pin(dcmotor26_t *ctx, uint8_t state)
DC Motor 26 set en1 pin function.
pin_name_t cm
Definition: dcmotor26.h:302
@ DCMOTOR26_ERROR
Definition: dcmotor26.h:329
pin_name_t slp
Definition: dcmotor26.h:306
uint32_t spi_speed
Definition: dcmotor26.h:310
spi_master_mode_t spi_mode
Definition: dcmotor26.h:311
pin_name_t sda
Definition: dcmotor26.h:297
err_t dcmotor26_set_ch1_operation_mode(dcmotor26_t *ctx, uint8_t mode)
DC Motor 26 set ch1 operation mode function.
analog_in_resolution_t resolution
Definition: dcmotor26.h:317
spi_master_t spi
Definition: dcmotor26.h:280
float vref
Definition: dcmotor26.h:318
err_t dcmotor26_set_en2_pin(dcmotor26_t *ctx, uint8_t state)
DC Motor 26 set en2 pin function.
uint8_t i2c_address
Definition: dcmotor26.h:315
err_t dcmotor26_set_ch2_duty_period(dcmotor26_t *ctx, uint16_t duty_period)
DC Motor 26 set ch1 duty period function.
pin_name_t chip_select
Definition: dcmotor26.h:285
pin_name_t miso
Definition: dcmotor26.h:298
pin_name_t mosi
Definition: dcmotor26.h:299
spi_master_chip_select_polarity_t cs_polarity
Definition: dcmotor26.h:312
dcmotor26_return_value_t
DC Motor 26 Click return value data.
Definition: dcmotor26.h:327
err_t dcmotor26_get_sleep_pin(dcmotor26_t *ctx, uint8_t *state)
DC Motor 26 get sleep pin function.
DC Motor 26 Click configuration object.
Definition: dcmotor26.h:294
err_t dcmotor26_init(dcmotor26_t *ctx, dcmotor26_cfg_t *cfg)
DC Motor 26 initialization function.
uint8_t slave_address
Definition: dcmotor26.h:284
err_t dcmotor26_set_ch1_duty_period(dcmotor26_t *ctx, uint16_t duty_period)
DC Motor 26 set ch1 duty period function.
pin_name_t cs
Definition: dcmotor26.h:301
err_t dcmotor26_default_cfg(dcmotor26_t *ctx)
DC Motor 26 default configuration function.
err_t dcmotor26_get_diag2_pin(dcmotor26_t *ctx, uint8_t *state)
DC Motor 26 get diag2 pin function.
digital_out_t clk
Definition: dcmotor26.h:273