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 CURRENT3_MAP_MIKROBUS( cfg, mikrobus ) \
53 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
54 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
55 cfg.trm = MIKROBUS( mikrobus, MIKROBUS_RST ); \
56 cfg.alr = MIKROBUS( mikrobus, MIKROBUS_INT )
64 #define CURRENT3_ERROR -1
71 #define CURRENT3_I2C_SLAVE_ADDR 0x4C
72 #define CURRENT3_ALERT_RESPONSE_ADDRESS 0x0C
79 #define CURRENT3_REG_INT_DIODE_DATA_HIGH_BYTE 0x00
80 #define CURRENT3_REG_EXT_DIODE_1_DATA_HIGH_BYTE 0x01
81 #define CURRENT3_REG_STATUS 0x02
82 #define CURRENT3_REG_CFG 0x03
83 #define CURRENT3_REG_CONVERSION_RATE 0x04
84 #define CURRENT3_REG_INT_DIODE_HIGH_LIMIT 0x05
85 #define CURRENT3_REG_INT_DIODE_LOW_LIMIT 0x06
86 #define CURRENT3_REG_EXT_DIODE_1_HIGH_LIMIT_HIGH_BYTE 0x07
87 #define CURRENT3_REG_EXT_DIODE_1_LOW_LIMIT_HIGH_BYTE 0x08
88 #define CURRENT3_REG_ONE_SHOT 0x0F
89 #define CURRENT3_REG_EXT_DIODE_1_DATA_LOW_BYTE 0x10
90 #define CURRENT3_REG_EXT_DIODE_1_HIGH_LIMIT_LOW_BYTE 0x13
91 #define CURRENT3_REG_EXT_DIODE_1_LOW_LIMIT_LOW_BYTE 0x14
92 #define CURRENT3_REG_EXT_DIODE_1_TCRIT_LIMIT 0x19
93 #define CURRENT3_REG_EXT_DIODE_FAULT 0x1B
94 #define CURRENT3_REG_CHANNEL_MASK_REGISTER 0x1F
95 #define CURRENT3_REG_INT_DIODE_TCRIT_LIMIT 0x20
96 #define CURRENT3_REG_TCRIT_HYSTERESIS 0x21
97 #define CURRENT3_REG_CONSECUTIVE_ALERT 0x22
98 #define CURRENT3_REG_EXT_DIODE_1_BETA_CFG 0x25
99 #define CURRENT3_REG_EXT_DIODE_1_IDEALITY_FACTOR 0x27
100 #define CURRENT3_REG_INT_DIODE_DATA_LOW_BYTE 0x29
101 #define CURRENT3_REG_HIGH_LIMIT_STATUS 0x35
102 #define CURRENT3_REG_LOW_LIMIT_STATUS 0x36
103 #define CURRENT3_REG_CRIT_LIMIT_STATUS 0x37
104 #define CURRENT3_REG_INT_DIODE_HIGH_BYTE 0x38
105 #define CURRENT3_REG_INT_DIODE_LOW_BYTE 0x39
106 #define CURRENT3_REG_EXT_DIODE_1_HIGH_BYTE 0x3A
107 #define CURRENT3_REG_EXT_DIODE_1_LOW_BYTE 0x3B
108 #define CURRENT3_REG_AVERAGING_CONTROL 0x40
115 #define CURRENT3_REG_VOLTAGE_SAMPLING_CFG 0x50
116 #define CURRENT3_REG_CURRENT_SENSE_SAMPLING_CFG 0x51
117 #define CURRENT3_REG_PEAK_DETECTION_CONFIG 0x52
118 #define CURRENT3_REG_SENSE_VOLTAGE_HIGH_BYTE 0x54
119 #define CURRENT3_REG_SENSE_VOLTAGE_LOW_BYTE 0x55
120 #define CURRENT3_REG_SOURCE_VOLTAGE_HIGH_BYTE 0x58
121 #define CURRENT3_REG_SOURCE_VOLTAGE_LOW_BYTE 0x59
122 #define CURRENT3_REG_POWER_RATIO_HIGH_BYTE 0x5B
123 #define CURRENT3_REG_POWER_RATIO_LOW_BYTE 0x5C
130 #define CURRENT3_REG_SENSE_VOLTAGE_HIGH_LIMIT 0x60
131 #define CURRENT3_REG_SENSE_VOLTAGE_LOW_LIMIT 0x61
132 #define CURRENT3_REG_SOURCE_VOLTAGE_HIGH_LIMIT 0x64
133 #define CURRENT3_REG_SOURCE_VOLTAGE_LOW_LIMIT 0x65
134 #define CURRENT3_REG_SENSE_VOLTAGE_VCRIT_LIMIT 0x66
135 #define CURRENT3_REG_SOURCE_VOLTAGE_VCRIT_LIMIT 0x68
136 #define CURRENT3_REG_SENSE_VCRIT_HYSTERESIS 0x69
137 #define CURRENT3_REG_SOURCE_VOLTAGE_VCRIT_HYSTERESIS 0x6A
138 #define CURRENT3_REG_PRODUCT_FEATURES 0xFC
139 #define CURRENT3_REG_PRODUCT_ID 0xFD
140 #define CURRENT3_REG_SMSC_ID 0xFE
141 #define CURRENT3_REG_REVISION 0xFF
148 #define CURRENT3_DEV_ID 0x39
155 #define CURRENT3_TEMP_INTERNAL_DIODE 0x00
156 #define CURRENT3_TEMP_EXTERNAL_DIODE 0x01
168 #define CURRENT3_PK_ALERT 0x00
169 #define CURRENT3_PK_THERM 0x01
176 #define CURRENT3_V_QUEUE_1 0x00
177 #define CURRENT3_V_QUEUE_2 0x01
178 #define CURRENT3_V_QUEUE_3 0x02
179 #define CURRENT3_V_QUEUE_4 0x03
181 #define CURRENT3_V_AVG_DISABLE 0x00
182 #define CURRENT3_V_AVG_2x 0x01
183 #define CURRENT3_V_AVG_4x 0x02
184 #define CURRENT3_V_AVG_8x 0x03
197 #define CURRENT3_NUM_OF_CONS_OUT_LIMIT_MEASUR_1 0x00
198 #define CURRENT3_NUM_OF_CONS_OUT_LIMIT_MEASUR_2 0x01
199 #define CURRENT3_NUM_OF_CONS_OUT_LIMIT_MEASUR_3 0x02
200 #define CURRENT3_NUM_OF_CONS_OUT_LIMIT_MEASUR_4 0x03
207 #define CURRENT3_CURRENT_SENSE_AVG_1X 0x00
208 #define CURRENT3_CURRENT_SENSE_AVG_2X 0x01
209 #define CURRENT3_CURRENT_SENSE_AVG_4X 0x02
210 #define CURRENT3_CURRENT_SENSE_AVG_8X 0x03
217 #define CURRENT3_CS_SAMP_TIME_82ms 0x00
218 #define CURRENT3_CS_SAMP_TIME_164ms 0x02
219 #define CURRENT3_CS_SAMP_TIME_328ms 0x03
226 #define CURRENT3_SENSOR_RANGE_BIT_MASK 0x03
227 #define CURRENT3_SENSOR_RANGE_10_mV 0x00
228 #define CURRENT3_SENSOR_RANGE_20_mV 0x01
229 #define CURRENT3_SENSOR_RANGE_40_mV 0x02
230 #define CURRENT3_SENSOR_RANGE_80_mV 0x03
243 #define CURRENT3_MASK_ALL_ALERT_NOT_MASKED 0x00
244 #define CURRENT3_MASK_ALL_ALERT_INTERRUPT_MODE 0x01
251 #define CURRENT3_TMEAS_STOP_MEASURING_ALL 0x00
252 #define CURRENT3_TMEAS_STOP_NOT_MEASURING 0x01
259 #define CURRENT3_ALERT_COMP_MODE_INTERRUPT 0x00
260 #define CURRENT3_ALERT_COMP_MODE_COMPARATOR 0x01
267 #define CURRENT3_DIS_REC1_ENABLED 0x00
268 #define CURRENT3_DIS_REC1_DISABLED 0x01
275 #define CURRENT3_IMEAS_SOURCE_SENSE_VOLTAGE_STOP_MEASUR 0x00
276 #define CURRENT3_IMEAS_SOURCE_SENSE_VOLTAGE_START_MEASUR 0x01
283 #define CURRENT3_DAVG_DIS_ENABLED 0x00
284 #define CURRENT3_DAVG_DIS_DISABLED 0x01
291 #define CURRENT3_SENSOR_RANGE_VALUE_10_mV 10.0
292 #define CURRENT3_SENSOR_RANGE_VALUE_20_mV 20.0
293 #define CURRENT3_SENSOR_RANGE_VALUE_40_mV 40.0
294 #define CURRENT3_SENSOR_RANGE_VALUE_80_mV 80.0
295 #define CURRENT3_DEFAULT_RSENSE 10.0
296 #define CURRENT3_FULL_SCALE_SENSE_VOLTAGE 2047
297 #define CURRENT3_CON_FCT_mV_TO_V 1000
298 #define CURRENT3_SOURCE_VOLTAGE_CALC_FACT 0.0117
299 #define CURRENT3_TEMPERATURE_CALC_FACT 0.125
644 #endif // _CURRENT3_H_
err_t current3_generic_read(current3_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Generic read function.
err_t current3_init(current3_t *ctx, current3_cfg_t *cfg)
Initialization function.
uint8_t current3_check_therm(current3_t *ctx)
Check therm ststus function.
uint8_t busy_data
Definition: current3.h:370
uint8_t mask_all
Definition: current3.h:356
void current3_default_cfg(current3_t *ctx, current3_sense_cfg_data_t sense_cfg_data)
Click Default Configuration function.
void current3_set_configuration(current3_t *ctx, current3_cfg_data_t cfg_data)
Set configuration function.
void current3_set_voltage_sampling_config(current3_t *ctx, current3_voltage_cfg_data_t vtg_cfg_data)
Set voltage sampling configuration function.
Click status data structure definition.
Definition: current3.h:369
int16_t current3_get_sense_voltage(current3_t *ctx)
Get sense voltage function.
uint8_t peak_data
Definition: current3.h:371
pin_name_t trm
Definition: current3.h:341
float current3_get_current(current3_t *ctx)
Get current measurement function.
uint32_t i2c_speed
Definition: current3.h:346
pin_name_t sda
Definition: current3.h:337
digital_in_t alr
Definition: current3.h:317
uint8_t low_data
Definition: current3.h:373
uint8_t crit_data
Definition: current3.h:375
void current3_set_sense_sampling_config(current3_t *ctx, current3_sense_cfg_data_t sense_cfg_data)
Set sense sampling configuration function.
uint8_t v_avg
Definition: current3.h:386
float current3_get_temperature(current3_t *ctx, uint8_t temp_sel)
Get temperature function.
uint8_t pk_alert_therm
Definition: current3.h:384
uint8_t cs_rng
Definition: current3.h:398
uint8_t v_queue
Definition: current3.h:385
uint8_t imeas_stop
Definition: current3.h:360
float current3_get_source_voltage(current3_t *ctx)
Get source voltage function.
Click configuration structure definition.
Definition: current3.h:333
void current3_get_voltage_sampling_config(current3_t *ctx, current3_voltage_cfg_data_t *vtg_cfg_data)
Get voltage sampling configuration function.
pin_name_t scl
Definition: current3.h:336
Click voltage configuration structure definition.
Definition: current3.h:383
uint8_t slave_address
Definition: current3.h:325
pin_name_t alr
Definition: current3.h:342
uint8_t i2c_address
Definition: current3.h:347
Click ctx object definition.
Definition: current3.h:313
uint8_t current3_check_alert(current3_t *ctx)
Check alert ststus function.
err_t current3_generic_write(current3_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Generic write function.
digital_in_t trm
Definition: current3.h:316
void current3_get_status(current3_t *ctx, current3_status_data_t *status_cfg)
Get status function.
uint8_t cs_samp_time
Definition: current3.h:397
Click sense configuration structure definition.
Definition: current3.h:394
Click configuration data definition.
Definition: current3.h:355
uint8_t cs_samp_avg
Definition: current3.h:396
uint8_t fault_data
Definition: current3.h:374
uint8_t tmeas_stop
Definition: current3.h:357
uint8_t cs_queue
Definition: current3.h:395
void current3_get_sense_sampling_config(current3_t *ctx, current3_sense_cfg_data_t *sense_cfg_data)
Get sense sampling configuration function.
uint8_t high_data
Definition: current3.h:372
i2c_master_t i2c
Definition: current3.h:321
void current3_cfg_setup(current3_cfg_t *cfg)
Config Object Initialization function.
uint8_t davg_dis
Definition: current3.h:361
void current3_get_configuration(current3_t *ctx, current3_cfg_data_t *cfg_data)
Get configuration function.
uint8_t alert_comp
Definition: current3.h:358
uint8_t dis_rec1
Definition: current3.h:359