buck2  2.0.0.0
buck2.h
Go to the documentation of this file.
1 /*
2  * MikroSDK - MikroE Software Development Kit
3  * Copyright (c) 2019, MikroElektronika - www.mikroe.com
4  * All rights reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 
33 // ----------------------------------------------------------------------------
34 
35 #ifndef BUCK2_H
36 #define BUCK2_H
37 
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 
41 // -------------------------------------------------------------- PUBLIC MACROS
51 #define BUCK2_MAP_MIKROBUS( cfg, mikrobus ) \
52  cfg.voset0 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
53  cfg.voset1 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
54  cfg.en= MIKROBUS( mikrobus, MIKROBUS_CS ); \
55  cfg.fq= MIKROBUS( mikrobus, MIKROBUS_PWM ); \
56  cfg.pg= MIKROBUS( mikrobus, MIKROBUS_INT );
57 
63 #define BUCK2_RETVAL uint8_t
64 
65 #define BUCK2_OK 0x00
66 #define BUCK2_INIT_ERROR 0xFF
67 
73 #define BUCK2_MODE_ACTIVE 0x01
74 #define BUCK2_MODE_SLEEP 0x00
75 
81 #define BUCK2_VOSET_LOW 0x00
82 #define BUCK2_VOSET_HIGH 0x01
83 
89 #define BUCK2_FREQ_790KHz 0x01
90 #define BUCK2_FREQ_565KHz 0x00
91 
97 #define BUCK2_SET_VOLTAGE_3300mV 0
98 #define BUCK2_SET_VOLTAGE_2500mV 1
99 #define BUCK2_SET_VOLTAGE_1800mV 2
100 #define BUCK2_SET_VOLTAGE_1500mV 3
101 
107 #define BUCK2_VOSET_CH_0 0
108 #define BUCK2_VOSET_CH_1 1
109  // End group macro
112 // --------------------------------------------------------------- PUBLIC TYPES
121 typedef struct
122 {
123  // Output pins
124 
125  digital_out_t voset0;
126  digital_out_t voset1;
127  digital_out_t en;
128  digital_out_t fq;
129 
130  // Input pins
131 
132  digital_in_t pg;
133 
134 } buck2_t;
135 
139 typedef struct
140 {
141  // Additional gpio pins
142 
143  pin_name_t voset0;
144  pin_name_t voset1;
145  pin_name_t en;
146  pin_name_t fq;
147  pin_name_t pg;
148 
149 } buck2_cfg_t;
150  // End types group
152 
153 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
154 
160 #ifdef __cplusplus
161 extern "C"{
162 #endif
163 
172 void buck2_cfg_setup ( buck2_cfg_t *cfg );
173 
182 
197 void buck2_default_cfg ( buck2_t *ctx );
198 
206 void buck2_set_voset ( buck2_t *ctx, uint8_t channel, uint8_t state );
207 
220 void busk2_set_frequency ( buck2_t *ctx, uint8_t freq );
221 
234 void buck2_set_power_mode ( buck2_t *ctx, uint8_t mode );
235 
241 void back2_device_reset ( buck2_t *ctx );
242 
253 uint8_t buck2_get_power_good ( buck2_t *ctx );
254 
269 void buck2_set_output_voltage ( buck2_t *ctx , uint8_t voltage );
270 
271 #ifdef __cplusplus
272 }
273 #endif
274 #endif // _BUCK2_H_
275  // End public_function group
278 
279 // ------------------------------------------------------------------------- END
buck2_t::voset0
digital_out_t voset0
Definition: buck2.h:125
buck2_t::pg
digital_in_t pg
Definition: buck2.h:132
buck2_t::fq
digital_out_t fq
Definition: buck2.h:128
BUCK2_RETVAL
#define BUCK2_RETVAL
Definition: buck2.h:63
buck2_cfg_t::voset0
pin_name_t voset0
Definition: buck2.h:143
back2_device_reset
void back2_device_reset(buck2_t *ctx)
Function for reset chip.
buck2_cfg_t::voset1
pin_name_t voset1
Definition: buck2.h:144
buck2_default_cfg
void buck2_default_cfg(buck2_t *ctx)
Click Default Configuration function.
buck2_init
BUCK2_RETVAL buck2_init(buck2_t *ctx, buck2_cfg_t *cfg)
Initialization function.
buck2_cfg_t::en
pin_name_t en
Definition: buck2.h:145
buck2_cfg_t::pg
pin_name_t pg
Definition: buck2.h:147
buck2_set_output_voltage
void buck2_set_output_voltage(buck2_t *ctx, uint8_t voltage)
Function settings output voltage.
busk2_set_frequency
void busk2_set_frequency(buck2_t *ctx, uint8_t freq)
Function settings Frequency.
buck2_t
Click ctx object definition.
Definition: buck2.h:121
buck2_cfg_setup
void buck2_cfg_setup(buck2_cfg_t *cfg)
Config Object Initialization function.
buck2_get_power_good
uint8_t buck2_get_power_good(buck2_t *ctx)
Function reads state PG pin.
buck2_cfg_t::fq
pin_name_t fq
Definition: buck2.h:146
buck2_t::voset1
digital_out_t voset1
Definition: buck2.h:126
buck2_set_power_mode
void buck2_set_power_mode(buck2_t *ctx, uint8_t mode)
Function settings chip mode.
buck2_t::en
digital_out_t en
Definition: buck2.h:127
buck2_cfg_t
Click configuration structure definition.
Definition: buck2.h:139
buck2_set_voset
void buck2_set_voset(buck2_t *ctx, uint8_t channel, uint8_t state)
Function settings VOSET pin state.