no-OS
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ade7754.h File Reference

Header file of ADE7754 Driver. More...

#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include "no_os_util.h"
#include "no_os_spi.h"
#include "no_os_gpio.h"
#include "no_os_irq.h"
#include "no_os_delay.h"
#include "no_os_units.h"
#include "no_os_alloc.h"
#include "no_os_crc16.h"
#include "no_os_print_log.h"
#include <stdlib.h>
#include <errno.h>
#include <math.h>
Include dependency graph for ade7754.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ade7754_init_param
 ADE7754 Device initialization parameters. More...
 
struct  ade7754_dev
 ADE7754 Device structure. More...
 
struct  ade7754_energy_values
 ADE7754 energy registers values. More...
 
struct  ade7754_rms_values
 ADE7754 rms registers values. More...
 
struct  ade7754_period_value
 ADE7754 period value. More...
 
struct  ade7754_temp_value
 ADE7754 pq values. More...
 

Macros

#define ADE7754_SPI_READ   NO_OS_BIT(7)
 
#define ADE7754_VERSION   0x3F
 
#define ADE7754_REG_VERSION_PRODUCT   0x0D
 
#define IS_5BITS_REG(x)
 
#define IS_8BITS_REG(x)
 
#define IS_12BITS_REG(x)
 
#define IS_15BITS_REG(x)
 
#define IS_16BITS_REG(x)
 
#define IS_24BITS_REG(x)
 
#define ADE7754_RESET_DEL   20
 
#define ADE7754_REG_AENERGY   0x01
 
#define ADE7754_REG_RAENERGY   0x02
 
#define ADE7754_REG_LAENERGY   0x03
 
#define ADE7754_REG_VAENERGY   0x04
 
#define ADE7754_REG_RVAENERGY   0x05
 
#define ADE7754_REG_LVAENERGY   0x06
 
#define ADE7754_REG_PERIOD   0x07
 
#define ADE7754_REG_TEMP   0x08
 
#define ADE7754_REG_WFORM   0x09
 
#define ADE7754_REG_OPMODE   0x0A
 
#define ADE7754_REG_MMODE   0x0B
 
#define ADE7754_REG_WAVMODE   0x0C
 
#define ADE7754_REG_WATMODE   0x0D
 
#define ADE7754_REG_VAMODE   0X0E
 
#define ADE7754_REG_IRQEN   0x0F
 
#define ADE7754_REG_STATUS   0x10
 
#define ADE7754_REG_RSTATUS   0x11
 
#define ADE7754_REG_ZXTOUT   0x12
 
#define ADE7754_REG_LINCYC   0x13
 
#define ADE7754_REG_SAGCYC   0x14
 
#define ADE7754_REG_SAGLVL   0x15
 
#define ADE7754_REG_VPEAK   0x16
 
#define ADE7754_REG_IPEAK   0x17
 
#define ADE7754_REG_GAIN   0x18
 
#define ADE7754_REG_AWG   0x19
 
#define ADE7754_REG_BWG   0x1A
 
#define ADE7754_REG_CWG   0X1B
 
#define ADE7754_REG_AVAG   0x1C
 
#define ADE7754_REG_BVAG   0x1D
 
#define ADE7754_REG_CVAG   0x1E
 
#define ADE7754_REG_APHCAL   0x1F
 
#define ADE7754_REG_BPHCAL   0x20
 
#define ADE7754_REG_CPHCAL   0x21
 
#define ADE7754_REG_AAPOS   0x22
 
#define ADE7754_REG_BAPOS   0x23
 
#define ADE7754_REG_CAPOS   0x24
 
#define ADE7754_REG_CFNUM   0x25
 
#define ADE7754_REG_CFDEN   0x26
 
#define ADE7754_REG_WDIV   0x27
 
#define ADE7754_REG_VADIV   0x28
 
#define ADE7754_REG_AIRMS   0x29
 
#define ADE7754_REG_BIRMS   0x2A
 
#define ADE7754_REG_CIRMS   0x2B
 
#define ADE7754_REG_AVRMS   0x2C
 
#define ADE7754_REG_BVRMS   0x2D
 
#define ADE7754_REG_CVRMS   0x2E
 
#define ADE7754_REG_AIRMSOS   0x2F
 
#define ADE7754_REG_BIRMSOS   0x30
 
#define ADE7754_REG_CIRMSOS   0x31
 
#define ADE7754_REG_AVRMSOS   0x32
 
#define ADE7754_REG_BVRMSOS   0x33
 
#define ADE7754_REG_CVRMSOS   0x34
 
#define ADE7754_REG_AAPGAIN   0x35
 
#define ADE7754_REG_BAPGAIN   0x36
 
#define ADE7754_REG_CAPGAIN   0x37
 
#define ADE7754_REG_AVGAIN   0x38
 
#define ADE7754_REG_BVGAIN   0x39
 
#define ADE7754_REG_CVGAIN   0x3A
 
#define ADE7754_REG_CHKSUM   0x3E
 
#define ADE7754_REG_VERSION   0x3F
 
#define ADE7754_SWRST_MSK   NO_OS_BIT(6)
 
#define ADE7754_DISMOD_MSK   NO_OS_GENMASK(5, 3)
 
#define ADE7754_DISCF_MSK   NO_OS_BIT(2)
 
#define ADE7754_DISLPF_MSK   NO_OS_BIT(1)
 
