buck13 2.0.0.0
buck13.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 BUCK13_H
36#define BUCK13_H
37
38#include "drv_digital_out.h"
39#include "drv_digital_in.h"
40#include "drv_spi_master.h"
41
42
43// -------------------------------------------------------------- PUBLIC MACROS
54#define BUCK13_MAP_MIKROBUS( cfg, mikrobus ) \
55 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
56 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
57 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
58 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
59 cfg.en = MIKROBUS( mikrobus, MIKROBUS_AN );
66#define BUCK13_RETVAL uint8_t
67
68#define BUCK13_OK 0x00
69#define BUCK13_INIT_ERROR 0xFF
76#define BUCK13_ENABLE 1
77#define BUCK13_DISABLE 0 // End group macro
80// --------------------------------------------------------------- PUBLIC TYPES
89typedef struct
90{
91 // Output pins
92
93 digital_out_t en;
94 digital_out_t cs;
95
96 // Modules
97
98 spi_master_t spi;
99 pin_name_t chip_select;
100
101} buck13_t;
102
106typedef struct
107{
108 // Communication gpio pins
109
110 pin_name_t miso;
111 pin_name_t mosi;
112 pin_name_t sck;
113 pin_name_t cs;
114
115 // Additional gpio pins
116
117 pin_name_t en;
118
119 // static variable
120
121 uint32_t spi_speed;
122 spi_master_mode_t spi_mode;
123 spi_master_chip_select_polarity_t cs_polarity;
124
126 // End types group
128// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
129
134#ifdef __cplusplus
135extern "C"{
136#endif
137
147
157
171
184(
185 buck13_t *ctx,
186 uint8_t *wr_buf,
187 uint16_t wr_len,
188 uint8_t *rd_buf,
189 uint16_t rd_len
190);
191
200void buck13_enable ( buck13_t *ctx, uint8_t pwr_state );
201
210uint16_t buck13_get_adc( buck13_t *ctx );
211
221
222#ifdef __cplusplus
223}
224#endif
225#endif // _BUCK13_H_
226 // End public_function group
229
230// ------------------------------------------------------------------------- END
#define BUCK13_RETVAL
Definition: buck13.h:66
void buck13_generic_transfer(buck13_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
Generic transfer function.
uint16_t buck13_get_voltage(buck13_t *ctx)
Get voltage function.
void buck13_default_cfg(buck13_t *ctx)
Click Default Configuration function.
void buck13_enable(buck13_t *ctx, uint8_t pwr_state)
Enable Buck13 function.
uint16_t buck13_get_adc(buck13_t *ctx)
Get ADC function.
void buck13_cfg_setup(buck13_cfg_t *cfg)
Config Object Initialization function.
BUCK13_RETVAL buck13_init(buck13_t *ctx, buck13_cfg_t *cfg)
Initialization function.
Click configuration structure definition.
Definition: buck13.h:107
spi_master_chip_select_polarity_t cs_polarity
Definition: buck13.h:123
pin_name_t sck
Definition: buck13.h:112
spi_master_mode_t spi_mode
Definition: buck13.h:122
pin_name_t mosi
Definition: buck13.h:111
uint32_t spi_speed
Definition: buck13.h:121
pin_name_t en
Definition: buck13.h:117
pin_name_t miso
Definition: buck13.h:110
pin_name_t cs
Definition: buck13.h:113
Click ctx object definition.
Definition: buck13.h:90
digital_out_t cs
Definition: buck13.h:94
spi_master_t spi
Definition: buck13.h:98
digital_out_t en
Definition: buck13.h:93
pin_name_t chip_select
Definition: buck13.h:99