buck14 2.0.0.0
buck14.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 BUCK14_H
36#define BUCK14_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// -------------------------------------------------------------- PUBLIC MACROS
66#define BUCK14_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
68 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
69 cfg.pg = MIKROBUS( mikrobus, MIKROBUS_AN ); \
70 cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
71 cfg.syn = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
72 cfg.alr = MIKROBUS( mikrobus, MIKROBUS_INT );
79#define BUCK14_RETVAL uint8_t
80
81#define BUCK14_OK 0x00
82#define BUCK14_INIT_ERROR 0xFF
89#define BUCK14_SLAVE_ADDR 0x0A
96#define BUCK14_CMD_OPERATION 0x01
97#define BUCK14_CMD_ON_OFF_CONFIG 0x02
98#define BUCK14_CMD_WRITE_PROTECT 0x10
105#define BUCK14_CMD_CAPABILITY 0x19
106#define BUCK14_CMD_VOUT_MODE 0x20
107#define BUCK14_CMD_VOUT_COMMAND 0x21
108#define BUCK14_CMD_VOUT_TRIM 0x22
109#define BUCK14_CMD_VOUT_CAL_OFFSET 0x23
110#define BUCK14_CMD_VOUT_MAX 0x24
111#define BUCK14_CMD_VOUT_MARGIN_HIGH 0x25
112#define BUCK14_CMD_VOUT_MARGIN_LOW 0x26
113#define BUCK14_CMD_VOUT_TRANSITION_RATE 0x27
114#define BUCK14_CMD_VOUT_DROOP 0x28
115#define BUCK14_CMD_FREQUENCY_SWITCH 0x33
116#define BUCK14_CMD_VIN_ON 0x35
117#define BUCK14_CMD_VIN_OFF 0x36
118#define BUCK14_CMD_IOUT_CAL_GAIN 0x38
119#define BUCK14_CMD_IOUT_CAL_OFFSET 0x39
126#define BUCK14_CMD_FAULT_POWER_GOOD_ON 0x5E
127#define BUCK14_CMD_FAULT_POWERGOOD_OFF 0x5F
128#define BUCK14_CMD_VOUT_OC_FAULT_LIMIT 0x40
129#define BUCK14_CMD_VOUT_UV_FAULT_LIMIT 0x44
130#define BUCK14_CMD_IOUT_OC_FAULT_LIMIT 0x46
131#define BUCK14_CMD_OT_FAULT_LIMIT 0x4F
132#define BUCK14_CMD_OT_WARN_LIMIT 0x51
133#define BUCK14_CMD_VIN_OV_FAULT_LIMIT 0x55
134#define BUCK14_CMD_VIN_UV_FAULT_LIMIT 0x59
141#define BUCK14_CMD_VOUT_OV_FAULT_RESPONSE 0x41
142#define BUCK14_CMD_VOUT_UV_FAULT_RESPONSE 0x45
143#define BUCK14_CMD_OT_FAULT_RESPONSE 0x50
144#define BUCK14_CMD_VIN_OV_FAULT_RESPONSE 0x56
145#define BUCK14_CMD_VIN_UV_FAULT_RESPONSE 0x5A
146#define BUCK14_CMD_IOUT_OC_FAULT_RESPONSE 0x47
147#define BUCK14_CMD_TON_MAX_FAULT_RESPONSE 0x63
154#define BUCK14_CMD_TON_DELAY 0x60
155#define BUCK14_CMD_TON_RISE 0x61
156#define BUCK14_CMD_TOFF_DELAY 0x64
157#define BUCK14_CMD_TOFF_FALL 0x65
158#define BUCK14_CMD_TON_MAX_FAULT_LIMIT 0x62
165#define BUCK14_CMD_CLEAR_FAULTS 0x03
166#define BUCK14_CMD_STATUS_BYTE 0x78
167#define BUCK14_CMD_STATUS_WORD 0x79
168#define BUCK14_CMD_STATUS_VOUT 0x7A
169#define BUCK14_CMD_STATUS_IOUT 0x7B
170#define BUCK14_CMD_STATUS_INPUT 0x7C
171#define BUCK14_CMD_STATUS_TEMPERATURE 0x7D
172#define BUCK14_CMD_STATUS_CML 0x7E
173#define BUCK14_CMD_STATUS_MFR_SPECIFIC 0x80
180#define BUCK14_CMD_READ_VIN 0x88
181#define BUCK14_CMD_READ_VOUT 0x8B
182#define BUCK14_CMD_READ_IOUT 0x8C
183#define BUCK14_CMD_READ_TEMPERATURE_1 0x8D
184#define BUCK14_CMD_READ_TEMPERATURE_2 0x8E
185#define BUCK14_CMD_READ_DUTY_CYCLE 0x94
186#define BUCK14_CMD_READ_FREQUENCY 0x95
193#define BUCK14_CMD_INTERLEAVE 0x37
200#define BUCK14_CMD_PMBUS_REVISION 0x98
201#define BUCK14_CMD_MFR_ID 0x99
202#define BUCK14_CMD_MFR_MODEL 0x9A
203#define BUCK14_CMD_MFR_REVISION 0x9B
204#define BUCK14_CMD_MFR_LOCATION 0x9C
205#define BUCK14_CMD_MFR_DATE 0x9D
206#define BUCK14_CMD_MFR_SERIAL 0x9E
207#define BUCK14_CMD_IC_DEVICE_ID 0xAD
208#define BUCK14_CMD_IC_DEVICE_REV 0xAE
215#define BUCK14_CMD_STORE_DEFAULT_ALL 0x11
216#define BUCK14_CMD_RESTORE_DEFAUL_ALL 0x12
217#define BUCK14_CMD_STORE_USER_ALL 0x15
218#define BUCK14_CMD_RESTORE_USER_ALL 0x16
225#define BUCK14_CMD_ADAPTIVE_MODE 0xD0
226#define BUCK14_CMD_FEEDBACK_EFFORT 0xD3
227#define BUCK14_CMD_LOOP_CONFIG 0xD5
228#define BUCK14_CMD_TEST_MODE 0xD9
229#define BUCK14_CMD_COMP_MODEL 0xDB
230#define BUCK14_CMD_STRAP_DISABLE 0xDC
231#define BUCK14_CMD_MANUF_CONF 0xE0
232#define BUCK14_CMD_MANUF_LOCK 0xE1
233#define BUCK14_CMD_MANUF_PASSWD 0xE2
234#define BUCK14_CMD_USER_CONF 0xE3
235#define BUCK14_CMD_USER_LOCK 0xE4
236#define BUCK14_CMD_USER_PASSWD 0xE5
237#define BUCK14_CMD_SECURITY_LEVVEL 0xE6
238#define BUCK14_CMD_DEADTIME_GCTRL 0xE7
239#define BUCK14_CMD_ZETAP 0xE8
246#define BUCK14_CTRL_DISABLE 0x00
247#define BUCK14_CTRL_SOFT_DISABLE 0x60
248#define BUCK14_CTRL_ENABLE_NO_MARGIN 0x80
249#define BUCK14_CTRL_ENABLE_LOW_MARGIN1 0x96
250#define BUCK14_CTRL_ENABLE_LOW_MARGIN2 0x98
251#define BUCK14_CTRL_ENABLE_HIGH_MARGIN1 0xA6
252#define BUCK14_CTRL_ENABLE_HIGH_MARGIN2 0xA8
259#define BUCK14_VOUT_MODE_EXPONENT_12 0x14
260#define BUCK14_VOUT_MODE_EXPONENT_13 0x13
261#define BUCK14_VOUT_MODE_VALUE 0.000244
268#define BUCK14_PIN_STATE_HIGH 1
269#define BUCK14_PIN_STATE_LOW 0
276#define BUCK14_SUCCESSFUL 0xAA
277#define BUCK14_ID_ERROR 0xBB
278#define BUCK14_CMD_ERROR 0xCC
279#define BUCK14_ERROR 0xDD
286#define BUCK14_AMODE_CALIB_CONT_RAMP_UP 0x4B
289 // End group macro
290// --------------------------------------------------------------- PUBLIC TYPES
299typedef struct
300{
301 // Output pins
302
303 digital_out_t en;
304 digital_out_t syn;
305
306 // Input pins
307
308 digital_in_t pg;
309 digital_in_t alr;
310
311 // Modules
312
313 i2c_master_t i2c;
314
315 // ctx variable
316
318
319} buck14_t;
320
324typedef struct
325{
326 // Communication gpio pins
327
328 pin_name_t scl;
329 pin_name_t sda;
330
331 // Additional gpio pins
332
333 pin_name_t pg;
334 pin_name_t en;
335 pin_name_t syn;
336 pin_name_t alr;
337
338 // static variable
339
340 uint32_t i2c_speed;
341 uint8_t i2c_address;
342
344
345 // End types group
346// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
347
353#ifdef __cplusplus
354extern "C"{
355#endif
356
366
375
384
395void buck14_generic_write ( buck14_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
396
407void buck14_generic_read ( buck14_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
408
417void buck14_power_ctrl ( buck14_t *ctx, uint8_t state );
418
427void buck14_power_sync ( buck14_t *ctx, uint8_t state );
428
437
445uint8_t buck14_salert ( buck14_t *ctx );
446
455
463void buck14_reset ( buck14_t *ctx );
464
472uint16_t buc14_read_vout ( buck14_t *ctx );
473
482uint8_t buc14_write_vout ( buck14_t *ctx, float vout );
483
484#ifdef __cplusplus
485}
486#endif
487#endif // _BUCK14_H_
488
489 // End public_function group
491
492// ------------------------------------------------------------------------- END
#define BUCK14_RETVAL
Definition buck14.h:79
uint8_t buck14_power_good(buck14_t *ctx)
Get power good function.
void buck14_reset(buck14_t *ctx)
Reset function.
void buck14_power_ctrl(buck14_t *ctx, uint8_t state)
Set power ctrl function.
uint16_t buc14_read_vout(buck14_t *ctx)
Read Vout function.
uint8_t buck14_check_mfr_id(buck14_t *ctx)
Fucntion for checking manufacturer id.
void buck14_default_cfg(buck14_t *ctx)
Click Default Configuration function.
void buck14_power_sync(buck14_t *ctx, uint8_t state)
Set power sync function.
void buck14_generic_write(buck14_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
uint8_t buck14_salert(buck14_t *ctx)
Get alert function.
BUCK14_RETVAL buck14_init(buck14_t *ctx, buck14_cfg_t *cfg)
Initialization function.
void buck14_cfg_setup(buck14_cfg_t *cfg)
Config Object Initialization function.
void buck14_generic_read(buck14_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
uint8_t buc14_write_vout(buck14_t *ctx, float vout)
Set Vout function.
Click configuration structure definition.
Definition buck14.h:325
pin_name_t alr
Definition buck14.h:336
uint32_t i2c_speed
Definition buck14.h:340
pin_name_t scl
Definition buck14.h:328
pin_name_t en
Definition buck14.h:334
pin_name_t sda
Definition buck14.h:329
pin_name_t pg
Definition buck14.h:333
pin_name_t syn
Definition buck14.h:335
uint8_t i2c_address
Definition buck14.h:341
Click ctx object definition.
Definition buck14.h:300
digital_in_t alr
Definition buck14.h:309
digital_out_t syn
Definition buck14.h:304
i2c_master_t i2c
Definition buck14.h:313
digital_out_t en
Definition buck14.h:303
uint8_t slave_address
Definition buck14.h:317
digital_in_t pg
Definition buck14.h:308