#define ADE7754_DISHPF_MSK   NO_OS_BIT(0)
 
#define ADE7754_PGA2_MSK   NO_OS_GENMASK(6, 5)
 
#define ADE7754_NO_LOAD_MSK   NO_OS_BIT(3)
 
#define ADE7754_ABS_MSK   NO_OS_BIT(2)
 
#define ADE7754_PGA1_MSK   NO_OS_GENMASK(1, 0)
 
#define ADE7754_NEGC_MSK   NO_OS_BIT(14)
 
#define ADE7754_NEGB_MSK   NO_OS_BIT(13)
 
#define ADE7754_NEGA_MSK   NO_OS_BIT(12)
 
#define ADE7754_CFNUM_MSK   NO_OS_GENMASK(11, 0)
 
#define ADE7754_ZXSEL_MSK   NO_OS_GENMASK(6, 4)
 
#define ADE7754_PEAKSEL_MSK   NO_OS_GENMASK(3, 2)
 
#define ADE7754_PERDSEL_MSK   NO_OS_GENMASK(1, 0)
 
#define ADE7754_LVARSEL_MSK   NO_OS_BIT(5)
 
#define ADE7754_DTRT_MSK   NO_OS_GENMASK(4, 3)
 
#define ADE7754_WAVSEL_MSK   NO_OS_GENMASK(2, 0)
 
#define ADE7754_WATM_MSK   NO_OS_GENMASK(7, 6)
 
#define ADE7754_WATSEL_MSK   NO_OS_GENMASK(5, 3)
 
#define ADE7754_LWATSEL_MSK   NO_OS_GENMASK(2, 0)
 
#define ADE7754_VAMOD_MSK   NO_OS_GENMASK(7, 6)
 
#define ADE7754_VASEL_MSK   NO_OS_GENMASK(5, 3)
 
#define ADE7754_LVASEL_MSK   NO_OS_GENMASK(2, 0)
 
#define ADE7754_VAEHF_MSK   NO_OS_BIT(15)
 
#define ADE7754_WFSM_MSK   NO_OS_BIT(14)
 
#define ADE7754_PKI_MSK   NO_OS_BIT(13)
 
#define ADE7754_PKV_MSK   NO_OS_BIT(12)
 
#define ADE7754_RESET_MSK   NO_OS_BIT(11)
 
#define ADE7754_LENERGY_MSK   NO_OS_BIT(10)
 
#define ADE7754_ZXC_MSK   NO_OS_BIT(9)
 
#define ADE7754_ZXB_MSK   NO_OS_BIT(8)
 
#define ADE7754_ZXA_MSK   NO_OS_BIT(7)
 
#define ADE7754_ZXTOC_MSK   NO_OS_BIT(6)
 
#define ADE7754_ZXTOB_MSK   NO_OS_BIT(5)
 
#define ADE7754_ZXTOA_MSK   NO_OS_BIT(4)
 
#define ADE7754_SAGC_MSK   NO_OS_BIT(3)
 
#define ADE7754_SAGB_MSK   NO_OS_BIT(2)
 
#define ADE7754_SAGA_MSK   NO_OS_BIT(1)
 
#define ADE7754_AEHF_MSK   NO_OS_BIT(0)
 

Enumerations

enum  ade7754_dismod {
  ADE7754_NORMAL_OPERATION ,
  ADE7754_SWITCH_OFF_CURRENT_ADC ,
  ADE7754_SWITCH_OFF_VOLTAGE_ADC ,
  ADE7754_SLEEP_MODE ,
  ADE7754_SWAP_VOLTAGE_CURRENT ,
  ADE7754_OFF_CURRENT_ADCS_REDIRECTED_TO_VOLTAGE ,
  ADE7754_OFF_VOLTAGE_ADCS_REDIRECTED_TO_CURRENT ,
  ADE7754_POWER_DOWN_MODE
}
 ADE7754 ADCs can be turned off by using these bits. More...
 
enum  ade7754_pga_gain {
  ADE7754_PGA_GAIN_1 ,
  ADE7754_PGA_GAIN_2 ,
  ADE7754_PGA_GAIN_4
}
 ADE7754 select the PGA gain for current and voltage ch inputs. More...
 
enum  ade7754_phsel {
  ADE7754_PHASE_A ,
  ADE7754_PHASE_B ,
  ADE7754_PHASE_C
}
 ADE7754 select the phase of peak detection or the source for the voltage line period measurement. More...
 
enum  ade7754_formsel {
  ADE7754_FORMULA_PART_1 ,
  ADE7754_FORMULA_PART_2 ,
  ADE7754_FORMULA_PART_3
}
 ADE7754 select each part of the formula separately depending on the line active energy measurement method. More...
 
enum  ade7754_wavsel {
  ADE7754_VOLTAGE_PHASE_A ,
  ADE7754_VOLTAGE_PHASE_B ,
  ADE7754_VOLTAGE_PHASE_C ,
  ADE7754_CURRENT_PHASE_A ,
  ADE7754_CURRENT_PHASE_B ,
  ADE7754_CURRENT_PHASE_C
}
 ADE7754 select the source of the waveform sample. More...
 
