boostinv  2.0.0.0
boostinv.h
Go to the documentation of this file.
1 /*
2  * MikroSDK - MikroE Software Development Kit
3  * Copyright (c) 2019, MikroElektronika - www.mikroe.com
4  * All rights reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 
33 // ----------------------------------------------------------------------------
34 
35 #ifndef BOOSTINV_H
36 #define BOOSTINV_H
37 
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_i2c_master.h"
41 
42 
43 // -------------------------------------------------------------- PUBLIC MACROS
53 #define BOOSTINV_MAP_MIKROBUS( cfg, mikrobus ) \
54  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
55  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
56  cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST );
57 
63 #define BOOSTINV_RETVAL uint8_t
64 
65 #define BOOSTINV_OK 0x00
66 #define BOOSTINV_INIT_ERROR 0xFF
67 
73 #define BOOSTINV_I2C_SLAVE_ADDRESS_GND 0x30
74 #define BOOSTINV_I2C_SLAVE_ADDRESS_VCC 0x31
75 
81 #define BOOSTINV_REG_POSITIVE_VOUT 0x00
82 #define BOOSTINV_REG_NEGATIVE_VOUT 0x01
83 #define BOOSTINV_REG_CONFIG 0x02
84 #define BOOSTINV_REG_COMMAND 0x04
85 #define BOOSTINV_REG_OTP0 0x00
86 #define BOOSTINV_REG_OTP1 0x01
87 #define BOOSTINV_REG_OTP2 0x02
88 
94 #define BOOSTINV_CFG_LOCKOUT_BIT_ENABLE 0x40
95 #define BOOSTINV_CFG_LOCKOUT_BIT_DISABLE 0x00
96 #define BOOSTINV_CFG_VPLUS_ENABLE 0x20
97 #define BOOSTINV_CFG_VPLUS_DISABLE 0x00
98 #define BOOSTINV_CFG_IRAMP_1uA 0x00
99 #define BOOSTINV_CFG_IRAMP_2uA 0x08
100 #define BOOSTINV_CFG_IRAMP_4uA 0x10
101 #define BOOSTINV_CFG_IRAMP_8uA 0x18
102 #define BOOSTINV_CFG_PDDIS_ENABLE 0x04
103 #define BOOSTINV_CFG_PDDIS_DISABLE 0x00
104 #define BOOSTINV_CFG_PUSEQ_OUTPUTS_DISABLED 0x00
105 #define BOOSTINV_CFG_PUSEQ_VOUTN_RAMP_1ST 0x01
106 #define BOOSTINV_CFG_PUSEQ_VOUTP_RAMP_1ST 0x02
107 #define BOOSTINV_CFG_PUSEQ_BOTH_RAMP_TOGETHER 0x03
108 
114 #define BOOSTINV_CMD_WRITE_OTP_MEMORY 0x80
115 #define BOOSTINV_CMD_CLEAR_OTP_FAULT 0x40
116 #define BOOSTINV_CMD_RESET 0x20
117 #define BOOSTINV_CMD_SWITCHES_OFF 0x10
118 #define BOOSTINV_CMD_REGISTER_SELECT_POS_VOUT 0x04
119 #define BOOSTINV_CMD_REGISTER_SELECT_NEG_VOUT 0x02
120 #define BOOSTINV_CMD_REGISTER_SELECT_CONFIG 0x01
121 #define BOOSTINV_CMD_REGISTER_SELECT_OTP2 0x00
122 #define BOOSTINV_CMD_REGISTER_SELECT_OTP1 0x00
123 #define BOOSTINV_CMD_REGISTER_SELECT_OTP0 0x00
124 
130 #define BOOSTINV_VOLTAGE_POSITIVE_3200_mV 3200
131 #define BOOSTINV_VOLTAGE_POSITIVE_7750_mV 7750
132 #define BOOSTINV_VOLTAGE_POSITIVE_12000_mV 12000
133 #define BOOSTINV_VOLTAGE_NEGATIVE_1450_mV -1450
134 #define BOOSTINV_VOLTAGE_NEGATIVE_6700_mV -6700
135 #define BOOSTINV_VOLTAGE_NEGATIVE_11050_mV -11050
136  // End group macro
139 // --------------------------------------------------------------- PUBLIC TYPES
148 typedef struct
149 {
150  // Output pins
151 
152  digital_out_t en;
153 
154  // Modules
155 
156  i2c_master_t i2c;
157 
158  // ctx variable
159 
160  hal_i2c_address_t slave_address;
161 
162 } boostinv_t;
163 
167 typedef struct
168 {
169  // Communication gpio pins
170 
171  pin_name_t scl;
172  pin_name_t sda;
173 
174  // Additional gpio pins
175 
176  pin_name_t en;
177 
178  // static variable
179 
180  hal_i2c_speed_t i2c_speed;
181  hal_i2c_address_t i2c_address;
182 
184  // End types group
186 
187 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
188 
194 #ifdef __cplusplus
195 extern "C"{
196 #endif
197 
206 void boostinv_cfg_setup ( boostinv_cfg_t *cfg );
207 
216 
249 void boostinv_default_cfg ( boostinv_t *ctx );
250 
260 void boostinv_generic_write ( boostinv_t *ctx, uint8_t reg_addr, uint8_t tx_data );
261 
272 uint8_t boostinv_generic_read ( boostinv_t *ctx, uint8_t reg_addr );
273 
281 void boostinv_enable ( boostinv_t *ctx );
282 
292 void boostinv_set_positive_voltage ( boostinv_t *ctx, uint16_t voltage );
293 
303 void boostinv_set_negative_voltage ( boostinv_t *ctx, int16_t voltage );
304 
305 #ifdef __cplusplus
306 }
307 #endif
308 #endif // _BOOSTINV_H_
309  // End public_function group
312 
313 // ------------------------------------------------------------------------- END
hal_i2c_speed_t i2c_speed
Definition: boostinv.h:180
Click ctx object definition.
Definition: boostinv.h:148
Click configuration structure definition.
Definition: boostinv.h:167
void boostinv_enable(boostinv_t *ctx)
Functions for enable chip.
hal_i2c_address_t i2c_address
Definition: boostinv.h:181
uint8_t boostinv_generic_read(boostinv_t *ctx, uint8_t reg_addr)
Generic read function.
hal_i2c_address_t slave_address
Definition: boostinv.h:160
pin_name_t scl
Definition: boostinv.h:171
void boostinv_generic_write(boostinv_t *ctx, uint8_t reg_addr, uint8_t tx_data)
Functions for write one byte in register.
void boostinv_default_cfg(boostinv_t *ctx)
Click Default Configuration function.
void boostinv_set_positive_voltage(boostinv_t *ctx, uint16_t voltage)
Functions for set positive output voltage.
pin_name_t en
Definition: boostinv.h:176
BOOSTINV_RETVAL boostinv_init(boostinv_t *ctx, boostinv_cfg_t *cfg)
Initialization function.
pin_name_t sda
Definition: boostinv.h:172
void boostinv_cfg_setup(boostinv_cfg_t *cfg)
Config Object Initialization function.
void boostinv_set_negative_voltage(boostinv_t *ctx, int16_t voltage)
Functions for set negative output voltage.
digital_out_t en
Definition: boostinv.h:152
#define BOOSTINV_RETVAL
Definition: boostinv.h:63
i2c_master_t i2c
Definition: boostinv.h:156