Go to the documentation of this file.
38 #include "mikrosdk_version.h"
41 #if mikroSDK_GET_VERSION < 20800ul
42 #include "rcu_delays.h"
48 #include "drv_digital_out.h"
49 #include "drv_digital_in.h"
50 #include "drv_i2c_master.h"
62 #define SMARTBUCK_MAP_MIKROBUS( cfg, mikrobus ) \
63 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
64 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
65 cfg.en1 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
66 cfg.en2 = MIKROBUS( mikrobus, MIKROBUS_CS ); \
67 cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
68 cfg.pg = MIKROBUS( mikrobus, MIKROBUS_INT )
75 #define SMARTBUCK_RETVAL uint8_t
76 #define SMARTBUCK_OK 0x00
77 #define SMARTBUCK_INIT_ERROR 0xFF
83 #define SMARTBUCK_EEPROM_SLAVE_000 0x50
84 #define SMARTBUCK_EEPROM_SLAVE_001 0x51
85 #define SMARTBUCK_EEPROM_SLAVE_010 0x52
86 #define SMARTBUCK_EEPROM_SLAVE_011 0x53
87 #define SMARTBUCK_EEPROM_SLAVE_100 0x54
88 #define SMARTBUCK_EEPROM_SLAVE_101 0x55
89 #define SMARTBUCK_EEPROM_SLAVE_110 0x56
90 #define SMARTBUCK_EEPROM_SLAVE_111 0x57
91 #define SMARTBUCK_MCP4661_SLAVE_000 0x28
92 #define SMARTBUCK_MCP4661_SLAVE_001 0x29
93 #define SMARTBUCK_MCP4661_SLAVE_010 0x2A
94 #define SMARTBUCK_MCP4661_SLAVE_011 0x2B
95 #define SMARTBUCK_MCP4661_SLAVE_100 0x2C
96 #define SMARTBUCK_MCP4661_SLAVE_101 0x2D
97 #define SMARTBUCK_MCP4661_SLAVE_110 0x2E
98 #define SMARTBUCK_MCP4661_SLAVE_111 0x2F
99 #define SMARTBUCK_PAC1934_SLAVE_0 0x10
100 #define SMARTBUCK_PAC1934_SLAVE_1 0x1F
106 #define SMARTBUCK_WIPER0_VOL_REG 0x00
107 #define SMARTBUCK_WIPER1_VOL_REG 0x01
108 #define SMARTBUCK_WIPER0_NONVOL_REG 0x02
109 #define SMARTBUCK_WIPER1_NONVOL_REG 0x03
110 #define SMARTBUCK_POT_TCON_VOL_REG 0x04
111 #define SMARTBUCK_POT_STATUS_REG 0x05
117 #define SMARTBUCK_WIPER_FULL_SCALE 0x100
118 #define SMARTBUCK_WIPER_HALF_SCALE 0x080
119 #define SMARTBUCK_WIPER_QUARTER_SCALE 0x040
120 #define SMARTBUCK_WIPER_FULL_PER_8_SCALE 0x020
121 #define SMARTBUCK_WIPER_ZERO_SCALE 0x000
127 #define SMARTBUCK_TCON_GENCALL_EN 0x100
128 #define SMARTBUCK_TCON_R1HW_SHDWN_EN 0x080
129 #define SMARTBUCK_TCON_R1A_CONNECT 0x040
130 #define SMARTBUCK_TCON_R1W_CONNECT 0x020
131 #define SMARTBUCK_TCON_R1B_CONNECT 0x010
132 #define SMARTBUCK_TCON_R0HW_SHDWN_EN 0x008
133 #define SMARTBUCK_TCON_R0A_CONNECT 0x004
134 #define SMARTBUCK_TCON_R0W_CONNECT 0x002
135 #define SMARTBUCK_TCON_R0B_CONNECT 0x001
141 #define SMARTBUCK_REFRESH_CMND 0x00
142 #define SMARTBUCK_PAC_CTRL_REG 0x01
143 #define SMARTBUCK_PAC_ACC_COUNT_REG 0x02
144 #define SMARTBUCK_PAC_VPOW1_ACC_REG 0x03
145 #define SMARTBUCK_PAC_VPOW2_ACC_REG 0x04
146 #define SMARTBUCK_PAC_VPOW3_ACC_REG 0x05
147 #define SMARTBUCK_PAC_VPOW4_ACC_REG 0x06
148 #define SMARTBUCK_PAC_VBUS1_REG 0x07
149 #define SMARTBUCK_PAC_VBUS2_REG 0x08
150 #define SMARTBUCK_PAC_VBUS3_REG 0x09
151 #define SMARTBUCK_PAC_VBUS4_REG 0x0A
152 #define SMARTBUCK_PAC_VSENSE1_REG 0x0B
153 #define SMARTBUCK_PAC_VSENSE2_REG 0x0C
154 #define SMARTBUCK_PAC_VSENSE3_REG 0x0D
155 #define SMARTBUCK_PAC_VSENSE4_REG 0x0E
156 #define SMARTBUCK_PAC_VBUS1_AVG_REG 0x0F
157 #define SMARTBUCK_PAC_VBUS2_AVG_REG 0x10
158 #define SMARTBUCK_PAC_VBUS3_AVG_REG 0x11
159 #define SMARTBUCK_PAC_VBUS4_AVG_REG 0x12
160 #define SMARTBUCK_PAC_VSENSE1_AVG_REG 0x13
161 #define SMARTBUCK_PAC_VSENSE2_AVG_REG 0x14
162 #define SMARTBUCK_PAC_VSENSE3_AVG_REG 0x15
163 #define SMARTBUCK_PAC_VSENSE4_AVG_REG 0x16
164 #define SMARTBUCK_PAC_VPOW1_REG 0x17
165 #define SMARTBUCK_PAC_VPOW2_REG 0x18
166 #define SMARTBUCK_PAC_VPOW3_REG 0x19
167 #define SMARTBUCK_PAC_VPOW4_REG 0x1A
168 #define SMARTBUCK_PAC_CHANN_DIS_REG 0x1C
169 #define SMARTBUCK_PAC_NEG_PWR_REG 0x1D
170 #define SMARTBUCK_REFRESH_G_CMND 0x1E
171 #define SMARTBUCK_REFRESH_V_CMND 0x1F
172 #define SMARTBUCK_PAC_SLOW_REG 0x20
173 #define SMARTBUCK_PAC_CTRL_STAT_REG 0x21
174 #define SMARTBUCK_PAC_CHANN_DIS_STAT_REG 0x22
175 #define SMARTBUCK_PAC_NEG_PWR_STAT_REG 0x23
176 #define SMARTBUCK_PAC_CTRL_LATCH_REG 0x24
177 #define SMARTBUCK_PAC_CHANN_DIS_LATCH_REG 0x25
178 #define SMARTBUCK_PAC_NEG_PWR_LATCH_REG 0x26
179 #define SMARTBUCK_PAC_PID_REG 0xFD
180 #define SMARTBUCK_PAC_MANU_ID_REG 0xFE
181 #define SMARTBUCK_PAC_REV_ID_REG 0xFF
187 #define SMARTBUCK_PAC_1024_SAMPL 0x00
188 #define SMARTBUCK_PAC_256_SAMPL 0x40
189 #define SMARTBUCK_PAC_64_SAMPL 0x80
190 #define SMARTBUCK_PAC_8_SAMPL 0xC0
191 #define SMARTBUCK_PAC_SLEEP_MODE 0x20
192 #define SMARTBUCK_PAC_SEQUENTIAL_MODE 0x00
193 #define SMARTBUCK_PAC_SINGLE_SHOT_MODE 0x10
194 #define SMARTBUCK_PAC_ALERT_PIN_EN 0x0C
195 #define SMARTBUCK_PAC_OVF_ALERT_EN 0x02
201 #define SMARTBUCK_WIPER0_SEL 0x00
202 #define SMARTBUCK_WIPER1_SEL 0x01
203 #define SMARTBUCK_REGULATOR_DIS 0x00
204 #define SMARTBUCK_REGULATOR_EN 0x01
205 #define SMARTBUCK_AUTO_TRICKLE_MODE 0x01
206 #define SMARTBUCK_FORCE_PWM_MODE 0x00
207 #define SMARTBUCK_ALL_CHANN_OFF 0xF0
208 #define SMARTBUCK_ALL_CHANN_ON 0x00
209 #define SMARTBUCK_CH1_ON 0x70
210 #define SMARTBUCK_CH2_ON 0xB0
211 #define SMARTBUCK_CH3_ON 0xD0
212 #define SMARTBUCK_CH4_ON 0xE0
213 #define SMARTBUCK_ALL_DATA_UNSIGN_FORM 0x00
214 #define SMARTBUCK_ALL_DATA_SIGN_FORM 0xFF
215 #define SMARTBUCK_CH1_VSENSE_SIGN_FORM 0x80
216 #define SMARTBUCK_CH2_VSENSE_SIGN_FORM 0x40
217 #define SMARTBUCK_CH3_VSENSE_SIGN_FORM 0x20
218 #define SMARTBUCK_CH4_VSENSE_SIGN_FORM 0x10
219 #define SMARTBUCK_CH1_VBUS_SIGN_FORM 0x08
220 #define SMARTBUCK_CH2_VBUS_SIGN_FORM 0x04
221 #define SMARTBUCK_CH3_VBUS_SIGN_FORM 0x02
222 #define SMARTBUCK_CH4_VBUS_SIGN_FORM 0x01
223 #define SMARTBUCK_SAMPL_DATA_MODE 0x00
224 #define SMARTBUCK_AVRG_DATA_MODE 0x01
230 #define SMARTBUCK_POT_WRITE_CMND 0x00
231 #define SMARTBUCK_POT_INCR_CMND 0x04
232 #define SMARTBUCK_POT_DECR_CMND 0x08
233 #define SMARTBUCK_POT_READ_CMND 0x0C
234 #define SMARTBUCK_PAC_GENERAL_CALL_SLAVE 0x00
575 #endif // _SMARTBUCK_H_
uint8_t smartbuck_read_pac(smartbuck_t *ctx, uint8_t reg_addr, uint8_t *data_out)
PAC1934 Read function.
uint8_t smartbuck_read_seq_eeprom(smartbuck_t *ctx, uint8_t eeprom_addr, uint8_t *data_out, uint8_t n_bytes)
Sequential EEPROM Read function.
pin_name_t en1
Definition: smartbuck.h:288
uint8_t smartbuck_write_pac(smartbuck_t *ctx, uint8_t reg_addr, uint8_t data_in)
PAC1934 Write function.
pin_name_t pg
Definition: smartbuck.h:291
uint8_t smartbuck_read_pot(smartbuck_t *ctx, uint8_t reg_addr, uint16_t *data_out)
Potentiometer Read function.
Click ctx object definition.
Definition: smartbuck.h:249
void smartbuck_default_cfg(smartbuck_t *ctx)
Click Default Configuration function.
pin_name_t scl
Definition: smartbuck.h:283
void smartbuck_en_regulator2(smartbuck_t *ctx, uint8_t state)
Regulator2 Enable function.
pin_name_t sda
Definition: smartbuck.h:284
uint8_t smartbuck_block_read_pac(smartbuck_t *ctx, uint8_t reg_addr, uint8_t *data_out, uint8_t n_bytes)
PAC1934 Block Read function.
digital_out_t en2
Definition: smartbuck.h:253
i2c_master_t i2c
Definition: smartbuck.h:262
uint8_t slave_mcp4661
Definition: smartbuck.h:267
uint8_t smartbuck_set_addr_ptr_pac(smartbuck_t *ctx, uint8_t reg_addr)
Address Pointer Set function.
uint8_t data_select
Definition: smartbuck.h:272
digital_out_t pwm
Definition: smartbuck.h:254
uint8_t smartbuck_decr_pot(smartbuck_t *ctx, uint8_t wiper_sel, uint16_t steps)
Potentiometer Decrement function.
uint8_t smartbuck_incr_pot(smartbuck_t *ctx, uint8_t wiper_sel, uint16_t steps)
Potentiometer Increment function.
uint8_t i2c_address_mcp4661
Definition: smartbuck.h:297
uint8_t smartbuck_write_pot(smartbuck_t *ctx, uint8_t reg_addr, uint16_t data_in)
Potentiometer Write function.
void smartbuck_force_pwm_mode(smartbuck_t *ctx, uint8_t state)
PWM Mode Force function.
Click configuration structure definition.
Definition: smartbuck.h:280
uint8_t slave_eeprom
Definition: smartbuck.h:266
void smartbuck_en_regulator1(smartbuck_t *ctx, uint8_t state)
Regulator1 Enable function.
digital_out_t en1
Definition: smartbuck.h:252
uint8_t slave_pac1934
Definition: smartbuck.h:268
uint8_t smartbuck_check_diagnostic(smartbuck_t *ctx)
Diagnostic Check function.
digital_in_t pg
Definition: smartbuck.h:258
uint8_t smartbuck_write_eeprom(smartbuck_t *ctx, uint8_t eeprom_addr, uint8_t data_in)
EEPROM Write function.
uint32_t i2c_speed
Definition: smartbuck.h:295
uint8_t data_form
Definition: smartbuck.h:271
uint8_t i2c_address_pac1934
Definition: smartbuck.h:298
uint8_t smartbuck_send_cmd_pac(smartbuck_t *ctx, uint8_t command)
Command Send function.
pin_name_t pwm
Definition: smartbuck.h:290
void smartbuck_receive_byte_pac(smartbuck_t *ctx, uint8_t *data_out)
Byte Receive function.
SMARTBUCK_RETVAL smartbuck_init(smartbuck_t *ctx, smartbuck_cfg_t *cfg)
Initialization function.
pin_name_t en2
Definition: smartbuck.h:289
void smartbuck_cfg_setup(smartbuck_cfg_t *cfg)
Config Object Initialization function.
void smartbuck_get_data(smartbuck_t *ctx, float *voltage, float *current, float *power)
Data Get function.
#define SMARTBUCK_RETVAL
Definition: smartbuck.h:75
uint8_t enabled_chann
Definition: smartbuck.h:270
uint8_t i2c_address_eeprom
Definition: smartbuck.h:296
uint8_t smartbuck_set_config_pac(smartbuck_t *ctx, uint8_t en_chann, uint8_t data_format, uint8_t data_sel)
PAC1934 Configuration Set function.
uint8_t smartbuck_read_eeprom(smartbuck_t *ctx, uint8_t eeprom_addr, uint8_t *data_out)
EEPROM Read function.