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 VCPMONITOR2_MAP_MIKROBUS( cfg, mikrobus ) \
63 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
64 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
65 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST )
73 #define VCPMONITOR2_RETVAL uint8_t
75 #define VCPMONITOR2_OK 0x00
76 #define VCPMONITOR2_INIT_ERROR 0xFF
83 #define VCPMONITOR2_DEVICE_SLAVE_ADDR_GND 0x40
84 #define VCPMONITOR2_DEVICE_SLAVE_ADDR_VCC 0x41
85 #define VCPMONITOR2_DEVICE_SLAVE_ADDR_SCL 0x42
86 #define VCPMONITOR2_DEVICE_SLAVE_ADDR_SDA 0x43
93 #define VCPMONITOR2_STATUS_ADDR_GND_GND 0x70
94 #define VCPMONITOR2_STATUS_ADDR_VCC_GND 0x72
95 #define VCPMONITOR2_STATUS_ADDR_GND_VCC 0x71
96 #define VCPMONITOR2_STATUS_ADDR_VCC_VCC 0x73
103 #define VCPMONITOR2_ALERT_REG_INPUT 0x00
104 #define VCPMONITOR2_ALERT_REG_POLARITY 0x02
105 #define VCPMONITOR2_ALERT_REG_CONFIG 0x03
112 #define VCPMONITOR2_REG_CONFIGURATION 0x00
113 #define VCPMONITOR2_REG_CH_1_SHUNT_VOLT 0x01
114 #define VCPMONITOR2_REG_CH_1_BUS_VOLT 0x02
115 #define VCPMONITOR2_REG_CH_2_SHUNT_VOLT 0x03
116 #define VCPMONITOR2_REG_CH_2_BUS_VOLT 0x04
117 #define VCPMONITOR2_REG_CH_3_SHUNT_VOLT 0x05
118 #define VCPMONITOR2_REG_CH_3_BUS_VOLT 0x06
119 #define VCPMONITOR2_REG_CH_1_CRITICAL_ALT 0x07
120 #define VCPMONITOR2_REG_CH_1_WARNING_ALT 0x08
121 #define VCPMONITOR2_REG_CH_2_CRITICAL_ALT 0x09
122 #define VCPMONITOR2_REG_CH_2_WARNING_ALT 0x0A
123 #define VCPMONITOR2_REG_CH_3_CRITICAL_ALT 0x0B
124 #define VCPMONITOR2_REG_CH_3_WARNING_ALT 0x0C
125 #define VCPMONITOR2_REG_SHUNT_VOLT_SUM 0x0D
126 #define VCPMONITOR2_REG_SHUNT_VOLT_SUM_LIMIT 0x0E
127 #define VCPMONITOR2_REG_MASK_ENABLE 0x0F
128 #define VCPMONITOR2_REG_PWR_UPPER_LIMIT 0x10
129 #define VCPMONITOR2_REG_PWR_LOWER_LIMIT 0x11
130 #define VCPMONITOR2_REG_MANUFACTURER_ID 0xFE
131 #define VCPMONITOR2_REG_DIE_ID 0xFF
138 #define VCPMONITOR2_DEF_MANUFACTURE_ID 0x5449
139 #define VCPMONITOR2_DEF_DIE_ID 0x3220
140 #define VCPMONITOR2_DEF_PWR_LOWER_LIMIT 0x2328
141 #define VCPMONITOR2_DEF_PWR_UPPER_LIMIT 0x2F10
142 #define VCPMONITOR2_DEF_MASK_ENABLE 0x0002
143 #define VCPMONITOR2_DEF_SHUNT_VOLT_SUM_LIMIT 0x7FFE
144 #define VCPMONITOR2_DEF_CONFIGURATION 0x7127
145 #define VCPMONITOR2_DEF_CH_1234_ALERT 0x7FF8
152 #define VCPMONITOR2_CFG_SW_RESET 0x8000
153 #define VCPMONITOR2_CFG_CH_1_ENABLE 0x4000
154 #define VCPMONITOR2_CFG_CH_1_DISABLE 0x0000
155 #define VCPMONITOR2_CFG_CH_2_ENABLE 0x2000
156 #define VCPMONITOR2_CFG_CH_2_DISABLE 0x0000
157 #define VCPMONITOR2_CFG_CH_3_ENABLE 0x1000
158 #define VCPMONITOR2_CFG_CH_3_DISABLE 0x0000
159 #define VCPMONITOR2_CFG_AVG_1 0x0000
160 #define VCPMONITOR2_CFG_AVG_4 0x0200
161 #define VCPMONITOR2_CFG_AVG_16 0x0400
162 #define VCPMONITOR2_CFG_AVG_64 0x0600
163 #define VCPMONITOR2_CFG_AVG_128 0x0800
164 #define VCPMONITOR2_CFG_AVG_256 0x0A00
165 #define VCPMONITOR2_CFG_AVG_512 0x0C00
166 #define VCPMONITOR2_CFG_AVG_1024 0x0D00
168 #define VCPMONITOR2_CFG_VBUS_CT_140us 0x0000
169 #define VCPMONITOR2_CFG_VBUS_CT_204us 0x0040
170 #define VCPMONITOR2_CFG_VBUS_CT_332us 0x0080
171 #define VCPMONITOR2_CFG_VBUS_CT_588us 0x00C0
172 #define VCPMONITOR2_CFG_VBUS_CT_1100us 0x0100
173 #define VCPMONITOR2_CFG_VBUS_CT_2116us 0x0140
174 #define VCPMONITOR2_CFG_VBUS_CT_4156us 0x0180
175 #define VCPMONITOR2_CFG_VBUS_CT_8244us 0x01C0
176 #define VCPMONITOR2_CFG_VSH_CT_140us 0x0000
177 #define VCPMONITOR2_CFG_VSH_CT_204us 0x0008
178 #define VCPMONITOR2_CFG_VSH_CT_332us 0x0010
179 #define VCPMONITOR2_CFG_VSH_CT_588us 0x0018
180 #define VCPMONITOR2_CFG_VSH_CT_1100us 0x0020
181 #define VCPMONITOR2_CFG_VSH_CT_2116us 0x0028
182 #define VCPMONITOR2_CFG_VSH_CT_4156us 0x0030
183 #define VCPMONITOR2_CFG_VSH_CT_8244us 0x0038
185 #define VCPMONITOR2_CFG_MODE_POWER_DOWN 0x0000
186 #define VCPMONITOR2_CFG_MODE_SS_SHUNT_VOLT 0x0001
187 #define VCPMONITOR2_CFG_MODE_SS_BUS_VOLT 0x0002
188 #define VCPMONITOR2_CFG_MODE_SS_SHUNT_BUS_VOLT 0x0003
189 #define VCPMONITOR2_CFG_MODE_CONT_SHUNT_VOLT 0x0005
190 #define VCPMONITOR2_CFG_MODE_CONT_BUS_VOLT 0x0006
191 #define VCPMONITOR2_CFG_MODE_CONT_SHUNT_BUS_VOLT 0x0007
198 #define VCPMONITOR2_CFG_MASK_SCC_1_ENABLE 0x4000
199 #define VCPMONITOR2_CFG_MASK_SCC_2_ENABLE 0x2000
200 #define VCPMONITOR2_CFG_MASK_SCC_3_ENABLE 0x1000
201 #define VCPMONITOR2_CFG_MASK_SCC_1_DISABLE 0x0000
202 #define VCPMONITOR2_CFG_MASK_SCC_2_DISABLE 0x0000
203 #define VCPMONITOR2_CFG_MASK_SCC_3_DISABLE 0x0000
204 #define VCPMONITOR2_CFG_MASK_WEN_TRANSPARENT 0x0000
205 #define VCPMONITOR2_CFG_MASK_WEN_LATCH_ENABLED 0x0800
206 #define VCPMONITOR2_CFG_MASK_CEN_TRANSPARENT 0x0000
207 #define VCPMONITOR2_CFG_MASK_CEN_LATCH_ENABLED 0x0400
208 #define VCPMONITOR2_CFG_MASK_CF_1_ENABLE 0x0080
209 #define VCPMONITOR2_CFG_MASK_CF_2_ENABLE 0x0100
210 #define VCPMONITOR2_CFG_MASK_CF_3_ENABLE 0x0200
211 #define VCPMONITOR2_CFG_MASK_CF_1_DISABLE 0x0000
212 #define VCPMONITOR2_CFG_MASK_CF_2_DISABLE 0x0000
213 #define VCPMONITOR2_CFG_MASK_CF_3_DISABLE 0x0000
214 #define VCPMONITOR2_CFG_MASK_SF_ENABLE 0x0040
215 #define VCPMONITOR2_CFG_MASK_SF_DISABLE 0x0000
216 #define VCPMONITOR2_CFG_MASK_VF_1_ENABLE 0x0008
217 #define VCPMONITOR2_CFG_MASK_VF_2_ENABLE 0x0010
218 #define VCPMONITOR2_CFG_MASK_VF_3_ENABLE 0x0020
219 #define VCPMONITOR2_CFG_MASK_VF_1_DISABLE 0x0000
220 #define VCPMONITOR2_CFG_MASK_VF_2_DISABLE 0x0000
221 #define VCPMONITOR2_CFG_MASK_VF_3_DISABLE 0x0000
222 #define VCPMONITOR2_CFG_MASK_PVF_ENABLE 0x0004
223 #define VCPMONITOR2_CFG_MASK_TCF_ENABLE 0x0002
224 #define VCPMONITOR2_CFG_MASK_CVRF_ENABLE 0x0001
225 #define VCPMONITOR2_CFG_MASK_PVF_DISABLE 0x0000
226 #define VCPMONITOR2_CFG_MASK_TCF_DISABLE 0x0000
227 #define VCPMONITOR2_CFG_MASK_CVRF_DISABLE 0x0000
234 #define VCPMONITOR2_CHANNEL_1 0x01
235 #define VCPMONITOR2_CHANNEL_2 0x02
236 #define VCPMONITOR2_CHANNEL_3 0x03
243 #define VCPMONITOR2_ALERT_PVALID 0x01
244 #define VCPMONITOR2_ALERT_WRNG 0x02
245 #define VCPMONITOR2_ALERT_CRTCL 0x04
246 #define VCPMONITOR2_ALERT_TCTRL 0x08
250 #define DEVICE_ERROR 1
475 #endif // _VCPMONITOR2_H_
uint8_t vcpmonitor2_get_alert_status(vcpmonitor2_t *ctx)
Get Alert status.
void vcpmonitor2_alert_config(vcpmonitor2_t *ctx, uint8_t cfg)
Alert configuration ( Enable / Disable )
uint16_t vcpmonitor2_get_manifacture_id(vcpmonitor2_t *ctx)
Get Manufacture ID.
void vcpmonitor2_generic_write(vcpmonitor2_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
uint32_t i2c_speed
Definition: vcpmonitor2.h:295
float vcpmonitor2_get_power(vcpmonitor2_t *ctx, uint8_t channel)
Get Power in W.
pin_name_t scl
Definition: vcpmonitor2.h:286
uint8_t device_status_address
Definition: vcpmonitor2.h:297
void vcpmonitor2_generic_read(vcpmonitor2_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
void vcpmonitor2_configuration(vcpmonitor2_t *ctx, uint16_t cfg)
Configuration function.
void vcpmonitor2_cfg_setup(vcpmonitor2_cfg_t *cfg)
Config Object Initialization function.
void vcpmonitor2_default_cfg(vcpmonitor2_t *ctx)
Click Default Configuration function.
uint8_t device_status_address
Definition: vcpmonitor2.h:275
uint8_t device_slave_address
Definition: vcpmonitor2.h:274
uint16_t vcpmonitor2_get_die_id(vcpmonitor2_t *ctx)
Get DIE ID.
float vcpmonitor2_get_current(vcpmonitor2_t *ctx, uint8_t channel)
Get Current data in mA.
pin_name_t sda
Definition: vcpmonitor2.h:287
Click configuration structure definition.
Definition: vcpmonitor2.h:283
VCPMONITOR2_RETVAL vcpmonitor2_init(vcpmonitor2_t *ctx, vcpmonitor2_cfg_t *cfg)
Initialization function.
uint8_t device_slave_address
Definition: vcpmonitor2.h:296
Click ctx object definition.
Definition: vcpmonitor2.h:263
pin_name_t rst
Definition: vcpmonitor2.h:291
float vcpmonitor2_get_shunt_voltage(vcpmonitor2_t *ctx, uint8_t channel)
Get Shunt voltage in mV.
i2c_master_t i2c
Definition: vcpmonitor2.h:270
void vcpmonitor2_reset_alert(vcpmonitor2_t *ctx)
Alert reset.
digital_out_t rst
Definition: vcpmonitor2.h:266
float vcpmonitor2_get_bus_voltage(vcpmonitor2_t *ctx, uint8_t channel)
Get BUS voltage in mV.
#define VCPMONITOR2_RETVAL
Definition: vcpmonitor2.h:73