buck6  2.0.0.0
buck6.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 BUCK6_H
36 #define BUCK6_H
37 
38 #include "mikrosdk_version.h"
39 
40 #ifdef __GNUC__
41 #if mikroSDK_GET_VERSION < 20800ul
42 #include "rcu_delays.h"
43 #else
44 #include "delays.h"
45 #endif
46 #endif
47 
48 #include "drv_digital_out.h"
49 #include "drv_digital_in.h"
50 #include "drv_i2c_master.h"
51 
52 
53 // -------------------------------------------------------------- PUBLIC MACROS
63 #define BUCK6_MAP_MIKROBUS( cfg, mikrobus ) \
64  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
65  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
66  cfg.en = MIKROBUS( mikrobus, MIKROBUS_AN ); \
67  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
68  cfg.syn = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
69 
70 
76 #define BUCK6_RETVAL uint8_t
77 
78 #define BUCK6_OK 0x00
79 #define BUCK6_INIT_ERROR 0xFF
80 
86 #define BUCK6_MAX_RANGE_1000mV 0xFA
87 #define BUCK6_MAX_RANGE_1500mV 0xF4
88 #define BUCK6_MAX_RANGE_2000mV 0xF1
89 #define BUCK6_MAX_RANGE_2500mV 0xEE
90 #define BUCK6_MAX_RANGE_3000mV 0xEA
91 #define BUCK6_MAX_RANGE_3500mV 0xE7
92 #define BUCK6_MAX_RANGE_4000mV 0xE4
93 #define BUCK6_MAX_RANGE_4500mV 0xE1
94 #define BUCK6_MAX_RANGE_5000mV 0xDE
95 #define BUCK6_MAX_RANGE_5500mV 0xDB
96 
97 #define BUCK6_MAX_RANGE_6000mV 0xD8
98 #define BUCK6_MAX_RANGE_6500mV 0xD4
99 #define BUCK6_MAX_RANGE_7000mV 0xD1
100 #define BUCK6_MAX_RANGE_7500mV 0xCF
101 #define BUCK6_MAX_RANGE_8000mV 0xCB
102 #define BUCK6_MAX_RANGE_8500mV 0xC8
103 #define BUCK6_MAX_RANGE_9000mV 0xC5
104 #define BUCK6_MAX_RANGE_9500mV 0xC2
105 #define BUCK6_MAX_RANGE_10000mV 0xBF
106 #define BUCK6_MAX_RANGE_10500mV 0xBC
107 #define BUCK6_MAX_RANGE_11000mV 0xB9
108 #define BUCK6_MAX_RANGE_11500mV 0xB6
109 #define BUCK6_MAX_RANGE_12000mV 0xB2
110 #define BUCK6_MAX_RANGE_12500mV 0xAF
111 
112 #define BUCK6_MAX_RANGE_13000mV 0xAB
113 #define BUCK6_MAX_RANGE_13500mV 0xA9
114 #define BUCK6_MAX_RANGE_14000mV 0xA6
115 #define BUCK6_MAX_RANGE_14500mV 0xA3
116 #define BUCK6_MAX_RANGE_15000mV 0xA0
117 #define BUCK6_MAX_RANGE_15500mV 0x9C
118 #define BUCK6_MAX_RANGE_16000mV 0x99
119 #define BUCK6_MAX_RANGE_16500mV 0x96
120 #define BUCK6_MAX_RANGE_17000mV 0x93
121 #define BUCK6_MAX_RANGE_17500mV 0x90
122 #define BUCK6_MAX_RANGE_18000mV 0x8D
123 #define BUCK6_MAX_RANGE_18500mV 0x8A
124 #define BUCK6_MAX_RANGE_19000mV 0x87
125 #define BUCK6_MAX_RANGE_19500mV 0x84
126 #define BUCK6_MAX_RANGE_20000mV 0x80
127 
133 #define BUCK6_SLEEP_MODE 0x00
134 
140 #define BUCK6_ACTIVE_MODE 0x01
141  // End group macro
144 // --------------------------------------------------------------- PUBLIC TYPES
153 typedef struct
154 {
155  // Output pins
156 
157  digital_out_t en;
158  digital_out_t syn;
159 
160  // Input pins
161 
162  digital_in_t rst;
163 
164  // Modules
165 
166  i2c_master_t i2c;
167 
168  // ctx variable
169 
170  uint8_t slave_address;
171 
172 } buck6_t;
173 
177 typedef struct
178 {
179  // Communication gpio pins
180 
181  pin_name_t scl;
182  pin_name_t sda;
183 
184  // Additional gpio pins
185 
186  pin_name_t en;
187  pin_name_t rst;
188  pin_name_t syn;
189 
190  // static variable
191 
192  uint32_t i2c_speed;
193  uint8_t i2c_address;
194 
195 } buck6_cfg_t;
196  // End types group
198 
199 
205 #ifdef __cplusplus
206 extern "C"{
207 #endif
208 
218 
227 
238 void buck6_generic_write ( buck6_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
239 
251 void buck6_generic_read ( buck6_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
252 
262 uint8_t buck6_get_rst( buck6_t *ctx );
263 
273 void buck6_set_mode( buck6_t *ctx, uint8_t mode);
274 
284 void buck6_set_max_voltage( buck6_t *ctx, uint8_t voltage );
285 
286 #ifdef __cplusplus
287 }
288 #endif
289 #endif // _BUCK6_H_
290  // End public_function group
293 
294 // ------------------------------------------------------------------------- END
buck6_get_rst
uint8_t buck6_get_rst(buck6_t *ctx)
buck6_cfg_t::i2c_address
uint8_t i2c_address
Definition: buck6.h:193
buck6_cfg_t::rst
pin_name_t rst
Definition: buck6.h:187
buck6_init
BUCK6_RETVAL buck6_init(buck6_t *ctx, buck6_cfg_t *cfg)
Initialization function.
buck6_generic_read
void buck6_generic_read(buck6_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
buck6_cfg_t::sda
pin_name_t sda
Definition: buck6.h:182
buck6_t
Click ctx object definition.
Definition: buck6.h:154
buck6_set_mode
void buck6_set_mode(buck6_t *ctx, uint8_t mode)
Set mode.
buck6_cfg_t::en
pin_name_t en
Definition: buck6.h:186
buck6_cfg_setup
void buck6_cfg_setup(buck6_cfg_t *cfg)
Config Object Initialization function.
buck6_generic_write
void buck6_generic_write(buck6_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
buck6_t::syn
digital_out_t syn
Definition: buck6.h:158
BUCK6_RETVAL
#define BUCK6_RETVAL
Definition: buck6.h:76
buck6_t::en
digital_out_t en
Definition: buck6.h:157
buck6_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: buck6.h:192
buck6_t::i2c
i2c_master_t i2c
Definition: buck6.h:166
buck6_t::rst
digital_in_t rst
Definition: buck6.h:162
buck6_cfg_t::syn
pin_name_t syn
Definition: buck6.h:188
buck6_set_max_voltage
void buck6_set_max_voltage(buck6_t *ctx, uint8_t voltage)
Set maximum voltage.
buck6_t::slave_address
uint8_t slave_address
Definition: buck6.h:170
buck6_cfg_t
Click configuration structure definition.
Definition: buck6.h:178
buck6_cfg_t::scl
pin_name_t scl
Definition: buck6.h:181