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
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 MIC24045_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
68 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
69 cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST ); \
70 cfg.pg = MIKROBUS( mikrobus, MIKROBUS_INT )
77#define MIC24045_RETVAL uint8_t
78
79#define MIC24045_OK 0x00
80#define MIC24045_INIT_ERROR 0xFF
87#define MIC24045_I2C_ADDRESS 0x50
88
95#define MIC24045_REG_STATUS 0x00
96#define MIC24045_REG_SETTINGS1 0x01
97#define MIC24045_REG_SETTINGS2 0x02
98#define MIC24045_REG_VOUT 0x03
99#define MIC24045_REG_COMMAND 0x04
106#define MIC24045_BIT_PGS 0x01
107#define MIC24045_BIT_ENS 0x08
108#define MIC24045_BIT_THWRNF 0x20
109#define MIC24045_BIT_THSDF 0x40
110#define MIC24045_BIT_OCF 0x80
111#define MIC24045_BIT_CIFF 0x01
118#define MIC24045_SETTING_CURRENT_NORMAL_LOAD_2_A 0x00
119#define MIC24045_SETTING_CURRENT_NORMAL_LOAD_3_A 0x40
120#define MIC24045_SETTING_CURRENT_NORMAL_LOAD_4_A 0x80
121#define MIC24045_SETTING_CURRENT_NORMAL_LOAD_5_A 0xC0
128#define MIC24045_SETTING_FREQUENCY_310_kHz 0x00
129#define MIC24045_SETTING_FREQUENCY_400_kHz 0x08
130#define MIC24045_SETTING_FREQUENCY_500_kHz 0x10
131#define MIC24045_SETTING_FREQUENCY_570_kHz 0x18
132#define MIC24045_SETTING_FREQUENCY_660_kHz 0x20
133#define MIC24045_SETTING_FREQUENCY_780_kHz 0x28
134#define MIC24045_SETTING_FREQUENCY_970_kHz 0x30
135#define MIC24045_SETTING_FREQUENCY_1200_kHz 0x38
142#define MIC24045_SETTING_START_UP_DELAY_0_ms 0x00
143#define MIC24045_SETTING_START_UP_DELAY_0_5_ms 0x10
144#define MIC24045_SETTING_START_UP_DELAY_1_ms 0x20
145#define MIC24045_SETTING_START_UP_DELAY_2_ms 0x30
146#define MIC24045_SETTING_START_UP_DELAY_4_ms 0x40
147#define MIC24045_SETTING_START_UP_DELAY_6_ms 0x50
148#define MIC24045_SETTING_START_UP_DELAY_8_ms 0x60
149#define MIC24045_SETTING_START_UP_DELAY_10_ms 0x70
156#define MIC24045_SETTING_CHANGE_NOMINAL_0_PERC 0x00
157#define MIC24045_SETTING_CHANGE_NOMINAL_NEG_5_PERC 0x04
158#define MIC24045_SETTING_CHANGE_NOMINAL_POS_5_PERC 0x08
159#define MIC24045_SETTING_CHANGE_NOMINAL_POS_5_0_PERC 0x0C
166#define MIC24045_SETTING_SOFT_START_SLOPE_0_16_Vms 0x00
167#define MIC24045_SETTING_SOFT_START_SLOPE_0_38_Vms 0x01
168#define MIC24045_SETTING_SOFT_START_SLOPE_0_76_Vms 0x02
169#define MIC24045_SETTING_SOFT_START_SLOPE_1_50_Vms 0x03
176#define MIC24045_MAX_VOUT 5.250
177#define MIC24045_MIN_VOUT 0.640
178#define MIC24045_MAX_VOUT_DEC 0xFF
179#define MIC24045_MIN_VOUT_DEC 0x00
182 // End group macro
183// --------------------------------------------------------------- PUBLIC TYPES
192typedef struct
193{
194 // Output pins
195
196 digital_out_t en;
197
198 // Input pins
199
200 digital_in_t pg;
201
202 // Modules
203
204 i2c_master_t i2c;
205
206 // ctx variable
207
209
210} mic24045_t;
211
215typedef struct
216{
217 // Communication gpio pins
218
219 pin_name_t scl;
220 pin_name_t sda;
221
222 // Additional gpio pins
223
224 pin_name_t en;
225 pin_name_t pg;
226
227 // static variable
228
229 uint32_t i2c_speed;
230 uint8_t i2c_address;
231
233
234 // End types group
235// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
236
242#ifdef __cplusplus
243extern "C"{
244#endif
245
255
265
276void mic24045_generic_write ( mic24045_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
277
289void mic24045_generic_read ( mic24045_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
290
299
308
317void mic24045_set_vout( mic24045_t *ctx, float v_out );
318
331void mic24045_set_vout_decimal ( mic24045_t *ctx, uint8_t dec );
332
341
350
359
360#ifdef __cplusplus
361}
362#endif
363#endif // _MIC24045_H_
364
365 // End public_function group
367
368// ------------------------------------------------------------------------- END
#define MIC24045_RETVAL
Definition mic24045.h:77
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:216
uint32_t i2c_speed
Definition mic24045.h:229
pin_name_t scl
Definition mic24045.h:219
pin_name_t en
Definition mic24045.h:224
pin_name_t sda
Definition mic24045.h:220
pin_name_t pg
Definition mic24045.h:225
uint8_t i2c_address
Definition mic24045.h:230
Click ctx object definition.
Definition mic24045.h:193
i2c_master_t i2c
Definition mic24045.h:204
digital_out_t en
Definition mic24045.h:196
uint8_t slave_address
Definition mic24045.h:208
digital_in_t pg
Definition mic24045.h:200