buck15  2.1.0.0
buck15.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 BUCK15_H
29 #define BUCK15_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 BUCK15_INSTR_RDAC_SEL_1 0x00
74 #define BUCK15_INSTR_RDAC_SEL_2 0x80
75 
80 #define BUCK15_INSTR_RDAC_MIDSCALE_DIS 0x00
81 #define BUCK15_INSTR_RDAC_MIDSCALE_EN 0x40
82 
87 #define BUCK15_INSTR_RDAC_SHUTDOWN_DIS 0x00
88 #define BUCK15_INSTR_RDAC_SHUTDOWN_EN 0x20
89 
94 #define BUCK15_INSTR_RDAC_OTUPUT_0 0x00
95 #define BUCK15_INSTR_RDAC_OTUPUT_1 0x08
96 #define BUCK15_INSTR_RDAC_OTUPUT_2 0x10
97 #define BUCK15_INSTR_RDAC_OTUPUT_3 0x18
98 
103 #define BUCK15_VOS_WIPER_POS 255, 175, 128, 128, 128, 199, 105, \
104  81, 91, 80, 79, 70, 69, 132, 130, \
105  130, 38, 102, 71, 8, 5, 1
106 
111 #define BUCK15_VSET_WIPER_POS 1, 10, 63, 101, 146, 218, 180, 175, \
112  185, 190, 200, 200, 205, 225, 227, \
113  228, 211, 235, 252, 254, 254, 255
114 
119 #define BUCK15_VOUT_TABLE 0.6f, 0.8f, 1.0f, 1.1f, 1.3f, 1.5f, \
120  1.8f, 1.9f, 2.0f, 2.2f, 2.5f, 2.6f, \
121  2.8f, 3.0f, 3.2f, 3.3f, 3.5f, 3.8f, \
122  4.0f, 4.3f, 4.6f, 5.0f
123 
124 
130 #define BUCK15_DEVICE_ADDRESS_GND 0x2C
131 #define BUCK15_DEVICE_ADDRESS_VCC 0x2D
132  // buck15_set
134 
149 #define BUCK15_MAP_MIKROBUS( cfg, mikrobus ) \
150  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
151  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
152  cfg.en = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
153  cfg.pg = MIKROBUS( mikrobus, MIKROBUS_INT )
154  // buck15_map // buck15
157 
162 typedef struct
163 {
164  // Output pins
165  digital_out_t en;
167  // Input pins
168  digital_in_t pg;
170  // Modules
171  i2c_master_t i2c;
173  // I2C slave address
174  uint8_t slave_address;
176 } buck15_t;
177 
182 typedef struct
183 {
184  pin_name_t scl;
185  pin_name_t sda;
187  pin_name_t en;
188  pin_name_t pg;
190  uint32_t i2c_speed;
191  uint8_t i2c_address;
193 } buck15_cfg_t;
194 
199 typedef enum
200 {
202  BUCK15_ERROR = -1
203 
205 
210 typedef enum
211 {
234 
235 } buck15_vout_t;
236 
253 
267 err_t buck15_init ( buck15_t *ctx, buck15_cfg_t *cfg );
268 
282 
294 
306 
318 
332 err_t buck15_generic_write ( buck15_t *ctx, uint8_t instr, uint8_t data_in );
333 
347 err_t buck15_generic_read ( buck15_t *ctx, uint8_t instr, uint8_t *data_out );
348 
361 err_t buck15_set_vset ( buck15_t *ctx, uint8_t vset_wp );
362 
375 err_t buck15_set_vos ( buck15_t *ctx, uint8_t vos_wp );
376 
391 
392 #ifdef __cplusplus
393 }
394 #endif
395 #endif // BUCK15_H
396  // buck15
398 
399 // ------------------------------------------------------------------------ END
BUCK15_VOUT_2V8
@ BUCK15_VOUT_2V8
Definition: buck15.h:224
BUCK15_VOUT_4V
@ BUCK15_VOUT_4V
Definition: buck15.h:230
BUCK15_VOUT_4V6
@ BUCK15_VOUT_4V6
Definition: buck15.h:232
BUCK15_VOUT_5V
@ BUCK15_VOUT_5V
Definition: buck15.h:233
buck15_disable_device
void buck15_disable_device(buck15_t *ctx)
Buck 15 disable device function.
BUCK15_VOUT_3V5
@ BUCK15_VOUT_3V5
Definition: buck15.h:228
buck15_generic_read
err_t buck15_generic_read(buck15_t *ctx, uint8_t instr, uint8_t *data_out)
Buck 15 I2C reading function.
buck15_t
Buck 15 Click context object.
Definition: buck15.h:163
BUCK15_VOUT_1V5
@ BUCK15_VOUT_1V5
Definition: buck15.h:217
buck15_cfg_t::sda
pin_name_t sda
Definition: buck15.h:185
BUCK15_VOUT_1V8
@ BUCK15_VOUT_1V8
Definition: buck15.h:218
buck15_cfg_t::pg
pin_name_t pg
Definition: buck15.h:188
buck15_set_vset
err_t buck15_set_vset(buck15_t *ctx, uint8_t vset_wp)
Buck 15 set VSET function.
BUCK15_VOUT_1V
@ BUCK15_VOUT_1V
Definition: buck15.h:214
buck15_cfg_t::en
pin_name_t en
Definition: buck15.h:187
BUCK15_VOUT_3V8
@ BUCK15_VOUT_3V8
Definition: buck15.h:229
buck15_t::i2c
i2c_master_t i2c
Definition: buck15.h:171
buck15_t::slave_address
uint8_t slave_address
Definition: buck15.h:174
BUCK15_VOUT_3V2
@ BUCK15_VOUT_3V2
Definition: buck15.h:226
buck15_cfg_t
Buck 15 Click configuration object.
Definition: buck15.h:183
BUCK15_VOUT_4V3
@ BUCK15_VOUT_4V3
Definition: buck15.h:231
buck15_default_cfg
err_t buck15_default_cfg(buck15_t *ctx)
Buck 15 default configuration function.
BUCK15_VOUT_2V6
@ BUCK15_VOUT_2V6
Definition: buck15.h:223
buck15_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: buck15.h:190
BUCK15_VOUT_2V
@ BUCK15_VOUT_2V
Definition: buck15.h:220
buck15_cfg_t::scl
pin_name_t scl
Definition: buck15.h:184
BUCK15_ERROR
@ BUCK15_ERROR
Definition: buck15.h:202
BUCK15_VOUT_0V6
@ BUCK15_VOUT_0V6
Definition: buck15.h:212
buck15_get_power_good
uint8_t buck15_get_power_good(buck15_t *ctx)
Buck 15 disable device function.
BUCK15_VOUT_2V2
@ BUCK15_VOUT_2V2
Definition: buck15.h:221
buck15_cfg_setup
void buck15_cfg_setup(buck15_cfg_t *cfg)
Buck 15 configuration object setup function.
buck15_set_vos
err_t buck15_set_vos(buck15_t *ctx, uint8_t vos_wp)
Buck 15 set VOS function.
buck15_vout_t
buck15_vout_t
Buck 15 output voltage values.
Definition: buck15.h:211
buck15_t::en
digital_out_t en
Definition: buck15.h:165
buck15_generic_write
err_t buck15_generic_write(buck15_t *ctx, uint8_t instr, uint8_t data_in)
Buck 15 I2C writing function.
buck15_set_vout
err_t buck15_set_vout(buck15_t *ctx, buck15_vout_t vout)
Buck 15 set VOUT function.
BUCK15_VOUT_2V5
@ BUCK15_VOUT_2V5
Definition: buck15.h:222
BUCK15_OK
@ BUCK15_OK
Definition: buck15.h:201
BUCK15_VOUT_1V3
@ BUCK15_VOUT_1V3
Definition: buck15.h:216
BUCK15_VOUT_1V1
@ BUCK15_VOUT_1V1
Definition: buck15.h:215
buck15_t::pg
digital_in_t pg
Definition: buck15.h:168
BUCK15_VOUT_1V9
@ BUCK15_VOUT_1V9
Definition: buck15.h:219
BUCK15_VOUT_3V
@ BUCK15_VOUT_3V
Definition: buck15.h:225
buck15_return_value_t
buck15_return_value_t
Buck 15 Click return value data.
Definition: buck15.h:200
BUCK15_VOUT_0V8
@ BUCK15_VOUT_0V8
Definition: buck15.h:213
BUCK15_VOUT_3V3
@ BUCK15_VOUT_3V3
Definition: buck15.h:227
buck15_enable_device
void buck15_enable_device(buck15_t *ctx)
Buck 15 enable device function.
buck15_cfg_t::i2c_address
uint8_t i2c_address
Definition: buck15.h:191
buck15_init
err_t buck15_init(buck15_t *ctx, buck15_cfg_t *cfg)
Buck 15 initialization function.