boostinv  2.0.0.0
boostinv.h
Go to the documentation of this file.
1 /*
2  * MikroSDK - MikroE Software Development Kit
3  * Copyright© 2020 MikroElektronika d.o.o.
4  *
5  * Permission is hereby granted, free of charge, to any person
6  * obtaining a copy of this software and associated documentation
7  * files (the "Software"), to deal in the Software without restriction,
8  * including without limitation the rights to use, copy, modify, merge,
9  * publish, distribute, sublicense, and/or sell copies of the Software,
10  * and to permit persons to whom the Software is furnished to do so,
11  * subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22  * OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
33 // ----------------------------------------------------------------------------
34 
35 #ifndef BOOSTINV_H
36 #define BOOSTINV_H
37 
42 #ifdef PREINIT_SUPPORTED
43 #include "preinit.h"
44 #endif
45 
46 #ifdef MikroCCoreVersion
47  #if MikroCCoreVersion >= 1
48  #include "delays.h"
49  #endif
50 #endif
51 
52 #include "drv_digital_out.h"
53 #include "drv_digital_in.h"
54 #include "drv_i2c_master.h"
55 
56 
57 // -------------------------------------------------------------- PUBLIC MACROS
67 #define BOOSTINV_MAP_MIKROBUS( cfg, mikrobus ) \
68  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
69  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
70  cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST );
71 
77 #define BOOSTINV_RETVAL uint8_t
78 
79 #define BOOSTINV_OK 0x00
80 #define BOOSTINV_INIT_ERROR 0xFF
81 
87 #define BOOSTINV_I2C_SLAVE_ADDRESS_GND 0x30
88 #define BOOSTINV_I2C_SLAVE_ADDRESS_VCC 0x31
89 
95 #define BOOSTINV_REG_POSITIVE_VOUT 0x00
96 #define BOOSTINV_REG_NEGATIVE_VOUT 0x01
97 #define BOOSTINV_REG_CONFIG 0x02
98 #define BOOSTINV_REG_COMMAND 0x04
99 #define BOOSTINV_REG_OTP0 0x00
100 #define BOOSTINV_REG_OTP1 0x01
101 #define BOOSTINV_REG_OTP2 0x02
102 
108 #define BOOSTINV_CFG_LOCKOUT_BIT_ENABLE 0x40
109 #define BOOSTINV_CFG_LOCKOUT_BIT_DISABLE 0x00
110 #define BOOSTINV_CFG_VPLUS_ENABLE 0x20
111 #define BOOSTINV_CFG_VPLUS_DISABLE 0x00
112 #define BOOSTINV_CFG_IRAMP_1uA 0x00
113 #define BOOSTINV_CFG_IRAMP_2uA 0x08
114 #define BOOSTINV_CFG_IRAMP_4uA 0x10
115 #define BOOSTINV_CFG_IRAMP_8uA 0x18
116 #define BOOSTINV_CFG_PDDIS_ENABLE 0x04
117 #define BOOSTINV_CFG_PDDIS_DISABLE 0x00
118 #define BOOSTINV_CFG_PUSEQ_OUTPUTS_DISABLED 0x00
119 #define BOOSTINV_CFG_PUSEQ_VOUTN_RAMP_1ST 0x01
120 #define BOOSTINV_CFG_PUSEQ_VOUTP_RAMP_1ST 0x02
121 #define BOOSTINV_CFG_PUSEQ_BOTH_RAMP_TOGETHER 0x03
122 
128 #define BOOSTINV_CMD_WRITE_OTP_MEMORY 0x80
129 #define BOOSTINV_CMD_CLEAR_OTP_FAULT 0x40
130 #define BOOSTINV_CMD_RESET 0x20
131 #define BOOSTINV_CMD_SWITCHES_OFF 0x10
132 #define BOOSTINV_CMD_REGISTER_SELECT_POS_VOUT 0x04
133 #define BOOSTINV_CMD_REGISTER_SELECT_NEG_VOUT 0x02
134 #define BOOSTINV_CMD_REGISTER_SELECT_CONFIG 0x01
135 #define BOOSTINV_CMD_REGISTER_SELECT_OTP2 0x00
136 #define BOOSTINV_CMD_REGISTER_SELECT_OTP1 0x00
137 #define BOOSTINV_CMD_REGISTER_SELECT_OTP0 0x00
138 
144 #define BOOSTINV_VOLTAGE_POSITIVE_3200_mV 3200
145 #define BOOSTINV_VOLTAGE_POSITIVE_7750_mV 7750
146 #define BOOSTINV_VOLTAGE_POSITIVE_12000_mV 12000
147 #define BOOSTINV_VOLTAGE_NEGATIVE_1450_mV -1450
148 #define BOOSTINV_VOLTAGE_NEGATIVE_6700_mV -6700
149 #define BOOSTINV_VOLTAGE_NEGATIVE_11050_mV -11050
150  // End group macro
153 // --------------------------------------------------------------- PUBLIC TYPES
162 typedef struct
163 {
164  // Output pins
165 
166  digital_out_t en;
167 
168  // Modules
169 
170  i2c_master_t i2c;
171 
172  // ctx variable
173 
174  uint8_t slave_address;
175 
176 } boostinv_t;
177 
181 typedef struct
182 {
183  // Communication gpio pins
184 
185  pin_name_t scl;
186  pin_name_t sda;
187 
188  // Additional gpio pins
189 
190  pin_name_t en;
191 
192  // static variable
193 
194  uint32_t i2c_speed;
195  uint8_t i2c_address;
196 
198  // End types group
200 
201 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
202 
208 #ifdef __cplusplus
209 extern "C"{
210 #endif
211 
221 
230 
264 
274 void boostinv_generic_write ( boostinv_t *ctx, uint8_t reg_addr, uint8_t tx_data );
275 
286 uint8_t boostinv_generic_read ( boostinv_t *ctx, uint8_t reg_addr );
287 
296 
306 void boostinv_set_positive_voltage ( boostinv_t *ctx, uint16_t voltage );
307 
317 void boostinv_set_negative_voltage ( boostinv_t *ctx, int16_t voltage );
318 
319 #ifdef __cplusplus
320 }
321 #endif
322 #endif // _BOOSTINV_H_
323  // End public_function group
326 
327 // ------------------------------------------------------------------------- END
boostinv_t::i2c
i2c_master_t i2c
Definition: boostinv.h:170
BOOSTINV_RETVAL
#define BOOSTINV_RETVAL
Definition: boostinv.h:77
boostinv_cfg_t::scl
pin_name_t scl
Definition: boostinv.h:185
boostinv_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: boostinv.h:194
boostinv_cfg_t::i2c_address
uint8_t i2c_address
Definition: boostinv.h:195
boostinv_cfg_t
Click configuration structure definition.
Definition: boostinv.h:182
boostinv_cfg_t::en
pin_name_t en
Definition: boostinv.h:190
boostinv_t::en
digital_out_t en
Definition: boostinv.h:166
boostinv_default_cfg
void boostinv_default_cfg(boostinv_t *ctx)
Click Default Configuration function.
boostinv_cfg_setup
void boostinv_cfg_setup(boostinv_cfg_t *cfg)
Config Object Initialization function.
boostinv_t
Click ctx object definition.
Definition: boostinv.h:163
boostinv_set_positive_voltage
void boostinv_set_positive_voltage(boostinv_t *ctx, uint16_t voltage)
Functions for set positive output voltage.
boostinv_init
BOOSTINV_RETVAL boostinv_init(boostinv_t *ctx, boostinv_cfg_t *cfg)
Initialization function.
boostinv_cfg_t::sda
pin_name_t sda
Definition: boostinv.h:186
boostinv_generic_read
uint8_t boostinv_generic_read(boostinv_t *ctx, uint8_t reg_addr)
Generic read function.
boostinv_enable
void boostinv_enable(boostinv_t *ctx)
Functions for enable chip.
boostinv_t::slave_address
uint8_t slave_address
Definition: boostinv.h:174
boostinv_set_negative_voltage
void boostinv_set_negative_voltage(boostinv_t *ctx, int16_t voltage)
Functions for set negative output voltage.
boostinv_generic_write
void boostinv_generic_write(boostinv_t *ctx, uint8_t reg_addr, uint8_t tx_data)
Functions for write one byte in register.