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 VCTMONITOR_REG_STATUS 0x00
74#define VCTMONITOR_REG_CONTROL 0x01
75#define VCTMONITOR_REG_TRIGGER 0x02
76#define VCTMONITOR_REG_AMB_TEMP_MSB 0x04
77#define VCTMONITOR_REG_AMB_TEMP_LSB 0x05
78#define VCTMONITOR_REG_V1_MSB 0x06
79#define VCTMONITOR_REG_V1_LSB 0x07
80#define VCTMONITOR_REG_V2_MSB 0x08
81#define VCTMONITOR_REG_V2_LSB 0x09
82#define VCTMONITOR_REG_V3_MSB 0x0A
83#define VCTMONITOR_REG_V3_LSB 0x0B
84#define VCTMONITOR_REG_V4_MSB 0x0C
85#define VCTMONITOR_REG_V4_LSB 0x0D
86#define VCTMONITOR_REG_VCC_MSB 0x0E
87#define VCTMONITOR_REG_VCC_LSB 0x0F
105#define VCTMONITOR_CTRL_TEMP_FORMAT_C 0x00
106#define VCTMONITOR_CTRL_TEMP_FORMAT_K 0x80
107#define VCTMONITOR_CTRL_REPEATED_MEAS 0x00
108#define VCTMONITOR_CTRL_SINGLE_MEAS 0x40
109#define VCTMONITOR_CTRL_MODE1_INT_TEMP 0x00
110#define VCTMONITOR_CTRL_MODE1_V12 0x08
111#define VCTMONITOR_CTRL_MODE1_V34 0x10
112#define VCTMONITOR_CTRL_MODE1_ALL 0x18
114#define VCTMONITOR_CTRL_MODE2_V12_TR2 0x00
115#define VCTMONITOR_CTRL_MODE2_V1_2_TR2 0x01
116#define VCTMONITOR_CTRL_MODE2_V1_2_V34 0x02
117#define VCTMONITOR_CTRL_MODE2_V34_TR1 0x03
118#define VCTMONITOR_CTRL_MODE2_V3_4_TR1 0x04
119#define VCTMONITOR_CTRL_MODE2_TR2_TR1 0x05
120#define VCTMONITOR_CTRL_MODE2_V1_2_V3_4 0x06
121#define VCTMONITOR_CTRL_MODE2_V1234 0x07
123#define VCTMONITOR_STATUS_VCC_READY 0x40
124#define VCTMONITOR_STATUS_V4_READY 0x20
125#define VCTMONITOR_STATUS_V3_READY 0x10
126#define VCTMONITOR_STATUS_V2_READY 0x08
127#define VCTMONITOR_STATUS_V1_READY 0x04
128#define VCTMONITOR_STATUS_TINT_READY 0x02
129#define VCTMONITOR_STATUS_BUSY 0x01
137#define VCTMONITOR_SLAVE_ADDR_GND_GND 0x4C
138#define VCTMONITOR_SLAVE_ADDR_GND_VCC 0x4D
139#define VCTMONITOR_SLAVE_ADDR_VCC_VCC 0x4F
140#define VCTMONITOR_SLAVE_ADDR_VCC_GND 0x4E
158#define VCTMONITOR_MAP_MIKROBUS( cfg, mikrobus ) \
159 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
160 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
void vctmonitor_cfg_setup(vctmonitor_cfg_t *cfg)
VCT Monitor configuration object setup function.
err_t vctmonitor_default_cfg(vctmonitor_t *ctx)
VCT Monitor default configuration function.
err_t vctmonitor_init(vctmonitor_t *ctx, vctmonitor_cfg_t *cfg)
VCT Monitor initialization function.
void vctmonitor_configuration(vctmonitor_t *ctx, uint8_t cfg)
Configuration function.
err_t vctmonitor_generic_read(vctmonitor_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
VCT Monitor I2C reading function.
float vctmonitor_read_temperature(vctmonitor_t *ctx)
Get temperature function.
err_t vctmonitor_generic_write(vctmonitor_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
VCT Monitor I2C writing function.
float vctmonitor_read_voltage_differential(vctmonitor_t *ctx)
Differential voltage function.
float vctmonitor_read_current(vctmonitor_t *ctx)
Current function.
uint8_t vctmonitor_get_status(vctmonitor_t *ctx)
Gets status value.
float vctmonitor_read_voltage_single(vctmonitor_t *ctx, uint8_t channel)
Single voltage function.
VCT Monitor Click configuration object.
Definition vctmonitor.h:184
uint32_t i2c_speed
Definition vctmonitor.h:188
pin_name_t scl
Definition vctmonitor.h:185
pin_name_t sda
Definition vctmonitor.h:186
uint8_t i2c_address
Definition vctmonitor.h:189
VCT Monitor Click context object.
Definition vctmonitor.h:170
i2c_master_t i2c
Definition vctmonitor.h:172
uint8_t slave_address
Definition vctmonitor.h:175
vctmonitor_return_value_t
VCT Monitor Click return value data.
Definition vctmonitor.h:198
@ VCTMONITOR_OK
Definition vctmonitor.h:199
@ VCTMONITOR_ERROR
Definition vctmonitor.h:200