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 VCPMONITOR_MAP_MIKROBUS( cfg, mikrobus ) \
53 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
54 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
55 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
62 #define VCPMONITOR_RETVAL uint8_t
64 #define VCPMONITOR_OK 0x00
65 #define VCPMONITOR_INIT_ERROR 0xFF
72 #define VCPMONITOR_REG_CONFIGURATION 0x00
73 #define VCPMONITOR_REG_CURRENT_DATA 0x01
74 #define VCPMONITOR_REG_BUS_VOLTAGE_DATA 0x02
75 #define VCPMONITOR_REG_POWER_DATA 0x03
76 #define VCPMONITOR_REG_MASK_ENABLE 0x06
77 #define VCPMONITOR_REG_ALERT_LIMIT 0x07
78 #define VCPMONITOR_REG_MANUFACTURE_ID 0xFE
79 #define VCPMONITOR_REG_DIE_ID 0xFF
86 #define VCPMONITOR_SLAVE_ADDR_GND_GND 0x40
87 #define VCPMONITOR_SLAVE_ADDR_GND_VS 0x41
88 #define VCPMONITOR_SLAVE_ADDR_GND_SDA 0x42
89 #define VCPMONITOR_SLAVE_ADDR_GND_SCL 0x43
90 #define VCPMONITOR_SLAVE_ADDR_VS_GND 0x44
91 #define VCPMONITOR_SLAVE_ADDR_VS_VS 0x45
92 #define VCPMONITOR_SLAVE_ADDR_VS_SDA 0x46
93 #define VCPMONITOR_SLAVE_ADDR_VS_SCL 0x47
94 #define VCPMONITOR_SLAVE_ADDR_SDA_GND 0x48
95 #define VCPMONITOR_SLAVE_ADDR_SDA_VS 0x49
96 #define VCPMONITOR_SLAVE_ADDR_SDA_SDA 0x4A
97 #define VCPMONITOR_SLAVE_ADDR_SDA_SCL 0x4B
98 #define VCPMONITOR_SLAVE_ADDR_SCL_GND 0x4C
99 #define VCPMONITOR_SLAVE_ADDR_SCL_VS 0x4D
100 #define VCPMONITOR_SLAVE_ADDR_SCL_SDA 0x4E
101 #define VCPMONITOR_SLAVE_ADDR_SCL_SCL 0x4F
108 #define VCPMONITOR_DEF_MANUFACTURE_ID 0x5449
109 #define VCPMONITOR_DEF_DIE_ID 0x2270
110 #define VCPMONITOR_DEF_CONFIGURATION 0x6127
118 #define VCPMONITOR_CFG_RESET_ON 0x8000
119 #define VCPMONITOR_CFG_RESET_OFF 0x0000
120 #define VCPMONITOR_CFG_NUM_OF_AVG_1 0x0000
121 #define VCPMONITOR_CFG_NUM_OF_AVG_4 0x0200
122 #define VCPMONITOR_CFG_NUM_OF_AVG_16 0x0400
123 #define VCPMONITOR_CFG_NUM_OF_AVG_64 0x0600
124 #define VCPMONITOR_CFG_NUM_OF_AVG_128 0x0800
125 #define VCPMONITOR_CFG_NUM_OF_AVG_256 0x0A00
126 #define VCPMONITOR_CFG_NUM_OF_AVG_512 0x0C00
127 #define VCPMONITOR_CFG_NUM_OF_AVG_1024 0x0E00
128 #define VCPMONITOR_CFG_VBUSCT_140us 0x0000
129 #define VCPMONITOR_CFG_VBUSCT_204us 0x0040
130 #define VCPMONITOR_CFG_VBUSCT_332us 0x0080
131 #define VCPMONITOR_CFG_VBUSCT_588us 0x00C0
132 #define VCPMONITOR_CFG_VBUSCT_1p1ms 0x0100
133 #define VCPMONITOR_CFG_VBUSCT_2p116ms 0x0140
134 #define VCPMONITOR_CFG_VBUSCT_4p156ms 0x0180
135 #define VCPMONITOR_CFG_VBUSCT_8p244ms 0x01C0
136 #define VCPMONITOR_CFG_ISHCT_140us 0x0000
137 #define VCPMONITOR_CFG_ISHCT_204us 0x0008
138 #define VCPMONITOR_CFG_ISHCT_332us 0x0010
139 #define VCPMONITOR_CFG_ISHCT_588us 0x0018
140 #define VCPMONITOR_CFG_ISHCT_1p1ms 0x0020
141 #define VCPMONITOR_CFG_ISHCT_2p116ms 0x0028
142 #define VCPMONITOR_CFG_ISHCT_4p156ms 0x0030
143 #define VCPMONITOR_CFG_ISHCT_8p244ms 0x0038
144 #define VCPMONITOR_CFG_MODE_POWER_DOWN 0x0000
145 #define VCPMONITOR_CFG_MODE_CURRENT_TRIG 0x0001
146 #define VCPMONITOR_CFG_MODE_VOLTAGE_TRIG 0x0002
147 #define VCPMONITOR_CFG_MODE_CURR_VOLT_TRIG 0x0003
148 #define VCPMONITOR_CFG_MODE_CURRENT_CONT 0x0005
149 #define VCPMONITOR_CFG_MODE_VOLTAGE_CONT 0x0006
150 #define VCPMONITOR_CFG_MODE_CURR_VOLT_CONT 0x0007
158 #define CURRENT_CONSTANT 1.25
159 #define VOLTAGE_CONSTANT 1.25
160 #define POWER_CONSTANT 10
168 #define VCPMONITOR_MASK_OCL_DISABLE 0x0000
169 #define VCPMONITOR_MASK_UCL_ENABLE 0x4000
170 #define VCPMONITOR_MASK_UCL_DISABLE 0x0000
171 #define VCPMONITOR_MASK_BOL_ENABLE 0x2000
172 #define VCPMONITOR_MASK_BOL_DISABLE 0x0000
173 #define VCPMONITOR_MASK_BUL_ENABLE 0x1000
174 #define VCPMONITOR_MASK_OCL_ENABLE 0x8000
175 #define VCPMONITOR_MASK_BUL_DISABLE 0x0000
176 #define VCPMONITOR_MASK_POL_ENABLE 0x0800
177 #define VCPMONITOR_MASK_POL_DISABLE 0x0000
178 #define VCPMONITOR_MASK_CNVR_ENABLE 0x0400
179 #define VCPMONITOR_MASK_CNVR_DISABLE 0x0000
180 #define VCPMONITOR_MASK_AFF_ENABLE 0x0010
181 #define VCPMONITOR_MASK_AFF_DISABLE 0x0000
182 #define VCPMONITOR_MASK_CVRF_ENABLE 0x0008
183 #define VCPMONITOR_MASK_CVRF_DISABLE 0x0000
184 #define VCPMONITOR_MASK_OVF_ENABLE 0x0004
185 #define VCPMONITOR_MASK_OVF_DISABLE 0x0000
186 #define VCPMONITOR_MASK_APOL_ENABLE 0x0002
187 #define VCPMONITOR_MASK_APOL_DISABLE 0x0000
188 #define VCPMONITOR_MASK_LEN_ENABLE 0x0001
189 #define VCPMONITOR_MASK_LEN_DISABLE 0x0000
388 #endif // _VCPMONITOR_H_
float vcpmonitor_get_voltage(vcpmonitor_t *ctx)
Reads voltage data in mV.
float vcpmonitor_get_current(vcpmonitor_t *ctx)
Reads current data in mA.
VCPMONITOR_RETVAL vcpmonitor_init(vcpmonitor_t *ctx, vcpmonitor_cfg_t *cfg)
Initialization function.
#define VCPMONITOR_RETVAL
Definition: vcpmonitor.h:62
float vcpmonitor_get_power(vcpmonitor_t *ctx)
Reads power data in mW.
i2c_master_t i2c
Definition: vcpmonitor.h:210
void vcpmonitor_write_data(vcpmonitor_t *ctx, uint8_t reg, uint16_t tx_data)
Writes data to register.
uint8_t vcpmonitor_get_id_value(vcpmonitor_t *ctx, uint16_t *manufacture_id, uint16_t *did_id)
Gets Manufacture ID and Device ID.
void vcpmonitor_cfg_setup(vcpmonitor_cfg_t *cfg)
Config Object Initialization function.
void vcpmonitor_generic_write(vcpmonitor_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
Click configuration structure definition.
Definition: vcpmonitor.h:222
uint8_t vcpmonitor_get_interrupt_state(vcpmonitor_t *ctx)
Gets Interrupt pin state.
pin_name_t int_pin
Definition: vcpmonitor.h:230
Click ctx object definition.
Definition: vcpmonitor.h:203
pin_name_t sda
Definition: vcpmonitor.h:226
digital_in_t int_pin
Definition: vcpmonitor.h:206
uint8_t slave_address
Definition: vcpmonitor.h:214
uint8_t i2c_address
Definition: vcpmonitor.h:235
uint32_t i2c_speed
Definition: vcpmonitor.h:234
pin_name_t scl
Definition: vcpmonitor.h:225
int16_t vcpmonitor_read_data(vcpmonitor_t *ctx, uint8_t reg_addr)
Reads data from register.
void vcpmonitor_default_cfg(vcpmonitor_t *ctx)
Click Default Configuration function.
void vcpmonitor_generic_read(vcpmonitor_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.