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 CURRENT12_REG_CONFIGURATION 0x00
74 #define CURRENT12_REG_SHUNT_VOLTAGE 0x01
75 #define CURRENT12_REG_LOAD_VOLTAGE 0x02
76 #define CURRENT12_REG_DC_POWER 0x03
77 #define CURRENT12_REG_CURRENT 0x04
78 #define CURRENT12_REG_TEMPERATURE 0x05
79 #define CURRENT12_REG_MASK 0x06
80 #define CURRENT12_REG_FLAG 0x07
81 #define CURRENT12_REG_RSHUNT 0x08
82 #define CURRENT12_REG_SOL 0x09
83 #define CURRENT12_REG_SUL 0x0A
84 #define CURRENT12_REG_LOL 0x0B
85 #define CURRENT12_REG_LUL 0x0C
86 #define CURRENT12_REG_POL 0x0D
87 #define CURRENT12_REG_TOL 0x0E
88 #define CURRENT12_REG_MANUFACTURING_ID 0xFE
89 #define CURRENT12_REG_DIE_ID 0xFF
107 #define CURRENT12_CFG_RST_DISABLE 0x00
108 #define CURRENT12_CFG_RST_ENABLE 0x01
109 #define CURRENT12_CFG_RST_BITMASK 0x01
110 #define CURRENT12_CFG_CT_128_US 0x00
111 #define CURRENT12_CFG_CT_256_US 0x01
112 #define CURRENT12_CFG_CT_512_US 0x02
113 #define CURRENT12_CFG_CT_1024_US 0x03
114 #define CURRENT12_CFG_CT_2048_US 0x04
115 #define CURRENT12_CFG_CT_4096_US 0x05
116 #define CURRENT12_CFG_CT_8192_US 0x06
117 #define CURRENT12_CFG_CT_16384_US 0x07
118 #define CURRENT12_CFG_CT_32768_US 0x08
119 #define CURRENT12_CFG_CT_BITMASK 0x0F
120 #define CURRENT12_CFG_TEMP_DISABLE 0x00
121 #define CURRENT12_CFG_TEMP_ENABLE 0x01
122 #define CURRENT12_CFG_TEMP_BITMASK 0x01
123 #define CURRENT12_CFG_OP_MODE_SHUTDOWN 0x00
124 #define CURRENT12_CFG_OP_MODE_SV_TRG 0x01
125 #define CURRENT12_CFG_OP_MODE_LV_TRG 0x02
126 #define CURRENT12_CFG_OP_MODE_SLV_TRG 0x03
127 #define CURRENT12_CFG_OP_MODE_IDLE_MODE 0x04
128 #define CURRENT12_CFG_OP_MODE_SV_CONT 0x05
129 #define CURRENT12_CFG_OP_MODE_LV_CONT 0x06
130 #define CURRENT12_CFG_OP_MODE_SLV_CONT 0x07
131 #define CURRENT12_CFG_OP_MODE_BITMASK 0x07
137 #define CURRENT12_DEVICE_ID 0x0006u
143 #define CURRENT12_RSHUNT_5_MOHM 5.0f
144 #define CURRENT12_RSHUNT_MAX 655.35f
150 #define CURRENT12_CALC_SHUNT_VTG_MV 0.025f
151 #define CURRENT12_CALC_LOAD_VTG_V 0.002f
152 #define CURRENT12_CALC_DC_POWER_W 0.025f
153 #define CURRENT12_CALC_CURRENT_MA 0.5f
154 #define CURRENT12_CALC_TEMP_C 0.5f
160 #define CURRENT12_TEMP_ERROR_BITMASK 0x8000u
167 #define CURRENT12_DEVICE_ADDRESS_0 0x40
168 #define CURRENT12_DEVICE_ADDRESS_1 0x41
169 #define CURRENT12_DEVICE_ADDRESS_2 0x42
170 #define CURRENT12_DEVICE_ADDRESS_3 0x43
188 #define CURRENT12_MAP_MIKROBUS( cfg, mikrobus ) \
189 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
190 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
191 cfg.alr = MIKROBUS( mikrobus, MIKROBUS_INT )
501 #endif // CURRENT12_H
err_t current12_set_rshunt(current12_t *ctx, float rshunt_mohm)
Current 12 set RSHUNT function.
pin_name_t scl
Definition: current12.h:219
pin_name_t alr
Definition: current12.h:222
uint8_t ct
Definition: current12.h:236
Current 12 Click configuration register object.
Definition: current12.h:234
uint8_t rst
Definition: current12.h:235
Current 12 Click configuration object.
Definition: current12.h:218
uint8_t slave_address
Definition: current12.h:209
err_t current12_get_current(current12_t *ctx, float *current)
Current 12 get current function.
uint32_t i2c_speed
Definition: current12.h:224
err_t current12_read_word(current12_t *ctx, uint8_t reg, uint16_t *data_out)
Current 12 word data reading function.
uint8_t current12_get_alert(current12_t *ctx)
Current 12 get interrupt function.
void current12_cfg_setup(current12_cfg_t *cfg)
Current 12 configuration object setup function.
uint8_t temp
Definition: current12.h:237
err_t current12_get_temperature(current12_t *ctx, float *temperature)
Current 12 get temperature function.
err_t current12_get_device_id(current12_t *ctx, uint16_t *device_id)
Current 12 get device ID function.
digital_in_t alr
Definition: current12.h:203
err_t current12_set_measure_cfg(current12_t *ctx, current12_measure_cfg_t measure_cfg)
Current 12 set measurement configuration function.
Current 12 Click context object.
Definition: current12.h:201
err_t current12_get_shunt_voltage(current12_t *ctx, float *shunt_voltage)
Current 12 get shunt voltage function.
uint8_t op_mode
Definition: current12.h:238
err_t current12_generic_read(current12_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Current 12 I2C reading function.
err_t current12_get_dc_power(current12_t *ctx, float *dc_power)
Current 12 get DC power function.
current12_return_value_t
Current 12 Click return value data.
Definition: current12.h:248
i2c_master_t i2c
Definition: current12.h:206
@ CURRENT12_ERROR
Definition: current12.h:250
err_t current12_default_cfg(current12_t *ctx)
Current 12 default configuration function.
err_t current12_write_word(current12_t *ctx, uint8_t reg, uint16_t data_in)
Current 12 word data writing function.
uint8_t i2c_address
Definition: current12.h:225
err_t current12_init(current12_t *ctx, current12_cfg_t *cfg)
Current 12 initialization function.
err_t current12_get_load_voltage(current12_t *ctx, float *load_voltage)
Current 12 get load voltage function.
pin_name_t sda
Definition: current12.h:220
err_t current12_generic_write(current12_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Current 12 I2C writing function.
@ CURRENT12_OK
Definition: current12.h:249