buck7 2.0.0.0
buck7.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 BUCK7_H
36#define BUCK7_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_spi_master.h"
55
56// -------------------------------------------------------------- PUBLIC MACROS
67#define BUCK7_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
69 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
70 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
71 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
72 cfg.en = MIKROBUS( mikrobus, MIKROBUS_AN ); \
73 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
74 cfg.mod = MIKROBUS( mikrobus, MIKROBUS_PWM );
81#define BUCK7_RETVAL uint8_t
82
83#define BUCK7_OK 0x00
84#define BUCK7_INIT_ERROR 0xFF
91#define BUCK7_MODE_DCM 0x01
92#define BUCK7_MODE_PWM 0x00
99#define BUCK7_OUT_VOLTAGE_3_3V 0x0FAF
100#define BUCK7_OUT_VOLTAGE_5V 0x0EA6
101#define BUCK7_OUT_VOLTAGE_6V 0x0E10
102#define BUCK7_OUT_VOLTAGE_7V 0x0D7A
103#define BUCK7_OUT_VOLTAGE_8V 0x0CE4
104#define BUCK7_OUT_VOLTAGE_9V 0x0C4E
105#define BUCK7_OUT_VOLTAGE_10V 0x0BB8
106#define BUCK7_OUT_VOLTAGE_11V 0x0B22
107#define BUCK7_OUT_VOLTAGE_12V 0x0A8C
108#define BUCK7_OUT_VOLTAGE_13V 0x09F6
109#define BUCK7_OUT_VOLTAGE_14V 0x0960
110#define BUCK7_OUT_VOLTAGE_15V 0x08CA
111#define BUCK7_OUT_VOLTAGE_16V 0x0834
112#define BUCK7_OUT_VOLTAGE_17V 0x079E
113#define BUCK7_OUT_VOLTAGE_18V 0x0708
114#define BUCK7_OUT_VOLTAGE_19V 0x0672
115#define BUCK7_OUT_VOLTAGE_20V 0x059C
116#define BUCK7_OUT_VOLTAGE_21V 0x0546
117#define BUCK7_OUT_VOLTAGE_22V 0x04B0
118#define BUCK7_OUT_VOLTAGE_23V 0x041A
119#define BUCK7_OUT_VOLTAGE_24V 0x0384
120#define BUCK7_OUT_VOLTAGE_25V 0x02EE
121#define BUCK7_OUT_VOLTAGE_26V 0x0244
122#define BUCK7_OUT_VOLTAGE_27V 0x0190
123#define BUCK7_OUT_VOLTAGE_28V 0x00FA
124#define BUCK7_OUT_VOLTAGE_29V 0x0096
125#define BUCK7_OUT_VOLTAGE_30V 0x0000
128 // End group macro
129// --------------------------------------------------------------- PUBLIC TYPES
138typedef struct
139{
140 // Output pins
141
142 digital_out_t en;
143 digital_out_t rst;
144 digital_out_t mod;
145 digital_out_t cs;
146
147 // Modules
148
149 spi_master_t spi;
150 pin_name_t chip_select;
151
152} buck7_t;
153
157typedef struct
158{
159 // Communication gpio pins
160
161 pin_name_t miso;
162 pin_name_t mosi;
163 pin_name_t sck;
164 pin_name_t cs;
165
166 // Additional gpio pins
167
168 pin_name_t en;
169 pin_name_t rst;
170 pin_name_t mod;
171
172 // static variable
173
174 uint32_t spi_speed;
175 uint8_t spi_mode;
176 spi_master_chip_select_polarity_t cs_polarity;
177
179
180 // End types group
181// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
182
187#ifdef __cplusplus
188extern "C"{
189#endif
190
200
209
218
231(
232 buck7_t *ctx,
233 uint8_t *wr_buf,
234 uint16_t wr_len,
235 uint8_t *rd_buf,
236 uint16_t rd_len
237);
238
247void buck7_set_output_voltage ( buck7_t *ctx, uint16_t voltage );
248
256void buck7_enable ( buck7_t *ctx );
257
266void buck7_set_mode ( buck7_t *ctx, uint8_t mode );
267
276
277
278#ifdef __cplusplus
279}
280#endif
281#endif // _BUCK7_H_
282
283 // End public_function group
285
286// ------------------------------------------------------------------------- END
#define BUCK7_RETVAL
Definition buck7.h:81
void buck7_default_cfg(buck7_t *ctx)
Click Default Configuration function.
void buck7_cfg_setup(buck7_cfg_t *cfg)
Config Object Initialization function.
void buck7_enable(buck7_t *ctx)
Function for enable chip.
uint8_t buck7_get_res_state(buck7_t *ctx)
Function for read RES state.
BUCK7_RETVAL buck7_init(buck7_t *ctx, buck7_cfg_t *cfg)
Initialization function.
void buck7_set_mode(buck7_t *ctx, uint8_t mode)
Function for settings chip mode.
void buck7_generic_transfer(buck7_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
Generic transfer function.
void buck7_set_output_voltage(buck7_t *ctx, uint16_t voltage)
Function for settings output voltage.
Click configuration structure definition.
Definition buck7.h:158
uint8_t spi_mode
Definition buck7.h:175
spi_master_chip_select_polarity_t cs_polarity
Definition buck7.h:176
pin_name_t sck
Definition buck7.h:163
pin_name_t mod
Definition buck7.h:170
pin_name_t mosi
Definition buck7.h:162
uint32_t spi_speed
Definition buck7.h:174
pin_name_t en
Definition buck7.h:168
pin_name_t miso
Definition buck7.h:161
pin_name_t rst
Definition buck7.h:169
pin_name_t cs
Definition buck7.h:164
Click ctx object definition.
Definition buck7.h:139
digital_out_t cs
Definition buck7.h:145
digital_out_t mod
Definition buck7.h:144
spi_master_t spi
Definition buck7.h:149
digital_out_t en
Definition buck7.h:142
digital_out_t rst
Definition buck7.h:143
pin_name_t chip_select
Definition buck7.h:150