smartbuck7 2.2.0
Loading...
Searching...
No Matches
smartbuck7.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2020 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
27
28#ifndef SMARTBUCK7_H
29#define SMARTBUCK7_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
52
58
63
68
73#define SMARTBUCK7_REG_SLAVE_ADDRESS 0x15
74#define SMARTBUCK7_REG_EN 0x22
75#define SMARTBUCK7_REG_STATUS_1 0x27
76#define SMARTBUCK7_REG_STATUS_2 0x28
77 // smartbuck7_reg
79
84
89
94#define SMARTBUCK7_BUCK_4 0x01
95#define SMARTBUCK7_BUCK_3 0x02
96#define SMARTBUCK7_BUCK_2 0x04
97#define SMARTBUCK7_BUCK_1 0x08
98#define SMARTBUCK7_BUCK_ALL 0x0F
99
104#define SMARTBUCK7_STATUS_1_PGBUCK4 0x08
105#define SMARTBUCK7_STATUS_1_PGBUCK3 0x04
106#define SMARTBUCK7_STATUS_1_PGBUCK2 0x02
107#define SMARTBUCK7_STATUS_1_PGBUCK1 0x01
108
113#define SMARTBUCK7_STATUS_2_OTWARNING 0x80
114#define SMARTBUCK7_STATUS_2_OTEMPP 0x40
115#define SMARTBUCK7_STATUS_2_CLEAR 0xFF
116
122#define SMARTBUCK7_DEVICE_ADDRESS 0x69
123 // smartbuck7_set
125
130
135
140#define SMARTBUCK7_MAP_MIKROBUS( cfg, mikrobus ) \
141 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
142 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
143 cfg.on = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
144 cfg.pg = MIKROBUS( mikrobus, MIKROBUS_INT )
145 // smartbuck7_map // smartbuck7
148
153typedef struct
154{
155 uint8_t status_1;
156 uint8_t status_2;
157
159
164typedef struct
165{
166 // Output pins
167 digital_out_t on;
168
169 // Input pins
170 digital_in_t pg;
171
172 // Modules
173 i2c_master_t i2c;
174
175 // I2C slave address
177
179
184typedef struct
185{
186 pin_name_t scl;
187 pin_name_t sda;
188
189 pin_name_t on;
190 pin_name_t pg;
191
192 uint32_t i2c_speed;
193 uint8_t i2c_address;
194
196
207
213
224
239
253
265err_t smartbuck7_write_reg ( smartbuck7_t *ctx, uint8_t reg, uint8_t data_in );
266
278err_t smartbuck7_read_reg ( smartbuck7_t *ctx, uint8_t reg, uint8_t *data_out );
279
289
299
309
322
333
344err_t smartbuck7_enable_buck ( smartbuck7_t *ctx, uint8_t buck_sel );
345
356err_t smartbuck7_disable_buck ( smartbuck7_t *ctx, uint8_t buck_sel );
357
358#ifdef __cplusplus
359}
360#endif
361#endif // SMARTBUCK7_H
362 // smartbuck7
364
365// ------------------------------------------------------------------------ END
err_t smartbuck7_default_cfg(smartbuck7_t *ctx)
Smart Buck 7 default configuration function.
void smartbuck7_enable_device(smartbuck7_t *ctx)
Smart Buck 7 enable device function.
void smartbuck7_disable_device(smartbuck7_t *ctx)
Smart Buck 7 disable device function.
uint8_t smartbuck7_get_pg_pin(smartbuck7_t *ctx)
Smart Buck 7 get power-good pin function.
err_t smartbuck7_read_reg(smartbuck7_t *ctx, uint8_t reg, uint8_t *data_out)
Smart Buck 7 read register function.
void smartbuck7_cfg_setup(smartbuck7_cfg_t *cfg)
Smart Buck 7 configuration object setup function.
err_t smartbuck7_read_status(smartbuck7_t *ctx, smartbuck7_status_t *status)
Smart Buck 7 read status registers function.
err_t smartbuck7_disable_buck(smartbuck7_t *ctx, uint8_t buck_sel)
Smart Buck 7 disable selected buck function.
err_t smartbuck7_write_reg(smartbuck7_t *ctx, uint8_t reg, uint8_t data_in)
Smart Buck 7 write register function.
err_t smartbuck7_clear_status(smartbuck7_t *ctx)
Smart Buck 7 clear status flags function.
err_t smartbuck7_init(smartbuck7_t *ctx, smartbuck7_cfg_t *cfg)
Smart Buck 7 initialization function.
err_t smartbuck7_enable_buck(smartbuck7_t *ctx, uint8_t buck_sel)
Smart Buck 7 enable selected buck function.
smartbuck7_return_value_t
Smart Buck 7 Click return value data.
Definition smartbuck7.h:202
@ SMARTBUCK7_ERROR
Definition smartbuck7.h:204
@ SMARTBUCK7_OK
Definition smartbuck7.h:203
Smart Buck 7 Click configuration object.
Definition smartbuck7.h:185
uint32_t i2c_speed
Definition smartbuck7.h:192
pin_name_t on
Definition smartbuck7.h:189
pin_name_t scl
Definition smartbuck7.h:186
pin_name_t sda
Definition smartbuck7.h:187
pin_name_t pg
Definition smartbuck7.h:190
uint8_t i2c_address
Definition smartbuck7.h:193
Smart Buck 7 Click status object.
Definition smartbuck7.h:154
uint8_t status_2
Definition smartbuck7.h:156
uint8_t status_1
Definition smartbuck7.h:155
Smart Buck 7 Click context object.
Definition smartbuck7.h:165
digital_out_t on
Definition smartbuck7.h:167
i2c_master_t i2c
Definition smartbuck7.h:173
uint8_t slave_address
Definition smartbuck7.h:176
digital_in_t pg
Definition smartbuck7.h:170