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"
73#define HBRIDGE16_REG_INPUT_PORT 0x00
74#define HBRIDGE16_REG_OUTPUT_PORT 0x01
75#define HBRIDGE16_REG_POLARITY_INV 0x02
76#define HBRIDGE16_REG_CONFIG 0x03
94#define HBRIDGE16_NONE_PIN 0x00
95#define HBRIDGE16_IN1_PIN 0x01
96#define HBRIDGE16_IN2_PIN 0x02
97#define HBRIDGE16_IN3_PIN 0x04
98#define HBRIDGE16_IN4_PIN 0x08
99#define HBRIDGE16_DECAY_PIN 0x10
100#define HBRIDGE16_MD_PIN 0x20
101#define HBRIDGE16_OCPM_PIN 0x40
102#define HBRIDGE16_FLT_PIN 0x80
103#define HBRIDGE16_ALL_OUTPUT_PIN 0x7F
104#define HBRIDGE16_ALL_PIN 0xFF
110#define HBRIDGE16_DRIVE_MOTOR_REVERSE 0x00
111#define HBRIDGE16_DRIVE_MOTOR_FORWARD 0x01
112#define HBRIDGE16_DRIVE_MOTOR_FREEWHEEL 0x02
113#define HBRIDGE16_DRIVE_MOTOR_BRAKE 0x03
119#define HBRIDGE16_PWM_MODE 0x01
120#define HBRIDGE16_PH_EN_MODE 0x00
126#define HBRIDGE16_SLEEP_MODE_OFF 0x01
127#define HBRIDGE16_SLEEP_MODE_ON 0x00
134#define HBRIDGE16_DEVICE_ADDRESS_A1A0_00 0x70
135#define HBRIDGE16_DEVICE_ADDRESS_A1A0_01 0x71
136#define HBRIDGE16_DEVICE_ADDRESS_A1A0_10 0x72
137#define HBRIDGE16_DEVICE_ADDRESS_A1A0_11 0x73
155#define HBRIDGE16_MAP_MIKROBUS( cfg, mikrobus ) \
156 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
157 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
158 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
159 cfg.slp = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
160 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
void hbridge16_reset_port_exp(hbridge16_t *ctx)
H-Bridge 16 reset port expander function.
err_t hbridge16_write_reg(hbridge16_t *ctx, uint8_t reg, uint8_t data_in)
H-Bridge 16 write register function.
err_t hbridge16_init(hbridge16_t *ctx, hbridge16_cfg_t *cfg)
H-Bridge 16 initialization function.
err_t hbridge16_read_reg(hbridge16_t *ctx, uint8_t reg, uint8_t *data_out)
H-Bridge 16 read register function.
void hbridge16_set_slp_pin(hbridge16_t *ctx, uint8_t pin_state)
H-Bridge 15 set Sleep pin function.
err_t hbridge16_generic_write(hbridge16_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
H-Bridge 16 I2C writing function.
err_t hbridge16_set_pins(hbridge16_t *ctx, uint8_t set_mask, uint8_t clr_mask)
H-Bridge 16 set pins function.
err_t hbridge16_set_mode(hbridge16_t *ctx, uint8_t mode_sel)
H-Bridge 16 set mode function.
uint8_t hbridge16_get_int_pin(hbridge16_t *ctx)
H-Bridge 16 get Interrupt pin function.
err_t hbridge16_set_out_state(hbridge16_t *ctx, uint8_t out_state)
H-Bridge 16 set output function.
void hbridge16_cfg_setup(hbridge16_cfg_t *cfg)
H-Bridge 16 configuration object setup function.
err_t hbridge16_default_cfg(hbridge16_t *ctx)
H-Bridge 16 default configuration function.
err_t hbridge16_generic_read(hbridge16_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
H-Bridge 16 I2C reading function.
hbridge16_return_value_t
H-Bridge 16 Click return value data.
Definition hbridge16.h:209
@ HBRIDGE16_ERROR
Definition hbridge16.h:211
@ HBRIDGE16_OK
Definition hbridge16.h:210
H-Bridge 16 Click configuration object.
Definition hbridge16.h:191
pin_name_t slp
Definition hbridge16.h:196
uint32_t i2c_speed
Definition hbridge16.h:199
pin_name_t scl
Definition hbridge16.h:192
pin_name_t int_pin
Definition hbridge16.h:197
pin_name_t sda
Definition hbridge16.h:193
pin_name_t rst
Definition hbridge16.h:195
uint8_t i2c_address
Definition hbridge16.h:200
H-Bridge 16 Click context object.
Definition hbridge16.h:170
digital_out_t slp
Definition hbridge16.h:173
digital_in_t int_pin
Definition hbridge16.h:176
i2c_master_t i2c
Definition hbridge16.h:179
digital_out_t rst
Definition hbridge16.h:172
uint8_t slave_address
Definition hbridge16.h:182