Go to the documentation of this file.
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_i2c_master.h"
52 #define SMARTBUCK_MAP_MIKROBUS( cfg, mikrobus ) \
53 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
54 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
55 cfg.en1 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
56 cfg.en2 = MIKROBUS( mikrobus, MIKROBUS_CS ); \
57 cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
58 cfg.pg = MIKROBUS( mikrobus, MIKROBUS_INT )
65 #define SMARTBUCK_RETVAL uint8_t
66 #define SMARTBUCK_OK 0x00
67 #define SMARTBUCK_INIT_ERROR 0xFF
73 #define SMARTBUCK_EEPROM_SLAVE_000 0x50
74 #define SMARTBUCK_EEPROM_SLAVE_001 0x51
75 #define SMARTBUCK_EEPROM_SLAVE_010 0x52
76 #define SMARTBUCK_EEPROM_SLAVE_011 0x53
77 #define SMARTBUCK_EEPROM_SLAVE_100 0x54
78 #define SMARTBUCK_EEPROM_SLAVE_101 0x55
79 #define SMARTBUCK_EEPROM_SLAVE_110 0x56
80 #define SMARTBUCK_EEPROM_SLAVE_111 0x57
81 #define SMARTBUCK_MCP4661_SLAVE_000 0x28
82 #define SMARTBUCK_MCP4661_SLAVE_001 0x29
83 #define SMARTBUCK_MCP4661_SLAVE_010 0x2A
84 #define SMARTBUCK_MCP4661_SLAVE_011 0x2B
85 #define SMARTBUCK_MCP4661_SLAVE_100 0x2C
86 #define SMARTBUCK_MCP4661_SLAVE_101 0x2D
87 #define SMARTBUCK_MCP4661_SLAVE_110 0x2E
88 #define SMARTBUCK_MCP4661_SLAVE_111 0x2F
89 #define SMARTBUCK_PAC1934_SLAVE_0 0x10
90 #define SMARTBUCK_PAC1934_SLAVE_1 0x1F
96 #define SMARTBUCK_WIPER0_VOL_REG 0x00
97 #define SMARTBUCK_WIPER1_VOL_REG 0x01
98 #define SMARTBUCK_WIPER0_NONVOL_REG 0x02
99 #define SMARTBUCK_WIPER1_NONVOL_REG 0x03
100 #define SMARTBUCK_POT_TCON_VOL_REG 0x04
101 #define SMARTBUCK_POT_STATUS_REG 0x05
107 #define SMARTBUCK_WIPER_FULL_SCALE 0x100
108 #define SMARTBUCK_WIPER_HALF_SCALE 0x080
109 #define SMARTBUCK_WIPER_QUARTER_SCALE 0x040
110 #define SMARTBUCK_WIPER_FULL_PER_8_SCALE 0x020
111 #define SMARTBUCK_WIPER_ZERO_SCALE 0x000
117 #define SMARTBUCK_TCON_GENCALL_EN 0x100
118 #define SMARTBUCK_TCON_R1HW_SHDWN_EN 0x080
119 #define SMARTBUCK_TCON_R1A_CONNECT 0x040
120 #define SMARTBUCK_TCON_R1W_CONNECT 0x020
121 #define SMARTBUCK_TCON_R1B_CONNECT 0x010
122 #define SMARTBUCK_TCON_R0HW_SHDWN_EN 0x008
123 #define SMARTBUCK_TCON_R0A_CONNECT 0x004
124 #define SMARTBUCK_TCON_R0W_CONNECT 0x002
125 #define SMARTBUCK_TCON_R0B_CONNECT 0x001
131 #define SMARTBUCK_REFRESH_CMND 0x00
132 #define SMARTBUCK_PAC_CTRL_REG 0x01
133 #define SMARTBUCK_PAC_ACC_COUNT_REG 0x02
134 #define SMARTBUCK_PAC_VPOW1_ACC_REG 0x03
135 #define SMARTBUCK_PAC_VPOW2_ACC_REG 0x04
136 #define SMARTBUCK_PAC_VPOW3_ACC_REG 0x05
137 #define SMARTBUCK_PAC_VPOW4_ACC_REG 0x06
138 #define SMARTBUCK_PAC_VBUS1_REG 0x07
139 #define SMARTBUCK_PAC_VBUS2_REG 0x08
140 #define SMARTBUCK_PAC_VBUS3_REG 0x09
141 #define SMARTBUCK_PAC_VBUS4_REG 0x0A
142 #define SMARTBUCK_PAC_VSENSE1_REG 0x0B
143 #define SMARTBUCK_PAC_VSENSE2_REG 0x0C
144 #define SMARTBUCK_PAC_VSENSE3_REG 0x0D
145 #define SMARTBUCK_PAC_VSENSE4_REG 0x0E
146 #define SMARTBUCK_PAC_VBUS1_AVG_REG 0x0F
147 #define SMARTBUCK_PAC_VBUS2_AVG_REG 0x10
148 #define SMARTBUCK_PAC_VBUS3_AVG_REG 0x11
149 #define SMARTBUCK_PAC_VBUS4_AVG_REG 0x12
150 #define SMARTBUCK_PAC_VSENSE1_AVG_REG 0x13
151 #define SMARTBUCK_PAC_VSENSE2_AVG_REG 0x14
152 #define SMARTBUCK_PAC_VSENSE3_AVG_REG 0x15
153 #define SMARTBUCK_PAC_VSENSE4_AVG_REG 0x16
154 #define SMARTBUCK_PAC_VPOW1_REG 0x17
155 #define SMARTBUCK_PAC_VPOW2_REG 0x18
156 #define SMARTBUCK_PAC_VPOW3_REG 0x19
157 #define SMARTBUCK_PAC_VPOW4_REG 0x1A
158 #define SMARTBUCK_PAC_CHANN_DIS_REG 0x1C
159 #define SMARTBUCK_PAC_NEG_PWR_REG 0x1D
160 #define SMARTBUCK_REFRESH_G_CMND 0x1E
161 #define SMARTBUCK_REFRESH_V_CMND 0x1F
162 #define SMARTBUCK_PAC_SLOW_REG 0x20
163 #define SMARTBUCK_PAC_CTRL_STAT_REG 0x21
164 #define SMARTBUCK_PAC_CHANN_DIS_STAT_REG 0x22
165 #define SMARTBUCK_PAC_NEG_PWR_STAT_REG 0x23
166 #define SMARTBUCK_PAC_CTRL_LATCH_REG 0x24
167 #define SMARTBUCK_PAC_CHANN_DIS_LATCH_REG 0x25
168 #define SMARTBUCK_PAC_NEG_PWR_LATCH_REG 0x26
169 #define SMARTBUCK_PAC_PID_REG 0xFD
170 #define SMARTBUCK_PAC_MANU_ID_REG 0xFE
171 #define SMARTBUCK_PAC_REV_ID_REG 0xFF
177 #define SMARTBUCK_PAC_1024_SAMPL 0x00
178 #define SMARTBUCK_PAC_256_SAMPL 0x40
179 #define SMARTBUCK_PAC_64_SAMPL 0x80
180 #define SMARTBUCK_PAC_8_SAMPL 0xC0
181 #define SMARTBUCK_PAC_SLEEP_MODE 0x20
182 #define SMARTBUCK_PAC_SEQUENTIAL_MODE 0x00
183 #define SMARTBUCK_PAC_SINGLE_SHOT_MODE 0x10
184 #define SMARTBUCK_PAC_ALERT_PIN_EN 0x0C
185 #define SMARTBUCK_PAC_OVF_ALERT_EN 0x02
191 #define SMARTBUCK_WIPER0_SEL 0x00
192 #define SMARTBUCK_WIPER1_SEL 0x01
193 #define SMARTBUCK_REGULATOR_DIS 0x00
194 #define SMARTBUCK_REGULATOR_EN 0x01
195 #define SMARTBUCK_AUTO_TRICKLE_MODE 0x01
196 #define SMARTBUCK_FORCE_PWM_MODE 0x00
197 #define SMARTBUCK_ALL_CHANN_OFF 0xF0
198 #define SMARTBUCK_ALL_CHANN_ON 0x00
199 #define SMARTBUCK_CH1_ON 0x70
200 #define SMARTBUCK_CH2_ON 0xB0
201 #define SMARTBUCK_CH3_ON 0xD0
202 #define SMARTBUCK_CH4_ON 0xE0
203 #define SMARTBUCK_ALL_DATA_UNSIGN_FORM 0x00
204 #define SMARTBUCK_ALL_DATA_SIGN_FORM 0xFF
205 #define SMARTBUCK_CH1_VSENSE_SIGN_FORM 0x80
206 #define SMARTBUCK_CH2_VSENSE_SIGN_FORM 0x40
207 #define SMARTBUCK_CH3_VSENSE_SIGN_FORM 0x20
208 #define SMARTBUCK_CH4_VSENSE_SIGN_FORM 0x10
209 #define SMARTBUCK_CH1_VBUS_SIGN_FORM 0x08
210 #define SMARTBUCK_CH2_VBUS_SIGN_FORM 0x04
211 #define SMARTBUCK_CH3_VBUS_SIGN_FORM 0x02
212 #define SMARTBUCK_CH4_VBUS_SIGN_FORM 0x01
213 #define SMARTBUCK_SAMPL_DATA_MODE 0x00
214 #define SMARTBUCK_AVRG_DATA_MODE 0x01
220 #define SMARTBUCK_POT_WRITE_CMND 0x00
221 #define SMARTBUCK_POT_INCR_CMND 0x04
222 #define SMARTBUCK_POT_DECR_CMND 0x08
223 #define SMARTBUCK_POT_READ_CMND 0x0C
224 #define SMARTBUCK_PAC_GENERAL_CALL_SLAVE 0x00
565 #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:278
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:281
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:238
void smartbuck_default_cfg(smartbuck_t *ctx)
Click Default Configuration function.
pin_name_t scl
Definition: smartbuck.h:273
void smartbuck_en_regulator2(smartbuck_t *ctx, uint8_t state)
Regulator2 Enable function.
pin_name_t sda
Definition: smartbuck.h:274
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:243
i2c_master_t i2c
Definition: smartbuck.h:252
uint8_t slave_mcp4661
Definition: smartbuck.h:257
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:262
digital_out_t pwm
Definition: smartbuck.h:244
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:287
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:269
uint8_t slave_eeprom
Definition: smartbuck.h:256
void smartbuck_en_regulator1(smartbuck_t *ctx, uint8_t state)
Regulator1 Enable function.
digital_out_t en1
Definition: smartbuck.h:242
uint8_t slave_pac1934
Definition: smartbuck.h:258
uint8_t smartbuck_check_diagnostic(smartbuck_t *ctx)
Diagnostic Check function.
digital_in_t pg
Definition: smartbuck.h:248
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:285
uint8_t data_form
Definition: smartbuck.h:261
uint8_t i2c_address_pac1934
Definition: smartbuck.h:288
uint8_t smartbuck_send_cmd_pac(smartbuck_t *ctx, uint8_t command)
Command Send function.
pin_name_t pwm
Definition: smartbuck.h:280
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:279
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:65
uint8_t enabled_chann
Definition: smartbuck.h:260
uint8_t i2c_address_eeprom
Definition: smartbuck.h:286
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.