42#ifdef PREINIT_SUPPORTED
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
55#include "drv_spi_master.h"
67#define HBRIDGE3_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
69 cfg.dir = MIKROBUS( mikrobus, MIKROBUS_AN ); \
70 cfg.dis = MIKROBUS( mikrobus, MIKROBUS_RST ); \
71 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
72 cfg.sdo = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
73 cfg.sdi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
74 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK )
81#define HBRIDGE3_RETVAL uint8_t
83#define HBRIDGE3_OK 0x00
84#define HBRIDGE3_INIT_ERROR 0xFF
91#define HBRIDGE3_DEF_FREQ 20000
98#define HBRIDGE3_CMD_RD_DIA 0x00
99#define HBRIDGE3_CMD_RES_DIA 0x80
100#define HBRIDGE3_CMD_RD_REV 0x20
101#define HBRIDGE3_CMD_RD_CTRL 0x60
102#define HBRIDGE3_CMD_WR_CTRL 0xE0
103#define HBRIDGE3_CMD_WR_CTRL_RD_DIA 0xC0
110#define HBRIDGE3_CTRL_VIA_PWM_DIR 0x00
111#define HBRIDGE3_CTRL_VIA_SPI 0x80
112#define HBRIDGE3_SPI_ENA_OUT 0x40
113#define HBRIDGE3_SPI_DIS_OUT 0x00
114#define HBRIDGE3_SPI_DIR_1 0x00
115#define HBRIDGE3_SPI_DIR_2 0x20
116#define HBRIDGE3_SPI_PWM_0 0x00
117#define HBRIDGE3_SPI_PWM_1 0x01
#define HBRIDGE3_RETVAL
Definition hbridge3.h:81
void hbridge3_set_duty_cycle(hbridge3_t *ctx, float duty_cycle)
Generic sets PWM duty cycle.
uint8_t hbridge3_spi(hbridge3_t *ctx, uint8_t spi_command)
Sending SPI command.
void hbridge3_dir_set(hbridge3_t *ctx, uint8_t pin_state)
Setting AN pin state.
void hbridge3_dis_set(hbridge3_t *ctx, uint8_t pin_state)
Setting RST pin state.
void hbridge3_default_cfg(hbridge3_t *ctx, float duty_cycle)
Click Default Configuration function.
void hbridge3_pwm_stop(hbridge3_t *ctx)
Stop PWM module.
void hbridge3_pwm_start(hbridge3_t *ctx)
Start PWM module.
HBRIDGE3_RETVAL hbridge3_init(hbridge3_t *ctx, hbridge3_cfg_t *cfg)
Initialization function.
void hbridge3_cs_set(hbridge3_t *ctx, uint8_t pin_state)
Setting CS pin state.
void hbridge3_cfg_setup(hbridge3_cfg_t *cfg)
Config Object Initialization function.
Click configuration structure definition.
Definition hbridge3.h:154
pin_name_t sdi
Definition hbridge3.h:159
spi_master_chip_select_polarity_t cs_polarity
Definition hbridge3.h:173
pin_name_t sck
Definition hbridge3.h:160
pin_name_t dis
Definition hbridge3.h:165
spi_master_mode_t spi_mode
Definition hbridge3.h:172
uint32_t spi_speed
Definition hbridge3.h:171
pin_name_t sdo
Definition hbridge3.h:158
uint32_t dev_pwm_freq
Definition hbridge3.h:170
pin_name_t dir
Definition hbridge3.h:164
pin_name_t pwm
Definition hbridge3.h:157
pin_name_t cs
Definition hbridge3.h:166
Click ctx object definition.
Definition hbridge3.h:130
digital_out_t cs
Definition hbridge3.h:135
digital_out_t dis
Definition hbridge3.h:134
spi_master_t spi
Definition hbridge3.h:139
uint32_t pwm_freq
Definition hbridge3.h:146
pin_name_t chip_select
Definition hbridge3.h:140
pwm_t pwm
Definition hbridge3.h:141
uint16_t pwm_period
Definition hbridge3.h:145
digital_out_t dir
Definition hbridge3.h:133