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
32 extern "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  // 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  // 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 // boostinv3
174 
179 typedef 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
189  uint8_t slave_address;
191 } boostinv3_t;
192 
197 typedef 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 
214 typedef enum
215 {
217  BOOSTINV3_ERROR = -1
218 
220 
237 
252 
266 
281 err_t boostinv3_generic_write ( boostinv3_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len );
282 
297 err_t boostinv3_generic_read ( boostinv3_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len );
298 
308 void boostinv3_set_enp ( boostinv3_t *ctx, uint8_t out_state );
309 
319 void boostinv3_set_enn ( boostinv3_t *ctx, uint8_t out_state );
320 
334 err_t boostinv3_write_reg ( boostinv3_t *ctx, uint8_t reg, uint8_t data_in );
335 
348 err_t boostinv3_set_pos_out ( boostinv3_t *ctx, uint8_t out_val );
349 
362 err_t boostinv3_set_neg_out ( boostinv3_t *ctx, uint8_t out_val );
363 
364 #ifdef __cplusplus
365 }
366 #endif
367 #endif // BOOSTINV3_H
368  // boostinv3
370 
371 // ------------------------------------------------------------------------ END
boostinv3_t::slave_address
uint8_t slave_address
Definition: boostinv3.h:189
boostinv3_t::enp
digital_out_t enp
Definition: boostinv3.h:182
boostinv3_return_value_t
boostinv3_return_value_t
Boost-INV 3 Click return value data.
Definition: boostinv3.h:215
boostinv3_set_neg_out
err_t boostinv3_set_neg_out(boostinv3_t *ctx, uint8_t out_val)
Boost-INV 3 set negative output voltage function.
boostinv3_generic_write
err_t boostinv3_generic_write(boostinv3_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Boost-INV 3 I2C writing function.
boostinv3_init
err_t boostinv3_init(boostinv3_t *ctx, boostinv3_cfg_t *cfg)
Boost-INV 3 initialization function.
boostinv3_set_enp
void boostinv3_set_enp(boostinv3_t *ctx, uint8_t out_state)
Boost-INV 3 set ENP pin state function.
boostinv3_cfg_t::enn
pin_name_t enn
Definition: boostinv3.h:203
boostinv3_set_pos_out
err_t boostinv3_set_pos_out(boostinv3_t *ctx, uint8_t out_val)
Boost-INV 3 set positive output voltage function.
boostinv3_generic_read
err_t boostinv3_generic_read(boostinv3_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Boost-INV 3 I2C reading function.
boostinv3_cfg_t::enp
pin_name_t enp
Definition: boostinv3.h:202
BOOSTINV3_OK
@ BOOSTINV3_OK
Definition: boostinv3.h:216
boostinv3_cfg_t::sda
pin_name_t sda
Definition: boostinv3.h:200
boostinv3_default_cfg
err_t boostinv3_default_cfg(boostinv3_t *ctx)
Boost-INV 3 default configuration function.
boostinv3_cfg_t::scl
pin_name_t scl
Definition: boostinv3.h:199
boostinv3_write_reg
err_t boostinv3_write_reg(boostinv3_t *ctx, uint8_t reg, uint8_t data_in)
Boost-INV 3 register write function.
boostinv3_cfg_t::i2c_address
uint8_t i2c_address
Definition: boostinv3.h:206
boostinv3_t
Boost-INV 3 Click context object.
Definition: boostinv3.h:180
boostinv3_set_enn
void boostinv3_set_enn(boostinv3_t *ctx, uint8_t out_state)
Boost-INV 3 set ENN pin state function.
boostinv3_cfg_setup
void boostinv3_cfg_setup(boostinv3_cfg_t *cfg)
Boost-INV 3 configuration object setup function.
boostinv3_cfg_t
Boost-INV 3 Click configuration object.
Definition: boostinv3.h:198
boostinv3_t::i2c
i2c_master_t i2c
Definition: boostinv3.h:186
boostinv3_t::enn
digital_out_t enn
Definition: boostinv3.h:183
boostinv3_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: boostinv3.h:205
BOOSTINV3_ERROR
@ BOOSTINV3_ERROR
Definition: boostinv3.h:217