pwrmeter3 2.1.0.0
pwrmeter3.h File Reference

This file contains API for PWR Meter 3 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  pwrmeter3_t
 PWR Meter 3 Click context object. More...
 
struct  pwrmeter3_cfg_t
 PWR Meter 3 Click configuration object. More...
 

Macros

#define PWRMETER3_REG_EEPROM_0B   0x0B
 PWR Meter 3 EEPROM registers.
 
#define PWRMETER3_REG_EEPROM_0C   0x0C
 
#define PWRMETER3_REG_EEPROM_0D   0x0D
 
#define PWRMETER3_REG_EEPROM_0E   0x0E
 
#define PWRMETER3_REG_EEPROM_0F   0x0F
 
#define PWRMETER3_REG_SHADOW_1B   0x1B
 PWR Meter 3 SHADOW registers.
 
#define PWRMETER3_REG_SHADOW_1C   0x1C
 
#define PWRMETER3_REG_SHADOW_1D   0x1D
 
#define PWRMETER3_REG_SHADOW_1E   0x1E
 
#define PWRMETER3_REG_SHADOW_1F   0x1F
 
#define PWRMETER3_REG_VOLATILE_20   0x20
 PWR Meter 3 VOLATILE registers.
 
#define PWRMETER3_REG_VOLATILE_21   0x21
 
#define PWRMETER3_REG_VOLATILE_22   0x22
 
#define PWRMETER3_REG_VOLATILE_25   0x25
 
#define PWRMETER3_REG_VOLATILE_26   0x26
 
#define PWRMETER3_REG_VOLATILE_27   0x27
 
#define PWRMETER3_REG_VOLATILE_28   0x28
 
#define PWRMETER3_REG_VOLATILE_29   0x29
 
#define PWRMETER3_REG_VOLATILE_2A   0x2A
 
#define PWRMETER3_REG_VOLATILE_2C   0x2C
 
#define PWRMETER3_REG_VOLATILE_2D   0x2D
 
#define PWRMETER3_REG_VOLATILE_2F   0x2F
 
#define PWRMETER3_REG_VOLATILE_30   0x30
 
#define PWRMETER3_CUST_ACCESS_CODE   0x4F70656Eul
 PWR Meter 3 access code values.
 
#define PWRMETER3_CUST_ACCESS_CODE_CLEAR   0x00000000ul
 
#define PWRMETER3_VEVENT_CYCS_MASK   0x0000003Ful
 PWR Meter 3 register 0E/1E settings.
 
#define PWRMETER3_OVERVREG_MASK   0x00003F00ul
 
#define PWRMETER3_UNDERVREG_MASK   0x000FC000ul
 
#define PWRMETER3_DELAYCNT_SEL_MASK   0x00100000ul
 
#define PWRMETER3_HALFCYCLC_EN_MASK   0x00200000ul
 
#define PWRMETER3_SQUAREWAVE_EN_MASK   0x00400000ul
 
#define PWRMETER3_ZEROCROSSCHANSEL_MASK   0x00800000ul
 
#define PWRMETER3_ZEROCROSSEDGESEL_MASK   0x01000000ul
 
#define PWRMETER3_ECC_MASK   0xFC000000ul
 
#define PWRMETER3_OVERVREG_MAX   63
 
#define PWRMETER3_UNDERVREG_MAX   63
 
#define PWRMETER3_OVERVREG_3   3
 
#define PWRMETER3_UNDERVREG_1   1
 
#define PWRMETER3_I2C_SLV_ADDR_MASK   0x000001FCul
 PWR Meter 3 register 0F/1F settings.
 
#define PWRMETER3_I2C_DIS_SLV_ADDR   0x00000200ul
 
#define PWRMETER3_DIO_0_SEL_MASK   0x00000C00ul
 
#define PWRMETER3_DIO_1_SEL_MASK   0x00003000ul
 
#define PWRMETER3_N_MASK   0x00FFC000ul
 
#define PWRMETER3_BYPASS_N_EN_MASK   0x01000000ul
 
#define PWRMETER3_DIO_0_SEL_ZC   0
 
#define PWRMETER3_DIO_0_SEL_OV   1
 
#define PWRMETER3_DIO_0_SEL_UV   2
 
#define PWRMETER3_DIO_0_SEL_OV_UV   3
 
#define PWRMETER3_DIO_1_SEL_OCF   0
 
#define PWRMETER3_DIO_1_SEL_UV   1
 
#define PWRMETER3_DIO_1_SEL_OV   2
 
#define PWRMETER3_DIO_1_SEL_OV_UV_OCF   3
 
#define PWRMETER3_BYPASS_N_DISABLE   0
 
