Go to the documentation of this file.
28 #ifndef POWERMONITOR2_H
29 #define POWERMONITOR2_H
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 POWERMONITOR2_REG_CONFIGURATION 0x00
74 #define POWERMONITOR2_REG_SHUNT_VOLTAGE 0x01
75 #define POWERMONITOR2_REG_BUS_VOLTAGE 0x02
76 #define POWERMONITOR2_REG_POWER 0x03
77 #define POWERMONITOR2_REG_CURRENT 0x04
78 #define POWERMONITOR2_REG_CALIBRATION 0x05
96 #define POWERMONITOR2_CONFIGURATION_RST 0x8000
97 #define POWERMONITOR2_CONFIGURATION_BRNG_16V 0x0000
98 #define POWERMONITOR2_CONFIGURATION_BRNG_32V 0x2000
99 #define POWERMONITOR2_CONFIGURATION_BRNG_MASK 0x2000
100 #define POWERMONITOR2_CONFIGURATION_PGA_DIV_1 0x0000
101 #define POWERMONITOR2_CONFIGURATION_PGA_DIV_2 0x0800
102 #define POWERMONITOR2_CONFIGURATION_PGA_DIV_4 0x1000
103 #define POWERMONITOR2_CONFIGURATION_PGA_DIV_8 0x1800
104 #define POWERMONITOR2_CONFIGURATION_PGA_MASK 0x1800
105 #define POWERMONITOR2_CONFIGURATION_BADC_84_US 0x0000
106 #define POWERMONITOR2_CONFIGURATION_BADC_148_US 0x0080
107 #define POWERMONITOR2_CONFIGURATION_BADC_276_US 0x0100
108 #define POWERMONITOR2_CONFIGURATION_BADC_532_US 0x0180
109 #define POWERMONITOR2_CONFIGURATION_BADC_1_06_MS 0x0480
110 #define POWERMONITOR2_CONFIGURATION_BADC_2_13_MS 0x0500
111 #define POWERMONITOR2_CONFIGURATION_BADC_4_26_MS 0x0580
112 #define POWERMONITOR2_CONFIGURATION_BADC_8_51_MS 0x0600
113 #define POWERMONITOR2_CONFIGURATION_BADC_17_02_MS 0x0680
114 #define POWERMONITOR2_CONFIGURATION_BADC_34_05_MS 0x0700
115 #define POWERMONITOR2_CONFIGURATION_BADC_68_10_MS 0x0780
116 #define POWERMONITOR2_CONFIGURATION_BADC_MASK 0x0780
117 #define POWERMONITOR2_CONFIGURATION_SADC_84_US 0x0000
118 #define POWERMONITOR2_CONFIGURATION_SADC_148_US 0x0008
119 #define POWERMONITOR2_CONFIGURATION_SADC_276_US 0x0010
120 #define POWERMONITOR2_CONFIGURATION_SADC_532_US 0x0018
121 #define POWERMONITOR2_CONFIGURATION_SADC_1_06_MS 0x0048
122 #define POWERMONITOR2_CONFIGURATION_SADC_2_13_MS 0x0050
123 #define POWERMONITOR2_CONFIGURATION_SADC_4_26_MS 0x0058
124 #define POWERMONITOR2_CONFIGURATION_SADC_8_51_MS 0x0060
125 #define POWERMONITOR2_CONFIGURATION_SADC_17_02_MS 0x0068
126 #define POWERMONITOR2_CONFIGURATION_SADC_34_05_MS 0x0070
127 #define POWERMONITOR2_CONFIGURATION_SADC_68_10_MS 0x0078
128 #define POWERMONITOR2_CONFIGURATION_SADC_MASK 0x0078
129 #define POWERMONITOR2_CONFIGURATION_MODE_PDOWN 0x0000
130 #define POWERMONITOR2_CONFIGURATION_MODE_SHT_V_TRG 0x0001
131 #define POWERMONITOR2_CONFIGURATION_MODE_BUS_V_TRG 0x0002
132 #define POWERMONITOR2_CONFIGURATION_MODE_SHT_BUS_V_TRG 0x0003
133 #define POWERMONITOR2_CONFIGURATION_MODE_ADC_OFF 0x0004
134 #define POWERMONITOR2_CONFIGURATION_MODE_SHT_V_CONT 0x0005
135 #define POWERMONITOR2_CONFIGURATION_MODE_BUS_V_CONT 0x0006
136 #define POWERMONITOR2_CONFIGURATION_MODE_SHT_BUS_V_CONT 0x0007
137 #define POWERMONITOR2_CONFIGURATION_MODE_MASK 0x0007
143 #define POWERMONITOR2_BUS_VOLTAGE_CNVR 0x0002
144 #define POWERMONITOR2_BUS_VOLTAGE_OVF 0x0001
150 #define POWERMONITOR2_SHUNT_LSB_MV 0.01f
151 #define POWERMONITOR2_BUS_V_LSB_V 0.004f
152 #define POWERMONITOR2_POWER_LSB_W 0.02f
153 #define POWERMONITOR2_CURRENT_LSB_A 0.001f
154 #define POWERMONITOR2_CALIBRATION_FOR_SHUNT_0_01_OHM 4096
155 #define POWERMONITOR2_DEFAULT_NUM_CONV 20
162 #define POWERMONITOR2_DEVICE_ADDRESS_3V3_0 0x40
163 #define POWERMONITOR2_DEVICE_ADDRESS_3V3_1 0x44
164 #define POWERMONITOR2_DEVICE_ADDRESS_5V_0 0x41
165 #define POWERMONITOR2_DEVICE_ADDRESS_5V_1 0x45
183 #define POWERMONITOR2_MAP_MIKROBUS( cfg, mikrobus ) \
184 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
185 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA );
366 #endif // POWERMONITOR2_H
@ POWERMONITOR2_ERROR
Definition: powermonitor2.h:242
float bus_v
Definition: powermonitor2.h:197
err_t powermonitor2_read_data_avg(powermonitor2_t *ctx, uint16_t num_conv, powermonitor2_data_t *data_out)
Power Monitor 2 read data avg function.
i2c_master_t i2c
Definition: powermonitor2.h:210
Power Monitor 2 Click configuration object.
Definition: powermonitor2.h:225
err_t powermonitor2_init(powermonitor2_t *ctx, powermonitor2_cfg_t *cfg)
Power Monitor 2 initialization function.
err_t powermonitor2_read_reg(powermonitor2_t *ctx, uint8_t reg, uint16_t *data_out)
Power Monitor 2 read reg function.
uint8_t slave_address
Definition: powermonitor2.h:213
Power Monitor 2 Click context object.
Definition: powermonitor2.h:208
err_t powermonitor2_write_reg(powermonitor2_t *ctx, uint8_t reg, uint16_t data_in)
Power Monitor 2 write reg function.
powermonitor2_return_value_t
Power Monitor 2 Click return value data.
Definition: powermonitor2.h:240
uint8_t address_5v
Definition: powermonitor2.h:216
float current
Definition: powermonitor2.h:198
uint32_t i2c_speed
Definition: powermonitor2.h:229
float power
Definition: powermonitor2.h:199
err_t powermonitor2_read_data(powermonitor2_t *ctx, powermonitor2_data_t *data_out)
Power Monitor 2 read data function.
uint8_t i2c_address_5v
Definition: powermonitor2.h:231
pin_name_t sda
Definition: powermonitor2.h:227
@ POWERMONITOR2_OK
Definition: powermonitor2.h:241
float shunt_mv
Definition: powermonitor2.h:196
pin_name_t scl
Definition: powermonitor2.h:226
err_t powermonitor2_default_cfg(powermonitor2_t *ctx)
Power Monitor 2 default configuration function.
uint8_t address_3v3
Definition: powermonitor2.h:215
err_t powermonitor2_set_address(powermonitor2_t *ctx, uint8_t slave_address)
Power Monitor 2 set slave address function.
uint8_t i2c_address_3v3
Definition: powermonitor2.h:230
void powermonitor2_cfg_setup(powermonitor2_cfg_t *cfg)
Power Monitor 2 configuration object setup function.
Power Monitor 2 Click data object.
Definition: powermonitor2.h:195