mic24045 2.0.0.0
mic24045.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 MIC24045_H
36#define MIC24045_H
37
38#include "drv_digital_out.h"
39#include "drv_digital_in.h"
40#include "drv_i2c_master.h"
41
42// -------------------------------------------------------------- PUBLIC MACROS
52#define MIC24045_MAP_MIKROBUS( cfg, mikrobus ) \
53 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
54 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
55 cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST ); \
56 cfg.pg = MIKROBUS( mikrobus, MIKROBUS_INT )
63#define MIC24045_RETVAL uint8_t
64
65#define MIC24045_OK 0x00
66#define MIC24045_INIT_ERROR 0xFF
73#define MIC24045_I2C_ADDRESS 0x50
74
81#define MIC24045_REG_STATUS 0x00
82#define MIC24045_REG_SETTINGS1 0x01
83#define MIC24045_REG_SETTINGS2 0x02
84#define MIC24045_REG_VOUT 0x03
85#define MIC24045_REG_COMMAND 0x04
92#define MIC24045_BIT_PGS 0x01
93#define MIC24045_BIT_ENS 0x08
94#define MIC24045_BIT_THWRNF 0x20
95#define MIC24045_BIT_THSDF 0x40
96#define MIC24045_BIT_OCF 0x80
97#define MIC24045_BIT_CIFF 0x01
104#define MIC24045_SETTING_CURRENT_NORMAL_LOAD_2_A 0x00
105#define MIC24045_SETTING_CURRENT_NORMAL_LOAD_3_A 0x40
106#define MIC24045_SETTING_CURRENT_NORMAL_LOAD_4_A 0x80
107#define MIC24045_SETTING_CURRENT_NORMAL_LOAD_5_A 0xC0
114#define MIC24045_SETTING_FREQUENCY_310_kHz 0x00
115#define MIC24045_SETTING_FREQUENCY_400_kHz 0x08
116#define MIC24045_SETTING_FREQUENCY_500_kHz 0x10
117#define MIC24045_SETTING_FREQUENCY_570_kHz 0x18
118#define MIC24045_SETTING_FREQUENCY_660_kHz 0x20
119#define MIC24045_SETTING_FREQUENCY_780_kHz 0x28
120#define MIC24045_SETTING_FREQUENCY_970_kHz 0x30
121#define MIC24045_SETTING_FREQUENCY_1200_kHz 0x38
128#define MIC24045_SETTING_START_UP_DELAY_0_ms 0x00
129#define MIC24045_SETTING_START_UP_DELAY_0_5_ms 0x10
130#define MIC24045_SETTING_START_UP_DELAY_1_ms 0x20
131#define MIC24045_SETTING_START_UP_DELAY_2_ms 0x30
132#define MIC24045_SETTING_START_UP_DELAY_4_ms 0x40
133#define MIC24045_SETTING_START_UP_DELAY_6_ms 0x50
134#define MIC24045_SETTING_START_UP_DELAY_8_ms 0x60
135#define MIC24045_SETTING_START_UP_DELAY_10_ms 0x70
142#define MIC24045_SETTING_CHANGE_NOMINAL_0_PERC 0x00
143#define MIC24045_SETTING_CHANGE_NOMINAL_NEG_5_PERC 0x04
144#define MIC24045_SETTING_CHANGE_NOMINAL_POS_5_PERC 0x08
145#define MIC24045_SETTING_CHANGE_NOMINAL_POS_5_0_PERC 0x0C
152#define MIC24045_SETTING_SOFT_START_SLOPE_0_16_Vms 0x00
153#define MIC24045_SETTING_SOFT_START_SLOPE_0_38_Vms 0x01
154#define MIC24045_SETTING_SOFT_START_SLOPE_0_76_Vms 0x02
155#define MIC24045_SETTING_SOFT_START_SLOPE_1_50_Vms 0x03
162#define MIC24045_MAX_VOUT 5.250
163#define MIC24045_MIN_VOUT 0.640
164#define MIC24045_MAX_VOUT_DEC 0xFF
165#define MIC24045_MIN_VOUT_DEC 0x00 // End group macro
169// --------------------------------------------------------------- PUBLIC TYPES
178typedef struct
179{
180 // Output pins
181
182 digital_out_t en;
183
184 // Input pins
185
186 digital_in_t pg;
187
188 // Modules
189
190 i2c_master_t i2c;
191
192 // ctx variable
193
195
196} mic24045_t;
197
201typedef struct
202{
203 // Communication gpio pins
204
205 pin_name_t scl;
206 pin_name_t sda;
207
208 // Additional gpio pins
209
210 pin_name_t en;
211 pin_name_t pg;
212
213 // static variable
214
215 uint32_t i2c_speed;
216 uint8_t i2c_address;
217
219 // End types group
221// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
222
228#ifdef __cplusplus
229extern "C"{
230#endif
231
241
251
262void mic24045_generic_write ( mic24045_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
263
275void mic24045_generic_read ( mic24045_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
276
285
294
303void mic24045_set_vout( mic24045_t *ctx, float v_out );
304
317void mic24045_set_vout_decimal ( mic24045_t *ctx, uint8_t dec );
318
327
336
345
346#ifdef __cplusplus
347}
348#endif
349#endif // _MIC24045_H_
350 // End public_function group
353
354// ------------------------------------------------------------------------- END
#define MIC24045_RETVAL
Definition: mic24045.h:63
uint8_t mic24045_get_status(mic24045_t *ctx)
Get status function.
MIC24045_RETVAL mic24045_init(mic24045_t *ctx, mic24045_cfg_t *cfg)
Initialization function.
void mic24045_disable(mic24045_t *ctx)
Disable voltage output.
void mic24045_set_vout(mic24045_t *ctx, float v_out)
Set voltage.
void mic24045_cfg_setup(mic24045_cfg_t *cfg)
Config Object Initialization function.
void mic24045_set_vout_decimal(mic24045_t *ctx, uint8_t dec)
Set voltage decimal.
void mic24045_generic_read(mic24045_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
float mic24045_get_vout(mic24045_t *ctx)
Get voltage.
void mic24045_enable(mic24045_t *ctx)
Enable voltage output.
void mic24045_generic_write(mic24045_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
uint8_t mic24045_get_power_good_state(mic24045_t *ctx)
Get power good state.
Click configuration structure definition.
Definition: mic24045.h:202
uint32_t i2c_speed
Definition: mic24045.h:215
pin_name_t scl
Definition: mic24045.h:205
pin_name_t en
Definition: mic24045.h:210
pin_name_t sda
Definition: mic24045.h:206
pin_name_t pg
Definition: mic24045.h:211
uint8_t i2c_address
Definition: mic24045.h:216
Click ctx object definition.
Definition: mic24045.h:179
i2c_master_t i2c
Definition: mic24045.h:190
digital_out_t en
Definition: mic24045.h:182
uint8_t slave_address
Definition: mic24045.h:194
digital_in_t pg
Definition: mic24045.h:186