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 CURRENT6_REG_CONFIGURATION 0x00
74#define CURRENT6_REG_STATUS 0x02
75#define CURRENT6_REG_THRESHOLD_OVER_CURRENT 0x04
76#define CURRENT6_REG_THRESHOLD_OVER_VOLTAGE 0x05
77#define CURRENT6_REG_THRESHOLD_UNDER_VOLTAGE 0x06
78#define CURRENT6_REG_WAKE_UP_CURRENT 0x07
79#define CURRENT6_REG_MAX_PEAK_CURRENT 0x08
80#define CURRENT6_REG_FIFO_CONFIGURATION 0x0A
81#define CURRENT6_REG_CURRENT_MEASUREMENT 0x0C
82#define CURRENT6_REG_VOLTAGE_MEASUREMENT 0x0E
83#define CURRENT6_REG_CURRENT_VOLTAGE_MEASUREMENT 0x10
84#define CURRENT6_REG_INT_EN 0x14
102#define CURRENT6_OPMODE_STANDBY 0x0000
103#define CURRENT6_OPMODE_LOW_POWER 0x0001
104#define CURRENT6_OPMODE_SINGLE_CONVERSION 0x0002
105#define CURRENT6_OPMODE_CONTINUOUS_MEASUREMENT 0x0003
106#define CURRENT6_OPMODE_ACTIVE_MODE_4_SPS 0x0004
107#define CURRENT6_OPMODE_ACTIVE_MODE_1_SPS 0x0005
108#define CURRENT6_OPMODE_ACTIVE_MODE_0p25_SPS 0x0006
109#define CURRENT6_OPMODE_ACTIVE_MODE_0p0625_SPS 0x0007
110#define CURRENT6_OPMODE_ACTIVE_MODE_0p25_SPS 0x0006
111#define CURRENT6_I2C_TIMEOUT_DISABLE 0x0008
112#define CURRENT6_I2C_TIMEOUT_ENABLE 0x0000
113#define CURRENT6_ALERT_UNFILTERED 0x0000
114#define CURRENT6_ALERT_FILTERED 0x0010
115#define CURRENT6_PEC_ENABLE 0x0020
116#define CURRENT6_PEC_DISABLE 0x0000
117#define CURRENT6_INPUT_RANGE_10mV 0x0040
118#define CURRENT6_INPUT_RANGE_50mV 0x0000
119#define CURRENT6_ENTER_HS_MODE 0x0080
120#define CURRENT6_EXIT_HS_MODE 0x0000
121#define CURRENT6_ADC_SAMPLE_RATE_15_KSPS 0x0000
122#define CURRENT6_ADC_SAMPLE_RATE_23p45_KSPS 0x0200
123#define CURRENT6_ADC_SAMPLE_RATE_30_KSPS 0x0300
124#define CURRENT6_ADC_SAMPLE_RATE_37p5_KSPS 0x0400
125#define CURRENT6_ADC_SAMPLE_RATE_47p1_KSPS 0x0500
126#define CURRENT6_ADC_SAMPLE_RATE_60_KSPS 0x0600
127#define CURRENT6_ADC_SAMPLE_RATE_93p5_KSPS 0x0700
128#define CURRENT6_ADC_SAMPLE_RATE_120_KSPS 0x0800
129#define CURRENT6_ADC_SAMPLE_RATE_150_KSPS 0x0900
130#define CURRENT6_ADC_SAMPLE_RATE_234p5_KSPS 0x0A00
131#define CURRENT6_ADC_SAMPLE_RATE_375_KSPS 0x0B00
132#define CURRENT6_ADC_SAMPLE_RATE_468p5_KSPS 0x0C00
133#define CURRENT6_ADC_SAMPLE_RATE_750_KSPS 0x0D00
134#define CURRENT6_ADC_SAMPLE_RATE_1000_KSPS 0x0E00
135#define CURRENT6_ADC_SAMPLE_RATE_0p5_KSPS 0x0F00
136#define CURRENT6_DIGITAL_FILTER_NO_AVG 0x0000
137#define CURRENT6_DIGITAL_FILTER_AVG_8_SAMPLES 0x1000
138#define CURRENT6_DIGITAL_FILTER_AVG_16_SAMPLES 0x2000
139#define CURRENT6_DIGITAL_FILTER_AVG_32_SAMPLES 0x3000
140#define CURRENT6_DIGITAL_FILTER_AVG_64_SAMPLES 0x4000
141#define CURRENT6_DIGITAL_FILTER_AVG_128_SAMPLES 0x5000
147#define CURRENT6_STATUS_WAKE_UP 0x0001
148#define CURRENT6_STATUS_CONVERSION_READY 0x0002
149#define CURRENT6_STATUS_OVERFLOW_CURRENT 0x0004
150#define CURRENT6_STATUS_OVERFLOW_VOLTAGE 0x0008
151#define CURRENT6_STATUS_UNDERFLOW_VOLTAGE 0x0010
152#define CURRENT6_STATUS_I2C_TIMEOUT 0x0020
153#define CURRENT6_STATUS_FIFO_ALARM 0x0040
154#define CURRENT6_STATUS_FIFO_OVERFLOW 0x0080
155#define CURRENT6_STATUS_FIFO_DATA_COUNT_MASK 0x3F00
161#define CURRENT6_FIFO_CFG_STORE_CURRENT_ONLY 0x0000
162#define CURRENT6_FIFO_CFG_STORE_VOLTAGE_ONLY 0x0001
163#define CURRENT6_FIFO_CFG_STORE_ALL 0x0002
164#define CURRENT6_FIFO_CFG_DATA_OVERFLOW_MASK 0x3F00
165#define CURRENT6_FIFO_CFG_DATA_OVERFLOW_DEFAULT 0x0100
166#define CURRENT6_FIFO_CFG_ROLL_OVER 0x4000
167#define CURRENT6_FIFO_CFG_FLUSH 0x8000
173#define CURRENT6_FIFO_DATA_VALID_32 0x80000000
174#define CURRENT6_FIFO_DATA_VALID_16 0x8000
175#define CURRENT6_FIFO_DATA_SIGN_BIT 0x1000
176#define CURRENT6_FIFO_DATA_RESOLUTION 0x0FFF
182#define CURRENT6_INT_EN_WAKE_UP 0x01
183#define CURRENT6_INT_EN_CONVERSION_READY 0x02
184#define CURRENT6_INT_EN_OVERFLOW_CURRENT 0x04
185#define CURRENT6_INT_EN_OVERFLOW_VOLTAGE 0x08
186#define CURRENT6_INT_EN_UNDERFLOW_VOLTAGE 0x10
187#define CURRENT6_INT_EN_I2C_TIMEOUT 0x20
188#define CURRENT6_INT_EN_ALARM 0x40
189#define CURRENT6_INT_EN_OVERFLOW 0x80
195#define CURRENT6_VOLTAGE_CALCULATION_COEFFICIENT 0.00917
196#define CURRENT6_CURRENT_CALCULATION_COEFFICIENT 0.00125
203#define CURRENT6_SET_DEV_ADDR 0x21
221#define CURRENT6_MAP_MIKROBUS( cfg, mikrobus ) \
222 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
223 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
224 cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
225 cfg.alr = MIKROBUS( mikrobus, MIKROBUS_INT )
current6_return_value_t
Current 6 Click return value data.
Definition current6.h:274
@ CURRENT6_ERROR
Definition current6.h:276
@ CURRENT6_OK
Definition current6.h:275
err_t current6_read_byte(current6_t *ctx, uint8_t reg, uint8_t *data_out)
Current 6 read byte function.
err_t current6_default_cfg(current6_t *ctx)
Current 6 default configuration function.
void current6_disable_device(current6_t *ctx)
Current 6 disable device function.
uint8_t current6_get_alert_pin(current6_t *ctx)
Current 6 get alert pin function.
err_t current6_write_word(current6_t *ctx, uint8_t reg, uint16_t data_in)
Current 6 write word function.
void current6_enable_device(current6_t *ctx)
Current 6 enable device function.
err_t current6_read_data(current6_t *ctx, float *voltage, float *current)
Current 6 read data function.
err_t current6_read_word(current6_t *ctx, uint8_t reg, uint16_t *data_out)
Current 6 read word function.
err_t current6_disable_pec(current6_t *ctx)
PEC Disable function.
err_t current6_read_32(current6_t *ctx, uint32_t *data_out)
Current 6 read 32-bit function.
void current6_cfg_setup(current6_cfg_t *cfg)
Current 6 configuration object setup function.
err_t current6_get_status(current6_t *ctx, uint16_t *status)
Current 6 get status function.
err_t current6_enable_pec(current6_t *ctx)
PEC Enable function.
err_t current6_init(current6_t *ctx, current6_cfg_t *cfg)
Current 6 initialization function.
err_t current6_write_byte(current6_t *ctx, uint8_t reg, uint8_t data_in)
Current 6 write byte function.
Current 6 Click configuration object.
Definition current6.h:257
pin_name_t alr
Definition current6.h:261
uint32_t i2c_speed
Definition current6.h:264
pin_name_t scl
Definition current6.h:258
pin_name_t en
Definition current6.h:262
pin_name_t sda
Definition current6.h:259
uint8_t i2c_address
Definition current6.h:265
Current 6 Click context object.
Definition current6.h:235
digital_in_t alr
Definition current6.h:240
i2c_master_t i2c
Definition current6.h:243
digital_out_t en
Definition current6.h:237
uint8_t slave_address
Definition current6.h:246
uint8_t pec_enable
Definition current6.h:248