buck7  2.0.0.0
buck7.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 BUCK7_H
36 #define BUCK7_H
37 
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_spi_master.h"
41 
42 // -------------------------------------------------------------- PUBLIC MACROS
53 #define BUCK7_MAP_MIKROBUS( cfg, mikrobus ) \
54  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
55  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
56  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
57  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
58  cfg.en = MIKROBUS( mikrobus, MIKROBUS_AN ); \
59  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
60  cfg.mod = MIKROBUS( mikrobus, MIKROBUS_PWM );
61 
67 #define BUCK7_RETVAL uint8_t
68 
69 #define BUCK7_OK 0x00
70 #define BUCK7_INIT_ERROR 0xFF
71 
77 #define BUCK7_MODE_DCM 0x01
78 #define BUCK7_MODE_PWM 0x00
79 
85 #define BUCK7_OUT_VOLTAGE_3_3V 0x0FAF
86 #define BUCK7_OUT_VOLTAGE_5V 0x0EA6
87 #define BUCK7_OUT_VOLTAGE_6V 0x0E10
88 #define BUCK7_OUT_VOLTAGE_7V 0x0D7A
89 #define BUCK7_OUT_VOLTAGE_8V 0x0CE4
90 #define BUCK7_OUT_VOLTAGE_9V 0x0C4E
91 #define BUCK7_OUT_VOLTAGE_10V 0x0BB8
92 #define BUCK7_OUT_VOLTAGE_11V 0x0B22
93 #define BUCK7_OUT_VOLTAGE_12V 0x0A8C
94 #define BUCK7_OUT_VOLTAGE_13V 0x09F6
95 #define BUCK7_OUT_VOLTAGE_14V 0x0960
96 #define BUCK7_OUT_VOLTAGE_15V 0x08CA
97 #define BUCK7_OUT_VOLTAGE_16V 0x0834
98 #define BUCK7_OUT_VOLTAGE_17V 0x079E
99 #define BUCK7_OUT_VOLTAGE_18V 0x0708
100 #define BUCK7_OUT_VOLTAGE_19V 0x0672
101 #define BUCK7_OUT_VOLTAGE_20V 0x059C
102 #define BUCK7_OUT_VOLTAGE_21V 0x0546
103 #define BUCK7_OUT_VOLTAGE_22V 0x04B0
104 #define BUCK7_OUT_VOLTAGE_23V 0x041A
105 #define BUCK7_OUT_VOLTAGE_24V 0x0384
106 #define BUCK7_OUT_VOLTAGE_25V 0x02EE
107 #define BUCK7_OUT_VOLTAGE_26V 0x0244
108 #define BUCK7_OUT_VOLTAGE_27V 0x0190
109 #define BUCK7_OUT_VOLTAGE_28V 0x00FA
110 #define BUCK7_OUT_VOLTAGE_29V 0x0096
111 #define BUCK7_OUT_VOLTAGE_30V 0x0000
112  // End group macro
115 // --------------------------------------------------------------- PUBLIC TYPES
124 typedef struct
125 {
126  // Output pins
127 
128  digital_out_t en;
129  digital_out_t rst;
130  digital_out_t mod;
131 
132  // Modules
133 
134  spi_master_t spi;
135 
136 } buck7_t;
137 
141 typedef struct
142 {
143  // Communication gpio pins
144 
145  pin_name_t miso;
146  pin_name_t mosi;
147  pin_name_t sck;
148  pin_name_t cs;
149 
150  // Additional gpio pins
151 
152  pin_name_t en;
153  pin_name_t rst;
154  pin_name_t mod;
155 
156  // static variable
157 
158  hal_spi_speed_t spi_speed;
159  hal_spi_mode_t spi_mode;
160 
161 } buck7_cfg_t;
162  // End types group
164 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
165 
170 #ifdef __cplusplus
171 extern "C"{
172 #endif
173 
182 void buck7_cfg_setup ( buck7_cfg_t *cfg );
183 
192 
200 void buck7_default_cfg ( buck7_t *ctx );
201 
210 void buck7_generic_transfer ( buck7_t *ctx, spi_master_transfer_data_t *block );
211 
220 void buck7_set_output_voltage ( buck7_t *ctx, uint16_t voltage );
221 
229 void buck7_enable ( buck7_t *ctx );
230 
239 void buck7_set_mode ( buck7_t *ctx, uint8_t mode );
240 
248 uint8_t buck7_get_res_state ( buck7_t *ctx );
249 
250 
251 #ifdef __cplusplus
252 }
253 #endif
254 #endif // _BUCK7_H_
255  // End public_function group
258 
259 // ------------------------------------------------------------------------- END
buck7_t::spi
spi_master_t spi
Definition: buck7.h:134
buck7_t::rst
digital_out_t rst
Definition: buck7.h:129
buck7_cfg_t::cs
pin_name_t cs
Definition: buck7.h:148
buck7_enable
void buck7_enable(buck7_t *ctx)
Function for enable chip.
buck7_cfg_t::mod
pin_name_t mod
Definition: buck7.h:154
buck7_get_res_state
uint8_t buck7_get_res_state(buck7_t *ctx)
Function for read RES state.
buck7_cfg_setup
void buck7_cfg_setup(buck7_cfg_t *cfg)
Config Object Initialization function.
buck7_set_output_voltage
void buck7_set_output_voltage(buck7_t *ctx, uint16_t voltage)
Function for settings output voltage.
buck7_cfg_t::miso
pin_name_t miso
Definition: buck7.h:145
buck7_set_mode
void buck7_set_mode(buck7_t *ctx, uint8_t mode)
Function for settings chip mode.
BUCK7_RETVAL
#define BUCK7_RETVAL
Definition: buck7.h:67
buck7_cfg_t::spi_speed
hal_spi_speed_t spi_speed
Definition: buck7.h:158
buck7_cfg_t::en
pin_name_t en
Definition: buck7.h:152
buck7_cfg_t::rst
pin_name_t rst
Definition: buck7.h:153
buck7_init
BUCK7_RETVAL buck7_init(buck7_t *ctx, buck7_cfg_t *cfg)
Initialization function.
buck7_t
Click ctx object definition.
Definition: buck7.h:124
buck7_t::en
digital_out_t en
Definition: buck7.h:128
buck7_cfg_t::mosi
pin_name_t mosi
Definition: buck7.h:146
buck7_generic_transfer
void buck7_generic_transfer(buck7_t *ctx, spi_master_transfer_data_t *block)
Generic transfer function.
buck7_t::mod
digital_out_t mod
Definition: buck7.h:130
buck7_default_cfg
void buck7_default_cfg(buck7_t *ctx)
Click Default Configuration function.
buck7_cfg_t
Click configuration structure definition.
Definition: buck7.h:141
buck7_cfg_t::sck
pin_name_t sck
Definition: buck7.h:147
buck7_cfg_t::spi_mode
hal_spi_mode_t spi_mode
Definition: buck7.h:159