enum  ade7754_data_rate {
  ADE7754_DATA_RATE_26_KSPS ,
  ADE7754_DATA_RATE_13_KSPS ,
  ADE7754_DATA_RATE_6_5KSPS ,
  ADE7754_DATA_RATE_3_KSPS
}
 ADE7754 select the data rate. More...
 
enum  ade7754_watm {
  ADE7754_ACTIVE_E_FORMULA_1 ,
  ADE7754_ACTIVE_E_FORMULA_2 ,
  ADE7754_ACTIVE_E_FORMULA_3
}
 ADE7754 select the formula used for active energy calculation. More...
 
enum  ade7754_vamod {
  ADE7754_APP_E_FORMULA_1 ,
  ADE7754_APP_E_FORMULA_2 ,
  ADE7754_APP_E_FORMULA_3
}
 ADE7754 select the formula used for apparent energy calculation. More...
 

Functions

int ade7754_init (struct ade7754_dev **device, struct ade7754_init_param init_param)
 Initialize the device.
 
int ade7754_setup (struct ade7754_dev *dev)
 Setup the ADE7754 device.
 
int ade7754_read (struct ade7754_dev *dev, uint16_t reg_addr, int32_t *reg_data)
 Read device register.
 
int ade7754_write (struct ade7754_dev *dev, uint16_t reg_addr, uint32_t reg_data)
 Write device register.
 
int ade7754_update_bits (struct ade7754_dev *dev, uint16_t reg_addr, uint32_t mask, uint32_t reg_data)
 Update specific register bits.
 
int ade7754_remove (struct ade7754_dev *dev)
 Remove the device and release resources.
 
int ade7754_sw_reset (struct ade7754_dev *dev)
 Reset the device using SW reset.
 
int ade7754_hw_reset (struct ade7754_dev *dev)
 Reset the device using HW reset.
 
int ade7754_version_product (struct ade7754_dev *dev, uint32_t *data_read)
 Version product.
 
int ade7754_write_ipk_val (struct ade7754_dev *dev, uint32_t val)
 Write Ipeak val.
 
int ade7754_write_vpk_val (struct ade7754_dev *dev, uint32_t val)
 Write Vpeak val.
 
int ade7754_get_int_status (struct ade7754_dev *dev, uint32_t msk, uint8_t *status)
 Get interrupt indicator from STATUS register.
 
int ade7754_clear_irq_status (struct ade7754_dev *dev, int32_t *reg_data)
 Clear irq status flags.
 
int ade7754_enable_irq (struct ade7754_dev *dev, uint32_t msk, uint8_t en)
 Enable/Disable interrupt.
 
int ade7754_wave_update_rate (struct ade7754_dev *dev, enum ade7754_data_rate sel)
 Select waveform register update rate.
 
int ade7754_wave_sample_data_source (struct ade7754_dev *dev, enum ade7754_wavsel sel)
 Select source of sampled data for wave register.
 
int ade7754_current_gain (struct ade7754_dev *dev, enum ade7754_pga_gain sel)
 Select the gain of the current channels inputs.
 
int ade7754_voltage_gain (struct ade7754_dev *dev, enum ade7754_pga_gain sel)
 Select the gain of the voltage channels inputs.
 
int ade7754_active_energy_formula (struct ade7754_dev *dev, enum ade7754_watm sel)
 Select the formula used for active energy calculation.
 
int ade7754_apparent_energy_formula (struct ade7754_dev *dev, enum ade7754_vamod sel)
 Select the formula used for apparent energy calculation.
 
int ade7754_period_source (struct ade7754_dev *dev, enum ade7754_phsel sel)
 Select the source of the measurement of the voltage line period.
 
int ade7754_zxsel (struct ade7754_dev *dev, enum ade7754_phsel sel)
 Select the phases used for counting the number of zero crossing in the line active and apparent accumulation modes and enables these phases for the zero-crossing timeout detection, zero crossing, period measurement, and SAG detection.
 
int ade7754_lwat_formula_term (struct ade7754_dev *dev, enum ade7754_formsel sel)
 Select part of the line active energy formula separately, depending on the line active energy measurement method.
 
int ade7754_lva_formula_term (struct ade7754_dev *dev, enum ade7754_formsel sel)
 Select part of the line apparent energy formula separately, depending on the line active energy measurement method.
 
int ade7754_wat_formula_term (struct ade7754_dev *dev, enum ade7754_formsel sel)
 Select part of the active energy formula separately, depending on the line active energy measurement method.
 
int ade7754_va_formula_term (struct ade7754_dev *dev, enum ade7754_formsel sel)
 Select part of the apparent energy formula separately, depending on the line active energy measurement method.
 
int ade7754_peak_source (struct ade7754_dev *dev, enum ade7754_phsel sel)
 Select the source of the voltage & current peak detection.
 
int ade7754_adcs_mode (struct ade7754_dev *dev, enum ade7754_dismod sel)
 Operation mode of the ADCs.
 
int ade7754_energy_vals (struct ade7754_dev *dev, struct ade7754_energy_values *data)
 Read energy values.
 
int ade7754_rms_vals_phase_a (struct ade7754_dev *dev, struct ade7754_rms_values *data)
 Read rms values phase A.
 
int ade7754_rms_vals_phase_b (struct ade7754_dev *dev, struct ade7754_rms_values *data)
 Read rms values phase B.
 
int ade7754_rms_vals_phase_c (struct ade7754_dev *dev, struct ade7754_rms_values *data)
 Read rms values phase C.
 
