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 
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 BUCK15_INSTR_RDAC_SEL_1 0x00
70 #define BUCK15_INSTR_RDAC_SEL_2 0x80
71 
76 #define BUCK15_INSTR_RDAC_MIDSCALE_DIS 0x00
77 #define BUCK15_INSTR_RDAC_MIDSCALE_EN 0x40
78 
83 #define BUCK15_INSTR_RDAC_SHUTDOWN_DIS 0x00
84 #define BUCK15_INSTR_RDAC_SHUTDOWN_EN 0x20
85 
90 #define BUCK15_INSTR_RDAC_OTUPUT_0 0x00
91 #define BUCK15_INSTR_RDAC_OTUPUT_1 0x08
92 #define BUCK15_INSTR_RDAC_OTUPUT_2 0x10
93 #define BUCK15_INSTR_RDAC_OTUPUT_3 0x18
94 
99 #define BUCK15_VOS_WIPER_POS 255, 175, 128, 128, 128, 199, 105, \
100  81, 91, 80, 79, 70, 69, 132, 130, \
101  130, 38, 102, 71, 8, 5, 1
102 
107 #define BUCK15_VSET_WIPER_POS 1, 10, 63, 101, 146, 218, 180, 175, \
108  185, 190, 200, 200, 205, 225, 227, \
109  228, 211, 235, 252, 254, 254, 255
110 
115 #define BUCK15_VOUT_TABLE 0.6f, 0.8f, 1.0f, 1.1f, 1.3f, 1.5f, \
116  1.8f, 1.9f, 2.0f, 2.2f, 2.5f, 2.6f, \
117  2.8f, 3.0f, 3.2f, 3.3f, 3.5f, 3.8f, \
118  4.0f, 4.3f, 4.6f, 5.0f
119 
120 
126 #define BUCK15_DEVICE_ADDRESS_GND 0x2C
127 #define BUCK15_DEVICE_ADDRESS_VCC 0x2D
128  // buck15_set
130 
145 #define BUCK15_MAP_MIKROBUS( cfg, mikrobus ) \
146  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
147  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
148  cfg.en = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
149  cfg.pg = MIKROBUS( mikrobus, MIKROBUS_INT )
150  // buck15_map // buck15
153 
158 typedef struct
159 {
160  // Output pins
161  digital_out_t en;
163  // Input pins
164  digital_in_t pg;
166  // Modules
167  i2c_master_t i2c;
169  // I2C slave address
170  uint8_t slave_address;
172 } buck15_t;
173 
178 typedef struct
179 {
180  pin_name_t scl;
181  pin_name_t sda;
183  pin_name_t en;
184  pin_name_t pg;
186  uint32_t i2c_speed;
187  uint8_t i2c_address;
189 } buck15_cfg_t;
190 
195 typedef enum
196 {
198  BUCK15_ERROR = -1
199 
201 
206 typedef enum
207 {
230 
231 } buck15_vout_t;
232 
249 
263 err_t buck15_init ( buck15_t *ctx, buck15_cfg_t *cfg );
264 
278 
290 
302 
314 
328 err_t buck15_generic_write ( buck15_t *ctx, uint8_t instr, uint8_t data_in );
329 
343 err_t buck15_generic_read ( buck15_t *ctx, uint8_t instr, uint8_t *data_out );
344 
357 err_t buck15_set_vset ( buck15_t *ctx, uint8_t vset_wp );
358 
371 err_t buck15_set_vos ( buck15_t *ctx, uint8_t vos_wp );
372 
387 
388 #ifdef __cplusplus
389 }
390 #endif
391 #endif // BUCK15_H
392  // buck15
394 
395 // ------------------------------------------------------------------------ END
BUCK15_VOUT_2V8
@ BUCK15_VOUT_2V8
Definition: buck15.h:220
BUCK15_VOUT_4V
@ BUCK15_VOUT_4V
Definition: buck15.h:226
BUCK15_VOUT_4V6
@ BUCK15_VOUT_4V6
Definition: buck15.h:228
BUCK15_VOUT_5V
@ BUCK15_VOUT_5V
Definition: buck15.h:229
buck15_disable_device
void buck15_disable_device(buck15_t *ctx)
Buck 15 disable device function.
BUCK15_VOUT_3V5
@ BUCK15_VOUT_3V5
Definition: buck15.h:224
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:159
BUCK15_VOUT_1V5
@ BUCK15_VOUT_1V5
Definition: buck15.h:213
buck15_cfg_t::sda
pin_name_t sda
Definition: buck15.h:181
BUCK15_VOUT_1V8
@ BUCK15_VOUT_1V8
Definition: buck15.h:214
buck15_cfg_t::pg
pin_name_t pg
Definition: buck15.h:184
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:210
buck15_cfg_t::en
pin_name_t en
Definition: buck15.h:183
BUCK15_VOUT_3V8
@ BUCK15_VOUT_3V8
Definition: buck15.h:225
buck15_t::i2c
i2c_master_t i2c
Definition: buck15.h:167
buck15_t::slave_address
uint8_t slave_address
Definition: buck15.h:170
BUCK15_VOUT_3V2
@ BUCK15_VOUT_3V2
Definition: buck15.h:222
buck15_cfg_t
Buck 15 Click configuration object.
Definition: buck15.h:179
BUCK15_VOUT_4V3
@ BUCK15_VOUT_4V3
Definition: buck15.h:227
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:219
buck15_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: buck15.h:186
BUCK15_VOUT_2V
@ BUCK15_VOUT_2V
Definition: buck15.h:216
buck15_cfg_t::scl
pin_name_t scl
Definition: buck15.h:180
BUCK15_ERROR
@ BUCK15_ERROR
Definition: buck15.h:198
BUCK15_VOUT_0V6
@ BUCK15_VOUT_0V6
Definition: buck15.h:208
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:217
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:207
buck15_t::en
digital_out_t en
Definition: buck15.h:161
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:218
BUCK15_OK
@ BUCK15_OK
Definition: buck15.h:197
BUCK15_VOUT_1V3
@ BUCK15_VOUT_1V3
Definition: buck15.h:212
BUCK15_VOUT_1V1
@ BUCK15_VOUT_1V1
Definition: buck15.h:211
buck15_t::pg
digital_in_t pg
Definition: buck15.h:164
BUCK15_VOUT_1V9
@ BUCK15_VOUT_1V9
Definition: buck15.h:215
BUCK15_VOUT_3V
@ BUCK15_VOUT_3V
Definition: buck15.h:221
buck15_return_value_t
buck15_return_value_t
Buck 15 Click return value data.
Definition: buck15.h:196
BUCK15_VOUT_0V8
@ BUCK15_VOUT_0V8
Definition: buck15.h:209
BUCK15_VOUT_3V3
@ BUCK15_VOUT_3V3
Definition: buck15.h:223
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:187
buck15_init
err_t buck15_init(buck15_t *ctx, buck15_cfg_t *cfg)
Buck 15 initialization function.