boostinv3 2.1.0.0
boostinv3.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2020 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
28#ifndef BOOSTINV3_H
29#define BOOSTINV3_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
52
73#define BOOSTINV3_REG_P_OUT_VOLTAGE 0x00
74#define BOOSTINV3_REG_N_OUT_VOLTAGE 0x01
75#define BOOSTINV3_REG_CONFIG 0x03
76#define BOOSTINV3_REG_CONTROL 0xFF
77
78
79 // boostinv3_reg
80
95#define BOOSTINV3_APPS_VALUE_40_MA 0x00
96#define BOOSTINV3_APPS_VALUE_80_MA 0x40
97#define BOOSTINV3_VPOS_NO_DISCHARGE 0x00
98#define BOOSTINV3_VPOS_DISCHARGE_EN 0x02
99#define BOOSTINV3_VPON_NO_DISCHARGE 0x00
100#define BOOSTINV3_VPON_DISCHARGE_EN 0x01
101
106#define BOOSTINV3_PIN_STATE_LOW 0x00
107#define BOOSTINV3_PIN_STATE_HIGH 0x01
108
113#define BOOSTINV3_OUT_VOLTAGE_4V 0x00
114#define BOOSTINV3_OUT_VOLTAGE_4V1 0x01
115#define BOOSTINV3_OUT_VOLTAGE_4V2 0x02
116#define BOOSTINV3_OUT_VOLTAGE_4V3 0x03
117#define BOOSTINV3_OUT_VOLTAGE_4V4 0x04
118#define BOOSTINV3_OUT_VOLTAGE_4V5 0x05
119#define BOOSTINV3_OUT_VOLTAGE_4V6 0x06
120#define BOOSTINV3_OUT_VOLTAGE_4V7 0x07
121#define BOOSTINV3_OUT_VOLTAGE_4V8 0x08
122#define BOOSTINV3_OUT_VOLTAGE_4V9 0x09
123#define BOOSTINV3_OUT_VOLTAGE_5V 0x0A
124#define BOOSTINV3_OUT_VOLTAGE_5V1 0x0B
125#define BOOSTINV3_OUT_VOLTAGE_5V2 0x0C
126#define BOOSTINV3_OUT_VOLTAGE_5V3 0x0D
127#define BOOSTINV3_OUT_VOLTAGE_5V4 0x0E
128#define BOOSTINV3_OUT_VOLTAGE_5V5 0x0F
129#define BOOSTINV3_OUT_VOLTAGE_5V6 0x10
130#define BOOSTINV3_OUT_VOLTAGE_5V7 0x11
131#define BOOSTINV3_OUT_VOLTAGE_5V8 0x12
132#define BOOSTINV3_OUT_VOLTAGE_5V9 0x13
133#define BOOSTINV3_OUT_VOLTAGE_6V 0x14
134
139#define BOOSTINV3_CMD_WRITE_EEPROM 0x80
140#define BOOSTINV3_CMD_READ_EEPROM 0x01
141#define BOOSTINV3_CMD_READ_REG 0x00
142
148#define BOOSTINV3_DEVICE_ADDRESS 0x3E
149
150 // boostinv3_set
151
166#define BOOSTINV3_MAP_MIKROBUS( cfg, mikrobus ) \
167 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
168 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
169 cfg.enp = MIKROBUS( mikrobus, MIKROBUS_RST ); \
170 cfg.enn = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
171
172 // boostinv3_map
173 // boostinv3
174
179typedef struct
180{
181 // Output pins
182 digital_out_t enp;
183 digital_out_t enn;
185 // Modules
186 i2c_master_t i2c;
188 // I2C slave address
192
197typedef struct
198{
199 pin_name_t scl;
200 pin_name_t sda;
202 pin_name_t enp;
203 pin_name_t enn;
205 uint32_t i2c_speed;
206 uint8_t i2c_address;
209
220
237
252
266
281err_t boostinv3_generic_write ( boostinv3_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len );
282
297err_t boostinv3_generic_read ( boostinv3_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len );
298
308void boostinv3_set_enp ( boostinv3_t *ctx, uint8_t out_state );
309
319void boostinv3_set_enn ( boostinv3_t *ctx, uint8_t out_state );
320
334err_t boostinv3_write_reg ( boostinv3_t *ctx, uint8_t reg, uint8_t data_in );
335
348err_t boostinv3_set_pos_out ( boostinv3_t *ctx, uint8_t out_val );
349
362err_t boostinv3_set_neg_out ( boostinv3_t *ctx, uint8_t out_val );
363
364#ifdef __cplusplus
365}
366#endif
367#endif // BOOSTINV3_H
368
369 // boostinv3
370
371// ------------------------------------------------------------------------ END
boostinv3_return_value_t
Boost-INV 3 Click return value data.
Definition boostinv3.h:215
@ BOOSTINV3_ERROR
Definition boostinv3.h:217
@ BOOSTINV3_OK
Definition boostinv3.h:216
void boostinv3_cfg_setup(boostinv3_cfg_t *cfg)
Boost-INV 3 configuration object setup function.
err_t boostinv3_init(boostinv3_t *ctx, boostinv3_cfg_t *cfg)
Boost-INV 3 initialization function.
err_t boostinv3_set_pos_out(boostinv3_t *ctx, uint8_t out_val)
Boost-INV 3 set positive output voltage function.
err_t boostinv3_set_neg_out(boostinv3_t *ctx, uint8_t out_val)
Boost-INV 3 set negative output voltage function.
err_t boostinv3_write_reg(boostinv3_t *ctx, uint8_t reg, uint8_t data_in)
Boost-INV 3 register write function.
void boostinv3_set_enp(boostinv3_t *ctx, uint8_t out_state)
Boost-INV 3 set ENP pin state function.
err_t boostinv3_generic_write(boostinv3_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Boost-INV 3 I2C writing function.
void boostinv3_set_enn(boostinv3_t *ctx, uint8_t out_state)
Boost-INV 3 set ENN pin state function.
err_t boostinv3_generic_read(boostinv3_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Boost-INV 3 I2C reading function.
err_t boostinv3_default_cfg(boostinv3_t *ctx)
Boost-INV 3 default configuration function.
Boost-INV 3 Click configuration object.
Definition boostinv3.h:198
pin_name_t enn
Definition boostinv3.h:203
uint32_t i2c_speed
Definition boostinv3.h:205
pin_name_t enp
Definition boostinv3.h:202
pin_name_t scl
Definition boostinv3.h:199
pin_name_t sda
Definition boostinv3.h:200
uint8_t i2c_address
Definition boostinv3.h:206
Boost-INV 3 Click context object.
Definition boostinv3.h:180
digital_out_t enp
Definition boostinv3.h:182
i2c_master_t i2c
Definition boostinv3.h:186
uint8_t slave_address
Definition boostinv3.h:189
digital_out_t enn
Definition boostinv3.h:183