int ade7754_period_val (struct ade7754_dev *dev, struct ade7754_period_value *data)
 Read period value.
 
int ade7754_temperature_val (struct ade7754_dev *dev, struct ade7754_temp_value *data)
 Read temperature value.
 

Detailed Description

Header file of ADE7754 Driver.

Author
REtz (radu..nosp@m.etz@.nosp@m.analo.nosp@m.g.co.nosp@m.m)

Copyright 2025(c) Analog Devices, Inc.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of Analog Devices, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Macro Definition Documentation

◆ ADE7754_ABS_MSK

#define ADE7754_ABS_MSK   NO_OS_BIT(2)

◆ ADE7754_AEHF_MSK

#define ADE7754_AEHF_MSK   NO_OS_BIT(0)

◆ ADE7754_CFNUM_MSK

#define ADE7754_CFNUM_MSK   NO_OS_GENMASK(11, 0)

◆ ADE7754_DISCF_MSK

#define ADE7754_DISCF_MSK   NO_OS_BIT(2)

◆ ADE7754_DISHPF_MSK

#define ADE7754_DISHPF_MSK   NO_OS_BIT(0)

◆ ADE7754_DISLPF_MSK

#define ADE7754_DISLPF_MSK   NO_OS_BIT(1)

◆ ADE7754_DISMOD_MSK

#define ADE7754_DISMOD_MSK   NO_OS_GENMASK(5, 3)

◆ ADE7754_DTRT_MSK

#define ADE7754_DTRT_MSK   NO_OS_GENMASK(4, 3)

◆ ADE7754_LENERGY_MSK

#define ADE7754_LENERGY_MSK   NO_OS_BIT(10)

◆ ADE7754_LVARSEL_MSK

#define ADE7754_LVARSEL_MSK   NO_OS_BIT(5)

◆ ADE7754_LVASEL_MSK

#define ADE7754_LVASEL_MSK   NO_OS_GENMASK(2, 0)

◆ ADE7754_LWATSEL_MSK

#define ADE7754_LWATSEL_MSK   NO_OS_GENMASK(2, 0)

◆ ADE7754_NEGA_MSK

#define ADE7754_NEGA_MSK   NO_OS_BIT(12)

◆ ADE7754_NEGB_MSK

#define ADE7754_NEGB_MSK   NO_OS_BIT(13)

◆ ADE7754_NEGC_MSK

#define ADE7754_NEGC_MSK   NO_OS_BIT(14)

◆ ADE7754_NO_LOAD_MSK

#define ADE7754_NO_LOAD_MSK   NO_OS_BIT(3)

◆ ADE7754_PEAKSEL_MSK

#define ADE7754_PEAKSEL_MSK   NO_OS_GENMASK(3, 2)

◆ ADE7754_PERDSEL_MSK

#define ADE7754_PERDSEL_MSK   NO_OS_GENMASK(1, 0)

◆ ADE7754_PGA1_MSK

#define ADE7754_PGA1_MSK   NO_OS_GENMASK(1, 0)

◆ ADE7754_PGA2_MSK

#define ADE7754_PGA2_MSK   NO_OS_GENMASK(6, 5)

◆ ADE7754_PKI_MSK

#define ADE7754_PKI_MSK   NO_OS_BIT(13)

◆ ADE7754_PKV_MSK

#define ADE7754_PKV_MSK   NO_OS_BIT(12)

◆ ADE7754_REG_AAPGAIN

#define ADE7754_REG_AAPGAIN   0x35

◆ ADE7754_REG_AAPOS

#define ADE7754_REG_AAPOS   0x22

◆ ADE7754_REG_AENERGY

#define ADE7754_REG_AENERGY   0x01

◆ ADE7754_REG_AIRMS

#define ADE7754_REG_AIRMS   0x29

◆ ADE7754_REG_AIRMSOS

#define ADE7754_REG_AIRMSOS   0x2F

◆ ADE7754_REG_APHCAL

#define ADE7754_REG_APHCAL   0x1F

◆ ADE7754_REG_AVAG

#define ADE7754_REG_AVAG   0x1C

◆ ADE7754_REG_AVGAIN

#define ADE7754_REG_AVGAIN   0x38

◆ ADE7754_REG_AVRMS

#define ADE7754_REG_AVRMS   0x2C

◆ ADE7754_REG_AVRMSOS

#define ADE7754_REG_AVRMSOS   0x32

◆ ADE7754_REG_AWG

#define ADE7754_REG_AWG   0x19

◆ ADE7754_REG_BAPGAIN

#define ADE7754_REG_BAPGAIN   0x36

◆ ADE7754_REG_BAPOS

#define ADE7754_REG_BAPOS   0x23

◆ ADE7754_REG_BIRMS

#define ADE7754_REG_BIRMS   0x2A

◆ ADE7754_REG_BIRMSOS

#define ADE7754_REG_BIRMSOS   0x30

◆ ADE7754_REG_BPHCAL

#define ADE7754_REG_BPHCAL   0x20

◆ ADE7754_REG_BVAG

#define ADE7754_REG_BVAG   0x1D

◆ ADE7754_REG_BVGAIN

#define ADE7754_REG_BVGAIN   0x39

◆ ADE7754_REG_BVRMS

#define ADE7754_REG_BVRMS   0x2D

