buck 2.0.0.0
buck.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 BUCK_H
36#define BUCK_H
37
38#include "drv_digital_out.h"
39#include "drv_digital_in.h"
40
41// -------------------------------------------------------------- PUBLIC MACROS
51#define BUCK_MAP_MIKROBUS( cfg, mikrobus ) \
52 cfg.a0= MIKROBUS( mikrobus, MIKROBUS_RST ); \
53 cfg.en= MIKROBUS( mikrobus, MIKROBUS_CS ); \
54 cfg.a1= MIKROBUS( mikrobus, MIKROBUS_PWM ); \
55 cfg.pg= MIKROBUS( mikrobus, MIKROBUS_INT );
62#define BUCK_RETVAL uint8_t
63
64#define BUCK_OK 0x00
65#define BUCK_INIT_ERROR 0xFF
72#define BUCK_DEVICE_DISABLE 0
73#define BUCK_DEVICE_ENABLE 1
80#define BUCK_FREQ_400KHz 0x00
81#define BUCK_FREQ_1200KHz 0x01
82#define BUCK_FREQ_800KHz 0x02
83#define BUCK_FREQ_1600KHz 0x03
90#define BUCK_SET_MULTIPLEXER_A0 0
91#define BUCK_SET_MULTIPLEXER_A1 1 // End group macro
95// --------------------------------------------------------------- PUBLIC TYPES
104typedef struct
105{
106 // Output pins
107
108 digital_out_t a0;
109 digital_out_t en;
110 digital_out_t a1;
111
112 // Input pins
113
114 digital_in_t pg;
115
116} buck_t;
117
121typedef struct
122{
123 // Additional gpio pins
124
125 pin_name_t a0;
126 pin_name_t en;
127 pin_name_t a1;
128 pin_name_t pg;
129
130} buck_cfg_t;
131 // End types group
133
134// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
135
141#ifdef __cplusplus
142extern "C"{
143#endif
144
154
163
178
188
195void buck_set_mode ( buck_t *ctx, uint8_t mode );
196
212
219void buck_set_multiplexer_state ( buck_t *ctx, uint8_t mux, uint8_t state );
220
236void buck_switch_frequency ( buck_t *ctx, uint8_t frequency );
237
238
239#ifdef __cplusplus
240}
241#endif
242#endif // _BUCK_H_
243 // End public_function group
246
247// ------------------------------------------------------------------------- END
#define BUCK_RETVAL
Definition: buck.h:62
void buck_device_reset(buck_t *ctx)
Device reset chip function.
void buck_default_cfg(buck_t *ctx)
Click Default Configuration function.
void buck_set_multiplexer_state(buck_t *ctx, uint8_t mux, uint8_t state)
Set multiplexer (A0 or A1) state.
BUCK_RETVAL buck_init(buck_t *ctx, buck_cfg_t *cfg)
Initialization function.
void buck_set_mode(buck_t *ctx, uint8_t mode)
Select buck mode (Disable / Enable)
void buck_switch_frequency(buck_t *ctx, uint8_t frequency)
Setting the switching frequency function.
uint8_t buck_get_power_good(buck_t *ctx)
Get state internal comparator function.
void buck_cfg_setup(buck_cfg_t *cfg)
Config Object Initialization function.
Click configuration structure definition.
Definition: buck.h:122
pin_name_t a0
Definition: buck.h:125
pin_name_t en
Definition: buck.h:126
pin_name_t a1
Definition: buck.h:127
pin_name_t pg
Definition: buck.h:128
Click ctx object definition.
Definition: buck.h:105
digital_out_t a0
Definition: buck.h:108
digital_out_t a1
Definition: buck.h:110
digital_out_t en
Definition: buck.h:109
digital_in_t pg
Definition: buck.h:114