#define PWRMETER3_BYPASS_N_ENABLE   1
 
#define PWRMETER3_MAX_NUM_SAMPLES   1023u
 
#define PWRMETER3_RSENSE_OHM   2000.0f
 PWR Meter 3 RMS voltage and current calculation values.
 
#define PWRMETER3_AC_RDIV_OHM   2000000.0f
 
#define PWRMETER3_DC_RDIV_OHM   4000000.0f
 
#define PWRMETER3_ADC_FSCALE   55000u
 
#define PWRMETER3_DELTA_VIN_MAX_mV   250
 
#define PWRMETER3_mV_TO_V   1000u
 
#define PWRMETER3_MAX_CURRENT   90
 
#define PWRMETER3_DEF_AVG_SAMPLES   500u
 
#define PWRMETER3_DEVICE_ADDRESS_0   0x60
 PWR Meter 3 device address setting.
 
#define PWRMETER3_DEVICE_ADDRESS_1   0x61
 
#define PWRMETER3_DEVICE_ADDRESS_2   0x64
 
#define PWRMETER3_DEVICE_ADDRESS_3   0x65
 
#define PWRMETER3_MAP_MIKROBUS(cfg, mikrobus)
 MikroBUS pin mapping.
 

Enumerations

enum  pwrmeter3_return_value_t { PWRMETER3_OK = 0 , PWRMETER3_ERROR = -1 }
 PWR Meter 3 Click return value data. More...
 

Functions

void pwrmeter3_cfg_setup (pwrmeter3_cfg_t *cfg)
 PWR Meter 3 configuration object setup function.
 
err_t pwrmeter3_init (pwrmeter3_t *ctx, pwrmeter3_cfg_t *cfg)
 PWR Meter 3 initialization function.
 
err_t pwrmeter3_default_cfg (pwrmeter3_t *ctx)
 PWR Meter 3 default configuration function.
 
err_t pwrmeter3_write_register (pwrmeter3_t *ctx, uint8_t reg, uint32_t data_in)
 PWR Meter 3 write register function.
 
err_t pwrmeter3_read_register (pwrmeter3_t *ctx, uint8_t reg, uint32_t *data_out)
 PWR Meter 3 read register function.
 
uint8_t pwrmeter3_get_dio0_pin (pwrmeter3_t *ctx)
 PWR Meter 3 get dio0 pin function.
 
uint8_t pwrmeter3_get_dio1_pin (pwrmeter3_t *ctx)
 PWR Meter 3 get dio1 pin function.
 
void pwrmeter3_enable_device (pwrmeter3_t *ctx)
 PWR Meter 3 enable device function.
 
void pwrmeter3_disable_device (pwrmeter3_t *ctx)
 PWR Meter 3 disable device function.
 
err_t pwrmeter3_allow_write_access (pwrmeter3_t *ctx)
 PWR Meter 3 allow write access function.
 
err_t pwrmeter3_deny_write_access (pwrmeter3_t *ctx)
 PWR Meter 3 deny write access function.
 
err_t pwrmeter3_set_bypass_n_state (pwrmeter3_t *ctx, uint8_t state)
 PWR Meter 3 set bypass n state function.
 
err_t pwrmeter3_set_num_samples (pwrmeter3_t *ctx, uint16_t num_samples)
 PWR Meter 3 set num samples function.
 
err_t pwrmeter3_set_dio0_sel (pwrmeter3_t *ctx, uint8_t dio_sel)
 PWR Meter 3 set dio0 sel function.
 
err_t pwrmeter3_set_dio1_sel (pwrmeter3_t *ctx, uint8_t dio_sel)
 PWR Meter 3 set dio1 sel function.
 
err_t pwrmeter3_set_ovrms_threshold (pwrmeter3_t *ctx, uint8_t ovrms)
 PWR Meter 3 set ovrms threshold function.
 
err_t pwrmeter3_set_uvrms_threshold (pwrmeter3_t *ctx, uint8_t uvrms)
 PWR Meter 3 set uvrms threshold function.
 
err_t pwrmeter3_read_rms (pwrmeter3_t *ctx, float *v_rms, float *i_rms)
 PWR Meter 3 read rms function.
 
err_t pwrmeter3_read_average_rms (pwrmeter3_t *ctx, float *v_rms, float *i_rms, uint16_t num_avg)
 PWR Meter 3 read average rms function.
 

Detailed Description

This file contains API for PWR Meter 3 Click Driver.

Enumeration Type Documentation

◆ pwrmeter3_return_value_t

PWR Meter 3 Click return value data.

Predefined enum values for driver return values.

Enumerator
PWRMETER3_OK 
PWRMETER3_ERROR