◆ ADE7754_REG_BVRMSOS

#define ADE7754_REG_BVRMSOS   0x33

◆ ADE7754_REG_BWG

#define ADE7754_REG_BWG   0x1A

◆ ADE7754_REG_CAPGAIN

#define ADE7754_REG_CAPGAIN   0x37

◆ ADE7754_REG_CAPOS

#define ADE7754_REG_CAPOS   0x24

◆ ADE7754_REG_CFDEN

#define ADE7754_REG_CFDEN   0x26

◆ ADE7754_REG_CFNUM

#define ADE7754_REG_CFNUM   0x25

◆ ADE7754_REG_CHKSUM

#define ADE7754_REG_CHKSUM   0x3E

◆ ADE7754_REG_CIRMS

#define ADE7754_REG_CIRMS   0x2B

◆ ADE7754_REG_CIRMSOS

#define ADE7754_REG_CIRMSOS   0x31

◆ ADE7754_REG_CPHCAL

#define ADE7754_REG_CPHCAL   0x21

◆ ADE7754_REG_CVAG

#define ADE7754_REG_CVAG   0x1E

◆ ADE7754_REG_CVGAIN

#define ADE7754_REG_CVGAIN   0x3A

◆ ADE7754_REG_CVRMS

#define ADE7754_REG_CVRMS   0x2E

◆ ADE7754_REG_CVRMSOS

#define ADE7754_REG_CVRMSOS   0x34

◆ ADE7754_REG_CWG

#define ADE7754_REG_CWG   0X1B

◆ ADE7754_REG_GAIN

#define ADE7754_REG_GAIN   0x18

◆ ADE7754_REG_IPEAK

#define ADE7754_REG_IPEAK   0x17

◆ ADE7754_REG_IRQEN

#define ADE7754_REG_IRQEN   0x0F

◆ ADE7754_REG_LAENERGY

#define ADE7754_REG_LAENERGY   0x03

◆ ADE7754_REG_LINCYC

#define ADE7754_REG_LINCYC   0x13

◆ ADE7754_REG_LVAENERGY

#define ADE7754_REG_LVAENERGY   0x06

◆ ADE7754_REG_MMODE

#define ADE7754_REG_MMODE   0x0B

◆ ADE7754_REG_OPMODE

#define ADE7754_REG_OPMODE   0x0A

◆ ADE7754_REG_PERIOD

#define ADE7754_REG_PERIOD   0x07

◆ ADE7754_REG_RAENERGY

#define ADE7754_REG_RAENERGY   0x02

◆ ADE7754_REG_RSTATUS

#define ADE7754_REG_RSTATUS   0x11

◆ ADE7754_REG_RVAENERGY

#define ADE7754_REG_RVAENERGY   0x05

◆ ADE7754_REG_SAGCYC

#define ADE7754_REG_SAGCYC   0x14

◆ ADE7754_REG_SAGLVL

#define ADE7754_REG_SAGLVL   0x15

◆ ADE7754_REG_STATUS

#define ADE7754_REG_STATUS   0x10

◆ ADE7754_REG_TEMP

#define ADE7754_REG_TEMP   0x08

◆ ADE7754_REG_VADIV

#define ADE7754_REG_VADIV   0x28

◆ ADE7754_REG_VAENERGY

#define ADE7754_REG_VAENERGY   0x04

◆ ADE7754_REG_VAMODE

#define ADE7754_REG_VAMODE   0X0E

◆ ADE7754_REG_VERSION

#define ADE7754_REG_VERSION   0x3F

◆ ADE7754_REG_VERSION_PRODUCT

#define ADE7754_REG_VERSION_PRODUCT   0x0D

◆ ADE7754_REG_VPEAK

#define ADE7754_REG_VPEAK   0x16

◆ ADE7754_REG_WATMODE

#define ADE7754_REG_WATMODE   0x0D

◆ ADE7754_REG_WAVMODE

#define ADE7754_REG_WAVMODE   0x0C

◆ ADE7754_REG_WDIV

#define ADE7754_REG_WDIV   0x27

◆ ADE7754_REG_WFORM

#define ADE7754_REG_WFORM   0x09

◆ ADE7754_REG_ZXTOUT

#define ADE7754_REG_ZXTOUT   0x12

◆ ADE7754_RESET_DEL

#define ADE7754_RESET_DEL   20

◆ ADE7754_RESET_MSK

#define ADE7754_RESET_MSK   NO_OS_BIT(11)

◆ ADE7754_SAGA_MSK

#define ADE7754_SAGA_MSK   NO_OS_BIT(1)

◆ ADE7754_SAGB_MSK

#define ADE7754_SAGB_MSK   NO_OS_BIT(2)

◆ ADE7754_SAGC_MSK

#define ADE7754_SAGC_MSK   NO_OS_BIT(3)

◆ ADE7754_SPI_READ

#define ADE7754_SPI_READ   NO_OS_BIT(7)

◆ ADE7754_SWRST_MSK

#define ADE7754_SWRST_MSK   NO_OS_BIT(6)

◆ ADE7754_VAEHF_MSK

#define ADE7754_VAEHF_MSK   NO_OS_BIT(15)

◆ ADE7754_VAMOD_MSK

#define ADE7754_VAMOD_MSK   NO_OS_GENMASK(7, 6)

◆ ADE7754_VASEL_MSK

