Go to the documentation of this file.
35 #include "mikrosdk_version.h"
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_i2c_master.h"
69 #define PAC1720_REG_CONFIG 0x00
70 #define PAC1720_REG_CONVERSION_RATE 0x01
71 #define PAC1720_REG_ONE_SHOT 0x02
72 #define PAC1720_REG_CHANNEL_MASK 0x03
73 #define PAC1720_REG_HIGH_LIMIT_STATUS 0x04
74 #define PAC1720_REG_LOW_LIMIT_STATUS 0x05
75 #define PAC1720_REG_VSOURCE_CONFIG 0x0A
76 #define PAC1720_REG_CH1_VSENSE_CONFIG 0x0B
77 #define PAC1720_REG_CH2_VSENSE_CONFIG 0x0C
78 #define PAC1720_REG_CH1_VSENSE_HIGH_BYTE 0x0D
79 #define PAC1720_REG_CH1_VSENSE_LOW_BYTE 0x0E
80 #define PAC1720_REG_CH2_VSENSE_HIGH_BYTE 0x0F
81 #define PAC1720_REG_CH2_VSENSE_LOW_BYTE 0x10
82 #define PAC1720_REG_CH1_VSOURCE_HIGH_BYTE 0x11
83 #define PAC1720_REG_CH1_VSOURCE_LOW_BYTE 0x12
84 #define PAC1720_REG_CH2_VSOURCE_HIGH_BYTE 0x13
85 #define PAC1720_REG_CH2_VSOURCE_LOW_BYTE 0x14
86 #define PAC1720_REG_CH1_POWER_RATIO_HIGH_BYTE 0x15
87 #define PAC1720_REG_CH1_POWER_RATIO_LOW_BYTE 0x16
88 #define PAC1720_REG_CH2_POWER_RATIO_HIGH_BYTE 0x17
89 #define PAC1720_REG_CH2_POWER_RATIO_LOW_BYTE 0x18
90 #define PAC1720_REG_CH1_VSENSE_HIGH_LIMIT 0x19
91 #define PAC1720_REG_CH2_VSENSE_HIGH_LIMIT 0x1A
92 #define PAC1720_REG_CH1_VSENSE_LOW_LIMIT 0x1B
93 #define PAC1720_REG_CH2_VSENSE_LOW_LIMIT 0x1C
94 #define PAC1720_REG_CH1_VSOURCE_HIGH_LIMIT 0x1D
95 #define PAC1720_REG_CH2_VSOURCE_HIGH_LIMIT 0x1E
96 #define PAC1720_REG_CH1_VSOURCE_LOW_LIMIT 0x1F
97 #define PAC1720_REG_CH2_VSOURCE_LOW_LIMIT 0x20
98 #define PAC1720_REG_PRODUCT_ID 0xFD
99 #define PAC1720_REG_MANUFACTURER_ID 0xFE
100 #define PAC1720_REG_REVISION 0xFF
118 #define PAC1720_MAX_VOLTAGE 40.0
119 #define PAC1720_CURRENT_SENSE_RANGE_V 0.010
120 #define PAC1720_RSENSE_OHM 0.004
121 #define PAC1720_POWER_RATIO_RESOLUTION 65535
127 #define PAC1720_PRODUCT_ID 0x57
134 #define PAC1720_SET_DEV_ADDR_SEL_0_OHM 0x4C
135 #define PAC1720_SET_DEV_ADDR_SEL_100_OHM 0x4D
136 #define PAC1720_SET_DEV_ADDR_SEL_180_OHM 0x4E
137 #define PAC1720_SET_DEV_ADDR_SEL_300_OHM 0x4F
138 #define PAC1720_SET_DEV_ADDR_SEL_430_OHM 0x48
139 #define PAC1720_SET_DEV_ADDR_SEL_560_OHM 0x49
140 #define PAC1720_SET_DEV_ADDR_SEL_750_OHM 0x4A
141 #define PAC1720_SET_DEV_ADDR_SEL_1270_OHM 0x4B
142 #define PAC1720_SET_DEV_ADDR_SEL_1600_OHM 0x28
143 #define PAC1720_SET_DEV_ADDR_SEL_2000_OHM 0x29
144 #define PAC1720_SET_DEV_ADDR_SEL_2700_OHM 0x2A
145 #define PAC1720_SET_DEV_ADDR_SEL_3600_OHM 0x2B
146 #define PAC1720_SET_DEV_ADDR_SEL_5600_OHM 0x2C
147 #define PAC1720_SET_DEV_ADDR_SEL_9100_OHM 0x2D
148 #define PAC1720_SET_DEV_ADDR_SEL_20000_OHM 0x2E
149 #define PAC1720_SET_DEV_ADDR_SEL_OPEN 0x18
167 #define PAC1720_MAP_MIKROBUS( cfg, mikrobus ) \
168 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
169 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
170 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
521 float *voltage,
float *current,
float *power );
@ PAC1720_SAMPLE_TIME_2p5mS
Definition: pac1720.h:243
@ PAC1720_OK
Definition: pac1720.h:220
PAC1720 Click configuration object.
Definition: pac1720.h:203
err_t pac1720_read_byte(pac1720_t *ctx, uint8_t reg, uint8_t *data_out)
PAC1720 read byte function.
uint8_t ch2_vsense_cfg
Definition: pac1720.h:194
err_t pac1720_check_communication(pac1720_t *ctx)
PAC1720 check communication function.
err_t pac1720_set_vsource_config(pac1720_t *ctx, pac1720_ch_sel_t ch, pac1720_sample_time_t stime, pac1720_avg_t avg)
PAC1720 set vsource config function.
pac1720_cs_rng_t
PAC1720 current sensing range setting.
Definition: pac1720.h:272
@ PAC1720_SAMPLE_TIME_5mS
Definition: pac1720.h:244
@ PAC1720_SAMPLE_TIME_160mS
Definition: pac1720.h:249
uint8_t ch2_vsrc_cfg
Definition: pac1720.h:193
err_t pac1720_get_measurements(pac1720_t *ctx, pac1720_ch_sel_t ch, float *voltage, float *current, float *power)
PAC1720 get measurements function.
pac1720_avg_t
PAC1720 averaging setting.
Definition: pac1720.h:259
pac1720_sample_time_t
PAC1720 sample time setting.
Definition: pac1720.h:242
@ PAC1720_AVG_4_SAMPLES
Definition: pac1720.h:262
err_t pac1720_set_vsense_config(pac1720_t *ctx, pac1720_ch_sel_t ch, pac1720_sample_time_t stime, pac1720_avg_t avg, pac1720_cs_rng_t cs_rng)
PAC1720 set vsense config function.
err_t pac1720_read_block(pac1720_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
PAC1720 read block function.
uint8_t slave_address
Definition: pac1720.h:188
uint8_t pac1720_get_int_pin(pac1720_t *ctx)
PAC1720 get int pin function.
err_t pac1720_read_last_accessed_register(pac1720_t *ctx, uint8_t *data_out)
PAC1720 read last accessed register function.
uint8_t ch1_vsrc_cfg
Definition: pac1720.h:190
@ PAC1720_CHANNEL_2
Definition: pac1720.h:232
pin_name_t int_pin
Definition: pac1720.h:207
pac1720_return_value_t
PAC1720 Click return value data.
Definition: pac1720.h:219
@ PAC1720_CS_RANGE_40mV
Definition: pac1720.h:275
err_t pac1720_set_address_pointer(pac1720_t *ctx, uint8_t reg)
PAC1720 set address pointer function.
err_t pac1720_write_block(pac1720_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
PAC1720 write block function.
i2c_master_t i2c
Definition: pac1720.h:185
@ PAC1720_SAMPLE_TIME_10mS
Definition: pac1720.h:245
@ PAC1720_SAMPLE_TIME_320mS
Definition: pac1720.h:250
err_t pac1720_init(pac1720_t *ctx, pac1720_cfg_t *cfg)
PAC1720 initialization function.
@ PAC1720_AVG_8_SAMPLES
Definition: pac1720.h:263
uint32_t i2c_speed
Definition: pac1720.h:209
digital_in_t int_pin
Definition: pac1720.h:182
@ PAC1720_SAMPLE_TIME_80mS
Definition: pac1720.h:248
@ PAC1720_AVG_2_SAMPLES
Definition: pac1720.h:261
void pac1720_cfg_setup(pac1720_cfg_t *cfg)
PAC1720 configuration object setup function.
pin_name_t sda
Definition: pac1720.h:205
pin_name_t scl
Definition: pac1720.h:204
@ PAC1720_CS_RANGE_20mV
Definition: pac1720.h:274
err_t pac1720_set_slave_address(pac1720_t *ctx, uint8_t slave_address)
PAC1720 set slave address function.
PAC1720 Click context object.
Definition: pac1720.h:180
@ PAC1720_SAMPLE_TIME_40mS
Definition: pac1720.h:247
@ PAC1720_CHANNEL_1
Definition: pac1720.h:231
uint8_t i2c_address
Definition: pac1720.h:210
@ PAC1720_CS_RANGE_80mV
Definition: pac1720.h:276
@ PAC1720_ERROR
Definition: pac1720.h:221
@ PAC1720_SAMPLE_TIME_20mS
Definition: pac1720.h:246
uint8_t ch1_vsense_cfg
Definition: pac1720.h:191
@ PAC1720_CS_RANGE_10mV
Definition: pac1720.h:273
err_t pac1720_write_byte(pac1720_t *ctx, uint8_t reg, uint8_t data_in)
PAC1720 write byte function.
err_t pac1720_default_cfg(pac1720_t *ctx)
PAC1720 default configuration function.
@ PAC1720_AVG_DISABLE
Definition: pac1720.h:260
pac1720_ch_sel_t
PAC1720 channel selection.
Definition: pac1720.h:230