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 HBRIDGE15_REG_INPUT_PORT 0x00
74#define HBRIDGE15_REG_OUTPUT_PORT 0x01
75#define HBRIDGE15_REG_POLARITY_INVERSION 0x02
76#define HBRIDGE15_REG_CONFIGURATION 0x03
94#define HBRIDGE15_PIN_MASK_NONE 0x00
95#define HBRIDGE15_PIN_MASK_SLP 0x01
96#define HBRIDGE15_PIN_MASK_FLT 0x02
97#define HBRIDGE15_PIN_MASK_CONFIG 0x04
98#define HBRIDGE15_PIN_MASK_M1 0x08
99#define HBRIDGE15_PIN_MASK_M0 0x10
100#define HBRIDGE15_PIN_MASK_DIR 0x20
101#define HBRIDGE15_PIN_MASK_EN_B 0x40
102#define HBRIDGE15_PIN_MASK_EN_A 0x80
103#define HBRIDGE15_PIN_MASK_ALL 0xFF
109#define HBRIDGE15_PIN_STATE_HIGH 0x01
110#define HBRIDGE15_PIN_STATE_LOW 0x00
116#define HBRIDGE15_SLEEP_STATE_ON 0x01
117#define HBRIDGE15_SLEEP_STATE_OFF 0x00
123#define HBRIDGE15_DRIVE_MOTOR_REVERSE 0x00
124#define HBRIDGE15_DRIVE_MOTOR_FORWARD 0x01
125#define HBRIDGE15_DRIVE_MOTOR_FREEWHEEL 0x02
126#define HBRIDGE15_DRIVE_MOTOR_BRAKE 0x03
133#define HBRIDGE15_DEVICE_ADDRESS_00 0x70
134#define HBRIDGE15_DEVICE_ADDRESS_01 0x71
135#define HBRIDGE15_DEVICE_ADDRESS_10 0x72
136#define HBRIDGE15_DEVICE_ADDRESS_11 0x73
154#define HBRIDGE15_MAP_MIKROBUS( cfg, mikrobus ) \
155 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
156 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
157 cfg.ena = MIKROBUS( mikrobus, MIKROBUS_CS ); \
158 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
159 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
void hbridge15_cfg_setup(hbridge15_cfg_t *cfg)
H-Bridge 15 configuration object setup function.
err_t hbridge15_set_sleep(hbridge15_t *ctx, uint8_t sleep_state)
H-Bridge 15 set sleep function.
void hbridge15_reset_port_exp(hbridge15_t *ctx)
H-Bridge 15 reset port expander function.
err_t hbridge15_generic_write(hbridge15_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
H-Bridge 15 I2C writing function.
err_t hbridge15_init(hbridge15_t *ctx, hbridge15_cfg_t *cfg)
H-Bridge 15 initialization function.
err_t hbridge15_generic_read(hbridge15_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
H-Bridge 15 I2C reading function.
err_t hbridge15_write_reg(hbridge15_t *ctx, uint8_t reg, uint8_t data_in)
H-Bridge 15 write register function.
err_t hbridge15_read_reg(hbridge15_t *ctx, uint8_t reg, uint8_t *data_out)
H-Bridge 15 read register function.
uint8_t hbridge15_get_int_state(hbridge15_t *ctx)
H-Bridge 15 get INT pin state function.
void hbridge15_set_rst_pin(hbridge15_t *ctx, uint8_t pin_state)
H-Bridge 15 set RST pin function.
void hbridge15_set_ena_pin(hbridge15_t *ctx, uint8_t pin_state)
H-Bridge 15 set ENA pin function.
err_t hbridge15_default_cfg(hbridge15_t *ctx)
H-Bridge 15 default configuration function.
err_t hbridge15_set_pins(hbridge15_t *ctx, uint8_t set_mask, uint8_t clr_mask)
H-Bridge 15 set pins function.
err_t hbridge15_set_out_state(hbridge15_t *ctx, uint8_t out_state)
H-Bridge 15 set output function.
hbridge15_return_value_t
H-Bridge 15 Click return value data.
Definition hbridge15.h:208
@ HBRIDGE15_ERROR
Definition hbridge15.h:210
@ HBRIDGE15_OK
Definition hbridge15.h:209
H-Bridge 15 Click configuration object.
Definition hbridge15.h:190
uint32_t i2c_speed
Definition hbridge15.h:198
pin_name_t ena
Definition hbridge15.h:194
pin_name_t scl
Definition hbridge15.h:191
pin_name_t int_pin
Definition hbridge15.h:196
pin_name_t sda
Definition hbridge15.h:192
pin_name_t rst
Definition hbridge15.h:195
uint8_t i2c_address
Definition hbridge15.h:199
H-Bridge 15 Click context object.
Definition hbridge15.h:169
digital_out_t ena
Definition hbridge15.h:171
digital_in_t int_pin
Definition hbridge15.h:175
i2c_master_t i2c
Definition hbridge15.h:178
digital_out_t rst
Definition hbridge15.h:172
uint8_t slave_address
Definition hbridge15.h:181