#define ADE7754_VASEL_MSK   NO_OS_GENMASK(5, 3)

◆ ADE7754_VERSION

#define ADE7754_VERSION   0x3F

◆ ADE7754_WATM_MSK

#define ADE7754_WATM_MSK   NO_OS_GENMASK(7, 6)

◆ ADE7754_WATSEL_MSK

#define ADE7754_WATSEL_MSK   NO_OS_GENMASK(5, 3)

◆ ADE7754_WAVSEL_MSK

#define ADE7754_WAVSEL_MSK   NO_OS_GENMASK(2, 0)

◆ ADE7754_WFSM_MSK

#define ADE7754_WFSM_MSK   NO_OS_BIT(14)

◆ ADE7754_ZXA_MSK

#define ADE7754_ZXA_MSK   NO_OS_BIT(7)

◆ ADE7754_ZXB_MSK

#define ADE7754_ZXB_MSK   NO_OS_BIT(8)

◆ ADE7754_ZXC_MSK

#define ADE7754_ZXC_MSK   NO_OS_BIT(9)

◆ ADE7754_ZXSEL_MSK

#define ADE7754_ZXSEL_MSK   NO_OS_GENMASK(6, 4)

◆ ADE7754_ZXTOA_MSK

#define ADE7754_ZXTOA_MSK   NO_OS_BIT(4)

◆ ADE7754_ZXTOB_MSK

#define ADE7754_ZXTOB_MSK   NO_OS_BIT(5)

◆ ADE7754_ZXTOC_MSK

#define ADE7754_ZXTOC_MSK   NO_OS_BIT(6)

◆ IS_12BITS_REG

#define IS_12BITS_REG ( x)
Value:
(((x) >= ADE7754_REG_AWG && (x) <= ADE7754_REG_CVAG) \
|| ((x) >= ADE7754_REG_AAPOS && (x) <= ADE7754_REG_CFDEN) \
|| ((x) >= ADE7754_REG_AIRMSOS && (x) <= ADE7754_REG_CVGAIN))
#define ADE7754_REG_CVAG
Definition ade7754.h:112
#define ADE7754_REG_CVGAIN
Definition ade7754.h:140
#define ADE7754_REG_AWG
Definition ade7754.h:107
#define ADE7754_REG_AAPOS
Definition ade7754.h:116
#define ADE7754_REG_AIRMSOS
Definition ade7754.h:129
#define ADE7754_REG_CFDEN
Definition ade7754.h:120

◆ IS_15BITS_REG

#define IS_15BITS_REG ( x)
Value:
#define ADE7754_REG_PERIOD
Definition ade7754.h:89

◆ IS_16BITS_REG

#define IS_16BITS_REG ( x)
Value:
#define ADE7754_REG_LINCYC
Definition ade7754.h:101
#define ADE7754_REG_IRQEN
Definition ade7754.h:97

◆ IS_24BITS_REG

#define IS_24BITS_REG ( x)
Value:
|| ((x) == ADE7754_REG_WFORM) \
|| ((x) >= ADE7754_REG_AIRMS && (x) <= ADE7754_REG_CVRMS))
#define ADE7754_REG_WFORM
Definition ade7754.h:91
#define ADE7754_REG_LVAENERGY
Definition ade7754.h:88
#define ADE7754_REG_CVRMS
Definition ade7754.h:128
#define ADE7754_REG_AENERGY
Definition ade7754.h:83
#define ADE7754_REG_AIRMS
Definition ade7754.h:123

◆ IS_5BITS_REG

#define IS_5BITS_REG ( x)
Value:
#define ADE7754_REG_CPHCAL
Definition ade7754.h:115
#define ADE7754_REG_APHCAL
Definition ade7754.h:113

◆ IS_8BITS_REG

