Go to the documentation of this file.
38 #include "mikrosdk_version.h"
41 #if mikroSDK_GET_VERSION < 20800ul
42 #include "rcu_delays.h"
48 #include "drv_digital_out.h"
49 #include "drv_digital_in.h"
50 #include "drv_i2c_master.h"
62 #define PAC1934_MAP_MIKROBUS( cfg, mikrobus ) \
63 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
64 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
65 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
66 cfg.ale = MIKROBUS( mikrobus, MIKROBUS_INT )
73 #define PAC1934_RETVAL uint8_t
75 #define PAC1934_OK 0x00
76 #define PAC1934_INIT_ERROR 0xFF
83 #define PAC1934_I2C_ADDR 0x10
90 #define PAC1934_REFRESH_CMD 0x00
97 #define PAC1934_CTRL_REG 0x01
99 #define PAC1934_CTRL_SAMPLE_RATE_8 0xC0
100 #define PAC1934_CTRL_SAMPLE_RATE_64 0x80
101 #define PAC1934_CTRL_SAMPLE_RATE_256 0x40
102 #define PAC1934_CTRL_SAMPLE_RATE_1024 0x00
103 #define PAC1934_CTRL_SINGLE_SHOT_MODE 0x10
110 #define PAC1934_ACC_COUNT 0x02
117 #define PAC1934_VPOWER1_ACC 0x03
118 #define PAC1934_VPOWER2_ACC 0x04
119 #define PAC1934_VPOWER3_ACC 0x05
120 #define PAC1934_VPOWER4_ACC 0x06
127 #define PAC1934_VBUS1 0x07
128 #define PAC1934_VBUS2 0x08
129 #define PAC1934_VBUS3 0x09
130 #define PAC1934_VBUS4 0x0A
137 #define PAC1934_VSENSE1 0x0B
138 #define PAC1934_VSENSE2 0x0C
139 #define PAC1934_VSENSE3 0x0D
140 #define PAC1934_VSENSE4 0x0E
147 #define PAC1934_VBUS1_AVG 0x0F
148 #define PAC1934_VBUS2_AVG 0x10
149 #define PAC1934_VBUS3_AVG 0x11
150 #define PAC1934_VBUS4_AVG 0x12
157 #define PAC1934_VSENSE1_AVG 0x13
158 #define PAC1934_VSENSE2_AVG 0x14
159 #define PAC1934_VSENSE3_AVG 0x15
160 #define PAC1934_VSENSE4_AVG 0x16
167 #define PAC1934_VPOWER1 0x17
168 #define PAC1934_VPOWER2 0x18
169 #define PAC1934_VPOWER3 0x19
170 #define PAC1934_VPOWER4 0x1A
177 #define PAC1934_CHANNEL_DIS 0x1C
178 #define PAC1934_CHANNEL_DIS_ALL_CHA 0xF0
185 #define PAC1934_NEG_PWR 0x1D
192 #define PAC1934_REFRESH_G_CMD 0x1E
199 #define PAC1934_REFRESH_V_CMD 0x1F
207 #define PAC1934_SLOW 0x20
214 #define PAC1934_CTRL_ACT 0x21
221 #define PAC1934_DIS_ACT 0x22
228 #define PAC1934_NEG_PWR_ACT 0x23
235 #define PAC1934_CTRL_LAT 0x24
242 #define PAC1934_DIS_LAT 0x25
249 #define PAC1934_NEG_PWR_LAT 0x26
256 #define PAC1934_PRODUCT_ID 0xFD
263 #define PAC1934_MANUFACT_ID 0xFE
270 #define PAC1934_REVISION_ID 0xFF
579 #endif // _PAC1934_H_
uint8_t slave_address
Definition: pac1934.h:299
PAC1934_RETVAL pac1934_init(pac1934_t *ctx, pac1934_cfg_t *cfg)
Initialization function.
uint8_t pac1934_check_interrupt(pac1934_t *ctx)
Check Interrupt function.
float pac1934_calc_power(pac1934_t *ctx, float voltage, float amperage)
Calculate Power function.
uint8_t i2c_address
Definition: pac1934.h:323
void pac1934_write_byte(pac1934_t *ctx, uint8_t wr_addr, uint8_t wr_data)
Write one byte function.
uint32_t i2c_speed
Definition: pac1934.h:322
void pac1934_dev_disable(pac1934_t *ctx)
Disable device function.
pin_name_t ale
Definition: pac1934.h:318
pin_name_t rst
Definition: pac1934.h:316
void pac1934_send_command(pac1934_t *ctx, uint8_t wr_cmd)
Send Command.
i2c_master_t i2c
Definition: pac1934.h:295
Click configuration structure definition.
Definition: pac1934.h:308
pin_name_t scl
Definition: pac1934.h:311
#define PAC1934_RETVAL
Definition: pac1934.h:73
uint8_t pac1934_read_byte(pac1934_t *ctx, uint8_t rd_addr)
Read one byte function.
void pac1934_dev_enable(pac1934_t *ctx)
Enable device function.
void pac1934_read_reg(pac1934_t *ctx, uint8_t reg_addr, uint8_t *output_data, uint8_t cnt)
Read chosen number of bytes function.
pin_name_t sda
Definition: pac1934.h:312
void pac1934_cfg_setup(pac1934_cfg_t *cfg)
Config Object Initialization function.
digital_in_t ale
Definition: pac1934.h:291
float pac1934_measure_power(pac1934_t *ctx, uint8_t channel)
Measure Power function.
uint32_t pac1934_read_four_byte(pac1934_t *ctx, uint8_t rd_addr)
Read four bytes function.
float pac1934_measure_current(pac1934_t *ctx, uint8_t channel)
Measure Current function.
Click ctx object definition.
Definition: pac1934.h:284
void pac1934_dev_reset(pac1934_t *ctx)
Reset device function.
uint16_t pac1934_read_two_byte(pac1934_t *ctx, uint8_t rd_addr)
Read two bytes function.
float pac1934_measure_voltage(pac1934_t *ctx, uint8_t channel)
Measure Voltage function.
void pac1934_generic_read(pac1934_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
float pac1934_measure_energy(pac1934_t *ctx, uint8_t chann, uint16_t samp_rate)
Measure Energy function.
digital_out_t rst
Definition: pac1934.h:287
void pac1934_generic_write(pac1934_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.