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
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
55// -------------------------------------------------------------- PUBLIC MACROS
65#define BUCK_MAP_MIKROBUS( cfg, mikrobus ) \
66 cfg.a0= MIKROBUS( mikrobus, MIKROBUS_RST ); \
67 cfg.en= MIKROBUS( mikrobus, MIKROBUS_CS ); \
68 cfg.a1= MIKROBUS( mikrobus, MIKROBUS_PWM ); \
69 cfg.pg= MIKROBUS( mikrobus, MIKROBUS_INT );
76#define BUCK_RETVAL uint8_t
77
78#define BUCK_OK 0x00
79#define BUCK_INIT_ERROR 0xFF
86#define BUCK_DEVICE_DISABLE 0
87#define BUCK_DEVICE_ENABLE 1
94#define BUCK_FREQ_400KHz 0x00
95#define BUCK_FREQ_1200KHz 0x01
96#define BUCK_FREQ_800KHz 0x02
97#define BUCK_FREQ_1600KHz 0x03
104#define BUCK_SET_MULTIPLEXER_A0 0
105#define BUCK_SET_MULTIPLEXER_A1 1
108 // End group macro
109// --------------------------------------------------------------- PUBLIC TYPES
118typedef struct
119{
120 // Output pins
121
122 digital_out_t a0;
123 digital_out_t en;
124 digital_out_t a1;
125
126 // Input pins
127
128 digital_in_t pg;
129
130} buck_t;
131
135typedef struct
136{
137 // Additional gpio pins
138
139 pin_name_t a0;
140 pin_name_t en;
141 pin_name_t a1;
142 pin_name_t pg;
143
144} buck_cfg_t;
145
146 // End types group
147
148// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
149
155#ifdef __cplusplus
156extern "C"{
157#endif
158
168
177
192
202
209void buck_set_mode ( buck_t *ctx, uint8_t mode );
210
226
233void buck_set_multiplexer_state ( buck_t *ctx, uint8_t mux, uint8_t state );
234
250void buck_switch_frequency ( buck_t *ctx, uint8_t frequency );
251
252
253#ifdef __cplusplus
254}
255#endif
256#endif // _BUCK_H_
257
258 // End public_function group
260
261// ------------------------------------------------------------------------- END
#define BUCK_RETVAL
Definition buck.h:76
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:136
pin_name_t a0
Definition buck.h:139
pin_name_t en
Definition buck.h:140
pin_name_t a1
Definition buck.h:141
pin_name_t pg
Definition buck.h:142
Click ctx object definition.
Definition buck.h:119
digital_out_t a0
Definition buck.h:122
digital_out_t a1
Definition buck.h:124
digital_out_t en
Definition buck.h:123
digital_in_t pg
Definition buck.h:128