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 HBRIDGE12_ADDR_AB 0x00
75#define HBRIDGE12_ADDR_CD 0x01
93#define HBRIDGE12_CURRENT_SCALE_20_PER 0x00
94#define HBRIDGE12_CURRENT_SCALE_38_PER 0x04
95#define HBRIDGE12_CURRENT_SCALE_56_PER 0x02
96#define HBRIDGE12_CURRENT_SCALE_71_PER 0x06
97#define HBRIDGE12_CURRENT_SCALE_83_PER 0x01
98#define HBRIDGE12_CURRENT_SCALE_92_PER 0x05
99#define HBRIDGE12_CURRENT_SCALE_98_PER 0x03
100#define HBRIDGE12_CURRENT_SCALE_100_PER 0x07
106#define HBRIDGE12_PHASE_OUT1_H_OUT2_L 0x01
107#define HBRIDGE12_PHASE_OUT1_L_OUT2_H 0x00
113#define HBRIDGE12_ENABLE_BRIDGE_OUTPUT 0x01
114#define HBRIDGE12_DISABLE_BRIDGE_OUTPUT 0x00
120#define HBRIDGE12_AB_BRIDGE_SEL 0x00
121#define HBRIDGE12_CD_BRIDGE_SEL 0x01
127#define HBRIDGE12_PIN_STATE_LOW 0x00
128#define HBRIDGE12_PIN_STATE_HIGH 0x01
138#define HBRIDGE12_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
139#define HBRIDGE12_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
157#define HBRIDGE12_MAP_MIKROBUS( cfg, mikrobus ) \
158 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
159 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
160 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
161 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
162 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
163 cfg.slp = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
164 cfg.stb = MIKROBUS( mikrobus, MIKROBUS_AN )
386 uint8_t out2_curr_scale );
401 uint8_t out2_decay );
void hbridge12_set_decay(hbridge12_t *ctx, uint8_t channel_sel, uint8_t out1_decay, uint8_t out2_decay)
H-Bridge 12 set decay function.
void hbridge12_set_settings(hbridge12_t *ctx, uint8_t channel_sel, hbridge12_config_t config_data)
H-Bridge 12 set settings function.
err_t hbridge12_init(hbridge12_t *ctx, hbridge12_cfg_t *cfg)
H-Bridge 12 initialization function.
void hbridge12_cfg_setup(hbridge12_cfg_t *cfg)
H-Bridge 12 configuration object setup function.
err_t hbridge12_turn_clockwise(hbridge12_t *ctx, uint8_t channel_sel)
H-Bridge 12 turn motor clockwise function.
err_t hbridge12_turn_counterclockwise(hbridge12_t *ctx, uint8_t channel_sel)
H-Bridge 12 turn motor counterclockwise function.
err_t hbridge12_freewheeling_on(hbridge12_t *ctx, uint8_t channel_sel)
H-Bridge 12 set motor into freewheeling mode function.
err_t hbridge12_turn_brake_on(hbridge12_t *ctx, uint8_t channel_sel)
H-Bridge 12 turn motor brake on function.
void hbridge12_set_rst(hbridge12_t *ctx, uint8_t pin_state)
H-Bridge 12 set RST pin state function.
void hbridge12_set_current_scale(hbridge12_t *ctx, uint8_t channel_sel, uint8_t out1_curr_scale, uint8_t out2_curr_scale)
H-Bridge 12 set current scale function.
err_t hbridge12_write_config(hbridge12_t *ctx, hbridge12_config_t config_data)
H-Bridge 12 write settings function.
void hbridge12_set_strobe(hbridge12_t *ctx, uint8_t pin_state)
H-Bridge 12 set STB pin state function.
void hbridge12_get_settings(hbridge12_t *ctx, uint8_t channel_sel, hbridge12_config_t *config_data)
H-Bridge 12 get settings function.
void hbridge12_set_slp(hbridge12_t *ctx, uint8_t pin_state)
H-Bridge 12 set SLP pin state function.
void hbridge12_generate_strobe(hbridge12_t *ctx)
H-Bridge 12 generate strobe signal function.
err_t hbridge12_default_cfg(hbridge12_t *ctx)
H-Bridge 12 default configuration function.
hbridge12_return_value_t
H-Bridge 12 Click return value data.
Definition hbridge12.h:238
@ HBRIDGE12_OK
Definition hbridge12.h:239
@ HBRIDGE12_ERROR
Definition hbridge12.h:240
This file contains SPI specific macros, functions, etc.
H-Bridge 12 Click configuration object.
Definition hbridge12.h:214
pin_name_t slp
Definition hbridge12.h:223
spi_master_chip_select_polarity_t cs_polarity
Definition hbridge12.h:229
pin_name_t sck
Definition hbridge12.h:218
spi_master_mode_t spi_mode
Definition hbridge12.h:228
pin_name_t mosi
Definition hbridge12.h:217
uint32_t spi_speed
Definition hbridge12.h:227
pin_name_t miso
Definition hbridge12.h:216
pin_name_t rst
Definition hbridge12.h:222
pin_name_t stb
Definition hbridge12.h:224
pin_name_t cs
Definition hbridge12.h:219
H-Bridge 12 Click configuration structure.
Definition hbridge12.h:174
uint8_t ch2_decay
Definition hbridge12.h:183
uint8_t ch1_cur_scale
Definition hbridge12.h:178
uint8_t ch2_cur_scale
Definition hbridge12.h:182
uint8_t ch1_en
Definition hbridge12.h:176
uint8_t ch2_phase
Definition hbridge12.h:181
uint8_t ch2_en
Definition hbridge12.h:180
uint8_t ch1_phase
Definition hbridge12.h:177
uint8_t addr
Definition hbridge12.h:175
uint8_t ch1_decay
Definition hbridge12.h:179
H-Bridge 12 Click context object.
Definition hbridge12.h:192
spi_master_t spi
Definition hbridge12.h:203
digital_out_t slp
Definition hbridge12.h:195
digital_out_t stb
Definition hbridge12.h:196
hbridge12_config_t ab_config_data
Definition hbridge12.h:199
digital_out_t rst
Definition hbridge12.h:194
hbridge12_config_t cd_config_data
Definition hbridge12.h:200
pin_name_t chip_select
Definition hbridge12.h:205