pac1720 2.0.0.0
pac1720.h File Reference

This file contains API for PAC1720 Click Driver. More...

#include "drv_digital_out.h"
#include "drv_digital_in.h"
#include "drv_i2c_master.h"

Go to the source code of this file.

Data Structures

struct  pac1720_t
 PAC1720 Click context object. More...
 
struct  pac1720_cfg_t
 PAC1720 Click configuration object. More...
 

Macros

#define PAC1720_REG_CONFIG   0x00
 PAC1720 register list.
 
#define PAC1720_REG_CONVERSION_RATE   0x01
 
#define PAC1720_REG_ONE_SHOT   0x02
 
#define PAC1720_REG_CHANNEL_MASK   0x03
 
#define PAC1720_REG_HIGH_LIMIT_STATUS   0x04
 
#define PAC1720_REG_LOW_LIMIT_STATUS   0x05
 
#define PAC1720_REG_VSOURCE_CONFIG   0x0A
 
#define PAC1720_REG_CH1_VSENSE_CONFIG   0x0B
 
#define PAC1720_REG_CH2_VSENSE_CONFIG   0x0C
 
#define PAC1720_REG_CH1_VSENSE_HIGH_BYTE   0x0D
 
#define PAC1720_REG_CH1_VSENSE_LOW_BYTE   0x0E
 
#define PAC1720_REG_CH2_VSENSE_HIGH_BYTE   0x0F
 
#define PAC1720_REG_CH2_VSENSE_LOW_BYTE   0x10
 
#define PAC1720_REG_CH1_VSOURCE_HIGH_BYTE   0x11
 
#define PAC1720_REG_CH1_VSOURCE_LOW_BYTE   0x12
 
#define PAC1720_REG_CH2_VSOURCE_HIGH_BYTE   0x13
 
#define PAC1720_REG_CH2_VSOURCE_LOW_BYTE   0x14
 
#define PAC1720_REG_CH1_POWER_RATIO_HIGH_BYTE   0x15
 
#define PAC1720_REG_CH1_POWER_RATIO_LOW_BYTE   0x16
 
#define PAC1720_REG_CH2_POWER_RATIO_HIGH_BYTE   0x17
 
#define PAC1720_REG_CH2_POWER_RATIO_LOW_BYTE   0x18
 
#define PAC1720_REG_CH1_VSENSE_HIGH_LIMIT   0x19
 
#define PAC1720_REG_CH2_VSENSE_HIGH_LIMIT   0x1A
 
#define PAC1720_REG_CH1_VSENSE_LOW_LIMIT   0x1B
 
#define PAC1720_REG_CH2_VSENSE_LOW_LIMIT   0x1C
 
#define PAC1720_REG_CH1_VSOURCE_HIGH_LIMIT   0x1D
 
#define PAC1720_REG_CH2_VSOURCE_HIGH_LIMIT   0x1E
 
#define PAC1720_REG_CH1_VSOURCE_LOW_LIMIT   0x1F
 
#define PAC1720_REG_CH2_VSOURCE_LOW_LIMIT   0x20
 
#define PAC1720_REG_PRODUCT_ID   0xFD
 
#define PAC1720_REG_MANUFACTURER_ID   0xFE
 
#define PAC1720_REG_REVISION   0xFF
 
#define PAC1720_MAX_VOLTAGE   40.0
 PAC1720 measurement calculation values.
 
#define PAC1720_CURRENT_SENSE_RANGE_V   0.010
 
#define PAC1720_RSENSE_OHM   0.004
 
#define PAC1720_POWER_RATIO_RESOLUTION   65535
 
#define PAC1720_PRODUCT_ID   0x57
 PAC1720 product ID value.
 
#define PAC1720_SET_DEV_ADDR_SEL_0_OHM   0x4C
 PAC1720 device address setting.
 
#define PAC1720_SET_DEV_ADDR_SEL_100_OHM   0x4D
 
#define PAC1720_SET_DEV_ADDR_SEL_180_OHM   0x4E
 
#define PAC1720_SET_DEV_ADDR_SEL_300_OHM   0x4F
 
#define PAC1720_SET_DEV_ADDR_SEL_430_OHM   0x48
 
#define PAC1720_SET_DEV_ADDR_SEL_560_OHM   0x49
 
#define PAC1720_SET_DEV_ADDR_SEL_750_OHM   0x4A
 
#define PAC1720_SET_DEV_ADDR_SEL_1270_OHM   0x4B
 
#define PAC1720_SET_DEV_ADDR_SEL_1600_OHM   0x28
 
#define PAC1720_SET_DEV_ADDR_SEL_2000_OHM   0x29
 
#define PAC1720_SET_DEV_ADDR_SEL_2700_OHM   0x2A
 
#define PAC1720_SET_DEV_ADDR_SEL_3600_OHM   0x2B
 
#define PAC1720_SET_DEV_ADDR_SEL_5600_OHM   0x2C
 
#define PAC1720_SET_DEV_ADDR_SEL_9100_OHM   0x2D
 
