Go to the documentation of this file.
35 #include "mikrosdk_version.h"
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_i2c_master.h"
69 #define VCPMONITOR6_REG_CONFIG 0x00
70 #define VCPMONITOR6_REG_ADC_CONFIG 0x01
71 #define VCPMONITOR6_REG_VBUS 0x05
72 #define VCPMONITOR6_REG_DIETEMP 0x06
73 #define VCPMONITOR6_REG_CURRENT 0x07
74 #define VCPMONITOR6_REG_POWER 0x08
75 #define VCPMONITOR6_REG_ENERGY 0x09
76 #define VCPMONITOR6_REG_CHARGE 0x0A
77 #define VCPMONITOR6_REG_ALERT_DIAG 0x0B
78 #define VCPMONITOR6_REG_COL 0x0C
79 #define VCPMONITOR6_REG_CUL 0x0D
80 #define VCPMONITOR6_REG_BOVL 0x0E
81 #define VCPMONITOR6_REG_BUVL 0x0F
82 #define VCPMONITOR6_REG_TEMP_LIMIT 0x10
83 #define VCPMONITOR6_REG_PWR_LIMIT 0x11
84 #define VCPMONITOR6_REG_MANUFACTURER_ID 0x3E
102 #define VCPMONITOR6_CFG_RST 0x80
103 #define VCPMONITOR6_CFG_RSTACC 0x40
104 #define VCPMONITOR6_CFG_CONVDLY 0x01FEu
110 #define VCPMONITOR6_ADC_CFG_MODE_SHD 0x00
111 #define VCPMONITOR6_ADC_CFG_MODE_TRG_BV 0x01
112 #define VCPMONITOR6_ADC_CFG_MODE_TRG_T 0x04
113 #define VCPMONITOR6_ADC_CFG_MODE_TRG_BV_T 0x05
114 #define VCPMONITOR6_ADC_CFG_MODE_TRG_T_C 0x06
115 #define VCPMONITOR6_ADC_CFG_MODE_TRG_ALL 0x07
116 #define VCPMONITOR6_ADC_CFG_MODE_SD 0x08
117 #define VCPMONITOR6_ADC_CFG_MODE_CNT_BV 0x09
118 #define VCPMONITOR6_ADC_CFG_MODE_CNT_T 0x0C
119 #define VCPMONITOR6_ADC_CFG_MODE_CNT_BV_T 0x0D
120 #define VCPMONITOR6_ADC_CFG_MODE_CNT_T_C 0x0E
121 #define VCPMONITOR6_ADC_CFG_MODE_CNT_ALL 0x0F
122 #define VCPMONITOR6_ADC_CFG_MODE_BITMASK 0x0FFFu
123 #define VCPMONITOR6_ADC_CFG_VBSTA 0x07
124 #define VCPMONITOR6_ADC_CFG_VBSTA_BITMASK 0xF007u
125 #define VCPMONITOR6_ADC_CFG_AVG 0x07
126 #define VCPMONITOR6_ADC_CFG_AVG_BITMASK 0xFFF8u
132 #define VCPMONITOR6_ALR_DIAG_TRANSPARENT 0x0000u
133 #define VCPMONITOR6_ALR_DIAG_ALATCH 0x8000u
134 #define VCPMONITOR6_ALR_DIAG_CNVR_DIS 0x0000u
135 #define VCPMONITOR6_ALR_DIAG_CNVR_EN 0x4000u
136 #define VCPMONITOR6_ALR_DIAG_SLWALR_NAVG 0x0000u
137 #define VCPMONITOR6_ALR_DIAG_SLWALR_AVG 0x2000u
138 #define VCPMONITOR6_ALR_DIAG_APOL_NORMAL 0x0000u
139 #define VCPMONITOR6_ALR_DIAG_APOL_INV 0x1000u
140 #define VCPMONITOR6_ALR_DIAG_W_BITMASK 0xF000u
141 #define VCPMONITOR6_ALR_DIAG_ENERGYOF 0x0800u
142 #define VCPMONITOR6_ALR_DIAG_CHARGEOF 0x0400u
143 #define VCPMONITOR6_ALR_DIAG_MATHOF 0x0200u
144 #define VCPMONITOR6_ALR_DIAG_TMPOL 0x0080u
145 #define VCPMONITOR6_ALR_DIAG_CURRENTOL 0x0040u
146 #define VCPMONITOR6_ALR_DIAG_CURRENTUL 0x0020u
147 #define VCPMONITOR6_ALR_DIAG_BUSOL 0x0010u
148 #define VCPMONITOR6_ALR_DIAG_BUSUL 0x0008u
149 #define VCPMONITOR6_ALR_DIAG_POL 0x0004u
150 #define VCPMONITOR6_ALR_DIAG_CNVRF 0x0002u
151 #define VCPMONITOR6_ALR_DIAG_MEMSTAT 0x0001u
152 #define VCPMONITOR6_ALR_DIAG_R_BITMASK 0x0FFFu
158 #define VCPMONITOR6_MANUFACTURER_ID 0x5449u
164 #define VCPMONITOR6_CONV_FACT_VBUS 3.125f
165 #define VCPMONITOR6_CONV_FACT_DIETEMP 125.0f
166 #define VCPMONITOR6_CONV_FACT_CURRENT 2500.0f
167 #define VCPMONITOR6_CONV_FACT_POWER 480.0f
168 #define VCPMONITOR6_CONV_FACT_ENERGY 7.68f
169 #define VCPMONITOR6_CONV_FACT_CHARGE 150.0f
170 #define VCPMONITOR6_CALC_EN_CHRG_RES 256.0f
171 #define VCPMONITOR6_CALC_EN_CHRG 4.0f
172 #define VCPMONITOR6_UN_CONV_1K 1000.0f
173 #define VCPMONITOR6_UN_CONV_1M 1000000.0f
180 #define VCPMONITOR6_DEVICE_ADDRESS_0 0x40
181 #define VCPMONITOR6_DEVICE_ADDRESS_1 0x41
182 #define VCPMONITOR6_DEVICE_ADDRESS_2 0x44
183 #define VCPMONITOR6_DEVICE_ADDRESS_3 0x45
201 #define VCPMONITOR6_MAP_MIKROBUS( cfg, mikrobus ) \
202 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
203 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
204 cfg.alr = MIKROBUS( mikrobus, MIKROBUS_INT )
588 #endif // VCPMONITOR6_H
err_t vcpmonitor6_set_diag_flg_alr(vcpmonitor6_t *ctx, uint16_t diag_flg_alr)
VCP Monitor 6 set diagnostic function.
err_t vcpmonitor6_wait_conv_cmpl(vcpmonitor6_t *ctx)
VCP Monitor 6 wait conversion function.
err_t vcpmonitor6_sw_reset(vcpmonitor6_t *ctx)
VCP Monitor 6 SW reset writing function.
err_t vcpmonitor6_set_conv_dly(vcpmonitor6_t *ctx, uint16_t dly_ms)
VCP Monitor 6 set conversion delay function.
digital_in_t alr
Definition: vcpmonitor6.h:216
i2c_master_t i2c
Definition: vcpmonitor6.h:219
pin_name_t alr
Definition: vcpmonitor6.h:235
pin_name_t sda
Definition: vcpmonitor6.h:233
void vcpmonitor6_cfg_setup(vcpmonitor6_cfg_t *cfg)
VCP Monitor 6 configuration object setup function.
err_t vcpmonitor6_get_energy(vcpmonitor6_t *ctx, float *energy)
VCP Monitor 6 get the energy function.
uint8_t vcpmonitor6_get_alarm(vcpmonitor6_t *ctx)
VCP Monitor 6 get alarm function.
err_t vcpmonitor6_set_adc_avg(vcpmonitor6_t *ctx, uint8_t avg)
VCP Monitor 6 set the ADC sample function.
err_t vcpmonitor6_get_bus_voltage(vcpmonitor6_t *ctx, float *voltage)
VCP Monitor 6 get the voltage function.
err_t vcpmonitor6_generic_write(vcpmonitor6_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
VCP Monitor 6 I2C writing function.
err_t vcpmonitor6_set_op_mode(vcpmonitor6_t *ctx, uint8_t op_mode)
VCP Monitor 6 set the operating mode function.
err_t vcpmonitor6_reg_read(vcpmonitor6_t *ctx, uint8_t reg, uint16_t *data_out)
VCP Monitor 6 register reading function.
err_t vcpmonitor6_get_power(vcpmonitor6_t *ctx, float *power)
VCP Monitor 6 get the power function.
err_t vcpmonitor6_get_indc_flg(vcpmonitor6_t *ctx, uint16_t *indc_flg)
VCP Monitor 6 get diagnostic indicates function.
err_t vcpmonitor6_default_cfg(vcpmonitor6_t *ctx)
VCP Monitor 6 default configuration function.
uint8_t slave_address
Definition: vcpmonitor6.h:222
err_t vcpmonitor6_reg_write(vcpmonitor6_t *ctx, uint8_t reg, uint16_t data_in)
VCP Monitor 6 register writing function.
err_t vcpmonitor6_get_device_id(vcpmonitor6_t *ctx, uint16_t *man_id)
VCP Monitor 6 get device ID function.
err_t vcpmonitor6_set_conv_time(vcpmonitor6_t *ctx, uint8_t vbusct, uint8_t vsenct, uint8_t tct)
VCP Monitor 6 set the conversion time function.
@ VCPMONITOR6_ERROR
Definition: vcpmonitor6.h:249
@ VCPMONITOR6_OK
Definition: vcpmonitor6.h:248
err_t vcpmonitor6_get_temperature(vcpmonitor6_t *ctx, float *temperature)
VCP Monitor 6 get the temperature function.
err_t vcpmonitor6_generic_read(vcpmonitor6_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
VCP Monitor 6 I2C reading function.
vcpmonitor6_return_value_t
VCP Monitor 6 Click return value data.
Definition: vcpmonitor6.h:247
err_t vcpmonitor6_init(vcpmonitor6_t *ctx, vcpmonitor6_cfg_t *cfg)
VCP Monitor 6 initialization function.
VCP Monitor 6 Click configuration object.
Definition: vcpmonitor6.h:231
uint8_t i2c_address
Definition: vcpmonitor6.h:238
pin_name_t scl
Definition: vcpmonitor6.h:232
err_t vcpmonitor6_get_current(vcpmonitor6_t *ctx, float *current)
VCP Monitor 6 get the current function.
uint32_t i2c_speed
Definition: vcpmonitor6.h:237
err_t vcpmonitor6_get_charge(vcpmonitor6_t *ctx, float *charge)
VCP Monitor 6 get the charge function.
VCP Monitor 6 Click context object.
Definition: vcpmonitor6.h:214