smartbuck4  2.1.0.0
smartbuck4.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 
28 #ifndef SMARTBUCK4_H
29 #define SMARTBUCK4_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_i2c_master.h"
48 
69 #define SMARTBUCK4_REG_R600A_PROGRAM 0x80
70 #define SMARTBUCK4_REG_R400A_PROGRAM 0x40
71 #define SMARTBUCK4_REG_R600B_PROGRAM 0x20
72 #define SMARTBUCK4_REG_R400B_PROGRAM 0x10
73 #define SMARTBUCK4_REG_PULSE_SKIP_MODE 0x00
74 #define SMARTBUCK4_REG_LDO_MODE 0x01
75 #define SMARTBUCK4_REG_FORCED_BURST_MODE 0x02
76 #define SMARTBUCK4_REG_BURST_MODE 0x03
77  // smartbuck4_reg
79 
94 #define SMARTBUCK4_PIN_STATE_LOW 0x00
95 #define SMARTBUCK4_PIN_STATE_HIGH 0x01
96 
101 #define SMARTBUCK4_ENABLE_REGULATOR 0x80
102 #define SMARTBUCK4_DISABLE_REGULATOR 0x00
103 
109 #define SMARTBUCK4_REGULATOR_A_FB_425_MV 0x00
110 #define SMARTBUCK4_REGULATOR_A_FB_450_MV 0x01
111 #define SMARTBUCK4_REGULATOR_A_FB_475_MV 0x02
112 #define SMARTBUCK4_REGULATOR_A_FB_500_MV 0x03
113 #define SMARTBUCK4_REGULATOR_A_FB_525_MV 0x04
114 #define SMARTBUCK4_REGULATOR_A_FB_550_MV 0x05
115 #define SMARTBUCK4_REGULATOR_A_FB_575_MV 0x06
116 #define SMARTBUCK4_REGULATOR_A_FB_600_MV 0x07
117 #define SMARTBUCK4_REGULATOR_A_FB_625_MV 0x08
118 #define SMARTBUCK4_REGULATOR_A_FB_650_MV 0x09
119 #define SMARTBUCK4_REGULATOR_A_FB_675_MV 0x0A
120 #define SMARTBUCK4_REGULATOR_A_FB_700_MV 0x0B
121 #define SMARTBUCK4_REGULATOR_A_FB_725_MV 0x0C
122 #define SMARTBUCK4_REGULATOR_A_FB_750_MV 0x0D
123 #define SMARTBUCK4_REGULATOR_A_FB_775_MV 0x0E
124 #define SMARTBUCK4_REGULATOR_A_FB_800_MV 0x0F
125 
131 #define SMARTBUCK4_REGULATOR_B_600_MV 0x00
132 #define SMARTBUCK4_REGULATOR_B_700_MV 0x04
133 #define SMARTBUCK4_REGULATOR_B_800_MV 0x08
134 #define SMARTBUCK4_REGULATOR_B_900_MV 0x0C
135 #define SMARTBUCK4_REGULATOR_B_1000_MV 0x10
136 #define SMARTBUCK4_REGULATOR_B_1100_MV 0x14
137 #define SMARTBUCK4_REGULATOR_B_1200_MV 0x18
138 #define SMARTBUCK4_REGULATOR_B_1300_MV 0x1C
139 #define SMARTBUCK4_REGULATOR_B_1400_MV 0x20
140 #define SMARTBUCK4_REGULATOR_B_1500_MV 0x24
141 #define SMARTBUCK4_REGULATOR_B_1600_MV 0x28
142 #define SMARTBUCK4_REGULATOR_B_1700_MV 0x2C
143 #define SMARTBUCK4_REGULATOR_B_1800_MV 0x30
144 #define SMARTBUCK4_REGULATOR_B_1900_MV 0x34
145 #define SMARTBUCK4_REGULATOR_B_2000_MV 0x38
146 #define SMARTBUCK4_REGULATOR_B_2100_MV 0x3C
147 #define SMARTBUCK4_REGULATOR_B_2200_MV 0x40
148 #define SMARTBUCK4_REGULATOR_B_2300_MV 0x44
149 #define SMARTBUCK4_REGULATOR_B_2400_MV 0x48
150 #define SMARTBUCK4_REGULATOR_B_2500_MV 0x4C
151 #define SMARTBUCK4_REGULATOR_B_2600_MV 0x50
152 #define SMARTBUCK4_REGULATOR_B_2700_MV 0x54
153 #define SMARTBUCK4_REGULATOR_B_2800_MV 0x58
154 #define SMARTBUCK4_REGULATOR_B_2900_MV 0x5C
155 #define SMARTBUCK4_REGULATOR_B_3000_MV 0x60
156 #define SMARTBUCK4_REGULATOR_B_3100_MV 0x64
157 #define SMARTBUCK4_REGULATOR_B_3200_MV 0x68
158 #define SMARTBUCK4_REGULATOR_B_3300_MV 0x6C
159 #define SMARTBUCK4_REGULATOR_B_3400_MV 0x70
160 #define SMARTBUCK4_REGULATOR_B_3500_MV 0x74
161 #define SMARTBUCK4_REGULATOR_B_3600_MV 0x78
162 #define SMARTBUCK4_REGULATOR_B_3700_MV 0x7C
163 
169 #define SMARTBUCK4_REGULATOR_B_INC_0_MV 0x00
170 #define SMARTBUCK4_REGULATOR_B_INC_25_MV 0x01
171 #define SMARTBUCK4_REGULATOR_B_INC_50_MV 0x02
172 #define SMARTBUCK4_REGULATOR_B_INC_75_MV 0x03
173 
179 #define SMARTBUCK4_DEVICE_ADDRESS 0x65
180  // smartbuck4_set
182 
197 #define SMARTBUCK4_MAP_MIKROBUS( cfg, mikrobus ) \
198  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
199  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
200  cfg.r40 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
201  cfg.r60 = MIKROBUS( mikrobus, MIKROBUS_PWM )
202  // smartbuck4_map // smartbuck4
205 
210 typedef struct
211 {
212  // Output pins
213  digital_out_t r40;
214  digital_out_t r60;
216  // Modules
217  i2c_master_t i2c;
219  // I2C slave address
220  uint8_t slave_address;
222 } smartbuck4_t;
223 
228 typedef struct
229 {
230  pin_name_t scl;
231  pin_name_t sda;
233  pin_name_t r40;
234  pin_name_t r60;
236  uint32_t i2c_speed;
237  uint8_t i2c_address;
240 
245 typedef enum
246 {
248  SMARTBUCK4_ERROR = -1
249 
251 
268 
283 
297 
308 void smartbuck4_set_r40_out ( smartbuck4_t *ctx, uint8_t out_level );
309 
320 
331 
342 void smartbuck4_set_r60_out ( smartbuck4_t *ctx, uint8_t out_level );
343 
354 
365 
379 err_t smartbuck4_send_command ( smartbuck4_t *ctx, uint8_t addr, uint8_t data_in );
380 
393 
394 #ifdef __cplusplus
395 }
396 #endif
397 #endif // SMARTBUCK4_H
398  // smartbuck4
400 
401 // ------------------------------------------------------------------------ END
smartbuck4_set_r60_out
void smartbuck4_set_r60_out(smartbuck4_t *ctx, uint8_t out_level)
Smart Buck 4 set R60 pin state function.
smartbuck4_set_r40_out
void smartbuck4_set_r40_out(smartbuck4_t *ctx, uint8_t out_level)
Smart Buck 4 set R40 pin state function.
smartbuck4_cfg_t
Smart Buck 4 Click configuration object.
Definition: smartbuck4.h:229
smartbuck4_t::i2c
i2c_master_t i2c
Definition: smartbuck4.h:217
SMARTBUCK4_OK
@ SMARTBUCK4_OK
Definition: smartbuck4.h:247
smartbuck4_init
err_t smartbuck4_init(smartbuck4_t *ctx, smartbuck4_cfg_t *cfg)
Smart Buck 4 initialization function.
smartbuck4_default_cfg
err_t smartbuck4_default_cfg(smartbuck4_t *ctx)
Smart Buck 4 default configuration function.
smartbuck4_cfg_t::r40
pin_name_t r40
Definition: smartbuck4.h:233
smartbuck4_disable_regulators
err_t smartbuck4_disable_regulators(smartbuck4_t *ctx)
Smart Buck 4 disable regulators function.
smartbuck4_cfg_t::scl
pin_name_t scl
Definition: smartbuck4.h:230
smartbuck4_t::r60
digital_out_t r60
Definition: smartbuck4.h:214
smartbuck4_dis_r40_reg
void smartbuck4_dis_r40_reg(smartbuck4_t *ctx)
Smart Buck 4 disable 400A regulator function.
smartbuck4_t
Smart Buck 4 Click context object.
Definition: smartbuck4.h:211
smartbuck4_cfg_t::r60
pin_name_t r60
Definition: smartbuck4.h:234
SMARTBUCK4_ERROR
@ SMARTBUCK4_ERROR
Definition: smartbuck4.h:248
smartbuck4_t::slave_address
uint8_t slave_address
Definition: smartbuck4.h:220
smartbuck4_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: smartbuck4.h:236
smartbuck4_en_r60_reg
void smartbuck4_en_r60_reg(smartbuck4_t *ctx)
Smart Buck 4 enable 600A regulator function.
smartbuck4_dis_r60_reg
void smartbuck4_dis_r60_reg(smartbuck4_t *ctx)
Smart Buck 4 disable 600A regulator function.
smartbuck4_return_value_t
smartbuck4_return_value_t
Smart Buck 4 Click return value data.
Definition: smartbuck4.h:246
smartbuck4_cfg_t::sda
pin_name_t sda
Definition: smartbuck4.h:231
smartbuck4_en_r40_reg
void smartbuck4_en_r40_reg(smartbuck4_t *ctx)
Smart Buck 4 enable 400A regulator function.
smartbuck4_t::r40
digital_out_t r40
Definition: smartbuck4.h:213
smartbuck4_cfg_setup
void smartbuck4_cfg_setup(smartbuck4_cfg_t *cfg)
Smart Buck 4 configuration object setup function.
smartbuck4_cfg_t::i2c_address
uint8_t i2c_address
Definition: smartbuck4.h:237
smartbuck4_send_command
err_t smartbuck4_send_command(smartbuck4_t *ctx, uint8_t addr, uint8_t data_in)
Smart Buck 4 send command function.