#define PAC1720_SET_DEV_ADDR_SEL_20000_OHM   0x2E
 
#define PAC1720_SET_DEV_ADDR_SEL_OPEN   0x18
 
#define PAC1720_MAP_MIKROBUS(cfg, mikrobus)
 MikroBUS pin mapping.
 

Enumerations

enum  pac1720_return_value_t { PAC1720_OK = 0 , PAC1720_ERROR = -1 }
 PAC1720 Click return value data. More...
 
enum  pac1720_ch_sel_t { PAC1720_CHANNEL_1 = 1 , PAC1720_CHANNEL_2 = 2 }
 PAC1720 channel selection. More...
 
enum  pac1720_sample_time_t {
  PAC1720_SAMPLE_TIME_2p5mS = 0 , PAC1720_SAMPLE_TIME_5mS , PAC1720_SAMPLE_TIME_10mS , PAC1720_SAMPLE_TIME_20mS ,
  PAC1720_SAMPLE_TIME_40mS , PAC1720_SAMPLE_TIME_80mS , PAC1720_SAMPLE_TIME_160mS , PAC1720_SAMPLE_TIME_320mS
}
 PAC1720 sample time setting. More...
 
enum  pac1720_avg_t { PAC1720_AVG_DISABLE = 0 , PAC1720_AVG_2_SAMPLES , PAC1720_AVG_4_SAMPLES , PAC1720_AVG_8_SAMPLES }
 PAC1720 averaging setting. More...
 
enum  pac1720_cs_rng_t { PAC1720_CS_RANGE_10mV = 0 , PAC1720_CS_RANGE_20mV , PAC1720_CS_RANGE_40mV , PAC1720_CS_RANGE_80mV }
 PAC1720 current sensing range setting. More...
 

Functions

void pac1720_cfg_setup (pac1720_cfg_t *cfg)
 PAC1720 configuration object setup function.
 
err_t pac1720_init (pac1720_t *ctx, pac1720_cfg_t *cfg)
 PAC1720 initialization function.
 
err_t pac1720_default_cfg (pac1720_t *ctx)
 PAC1720 default configuration function.
 
err_t pac1720_write_block (pac1720_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
 PAC1720 write block function.
 
err_t pac1720_read_block (pac1720_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
 PAC1720 read block function.
 
err_t pac1720_write_byte (pac1720_t *ctx, uint8_t reg, uint8_t data_in)
 PAC1720 write byte function.
 
err_t pac1720_read_byte (pac1720_t *ctx, uint8_t reg, uint8_t *data_out)
 PAC1720 read byte function.
 
err_t pac1720_set_address_pointer (pac1720_t *ctx, uint8_t reg)
 PAC1720 set address pointer function.
 
err_t pac1720_read_last_accessed_register (pac1720_t *ctx, uint8_t *data_out)
 PAC1720 read last accessed register function.
 
err_t pac1720_set_slave_address (pac1720_t *ctx, uint8_t slave_address)
 PAC1720 set slave address function.
 
uint8_t pac1720_get_int_pin (pac1720_t *ctx)
 PAC1720 get int pin function.
 
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.
 
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_get_measurements (pac1720_t *ctx, pac1720_ch_sel_t ch, float *voltage, float *current, float *power)
 PAC1720 get measurements function.
 

Detailed Description

This file contains API for PAC1720 Click Driver.

Enumeration Type Documentation

◆ pac1720_avg_t

PAC1720 averaging setting.

Predefined enum values for averaging samples setting.

Enumerator
PAC1720_AVG_DISABLE 
PAC1720_AVG_2_SAMPLES 
PAC1720_AVG_4_SAMPLES 
PAC1720_AVG_8_SAMPLES 

◆ pac1720_ch_sel_t

PAC1720 channel selection.

Predefined enum values for channel selection.

Enumerator
PAC1720_CHANNEL_1 
PAC1720_CHANNEL_2 

◆ pac1720_cs_rng_t

PAC1720 current sensing range setting.

Predefined enum values for current sensing range setting.

Enumerator
PAC1720_CS_RANGE_10mV 
PAC1720_CS_RANGE_20mV 
PAC1720_CS_RANGE_40mV 
PAC1720_CS_RANGE_80mV 

◆ pac1720_return_value_t

PAC1720 Click return value data.

Predefined enum values for driver return values.

Enumerator
PAC1720_OK 
PAC1720_ERROR 

◆ pac1720_sample_time_t

PAC1720 sample time setting.

Predefined enum values for sample time setting.

Note
The values above 20ms are not supported for Vsource settings.
Enumerator
PAC1720_SAMPLE_TIME_2p5mS 
PAC1720_SAMPLE_TIME_5mS 
PAC1720_SAMPLE_TIME_10mS 
PAC1720_SAMPLE_TIME_20mS 
PAC1720_SAMPLE_TIME_40mS 
PAC1720_SAMPLE_TIME_80mS 
PAC1720_SAMPLE_TIME_160mS 
PAC1720_SAMPLE_TIME_320mS