stepdown6 2.1.0.0
stepdown6.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 STEPDOWN6_H
29#define STEPDOWN6_H
30
31#ifdef __cplusplus
32extern "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 STEPDOWN6_REG_BUCK1_CTRL1 0x00
74#define STEPDOWN6_REG_BUCK1_CTRL2 0x01
75#define STEPDOWN6_REG_BUCK1_CTRL3 0x02
76#define STEPDOWN6_REG_BUCK2_CTRL1 0x03
77#define STEPDOWN6_REG_BUCK2_CTRL2 0x04
78#define STEPDOWN6_REG_BUCK2_CTRL3 0x05
79#define STEPDOWN6_REG_BUCK3_CTRL1 0x06
80#define STEPDOWN6_REG_BUCK3_CTRL2 0x07
81#define STEPDOWN6_REG_BUCK3_CTRL3 0x08
82#define STEPDOWN6_REG_BUCK4_CTRL1 0x09
83#define STEPDOWN6_REG_BUCK4_CTRL2 0x0A
84#define STEPDOWN6_REG_BUCK4_CTRL3 0x0B
85#define STEPDOWN6_REG_SYSTEM_CTRL1 0x0C
86#define STEPDOWN6_REG_SYSTEM_CTRL2 0x0D
87#define STEPDOWN6_REG_SYSTEM_CTRL3 0x0E
88#define STEPDOWN6_REG_SYSTEM_CTRL4 0x0F
89#define STEPDOWN6_REG_SYSTEM_CTRL5 0x10
90#define STEPDOWN6_REG_SYSTEM_CTRL6 0x11
91#define STEPDOWN6_REG_STATUS 0x12
92#define STEPDOWN6_REG_SYSTEM_CTRL7 0x13
93
94 // stepdown6_reg
95
115#define STEPDOWN6_SOFT_START_DLY_0_MS 0x00
116#define STEPDOWN6_SOFT_START_DLY_1_MS 0x10
117#define STEPDOWN6_SOFT_START_DLY_2_MS 0x20
118#define STEPDOWN6_SOFT_START_DLY_3_MS 0x30
119#define STEPDOWN6_SOFT_ADD_DLY_100_US 0x08
120#define STEPDOWN6_SOFT_START_CFG0 0x00
121#define STEPDOWN6_SOFT_START_CFG1 0x01
122#define STEPDOWN6_SOFT_START_CFG2 0x02
123#define STEPDOWN6_SOFT_START_CFG3 0x03
124#define STEPDOWN6_SOFT_START_CFG4 0x04
125#define STEPDOWN6_SOFT_START_CFG5 0x05
126#define STEPDOWN6_SOFT_START_CFG6 0x06
127#define STEPDOWN6_SOFT_START_CFG7 0x07
128
133#define STEPDOWN6_VOUT_LIMIT_FB_EN 0x80
134#define STEPDOWN6_VOUT_LIMIT_I2C_EN 0x00
135#define STEPDOWN6_MODE_AUTO_PWM 0x00
136#define STEPDOWN6_MODE_FORCED_PWM 0x40
137#define STEPDOWN6_CURRENT_LIM_1A 0x00
138#define STEPDOWN6_CURRENT_LIM_2A 0x10
139#define STEPDOWN6_CURRENT_LIM_3A 0x20
140#define STEPDOWN6_CURRENT_LIM_4A 0x30
141#define STEPDOWN6_VOUT_OVP_EN 0x08
142#define STEPDOWN6_PH_DELAY_0 0x00
143#define STEPDOWN6_PH_DELAY_90 0x02
144#define STEPDOWN6_PH_DELAY_180 0x04
145#define STEPDOWN6_PH_DELAY_270 0x06
146#define STEPDOWN6_VOUT_DIS_EN 0x01
147
152#define STEPDOWN6_VOUT_SELECT 0x80
153#define STEPDOWN6_VOUT_REF 0x7F
154
159#define STEPDOWN6_EN1_OUTPUT 0x80
160#define STEPDOWN6_EN2_OUTPUT 0x40
161#define STEPDOWN6_EN3_OUTPUT 0x20
162#define STEPDOWN6_EN4_OUTPUT 0x10
163#define STEPDOWN6_UVLO_TH_3V5 0x00
164#define STEPDOWN6_UVLO_TH_4V5 0x02
165#define STEPDOWN6_UVLO_TH_5V8 0x04
166#define STEPDOWN6_UVLO_TH_8V5 0x06
167
172#define STEPDOWN6_FREQ_533_HZ 0x00
173#define STEPDOWN6_FREQ_800_HZ 0x40
174#define STEPDOWN6_FREQ_1060_HZ 0x80
175#define STEPDOWN6_FREQ_1600_HZ 0xC0
176#define STEPDOWN6_SHUTDOWN_DELAY_EN 0x20
177
182#define STEPDOWN6_PG_DELAY_200_US 0x00
183#define STEPDOWN6_PG_DELAY_5_MS 0x04
184#define STEPDOWN6_PG_DELAY_25_MS 0x08
185#define STEPDOWN6_PG_DELAY_75_MS 0x0C
186#define STEPDOWN6_PG_DELAY_200_MS 0x10
187#define STEPDOWN6_PARALLEL_2_EN 0x02
188#define STEPDOWN6_PARALLEL_1_EN 0x01
189
194#define STEPDOWN6_SELECT_VOUT1 0x00
195#define STEPDOWN6_SELECT_VOUT2 0x01
196#define STEPDOWN6_SELECT_VOUT3 0x02
197#define STEPDOWN6_SELECT_VOUT4 0x03
198
203#define STEPDOWN6_PIN_STATE_HIGH 0x01
204#define STEPDOWN6_PIN_STATE_LOW 0x00
205
210#define STEPDOWN6_MIN_VOUT_VAL 550
211#define STEPDOWN6_MAX_VOUT_VAL 1820
212#define STEPDOWN6_INCREMENT_VOUT_VAL 10
213
219#define STEPDOWN6_DEVICE_ADDRESS 0x68
220
221 // stepdown6_set
222
237#define STEPDOWN6_MAP_MIKROBUS( cfg, mikrobus ) \
238 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
239 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
240 cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST )
241
242 // stepdown6_map
243 // stepdown6
244
249typedef struct
250{
251 // Output pins
252 digital_out_t en;
254 // Modules
255 i2c_master_t i2c;
257 // I2C slave address
261
266typedef struct
267{
268 pin_name_t scl;
269 pin_name_t sda;
271 pin_name_t en;
273 uint32_t i2c_speed;
274 uint8_t i2c_address;
277
288
305
320
334
349err_t stepdown6_generic_write ( stepdown6_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len );
350
365err_t stepdown6_generic_read ( stepdown6_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len );
366
376void stepdown6_set_en_pin ( stepdown6_t *ctx, uint8_t pin_state );
377
391err_t stepdown6_write_reg ( stepdown6_t *ctx, uint8_t reg, uint8_t data_in );
392
406err_t stepdown6_read_reg ( stepdown6_t *ctx, uint8_t reg, uint8_t *data_out );
407
420err_t stepdown6_set_out_voltage ( stepdown6_t *ctx, uint8_t out_sel, uint16_t out_val );
421
422#ifdef __cplusplus
423}
424#endif
425#endif // STEPDOWN6_H
426
427 // stepdown6
428
429// ------------------------------------------------------------------------ END
err_t stepdown6_read_reg(stepdown6_t *ctx, uint8_t reg, uint8_t *data_out)
Step Down 6 Register reading function.
err_t stepdown6_set_out_voltage(stepdown6_t *ctx, uint8_t out_sel, uint16_t out_val)
Step Down 6 Set output voltage function.
err_t stepdown6_default_cfg(stepdown6_t *ctx)
Step Down 6 default configuration function.
void stepdown6_cfg_setup(stepdown6_cfg_t *cfg)
Step Down 6 configuration object setup function.
err_t stepdown6_generic_write(stepdown6_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Step Down 6 I2C writing function.
err_t stepdown6_init(stepdown6_t *ctx, stepdown6_cfg_t *cfg)
Step Down 6 initialization function.
void stepdown6_set_en_pin(stepdown6_t *ctx, uint8_t pin_state)
Step Down 6 set EN pin state function.
err_t stepdown6_write_reg(stepdown6_t *ctx, uint8_t reg, uint8_t data_in)
Step Down 6 Register writing function.
err_t stepdown6_generic_read(stepdown6_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Step Down 6 I2C reading function.
stepdown6_return_value_t
Step Down 6 Click return value data.
Definition stepdown6.h:283
@ STEPDOWN6_ERROR
Definition stepdown6.h:285
@ STEPDOWN6_OK
Definition stepdown6.h:284
Step Down 6 Click configuration object.
Definition stepdown6.h:267
uint32_t i2c_speed
Definition stepdown6.h:273
pin_name_t scl
Definition stepdown6.h:268
pin_name_t en
Definition stepdown6.h:271
pin_name_t sda
Definition stepdown6.h:269
uint8_t i2c_address
Definition stepdown6.h:274
Step Down 6 Click context object.
Definition stepdown6.h:250
i2c_master_t i2c
Definition stepdown6.h:255
digital_out_t en
Definition stepdown6.h:252
uint8_t slave_address
Definition stepdown6.h:258