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 
35 #include "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_i2c_master.h"
48 
69 #define BOOSTINV3_REG_P_OUT_VOLTAGE 0x00
70 #define BOOSTINV3_REG_N_OUT_VOLTAGE 0x01
71 #define BOOSTINV3_REG_CONFIG 0x03
72 #define BOOSTINV3_REG_CONTROL 0xFF
73 
74  // boostinv3_reg
76 
91 #define BOOSTINV3_APPS_VALUE_40_MA 0x00
92 #define BOOSTINV3_APPS_VALUE_80_MA 0x40
93 #define BOOSTINV3_VPOS_NO_DISCHARGE 0x00
94 #define BOOSTINV3_VPOS_DISCHARGE_EN 0x02
95 #define BOOSTINV3_VPON_NO_DISCHARGE 0x00
96 #define BOOSTINV3_VPON_DISCHARGE_EN 0x01
97 
102 #define BOOSTINV3_PIN_STATE_LOW 0x00
103 #define BOOSTINV3_PIN_STATE_HIGH 0x01
104 
109 #define BOOSTINV3_OUT_VOLTAGE_4V 0x00
110 #define BOOSTINV3_OUT_VOLTAGE_4V1 0x01
111 #define BOOSTINV3_OUT_VOLTAGE_4V2 0x02
112 #define BOOSTINV3_OUT_VOLTAGE_4V3 0x03
113 #define BOOSTINV3_OUT_VOLTAGE_4V4 0x04
114 #define BOOSTINV3_OUT_VOLTAGE_4V5 0x05
115 #define BOOSTINV3_OUT_VOLTAGE_4V6 0x06
116 #define BOOSTINV3_OUT_VOLTAGE_4V7 0x07
117 #define BOOSTINV3_OUT_VOLTAGE_4V8 0x08
118 #define BOOSTINV3_OUT_VOLTAGE_4V9 0x09
119 #define BOOSTINV3_OUT_VOLTAGE_5V 0x0A
120 #define BOOSTINV3_OUT_VOLTAGE_5V1 0x0B
121 #define BOOSTINV3_OUT_VOLTAGE_5V2 0x0C
122 #define BOOSTINV3_OUT_VOLTAGE_5V3 0x0D
123 #define BOOSTINV3_OUT_VOLTAGE_5V4 0x0E
124 #define BOOSTINV3_OUT_VOLTAGE_5V5 0x0F
125 #define BOOSTINV3_OUT_VOLTAGE_5V6 0x10
126 #define BOOSTINV3_OUT_VOLTAGE_5V7 0x11
127 #define BOOSTINV3_OUT_VOLTAGE_5V8 0x12
128 #define BOOSTINV3_OUT_VOLTAGE_5V9 0x13
129 #define BOOSTINV3_OUT_VOLTAGE_6V 0x14
130 
135 #define BOOSTINV3_CMD_WRITE_EEPROM 0x80
136 #define BOOSTINV3_CMD_READ_EEPROM 0x01
137 #define BOOSTINV3_CMD_READ_REG 0x00
138 
144 #define BOOSTINV3_DEVICE_ADDRESS 0x3E
145  // boostinv3_set
147 
162 #define BOOSTINV3_MAP_MIKROBUS( cfg, mikrobus ) \
163  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
164  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
165  cfg.enp = MIKROBUS( mikrobus, MIKROBUS_RST ); \
166  cfg.enn = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
167 
168  // boostinv3_map // boostinv3
170 
175 typedef struct
176 {
177  // Output pins
178  digital_out_t enp;
179  digital_out_t enn;
181  // Modules
182  i2c_master_t i2c;
184  // I2C slave address
185  uint8_t slave_address;
187 } boostinv3_t;
188 
193 typedef struct
194 {
195  pin_name_t scl;
196  pin_name_t sda;
198  pin_name_t enp;
199  pin_name_t enn;
201  uint32_t i2c_speed;
202  uint8_t i2c_address;
205 
210 typedef enum
211 {
213  BOOSTINV3_ERROR = -1
214 
216 
233 
248 
262 
277 err_t boostinv3_generic_write ( boostinv3_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len );
278 
293 err_t boostinv3_generic_read ( boostinv3_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len );
294 
304 void boostinv3_set_enp ( boostinv3_t *ctx, uint8_t out_state );
305 
315 void boostinv3_set_enn ( boostinv3_t *ctx, uint8_t out_state );
316 
330 err_t boostinv3_write_reg ( boostinv3_t *ctx, uint8_t reg, uint8_t data_in );
331 
344 err_t boostinv3_set_pos_out ( boostinv3_t *ctx, uint8_t out_val );
345 
358 err_t boostinv3_set_neg_out ( boostinv3_t *ctx, uint8_t out_val );
359 
360 #ifdef __cplusplus
361 }
362 #endif
363 #endif // BOOSTINV3_H
364  // boostinv3
366 
367 // ------------------------------------------------------------------------ END
boostinv3_t::slave_address
uint8_t slave_address
Definition: boostinv3.h:185
boostinv3_t::enp
digital_out_t enp
Definition: boostinv3.h:178
boostinv3_return_value_t
boostinv3_return_value_t
Boost-INV 3 Click return value data.
Definition: boostinv3.h:211
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:199
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:198
BOOSTINV3_OK
@ BOOSTINV3_OK
Definition: boostinv3.h:212
boostinv3_cfg_t::sda
pin_name_t sda
Definition: boostinv3.h:196
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:195
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:202
boostinv3_t
Boost-INV 3 Click context object.
Definition: boostinv3.h:176
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:194
boostinv3_t::i2c
i2c_master_t i2c
Definition: boostinv3.h:182
boostinv3_t::enn
digital_out_t enn
Definition: boostinv3.h:179
boostinv3_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: boostinv3.h:201
BOOSTINV3_ERROR
@ BOOSTINV3_ERROR
Definition: boostinv3.h:213