#define IS_8BITS_REG ( x)
Value:
(((x) == ADE7754_REG_TEMP) \
|| ((x) >= ADE7754_REG_OPMODE && (x) <= ADE7754_REG_VAMODE) \
|| ((x) >= ADE7754_REG_SAGCYC && (x) <= ADE7754_REG_GAIN) \
|| ((x) >= ADE7754_REG_WDIV && (x) <= ADE7754_REG_VADIV) \
#define ADE7754_REG_VAMODE
Definition ade7754.h:96
#define ADE7754_REG_CHKSUM
Definition ade7754.h:141
#define ADE7754_REG_GAIN
Definition ade7754.h:106
#define ADE7754_REG_WDIV
Definition ade7754.h:121
#define ADE7754_REG_VERSION
Definition ade7754.h:142
#define ADE7754_REG_TEMP
Definition ade7754.h:90
#define ADE7754_REG_SAGCYC
Definition ade7754.h:102
#define ADE7754_REG_VADIV
Definition ade7754.h:122
#define ADE7754_REG_OPMODE
Definition ade7754.h:92

Enumeration Type Documentation

◆ ade7754_data_rate

ADE7754 select the data rate.

Enumerator
ADE7754_DATA_RATE_26_KSPS 
ADE7754_DATA_RATE_13_KSPS 
ADE7754_DATA_RATE_6_5KSPS 
ADE7754_DATA_RATE_3_KSPS 

◆ ade7754_dismod

ADE7754 ADCs can be turned off by using these bits.

Enumerator
ADE7754_NORMAL_OPERATION 
ADE7754_SWITCH_OFF_CURRENT_ADC 
ADE7754_SWITCH_OFF_VOLTAGE_ADC 
ADE7754_SLEEP_MODE 
ADE7754_SWAP_VOLTAGE_CURRENT 
ADE7754_OFF_CURRENT_ADCS_REDIRECTED_TO_VOLTAGE 
ADE7754_OFF_VOLTAGE_ADCS_REDIRECTED_TO_CURRENT 
ADE7754_POWER_DOWN_MODE 

◆ ade7754_formsel

ADE7754 select each part of the formula separately depending on the line active energy measurement method.

Enumerator
ADE7754_FORMULA_PART_1 
ADE7754_FORMULA_PART_2 
ADE7754_FORMULA_PART_3 

◆ ade7754_pga_gain

ADE7754 select the PGA gain for current and voltage ch inputs.

Enumerator
ADE7754_PGA_GAIN_1 
ADE7754_PGA_GAIN_2 
ADE7754_PGA_GAIN_4 

◆ ade7754_phsel

ADE7754 select the phase of peak detection or the source for the voltage line period measurement.

Enumerator
ADE7754_PHASE_A 
ADE7754_PHASE_B 
ADE7754_PHASE_C 

◆ ade7754_vamod

ADE7754 select the formula used for apparent energy calculation.

Enumerator
ADE7754_APP_E_FORMULA_1 
ADE7754_APP_E_FORMULA_2 
ADE7754_APP_E_FORMULA_3 

◆ ade7754_watm

ADE7754 select the formula used for active energy calculation.

Enumerator
ADE7754_ACTIVE_E_FORMULA_1 
ADE7754_ACTIVE_E_FORMULA_2 
ADE7754_ACTIVE_E_FORMULA_3 

◆ ade7754_wavsel

ADE7754 select the source of the waveform sample.

Enumerator
ADE7754_VOLTAGE_PHASE_A 
ADE7754_VOLTAGE_PHASE_B 
ADE7754_VOLTAGE_PHASE_C 
ADE7754_CURRENT_PHASE_A 
ADE7754_CURRENT_PHASE_B 
ADE7754_CURRENT_PHASE_C 

Function Documentation

◆ ade7754_active_energy_formula()

int ade7754_active_energy_formula ( struct ade7754_dev * dev,
enum ade7754_watm sel )

Select the formula used for active energy calculation.

Parameters
dev- The device structure.
sel- formula value
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ade7754_adcs_mode()

int ade7754_adcs_mode ( struct ade7754_dev * dev,
enum ade7754_dismod sel )

Operation mode of the ADCs.

Parameters
dev- The device structure.
sel- mode of the ADCs
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ade7754_apparent_energy_formula()

int ade7754_apparent_energy_formula ( struct ade7754_dev * dev,
enum ade7754_vamod sel )

Select the formula used for apparent energy calculation.

Parameters
dev- The device structure.
sel- formula value
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ade7754_clear_irq_status()

int ade7754_clear_irq_status ( struct ade7754_dev * dev,
int32_t * reg_data )

Clear irq status flags.

Parameters
dev- The device structure.
reg_data- value of the status register
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ade7754_current_gain()

int ade7754_current_gain ( struct ade7754_dev * dev,
enum ade7754_pga_gain sel )

Select the gain of the current channels inputs.

Parameters
dev- The device structure.
sel- gain value
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ade7754_enable_irq()

int ade7754_enable_irq ( struct ade7754_dev * dev,
uint32_t msk,
uint8_t en )

Enable/Disable interrupt.

Parameters
dev- The device structure.
msk- Interrupt mask.
en-Enable/Disable
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ade7754_energy_vals()

int ade7754_energy_vals ( struct ade7754_dev * dev,
struct ade7754_energy_values * data )

Read energy values.

Parameters
dev- The device structure.
data- Structure to store energy values
Returns
0 in case of success, negative error code otherwise.

◆ ade7754_get_int_status()

int ade7754_get_int_status ( struct ade7754_dev * dev,
uint32_t msk,
uint8_t * status )

Get interrupt indicator from STATUS register.

Parameters
dev- The device structure.
msk- Interrupt mask.
status- Status indicator.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ade7754_hw_reset()

int ade7754_hw_reset ( struct ade7754_dev * dev)

Reset the device using HW reset.

Parameters
dev- The device structure.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ade7754_init()

int ade7754_init ( struct ade7754_dev ** device,
struct ade7754_init_param init_param )

Initialize the device.

Parameters
device- The device structure.
init_param- The structure that contains the device initial parameters.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ade7754_lva_formula_term()

int ade7754_lva_formula_term ( struct ade7754_dev * dev,
enum ade7754_formsel sel )

Select part of the line apparent energy formula separately, depending on the line active energy measurement method.

Parameters
dev- The device structure.
sel- formula part selection
Returns
0 in case of success, negative error code otherwise.

◆ ade7754_lwat_formula_term()

int ade7754_lwat_formula_term ( struct ade7754_dev * dev,
enum ade7754_formsel sel )

Select part of the line active energy formula separately, depending on the line active energy measurement method.

Parameters
dev- The device structure.
sel- formula part selection
Returns
0 in case of success, negative error code otherwise.

◆ ade7754_peak_source()

int ade7754_peak_source ( struct ade7754_dev * dev,
enum ade7754_phsel sel )

Select the source of the voltage & current peak detection.

Parameters
dev- The device structure.
sel- peak detection source
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ade7754_period_source()

int ade7754_period_source ( struct ade7754_dev * dev,
enum ade7754_phsel sel )

Select the source of the measurement of the voltage line period.

Parameters
dev- The device structure.
sel- period measurement source
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ade7754_period_val()

int ade7754_period_val ( struct ade7754_dev * dev,
struct ade7754_period_value * data )

Read period value.

Parameters
dev- The device structure.
data- Structure to store the period val
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ade7754_read()

int ade7754_read ( struct ade7754_dev * dev,
uint16_t reg_addr,
int32_t * reg_data )

Read device register.

Parameters
dev- The device structure.
reg_addr- The register address.
reg_data- The data read from 32bit register.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ade7754_remove()

int ade7754_remove ( struct ade7754_dev * dev)

Remove the device and release resources.

Parameters
dev- The device structure.
Returns
0 in case of success, negative error code otherwise.

◆ ade7754_rms_vals_phase_a()

int ade7754_rms_vals_phase_a ( struct ade7754_dev * dev,
struct ade7754_rms_values * data )

Read rms values phase A.

Parameters
dev- The device structure.
data- Structure to store rms values
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ade7754_rms_vals_phase_b()

int ade7754_rms_vals_phase_b ( struct ade7754_dev * dev,
struct ade7754_rms_values * data )

Read rms values phase B.

Parameters
dev- The device structure.
data- Structure to store rms values
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ade7754_rms_vals_phase_c()

int ade7754_rms_vals_phase_c ( struct ade7754_dev * dev,
struct ade7754_rms_values * data )

Read rms values phase C.

Parameters
dev- The device structure.
data- Structure to store rms values
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ade7754_setup()

int ade7754_setup ( struct ade7754_dev * dev)

Setup the ADE7754 device.

Parameters
dev- The device structure.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ade7754_sw_reset()

int ade7754_sw_reset ( struct ade7754_dev * dev)

Reset the device using SW reset.

Parameters
dev- The device structure.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ade7754_temperature_val()

int ade7754_temperature_val ( struct ade7754_dev * dev,
struct ade7754_temp_value * data )

Read temperature value.

Parameters
dev- The device structure.
data- Structure to store the temperature val
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ade7754_update_bits()

int ade7754_update_bits ( struct ade7754_dev * dev,
uint16_t reg_addr,
uint32_t mask,
uint32_t reg_data )

Update specific register bits.

Parameters
dev- The device structure.
reg_addr- The register address.
mask- Specific bits mask.
reg_data- The data to be written.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ade7754_va_formula_term()

int ade7754_va_formula_term ( struct ade7754_dev * dev,
enum ade7754_formsel sel )

Select part of the apparent energy formula separately, depending on the line active energy measurement method.

Parameters
dev- The device structure.
sel- formula part selection
Returns
0 in case of success, negative error code otherwise.

◆ ade7754_version_product()

int ade7754_version_product ( struct ade7754_dev * dev,
uint32_t * data_read )

Version product.

Parameters
dev- The device structure.
data_read- The version product read value
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ade7754_voltage_gain()

int ade7754_voltage_gain ( struct ade7754_dev * dev,
enum ade7754_pga_gain sel )

Select the gain of the voltage channels inputs.

Parameters
dev- The device structure.
sel- gain value
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ade7754_wat_formula_term()

int ade7754_wat_formula_term ( struct ade7754_dev * dev,
enum ade7754_formsel sel )

Select part of the active energy formula separately, depending on the line active energy measurement method.

Parameters
dev- The device structure.
sel- formula part selection
Returns
0 in case of success, negative error code otherwise.

◆ ade7754_wave_sample_data_source()

int ade7754_wave_sample_data_source ( struct ade7754_dev * dev,
enum ade7754_wavsel sel )

Select source of sampled data for wave register.

Parameters
dev- The device structure.
sel- Update rate
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ade7754_wave_update_rate()

int ade7754_wave_update_rate ( struct ade7754_dev * dev,
enum ade7754_data_rate sel )

Select waveform register update rate.

Parameters
dev- The device structure.
sel- Update rate
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ade7754_write()

int ade7754_write ( struct ade7754_dev * dev,
uint16_t reg_addr,
uint32_t reg_data )

Write device register.

Parameters
dev-The device structure.
reg_addr- The register address.
reg_data- The data to be written.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ade7754_write_ipk_val()

int ade7754_write_ipk_val ( struct ade7754_dev * dev,
uint32_t val )

Write Ipeak val.

Parameters
dev- The device structure.
val- Ipeak set val
Returns
0 in case of success, negative error code otherwise.

◆ ade7754_write_vpk_val()

int ade7754_write_vpk_val ( struct ade7754_dev * dev,
uint32_t val )

Write Vpeak val.

Parameters
dev- The device structure.
val- Vpeak set val
Returns
0 in case of success, negative error code otherwise.

◆ ade7754_zxsel()

int ade7754_zxsel ( struct ade7754_dev * dev,
enum ade7754_phsel sel )

Select the phases used for counting the number of zero crossing in the line active and apparent accumulation modes and enables these phases for the zero-crossing timeout detection, zero crossing, period measurement, and SAG detection.

Parameters
dev- The device structure.
sel- phase selection
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function: