Go to the documentation of this file.
39 #ifdef PREINIT_SUPPORTED
43 #ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49 #include "drv_digital_out.h"
50 #include "drv_digital_in.h"
51 #include "drv_i2c_master.h"
73 #define VCPMONITOR6_REG_CONFIG 0x00
74 #define VCPMONITOR6_REG_ADC_CONFIG 0x01
75 #define VCPMONITOR6_REG_VBUS 0x05
76 #define VCPMONITOR6_REG_DIETEMP 0x06
77 #define VCPMONITOR6_REG_CURRENT 0x07
78 #define VCPMONITOR6_REG_POWER 0x08
79 #define VCPMONITOR6_REG_ENERGY 0x09
80 #define VCPMONITOR6_REG_CHARGE 0x0A
81 #define VCPMONITOR6_REG_ALERT_DIAG 0x0B
82 #define VCPMONITOR6_REG_COL 0x0C
83 #define VCPMONITOR6_REG_CUL 0x0D
84 #define VCPMONITOR6_REG_BOVL 0x0E
85 #define VCPMONITOR6_REG_BUVL 0x0F
86 #define VCPMONITOR6_REG_TEMP_LIMIT 0x10
87 #define VCPMONITOR6_REG_PWR_LIMIT 0x11
88 #define VCPMONITOR6_REG_MANUFACTURER_ID 0x3E
106 #define VCPMONITOR6_CFG_RST 0x80
107 #define VCPMONITOR6_CFG_RSTACC 0x40
108 #define VCPMONITOR6_CFG_CONVDLY 0x01FEu
114 #define VCPMONITOR6_ADC_CFG_MODE_SHD 0x00
115 #define VCPMONITOR6_ADC_CFG_MODE_TRG_BV 0x01
116 #define VCPMONITOR6_ADC_CFG_MODE_TRG_T 0x04
117 #define VCPMONITOR6_ADC_CFG_MODE_TRG_BV_T 0x05
118 #define VCPMONITOR6_ADC_CFG_MODE_TRG_T_C 0x06
119 #define VCPMONITOR6_ADC_CFG_MODE_TRG_ALL 0x07
120 #define VCPMONITOR6_ADC_CFG_MODE_SD 0x08
121 #define VCPMONITOR6_ADC_CFG_MODE_CNT_BV 0x09
122 #define VCPMONITOR6_ADC_CFG_MODE_CNT_T 0x0C
123 #define VCPMONITOR6_ADC_CFG_MODE_CNT_BV_T 0x0D
124 #define VCPMONITOR6_ADC_CFG_MODE_CNT_T_C 0x0E
125 #define VCPMONITOR6_ADC_CFG_MODE_CNT_ALL 0x0F
126 #define VCPMONITOR6_ADC_CFG_MODE_BITMASK 0x0FFFu
127 #define VCPMONITOR6_ADC_CFG_VBSTA 0x07
128 #define VCPMONITOR6_ADC_CFG_VBSTA_BITMASK 0xF007u
129 #define VCPMONITOR6_ADC_CFG_AVG 0x07
130 #define VCPMONITOR6_ADC_CFG_AVG_BITMASK 0xFFF8u
136 #define VCPMONITOR6_ALR_DIAG_TRANSPARENT 0x0000u
137 #define VCPMONITOR6_ALR_DIAG_ALATCH 0x8000u
138 #define VCPMONITOR6_ALR_DIAG_CNVR_DIS 0x0000u
139 #define VCPMONITOR6_ALR_DIAG_CNVR_EN 0x4000u
140 #define VCPMONITOR6_ALR_DIAG_SLWALR_NAVG 0x0000u
141 #define VCPMONITOR6_ALR_DIAG_SLWALR_AVG 0x2000u
142 #define VCPMONITOR6_ALR_DIAG_APOL_NORMAL 0x0000u
143 #define VCPMONITOR6_ALR_DIAG_APOL_INV 0x1000u
144 #define VCPMONITOR6_ALR_DIAG_W_BITMASK 0xF000u
145 #define VCPMONITOR6_ALR_DIAG_ENERGYOF 0x0800u
146 #define VCPMONITOR6_ALR_DIAG_CHARGEOF 0x0400u
147 #define VCPMONITOR6_ALR_DIAG_MATHOF 0x0200u
148 #define VCPMONITOR6_ALR_DIAG_TMPOL 0x0080u
149 #define VCPMONITOR6_ALR_DIAG_CURRENTOL 0x0040u
150 #define VCPMONITOR6_ALR_DIAG_CURRENTUL 0x0020u
151 #define VCPMONITOR6_ALR_DIAG_BUSOL 0x0010u
152 #define VCPMONITOR6_ALR_DIAG_BUSUL 0x0008u
153 #define VCPMONITOR6_ALR_DIAG_POL 0x0004u
154 #define VCPMONITOR6_ALR_DIAG_CNVRF 0x0002u
155 #define VCPMONITOR6_ALR_DIAG_MEMSTAT 0x0001u
156 #define VCPMONITOR6_ALR_DIAG_R_BITMASK 0x0FFFu
162 #define VCPMONITOR6_MANUFACTURER_ID 0x5449u
168 #define VCPMONITOR6_CONV_FACT_VBUS 3.125f
169 #define VCPMONITOR6_CONV_FACT_DIETEMP 125.0f
170 #define VCPMONITOR6_CONV_FACT_CURRENT 2500.0f
171 #define VCPMONITOR6_CONV_FACT_POWER 480.0f
172 #define VCPMONITOR6_CONV_FACT_ENERGY 7.68f
173 #define VCPMONITOR6_CONV_FACT_CHARGE 150.0f
174 #define VCPMONITOR6_CALC_EN_CHRG_RES 256.0f
175 #define VCPMONITOR6_CALC_EN_CHRG 4.0f
176 #define VCPMONITOR6_UN_CONV_1K 1000.0f
177 #define VCPMONITOR6_UN_CONV_1M 1000000.0f
184 #define VCPMONITOR6_DEVICE_ADDRESS_0 0x40
185 #define VCPMONITOR6_DEVICE_ADDRESS_1 0x41
186 #define VCPMONITOR6_DEVICE_ADDRESS_2 0x44
187 #define VCPMONITOR6_DEVICE_ADDRESS_3 0x45
205 #define VCPMONITOR6_MAP_MIKROBUS( cfg, mikrobus ) \
206 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
207 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
208 cfg.alr = MIKROBUS( mikrobus, MIKROBUS_INT )
592 #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:220
i2c_master_t i2c
Definition: vcpmonitor6.h:223
pin_name_t alr
Definition: vcpmonitor6.h:239
pin_name_t sda
Definition: vcpmonitor6.h:237
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:226
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:253
@ VCPMONITOR6_OK
Definition: vcpmonitor6.h:252
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:251
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:235
uint8_t i2c_address
Definition: vcpmonitor6.h:242
pin_name_t scl
Definition: vcpmonitor6.h:236
err_t vcpmonitor6_get_current(vcpmonitor6_t *ctx, float *current)
VCP Monitor 6 get the current function.
uint32_t i2c_speed
Definition: vcpmonitor6.h:241
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:218