Go to the documentation of this file.
52 #define ADE7913_SPI_READ NO_OS_BIT(2)
59 #define ADE7913_REG_IWV 0x00
60 #define ADE7913_REG_V1WV 0x01
61 #define ADE7913_REG_V2WV 0x02
62 #define ADE7913_REG_ADC_CRC 0x04
63 #define ADE7913_REG_CTRL_CRC 0x05
64 #define ADE7913_REG_CNT_SNAPSHOT 0x07
65 #define ADE7913_REG_CONFIG 0x08
66 #define ADE7913_REG_STATUS0 0x09
67 #define ADE7913_REG_LOCK 0x0A
68 #define ADE7913_REG_SYNC_SNAP 0x0B
69 #define ADE7913_REG_COUNTER0 0x0C
70 #define ADE7913_REG_COUNTER1 0x0D
71 #define ADE7913_REG_EMI_CTRL 0x0E
72 #define ADE7913_REG_STATUS1 0x0F
73 #define ADE7913_REG_TEMPOS 0x08
76 #define ADE7913_CNT_VAL_MSK NO_OS_GENMASK(11, 0)
79 #define ADE7913_CLKOUT_EN_MSK NO_OS_BIT(0)
80 #define ADE7913_PWRDWN_EN_MSK NO_OS_BIT(2)
81 #define ADE7913_TEMP_EN_MSK NO_OS_BIT(3)
82 #define ADE7913_ADC_FREQ_MSK NO_OS_GENMASK(5, 4)
83 #define ADE7913_SWRST_MSK NO_OS_BIT(6)
84 #define ADE7913_BW_MSK NO_OS_BIT(7)
87 #define ADE7913_RESET_ON_MSK NO_OS_BIT(0)
88 #define ADE7913_CRC_STAT_MSK NO_OS_BIT(1)
89 #define ADE7913_IC_PROT_MSK NO_OS_BIT(2)
92 #define ADE7913_LOCK_KEY_MSK NO_OS_GENMASK(5, 4)
95 #define ADE7913_SYNC_MSK NO_OS_BIT(0)
96 #define ADE7913_SNAP_MSK NO_OS_BIT(1)
99 #define ADE7913_SLOT0_MSK NO_OS_BIT(0)
100 #define ADE7913_SLOT1_MSK NO_OS_BIT(1)
101 #define ADE7913_SLOT2_MSK NO_OS_BIT(2)
102 #define ADE7913_SLOT3_MSK NO_OS_BIT(3)
103 #define ADE7913_SLOT4_MSK NO_OS_BIT(4)
104 #define ADE7913_SLOT5_MSK NO_OS_BIT(5)
105 #define ADE7913_SLOT6_MSK NO_OS_BIT(6)
106 #define ADE7913_SLOT7_MSK NO_OS_BIT(7)
109 #define ADE7913_VERSION_MSK NO_OS_GENMASK(2, 0)
110 #define ADE7913_ADC_NA_MSK NO_OS_BIT(6)
113 #define ADE7913_LOCK_KEY 0XCA
114 #define ADE7913_UNLOCK_KEY 0X9C
117 #define ADE7913_3_CHANNEL_ADE7913 3U
118 #define ADE7913_2_CHANNEL_ADE7912 2U
121 #define ADE7913_VREF_V (788)
122 #define ADE7913_VREF_I (49)
220 static int ade7913_update_bits(
struct ade7913_dev *dev, uint8_t reg_addr,
221 uint8_t mask, uint8_t reg_data);
282 uint8_t *ver_product);
284 #endif // __ADE7913_H__
#define ADE7913_REG_ADC_CRC
Definition: ade7913.h:62
int ade7913_ic_prot_status(struct ade7913_dev *dev, uint8_t *status)
IC config regs protection status.
Definition: ade7913.c:828
int16_t no_os_sign_extend16(uint16_t value, int index)
uint32_t timeout
Definition: ad413x.c:49
int ade7913_init(struct ade7913_dev **device, struct ade7913_init_param init_param)
Initialize the device.
Definition: ade7913.c:342
#define ADE7913_BW_MSK
Definition: ade7913.h:84
#define ADE7913_REG_SYNC_SNAP
Definition: ade7913.h:68
int32_t * v1_wav
Definition: ade7913.h:178
int32_t no_os_i2c_write(struct no_os_i2c_desc *desc, uint8_t *data, uint8_t bytes_number, uint8_t stop_bit)
I2C Write data to slave device.
Definition: no_os_i2c.c:159
#define ADE7816_CONFIG_REG
Definition: ade7816.h:157
int ade7913_read_waveforms(struct ade7913_dev *dev, uint8_t reg_addr, uint8_t *reg_data)
Read multiple devices.
Definition: ade7913.c:143
uint16_t * adc_crc
Definition: ade7913.h:188
Header file of ADE7816 Driver.
#define ADE7816_FIRST_BYTE_MASK
Definition: ade7816.h:177
#define NO_OS_GENMASK(h, l)
Definition: no_os_util.h:82
int32_t no_os_spi_write_and_read(struct no_os_spi_desc *desc, uint8_t *data, uint16_t bytes_number)
Write and read data to/from SPI.
Definition: no_os_spi.c:159
int ade7913_adc_na_status(struct ade7913_dev *dev, uint8_t *status)
ADC not accesed during one period status.
Definition: ade7913.c:872
int ade9153a_read(struct ade9153a_dev *dev, uint16_t reg_addr, uint32_t *reg_data)
Read device register.
Definition: ade9153a.c:365
int ade7913_cnt_snapshot_val(struct ade7913_dev *dev, uint16_t *val)
Cnt snapshot.
Definition: ade7913.c:899
#define ADE7913_IC_PROT_MSK
Definition: ade7913.h:89
Header file of SPI Interface.
struct no_os_spi_desc * spi_desc2
Definition: ade7913.h:172
Header file of IRQ interface.
int ade7913_pwrdwn(struct ade7913_dev *dev, uint8_t pwrdwn)
Power down enable.
Definition: ade7913.c:700
#define ADE7816_LSB_REG_MASK
Definition: ade7816.h:171
struct no_os_spi_desc * spi_desc
Definition: ade7816.h:328
uint8_t burst_mode
Definition: ade7913.h:151
#define ADE7913_REG_STATUS0
Definition: ade7913.h:66
struct no_os_i2c_desc * i2c_desc
Definition: ade7816.h:329
int ade7913_cnt_snapshot_val(struct ade7913_dev *dev, uint16_t *val)
Cnt snapshot.
Definition: ade7913.c:899
int ade7913_init(struct ade7913_dev **device, struct ade7913_init_param init_param)
Initialize the device.
Definition: ade7913.c:342
struct no_os_spi_init_param * spi_init1
Definition: ade7913.h:155
#define ADE7816_ZSPE_MASK
Definition: ade7816.h:183
Header file of Delay functions.
int ade7913_wr_lock(struct ade7913_dev *dev)
Lock device.
Definition: ade7913.c:629
#define ADE7913_REG_STATUS1
Definition: ade7913.h:72
int ade7913_emi_ctrl(struct ade7913_dev *dev, uint8_t emi_ctrl)
Set EMI CTRL register.
Definition: ade7913.c:855
Definition: ade7816.h:327
#define ADE7913_2_CHANNEL_ADE7912
Definition: ade7913.h:118
int32_t * v2_wav_m
Definition: ade7913.h:186
#define ENABLE
Definition: ad77681.h:339
Definition: ad9361_util.h:69
#define ADE7913_REG_COUNTER1
Definition: ade7913.h:70
int ade7913_read(struct ade7913_dev *dev, uint8_t reg_addr, uint8_t *reg_data)
Read device register.
Definition: ade7913.c:60
#define ADE7816_MSB_REG_MASK
Definition: ade7816.h:172
#define ADE7816_THIRD_BYTE_MASK
Definition: ade7816.h:175
#define ADE7913_REG_COUNTER0
Definition: ade7913.h:69
int ade7913_temp_en(struct ade7913_dev *dev, uint8_t temp_en)
Temperature enable.
Definition: ade7913.c:716
#define ADE7816_CONFIG2_REG
Definition: ade7816.h:168
void * no_os_calloc(size_t nitems, size_t size)
Allocate memory and return a pointer to it, set memory to 0.
Definition: chibios_alloc.c:54
ADE7913 Device structure.
Definition: ade7913.h:164
struct no_os_spi_init_param * spi_init0
Definition: ade7913.h:153
int ade7913_sw_reset(struct ade7913_dev *dev)
Reset the device using SW reset.
Definition: ade7913.c:593
#define ADE7913_REG_CONFIG
Definition: ade7913.h:65
#define ADE7816_FVAROS_REG
Definition: ade7816.h:87
uint8_t * status0
Definition: ade7913.h:190
#define ADE7816_VGAIN_REG
Definition: ade7816.h:47
int ade7913_remove(struct ade7913_dev *dev)
Remove the device and release resources.
Definition: ade7913.c:562
#define ADE7816_MMODE_REG
Definition: ade7816.h:159
void no_os_mdelay(uint32_t msecs)
Wait until msecs milliseconds passed.
Definition: aducm3029_delay.c:126
uint32_t no_os_field_prep(uint32_t mask, uint32_t val)
#define ADE7913_REG_V2WV
Definition: ade7913.h:61
int32_t * i_wav_m
Definition: ade7913.h:182
int ade7913_remove(struct ade7913_dev *dev)
Remove the device and release resources.
Definition: ade7913.c:562
@ ADE7913_ADC_FREQ_8KHZ
Definition: ade7913.h:134
#define ADE7816_SECOND_BYTE_MASK
Definition: ade7816.h:176
#define ADE7913_SYNC_MSK
Definition: ade7913.h:95
int ade7913_read_waveforms(struct ade7913_dev *dev, uint8_t reg_addr, uint8_t *reg_data)
Read multiple devices.
Definition: ade7913.c:143
int ade7913_crc_status(struct ade7913_dev *dev, uint8_t *status)
CRC of config registers status.
Definition: ade7913.c:801
int ade7913_wr_unlock(struct ade7913_dev *dev)
Unlock device.
Definition: ade7913.c:642
int32_t * v1_wav_m
Definition: ade7913.h:184
int ade7816_i2c_reg_read(struct ade7816_desc *desc, uint16_t reg, uint32_t *val)
ADE7816 I2C Read Register function.
Definition: ade7816_i2c.c:48
Header file of CRC-16 computation.
uint8_t burst_mode
Definition: ade7913.h:196
struct no_os_irq_ctrl_desc * irq_ctrl
Definition: ade7913.h:198
ADE7913 Device initialization parameters.
Definition: ade7913.h:147
int ade7913_write(struct ade7913_dev *dev, uint8_t reg_addr, uint8_t reg_data)
Write device register.
Definition: ade7913.c:230
uint32_t no_os_get_unaligned_be24(uint8_t *buf)
int ade7913_get_version_product(struct ade7913_dev *dev, uint8_t *ver_product)
Get version product value.
Definition: ade7913.c:924
int ade7913_ic_prot_status(struct ade7913_dev *dev, uint8_t *status)
IC config regs protection status.
Definition: ade7913.c:828
struct no_os_spi_desc * spi_desc0
Definition: ade7913.h:168
Structure holding SPI descriptor.
Definition: no_os_spi.h:192
int32_t * v2_wav
Definition: ade7913.h:180
uint8_t no_devs
Definition: ade7913.h:149
Header file of ADE7913 Driver.
#define ADE7913_REG_CNT_SNAPSHOT
Definition: ade7913.h:64
int ade7913_sync_en(struct ade7913_dev *dev)
Sync enable.
Definition: ade7913.c:731
int ade7913_set_clkout_en(struct ade7913_dev *dev, uint8_t clkout_en)
Set clkout enable.
Definition: ade7913.c:684
int ade7913_sw_reset(struct ade7913_dev *dev)
Reset the device using SW reset.
Definition: ade7913.c:593
int ade7913_write(struct ade7913_dev *dev, uint8_t reg_addr, uint8_t reg_data)
Write device register.
Definition: ade7913.c:230
int ade7913_adc_freq(struct ade7913_dev *dev, enum ade7913_adc_freq_e frequency)
Set ADC frequency.
Definition: ade7913.c:746
#define ADE7913_REG_EMI_CTRL
Definition: ade7913.h:71
int ade7913_get_version_product(struct ade7913_dev *dev, uint8_t *ver_product)
Get version product value.
Definition: ade7913.c:924
struct no_os_spi_init_param * spi_init2
Definition: ade7913.h:157
int32_t no_os_i2c_read(struct no_os_i2c_desc *desc, uint8_t *data, uint8_t bytes_number, uint8_t stop_bit)
I2C Read data from slave device.
Definition: no_os_i2c.c:190
#define ADE7913_LOCK_KEY
Definition: ade7913.h:113
@ ADE7913_ADC_FREQ_4KHZ
Definition: ade7913.h:136
int32_t * i_wav
Definition: ade7913.h:176
Header file of I2C Interface.
int ade7913_lfp_bw(struct ade7913_dev *dev, uint8_t bw)
Digital lpf bandwith select.
Definition: ade7913.c:786
#define ADE7913_PWRDWN_EN_MSK
Definition: ade7913.h:80
#define ADE7816_CHSTATUS_REG
Definition: ade7816.h:143
#define ADE7913_REG_V1WV
Definition: ade7913.h:60
uint32_t no_os_field_get(uint32_t mask, uint32_t word)
#define ADE7913_UNLOCK_KEY
Definition: ade7913.h:114
ade7913_adc_freq_e
ADE7913 ADC output frequency.
Definition: ade7913.h:132
int ade7913_get_sync_cnt_val(struct ade7913_dev *dev, uint16_t *counter)
Get synchronization counter value.
Definition: ade7913.c:656
#define ADE7913_ADC_FREQ_MSK
Definition: ade7913.h:82
int ade7913_wr_lock(struct ade7913_dev *dev)
Lock device.
Definition: ade7913.c:629
#define ADE7913_VERSION_MSK
Definition: ade7913.h:109
void no_os_free(void *ptr)
Deallocate memory previously allocated by a call to no_os_calloc or no_os_malloc.
Definition: chibios_alloc.c:69
int ade7816_i2c_reg_write(struct ade7816_desc *desc, uint16_t reg, uint32_t val)
ADE7816 I2C Write Register function.
Definition: ade7816_i2c.c:98
uint16_t no_os_get_unaligned_le16(uint8_t *buf)
int ade7816_spi_reg_write(struct ade7816_desc *desc, uint16_t reg, uint32_t val)
ADE7816 SPI Write Register function.
Definition: ade7816_spi.c:109
int ade7913_sync_en(struct ade7913_dev *dev)
Sync enable.
Definition: ade7913.c:731
int ade7913_set_clkout_en(struct ade7913_dev *dev, uint8_t clkout_en)
Set clkout enable.
Definition: ade7913.c:684
#define ADE7816_FOURTH_BYTE_MASK
Definition: ade7816.h:174
int ade7913_write_broadcast(struct ade7913_dev *dev, uint8_t reg_addr, uint8_t *reg_data)
Write broadcast.
Definition: ade7913.c:259
int ade7913_read(struct ade7913_dev *dev, uint8_t reg_addr, uint8_t *reg_data)
Read device register.
Definition: ade7913.c:60
uint32_t no_os_get_unaligned_be32(uint8_t *buf)
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
int ade7913_temp_en(struct ade7913_dev *dev, uint8_t temp_en)
Temperature enable.
Definition: ade7913.c:716
uint8_t no_devs
Definition: ade7913.h:194
@ ADE7913_ADC_FREQ_2KHZ
Definition: ade7913.h:138
#define ADE7913_CNT_VAL_MSK
Definition: ade7913.h:76
int ade7913_pwrdwn(struct ade7913_dev *dev, uint8_t pwrdwn)
Power down enable.
Definition: ade7913.c:700
struct no_os_spi_desc * spi_desc
Definition: ade7913.h:166
#define ADE7913_TEMP_EN_MSK
Definition: ade7913.h:81
int32_t no_os_spi_remove(struct no_os_spi_desc *desc)
Free the resources allocated by no_os_spi_init().
Definition: no_os_spi.c:116
int ade7913_get_sync_cnt_val(struct ade7913_dev *dev, uint16_t *counter)
Get synchronization counter value.
Definition: ade7913.c:656
Header file of GPIO Interface.
#define ADE7913_REG_IWV
Definition: ade7913.h:59
int32_t no_os_spi_init(struct no_os_spi_desc **desc, const struct no_os_spi_init_param *param)
Initialize the SPI communication peripheral.
Definition: no_os_spi.c:52
uint16_t no_os_get_unaligned_be16(uint8_t *buf)
#define ADE7913_REG_LOCK
Definition: ade7913.h:67
#define ADE7913_3_CHANNEL_ADE7913
Definition: ade7913.h:117
#define ADE7913_SPI_READ
Definition: ade7913.h:52
struct no_os_spi_desc * spi_desc1
Definition: ade7913.h:170
Header file of utility functions.
int ade7913_write_broadcast(struct ade7913_dev *dev, uint8_t reg_addr, uint8_t *reg_data)
Write broadcast.
Definition: ade7913.c:259
uint32_t no_os_find_first_set_bit(uint32_t word)
int32_t no_os_sign_extend32(uint32_t value, int index)
uint16_t * cnt_snapshot
Definition: ade7913.h:192
int ade7913_emi_ctrl(struct ade7913_dev *dev, uint8_t emi_ctrl)
Set EMI CTRL register.
Definition: ade7913.c:855
#define ADE7913_ADC_NA_MSK
Definition: ade7913.h:110
int ade7913_crc_status(struct ade7913_dev *dev, uint8_t *status)
CRC of config registers status.
Definition: ade7913.c:801
#define ADE7816_VARNOLOAD_REG
Definition: ade7816.h:94
Definition: no_os_irq.h:123
int ade7913_wr_unlock(struct ade7913_dev *dev)
Unlock device.
Definition: ade7913.c:642
#define ADE7913_CRC_STAT_MSK
Definition: ade7913.h:88
int ade7913_adc_freq(struct ade7913_dev *dev, enum ade7913_adc_freq_e frequency)
Set ADC frequency.
Definition: ade7913.c:746
int no_os_test_bit(int pos, const volatile void *addr)
Definition: no_os_util.h:132
#define ADE7913_CLKOUT_EN_MSK
Definition: ade7913.h:79
Header file of CRC-8 computation.
Error macro definition for ARM Compiler.
int ade7913_adc_na_status(struct ade7913_dev *dev, uint8_t *status)
ADC not accesed during one period status.
Definition: ade7913.c:872
int ade7816_spi_reg_read(struct ade7816_desc *desc, uint16_t reg, uint32_t *val)
ADE7816 SPI Read Register function.
Definition: ade7816_spi.c:48
int ade7913_lfp_bw(struct ade7913_dev *dev, uint8_t bw)
Digital lpf bandwith select.
Definition: ade7913.c:786
uint8_t * ver_product
Definition: ade7913.h:174
#define ADE7913_SWRST_MSK
Definition: ade7913.h:83
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:140
@ ADE7913_ADC_FREQ_1KHZ
Definition: ade7913.h:140