no-OS
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ade7953.h
Go to the documentation of this file.
1/***************************************************************************/
33#ifndef __ADE7953_H__
34#define __ADE7953_H__
35
36#include <stdbool.h>
37#include <stdint.h>
38#include <string.h>
39#include "no_os_util.h"
40#include "no_os_spi.h"
41#include "no_os_gpio.h"
42#include "no_os_irq.h"
43#include "no_os_delay.h"
44#include "no_os_units.h"
45#include "no_os_alloc.h"
46#include "no_os_crc16.h"
47#include "no_os_print_log.h"
48#include <stdlib.h>
49#include <errno.h>
50#include <math.h>
51
52/* SPI commands */
53#define ADE7953_SPI_READ NO_OS_BIT(7)
54
55/* Version product */
56#define ADE7953_VERSION 0x40
57#define ADE7953_REG_VERSION_PRODUCT 0x004
58
59/* Miscellaneous Definitions */
60#define IS_8BITS_REG(x) ((x >= ADE7953_REG_SAGCYC && x <= ADE7953_REG_LAST_RWDATA) \
61 || (x == ADE7953_REG_VERSION) || (x == ADE7953_REG_EX_REF))
62#define IS_16BITS_REG(x) ((x >= ADE7953_REG_ZXTOUT && x <= ADE7953_REG_LAST_RWDATA_16))
63
64/* Key needed to unlock register 0x120 */
65#define ADE7953_UNLOCK_KEY 0xAD
66/* Value that needs to be write to the 0x120 register */
67#define ADE7953_OPT_SETT 0x30
68
69/* Reset Delay */
70#define ADE7953_RESET_DEL 100
71
72/* ENABLE and DISABLE */
73#define ENABLE 1u
74#define DISABLE 0u
75
76/* ADE7953 Register Map */
77/* 8 BIT REGISTERS */
78#define ADE7953_REG_SAGCYC 0x000
79#define ADE7953_REG_DISNOLOAD 0x001
80#define ADE7953_REG_LCYCMODE 0x004
81#define ADE7953_REG_PGA_V 0x007
82#define ADE7953_REG_PGA_IA 0x008
83#define ADE7953_REG_PGA_IB 0x009
84#define ADE7953_REG_WRITE_PROTECT 0x040
85#define ADE7953_REG_LAST_OP 0x0FD
86#define ADE7953_REG_UNLOCK_120 0x0FE
87#define ADE7953_REG_LAST_RWDATA 0x0FF
88#define ADE7953_REG_VERSION 0x702
89#define ADE7953_REG_EX_REF 0x800
90/* 16 BIT REGISTERS */
91#define ADE7953_REG_ZXTOUT 0x100
92#define ADE7953_REG_LINECYC 0x101
93#define ADE7953_REG_CONFIG 0x102
94#define ADE7953_REG_CF1DEN 0x103
95#define ADE7953_REG_CF2DEN 0x104
96#define ADE7953_REG_CFMODE 0x107
97#define ADE7953_REG_PHCALA 0x108
98#define ADE7953_REG_PHCALB 0x109
99#define ADE7953_REG_PFA 0x10A
100#define ADE7953_REG_PFB 0x10B
101#define ADE7953_REG_ANGLE_A 0x10C
102#define ADE7953_REG_ANGLE_B 0x10D
103#define ADE7953_REG_PERIOD 0x10E
104#define ADE7953_REG_ALT_OUTPUT 0x110
105#define ADE7953_REG_LAST_ADD 0x1FE
106#define ADE7953_REG_LAST_RWDATA_16 0x1FF
107#define ADE7953_REG_RESERVED 0x120
108/* 24 BIT REGISTERS */
109#define ADE7953_REG_SAGLVL 0x200
110#define ADE7953_REG_ACCMODE 0x201
111#define ADE7953_REG_AP_NOLOAD 0x203
112#define ADE7953_REG_VAR_NOLOAD 0x204
113#define ADE7953_REG_VA_NOLOAD 0x205
114#define ADE7953_REG_AVA 0x210
115#define ADE7953_REG_BVA 0x211
116#define ADE7953_REG_AWATT 0x212
117#define ADE7953_REG_BWATT 0x213
118#define ADE7953_REG_AVAR 0x214
119#define ADE7953_REG_BVAR 0x215
120#define ADE7953_REG_IA 0x216
121#define ADE7953_REG_IB 0x217
122#define ADE7953_REG_V 0x218
123#define ADE7953_REG_IRMSA 0x21A
124#define ADE7953_REG_IRMSB 0x21B
125#define ADE7953_REG_VRMS 0x21C
126#define ADE7953_REG_AENERGYA 0x21E
127#define ADE7953_REG_AENERGYB 0x21F
128#define ADE7953_REG_RENERGYA 0x220
129#define ADE7953_REG_RENERGYB 0x221
130#define ADE7953_REG_APENERGYA 0x222
131#define ADE7953_REG_APENERGYB 0x223
132#define ADE7953_REG_OVLVL 0x224
133#define ADE7953_REG_OILVL 0x225
134#define ADE7953_REG_VPEAK 0x226
135#define ADE7953_REG_RSTVPEAK 0x227
136#define ADE7953_REG_IAPEAK 0x228
137#define ADE7953_REG_RSTIAPEAK 0x229
138#define ADE7953_REG_IBPEAK 0x22A
139#define ADE7953_REG_RSTIBPEAK 0x22B
140#define ADE7953_REG_IRQENA 0x22C
141#define ADE7953_REG_IRQSTATA 0x22D
142#define ADE7953_REG_RSTIRQSTATA 0x22E
143#define ADE7953_REG_IRQENB 0x22F
144#define ADE7953_REG_IRQSTATB 0x230
145#define ADE7953_REG_RSTIRQSTATB 0x231
146#define ADE7953_REG_AIGAIN 0x280
147#define ADE7953_REG_AVGAIN 0x281
148#define ADE7953_REG_AWGAIN 0x282
149#define ADE7953_REG_AVARGAIN 0x283
150#define ADE7953_REG_AVAGAIN 0x284
151#define ADE7953_REG_AIRMSOS 0x286
152#define ADE7953_REG_VRMSOS 0x288
153#define ADE7953_REG_AWATTOS 0x289
154#define ADE7953_REG_AVAROS 0x28A
155#define ADE7953_REG_AVAOS 0x28B
156#define ADE7953_REG_BIGAIN 0x28C
157#define ADE7953_REG_BVGAIN 0x28D
158#define ADE7953_REG_BWGAIN 0x28E
159#define ADE7953_REG_BVARGAIN 0x28F
160#define ADE7953_REG_BVAGAIN 0x290
161#define ADE7953_REG_BIRMSOS 0x292
162#define ADE7953_REG_BWATTOS 0x295
163#define ADE7953_REG_BVAROS 0x296
164#define ADE7953_REG_BVAOS 0x297
165#define ADE7953_REG_LAST_RWDATA_24 0x2FF
166/* 32 BIT REGISTERS */
167/* Same registers as 24 bit registers +0x100 address offset*/
168#define ADE7953_REG_CRC 0x37F
169
170/* ADE7953_REG_DISNOLOAD Bit Definition */
171#define ADE7953_DIS_VANLOAD_MSK NO_OS_BIT(2)
172#define ADE7953_DIS_VARNLOAD_MSK NO_OS_BIT(1)
173#define ADE7953_DIS_APNLOAD_MSK NO_OS_BIT(0)
174
175/* ADE7953_REG_LCYCMODE Bit Definition */
176#define ADE7953_RSTREAD_MSK NO_OS_BIT(6)
177#define ADE7953_BLVA_MSK NO_OS_BIT(5)
178#define ADE7953_ALVA_MSK NO_OS_BIT(4)
179#define ADE7953_BLVAR_MSK NO_OS_BIT(3)
180#define ADE7953_ALVAR_MSK NO_OS_BIT(2)
181#define ADE7953_BLWATT_MSK NO_OS_BIT(1)
182#define ADE7953_ALWATT_MSK NO_OS_BIT(0)
183
184/* ADE7953_REG_PGA_V Bit Definition */
185#define ADE7953_PGA_V_MSK NO_OS_GENMASK(2, 0)
186
187/* ADE7953_REG_PGA_IA / ADE7953_REG_PGA_IB Bit Definition */
188#define ADE7953_PGA_IA_MSK NO_OS_GENMASK(2, 0)
189
190/* ADE7953_REG_CONFIG Bit Definition */
191#define ADE7953_COMM_LOCK_MSK NO_OS_BIT(15)
192#define ADE7953_ZX_EDGE_MSK NO_OS_GENMASK(13, 12)
193#define ADE7953_ZX_I_MSK NO_OS_BIT(11)
194#define ADE7953_CRC_ENABLE_MSK NO_OS_BIT(8)
195#define ADE7953_SWRST_MSK NO_OS_BIT(7)
196#define ADE7953_ZXLPF_MSK NO_OS_BIT(6)
197#define ADE7953_REV_PULSE_MSK NO_OS_BIT(5)
198#define ADE7953_REVP_CF_MSK NO_OS_BIT(4)
199#define ADE7953_PFMODE_MSK NO_OS_BIT(3)
200#define ADE7953_HPFEN_MSK NO_OS_BIT(2)
201#define ADE7953_INTENB_MSK NO_OS_BIT(1)
202#define ADE7953_INTENA_MSK NO_OS_BIT(0)
203
204/* ADE7953_REG_CFMODE Bit Definition */
205#define ADE7953_CF2DIS_MSK NO_OS_BIT(9)
206#define ADE7953_CF1DIS_MSK NO_OS_BIT(8)
207#define ADE7953_CF2SEL_MSK NO_OS_GENMASK(7, 4)
208#define ADE7953_CF1SEL_MSK NO_OS_GENMASK(3, 0)
209
210/* ADE7953_REG_ALT_OUTPUT Bit Definition */
211#define ADE7953_REVP_ALT_MSK NO_OS_GENMASK(11, 8)
212#define ADE7953_ZXI_ALT_MSK NO_OS_GENMASK(7, 4)
213#define ADE7953_ZX_ALT_MSK NO_OS_GENMASK(3, 0)
214
215/* ADE7953_REG_ACCMODE Bit Definition */
216#define ADE7953_VARNLOAD_B_MSK NO_OS_BIT(21)
217#define ADE7953_VANLOAD_B_MSK NO_OS_BIT(20)
218#define ADE7953_ACTNLOAD_B_MSK NO_OS_BIT(19)
219#define ADE7953_VARNLOAD_A_MSK NO_OS_BIT(18)
220#define ADE7953_VANLOAD_A_MSK NO_OS_BIT(17)
221#define ADE7953_ACTNLOAD_A_MSK NO_OS_BIT(16)
222#define ADE7953_VARSIGN_B_MSK NO_OS_BIT(13)
223#define ADE7953_VARSIGN_A_MSK NO_OS_BIT(12)
224#define ADE7953_APSIGN_B_MSK NO_OS_BIT(11)
225#define ADE7953_APSIGN_A_MSK NO_OS_BIT(10)
226#define ADE7953_BVAACC_MSK NO_OS_BIT(9)
227#define ADE7953_AVAACC_MSK NO_OS_BIT(8)
228#define ADE7953_BVARACC_MSK NO_OS_GENMASK(7, 6)
229#define ADE7953_AVARACC_MSK NO_OS_GENMASK(5, 4)
230#define ADE7953_BWATTACC_MSK NO_OS_GENMASK(3, 2)
231#define ADE7953_AWATTACC_MSK NO_OS_GENMASK(1, 0)
232
233/* ADE7953_REG_IRQENA / ADE7953_REG_IRQSTATA Bit Definition */
234#define ADE7953_CRC_MSK NO_OS_BIT(21)
235#define ADE7953_RESET_MSK NO_OS_BIT(20)
236#define ADE7953_SAG_MSK NO_OS_BIT(19)
237#define ADE7953_CYCEND_MSK NO_OS_BIT(18)
238#define ADE7953_WSMP_MSK NO_OS_BIT(17)
239#define ADE7953_OV_MSK NO_OS_BIT(16)
240#define ADE7953_ZXV_MSK NO_OS_BIT(15)
241#define ADE7953_ZXTO_MSK NO_OS_BIT(14)
242#define ADE7953_OIA_MSK NO_OS_BIT(13)
243#define ADE7953_ZXIA_MSK NO_OS_BIT(12)
244#define ADE7953_ZXTO_IA_MSK NO_OS_BIT(11)
245#define ADE7953_VARSIGN_A_MSK NO_OS_BIT(10)
246#define ADE7953_APSIGN_A_MSK NO_OS_BIT(9)
247#define ADE7953_VA_NOLOADA_MSK NO_OS_BIT(8)
248#define ADE7953_VAR_NOLOADA_MSK NO_OS_BIT(7)
249#define ADE7953_AP_NOLOADA_MSK NO_OS_BIT(6)
250#define ADE7953_VAEOFA_MSK NO_OS_BIT(5)
251#define ADE7953_VAREOFA_MSK NO_OS_BIT(4)
252#define ADE7953_AEOFA_MSK NO_OS_BIT(3)
253#define ADE7953_VAEHFA_MSK NO_OS_BIT(2)
254#define ADE7953_VAREHFA_MSK NO_OS_BIT(1)
255#define ADE7953_AEHFA_MSK NO_OS_BIT(0)
256
257/* ADE7953_REG_IRQENB / ADE7953_REG_IRQSTATB Bit Definition */
258#define ADE7953_OIB_MSK NO_OS_BIT(13)
259#define ADE7953_ZXIB_MSK NO_OS_BIT(12)
260#define ADE7953_ZXTO_IB_MSK NO_OS_BIT(11)
261#define ADE7953_VARSIGN_B_MSK NO_OS_BIT(10)
262#define ADE7953_APSIGN_B_MSK NO_OS_BIT(9)
263#define ADE7953_VA_NOLOADB_MSK NO_OS_BIT(8)
264#define ADE7953_VAR_NOLOADB_MSK NO_OS_BIT(7)
265#define ADE7953_AP_NOLOADB_MSK NO_OS_BIT(6)
266#define ADE7953_VAEOFB_MSK NO_OS_BIT(5)
267#define ADE7953_VAREOFB_MSK NO_OS_BIT(4)
268#define ADE7953_AEOFB_MSK NO_OS_BIT(3)
269#define ADE7953_VAEHFB_MSK NO_OS_BIT(2)
270#define ADE7953_VAREHFB_MSK NO_OS_BIT(1)
271#define ADE7953_AEHFB_MSK NO_OS_BIT(0)
272
273/* ADE7953_REG_WRITE_PROTECT Bit Definition */
274#define ADE7953_24_32_BITS_PROTECT NO_OS_BIT(2)
275#define ADE7953_16_BITS_PROTECT NO_OS_BIT(1)
276#define ADE7953_8_BITS_PROTECT NO_OS_BIT(0)
277
283 /* Current channel selection */
284 /* current ch A */
286 /* current ch B */
288};
289
295 /* Current channel selection */
296 /* CF 1 pin */
298 /* CF 2 pin */
300};
301
307 /* Select the registers that have write protect enabled */
308 /* 8 bits regs */
310 /* 16 bits regs */
312 /* 24/32 bits regs */
314};
315
321 /* Zero-crossing interrupt edge selection */
322 /* Interrupt is issued on both positive-going and
323 negative-going zero crossing */
325 /* Interrupt is issued on negative-going zero crossing */
327 /* Interrupt is issued on positive-going zero crossing */
329 /* Interrupt is issued on both positive-going and
330 negative-going zero crossing */
332};
333
339 /* CF is proportional to active power (Current Channel A). */
341 /* CF is proportional to reactive power (Current Channel A). */
343 /* CF is proportional to apparent power (Current Channel A). */
345 /* CF is proportional to IRMS (Current Channel A). */
347 /* CF is proportional to active power (Current Channel B). */
349 /* CF is proportional to reactive power (Current Channel B). */
351 /* CF is proportional to apparent power (Current Channel B). */
353 /* CF is proportional to IRMS (Current Channel B). */
355 /* CF is proportional to
356 IRMS (Current Channel A) + IRMS (Current Channel B). */
358 /* CF is proportional to
359 active power (Current Channel A) + active power (Current Channel B). */
361};
362
368 /* ZX detection is output on Pin 1 (default) */
370 /* Sag detection is output on Pin 1 */
372 /* Active power no-load detection
373 (Current Channel A) is output on Pin 1 */
375 /* Active power no-load detection
376 (Current Channel B) is output on Pin 1 */
378 /* Reactive power no-load detection
379 (Current Channel A) is output on Pin 1 */
381 /* Reactive power no-load detection
382 (Current Channel B) is output on Pin 1 */
384 /* Unlatched waveform sampling signal is output on Pin 1 */
386 /* IRQsignal is output on Pin 1 */
388 /* ZX_I detection is output on Pin 1 */
390 /* REVP detection is output on Pin 1 */
392};
393
399 /* ZXI detection is output on Pin 21 (default) */
401 /* Sag detection is output on Pin 21 */
403 /* Active power no-load detection
404 (Current Channel A) is output on Pin 21 */
406 /* Active power no-load detection
407 (Current Channel B) is output on Pin 21 */
409 /* Reactive power no-load detection
410 (Current Channel A) is output on Pin 21 */
412 /* Reactive power no-load detection
413 (Current Channel B) is output on Pin 21 */
415 /* Unlatched waveform sampling signal is output on Pin 21 */
417 /* IRQsignal is output on Pin 21 */
419 /* ZX detection is output on Pin 21 */
421 /* REVP detection is output on Pin 21 */
423};
424
430 /* REVP detection is output on Pin 20 (default) */
432 /* Sag detection is output on Pin 20 */
434 /* Active power no-load detection
435 (Current Channel A) is output on Pin 20 */
437 /* Active power no-load detection
438 (Current Channel B) is output on Pin 20 */
440 /* Reactive power no-load detection
441 (Current Channel A) is output on Pin 20 */
443 /* Reactive power no-load detection
444 (Current Channel B) is output on Pin 20 */
446 /* Unlatched waveform sampling signal is output on Pin 20 */
448 /* IRQsignal is output on Pin 20 */
450 /* ZX detection is output on Pin 20 */
452 /* ZX_I detection is output on Pin 20 */
454};
455
461 /* Normal mode. */
463 /* Positive-olny accumulation mode */
465 /* Absolute accumulation mode */
467};
468
474 /* Normal mode. */
476 /* Antitamper accumulation mode */
478 /* Absolute accumulation mode */
480};
481
487 /* Gain = 1 */
489 /* Gain = 2 */
491 /* Gain = 4 */
493 /* Gain = 8 */
495 /* Gain = 16 */
497 /* Gain = 22 */
498 /* applicable only for Current Channel A */
500};
501
515
532
545
558
571
582
583/* Initialize the device. */
584int ade7953_init(struct ade7953_dev **device,
586
587/* Read device register. */
588int ade7953_read(struct ade7953_dev *dev, uint16_t reg_addr,
589 int32_t *reg_data);
590
591/* Write device register. */
592int ade7953_write(struct ade7953_dev *dev, uint16_t reg_addr,
593 uint32_t reg_data);
594
595/* Update specific register bits. */
596static int ade7953_update_bits(struct ade7953_dev *dev, uint16_t reg_addr,
597 uint32_t mask, uint32_t reg_data);
598
599/* Remove the device and release resources. */
600int ade7953_remove(struct ade7953_dev *dev);
601
602/* Reset the device using SW reset. */
603int ade7953_sw_reset(struct ade7953_dev *dev);
604
605/* Reset the device using HW reset. */
606int ade7953_hw_reset(struct ade7953_dev *dev);
607
608/* Lock write to registers. */
609int ade7953_wr_lock_8bit(struct ade7953_dev *dev,
610 enum ade7953_write_protect_e regs_select);
611
612/* Version product */
613int ade7953_version_product(struct ade7953_dev *dev, uint32_t *data_read);
614
615/* reseat IApeak val */
616int ade7953_reset_iapk_val(struct ade7953_dev *dev, uint32_t *val);
617
618/* reseat IBpeak val */
619int ade7953_reset_ibpk_val(struct ade7953_dev *dev, uint32_t *val);
620
621/* reseat Vpeak val */
622int ade7953_reset_vpk_val(struct ade7953_dev *dev, uint32_t *val);
623
624/* Get interrupt indicator from STATA register. */
625int ade7953_get_int_stata(struct ade7953_dev *dev, uint32_t msk,
626 uint8_t *status);
627
628/* Get interrupt indicator from STATB register. */
629int ade7953_get_int_statb(struct ade7953_dev *dev, uint32_t msk,
630 uint8_t *status);
631
632/* Clear irq STATA flags. */
633int ade7953_clear_irq_stata(struct ade7953_dev *dev);
634
635/* Clear irq STATB flags. */
636int ade7953_clear_irq_statb(struct ade7953_dev *dev);
637
638/* Enable interrupt voltage ch and current ch A. */
639int ade7953_enable_int_a(struct ade7953_dev *dev, uint32_t msk, uint8_t en);
640
641/* Enable/disable interrupt voltage ch and current ch B. */
642int ade7953_enable_int_b(struct ade7953_dev *dev, uint32_t msk, uint8_t en);
643
644/* Zero-crossing interrupt edge selection */
646 enum ade7953_zx_edge_e sel);
647
648/* Configure output signal on CF1/CF2 pin */
649int ade7953_cf_output_set(struct ade7953_dev *dev,
650 enum ade7953_cfsel_e sel, enum ade7953_cf_pin_e cf_pin);
651
652/* Configure of ZX pin (Pin1) */
653int ade7953_zx_config_pin(struct ade7953_dev *dev,
654 enum ade7953_zx_alt_e sel);
655
656/* Configure of ZXI pin (Pin21) */
657int ade7953_zxi_config_pin(struct ade7953_dev *dev,
658 enum ade7953_zxi_alt_e sel);
659
660/* Configure of REVP pin (Pin20) */
662 enum ade7953_revp_alt_e sel);
663
664/* ACC mode selection for active energy */
666 enum ade7953_awattacc_e mode, enum ade7953_i_ch_e channel);
667
668/* ACC mode selection for reactive energy */
670 enum ade7953_avaracc_e mode, enum ade7953_i_ch_e channel);
671
672/* Read energy values */
673int ade7953_energy_vals(struct ade7953_dev *dev,
674 struct ade7953_energy_values *data, enum ade7953_i_ch_e channel);
675
676/* Read power values */
677int ade7953_power_vals(struct ade7953_dev *dev,
678 struct ade7953_power_values *data, enum ade7953_i_ch_e channel);
679
680/* Read rms values */
681int ade7953_rms_vals(struct ade7953_dev *dev,
682 struct ade7953_rms_values *data, enum ade7953_i_ch_e channel);
683
684/* Read power quaility values */
686 struct ade7953_pq_values *data);
687
688#endif /* __ADE7953_H__ */
struct ad7616_init_param init_param
Definition ad7616_sdz.c:107
int ade7953_clear_irq_statb(struct ade7953_dev *dev)
Clear irq statb flags.
Definition ade7953.c:544
int ade7953_get_int_statb(struct ade7953_dev *dev, uint32_t msk, uint8_t *status)
Get interrupt indicator from STATB register.
Definition ade7953.c:507
ade7953_zx_edge_e
ADE7953 zero-crossing interrupt edge selection.
Definition ade7953.h:320
@ ADE7953_ZX_BOTH_1
Definition ade7953.h:324
@ ADE7953_ZX_BOTH_2
Definition ade7953.h:331
@ ADE7953_ZX_POS
Definition ade7953.h:328
@ ADE7953_ZX_NEG
Definition ade7953.h:326
int ade7953_zx_int_edge_set(struct ade7953_dev *dev, enum ade7953_zx_edge_e sel)
Zero-crossing interrupt edge selection.
Definition ade7953.c:588
int ade7953_enable_int_a(struct ade7953_dev *dev, uint32_t msk, uint8_t en)
Enable interrupt voltage ch and current ch A.
Definition ade7953.c:559
int ade7953_rms_vals(struct ade7953_dev *dev, struct ade7953_rms_values *data, enum ade7953_i_ch_e channel)
Read rms values.
Definition ade7953.c:1039
int ade7953_reset_vpk_val(struct ade7953_dev *dev, uint32_t *val)
reset Vpeak val
Definition ade7953.c:457
ade7953_zxi_alt_e
ADE7953 configuration of ZX_I pin (Pin 21)
Definition ade7953.h:398
@ ZXI_ALT_VARNLOAD_A
Definition ade7953.h:411
@ ZXI_ALT_SAG
Definition ade7953.h:402
@ ZXI_ALT_REVP
Definition ade7953.h:422
@ ZXI_ALT_WSMP
Definition ade7953.h:416
@ ZXI_ALT_APNLOAD_A
Definition ade7953.h:405
@ ZXI_ALT_APNLOAD_B
Definition ade7953.h:408
@ ZXI_ALT_ZX
Definition ade7953.h:420
@ ZXI_ALT_IRQ
Definition ade7953.h:418
@ ZXI_ALT_ZX_I
Definition ade7953.h:400
@ ZXI_ALT_VARNLOAD_B
Definition ade7953.h:414
int ade7953_zx_config_pin(struct ade7953_dev *dev, enum ade7953_zx_alt_e sel)
Configure of ZX pin (Pin1)
Definition ade7953.c:688
int ade7953_sw_reset(struct ade7953_dev *dev)
Reset the device using SW reset.
Definition ade7953.c:306
ade7953_awattacc_e
ADE7953 Current Channel A and B active energy accumulation mode.
Definition ade7953.h:460
@ ADE7953_POSITIVE_ACC_MODE
Definition ade7953.h:464
@ ADE7953_ABSOLUTE_ACC_MODE_AWATT
Definition ade7953.h:466
@ ADE7953_NORMAL_ACC_MODE_AWATT
Definition ade7953.h:462
int ade7953_acc_active_engy_mode(struct ade7953_dev *dev, enum ade7953_awattacc_e mode, enum ade7953_i_ch_e channel)
ACC mode selection for active energy.
Definition ade7953.c:860
ade7953_zx_alt_e
ADE7953 configuration of ZX pin (Pin 1)
Definition ade7953.h:367
@ ZX_ALT_APNLOAD_B
Definition ade7953.h:377
@ ZX_ALT_REVP
Definition ade7953.h:391
@ ZX_ALT_ZX_I
Definition ade7953.h:389
@ ZX_ALT_APNLOAD_A
Definition ade7953.h:374
@ ZX_ALT_VARNLOAD_B
Definition ade7953.h:383
@ ZX_ALT_IRQ
Definition ade7953.h:387
@ ZX_ALT_SAG
Definition ade7953.h:371
@ ZX_ALT_VARNLOAD_A
Definition ade7953.h:380
@ ZX_ALT_WSMP
Definition ade7953.h:385
@ ZX_ALT_ZX
Definition ade7953.h:369
ade7953_write_protect_e
ADE7953 write protect select.
Definition ade7953.h:306
@ ADE7953_24_32BITS_REGS
Definition ade7953.h:313
@ ADE7953_8BITS_REGS
Definition ade7953.h:309
@ ADE7953_16BITS_REGS
Definition ade7953.h:311
ade7953_revp_alt_e
ADE7953 configuration of REVP pin (Pin 20)
Definition ade7953.h:429
@ REVP_ALT_APNLOAD_B
Definition ade7953.h:439
@ REVP_ALT_VARNLOAD_A
Definition ade7953.h:442
@ REVP_ALT_VARNLOAD_B
Definition ade7953.h:445
@ REVP_ALT_ZX_I
Definition ade7953.h:453
@ REVP_ALT_SAG
Definition ade7953.h:433
@ REVP_ALT_IRQ
Definition ade7953.h:449
@ REVP_ALT_ZX
Definition ade7953.h:451
@ REVP_ALT_WSMP
Definition ade7953.h:447
@ REVP_ALT_APNLOAD_A
Definition ade7953.h:436
@ REVP_ALT_REVP
Definition ade7953.h:431
ade7953_pga_gain_e
ADE7953 PGA gain for Current Channel A, B and Voltage Channel.
Definition ade7953.h:486
@ ADE7953_GAIN_4
Definition ade7953.h:492
@ ADE7953_GAIN_16
Definition ade7953.h:496
@ ADE7953_GAIN_1
Definition ade7953.h:488
@ ADE7953_GAIN_2
Definition ade7953.h:490
@ ADE7953_GAIN_8
Definition ade7953.h:494
@ ADE7953_GAIN_22
Definition ade7953.h:499
int ade7953_write(struct ade7953_dev *dev, uint16_t reg_addr, uint32_t reg_data)
Write device register.
Definition ade7953.c:196
int ade7953_reset_ibpk_val(struct ade7953_dev *dev, uint32_t *val)
reset IBpeak val
Definition ade7953.c:434
int ade7953_init(struct ade7953_dev **device, struct ade7953_init_param init_param)
Initialize the device.
Definition ade7953.c:59
int ade7953_power_quality_vals(struct ade7953_dev *dev, struct ade7953_pq_values *data)
Read power quaility values.
Definition ade7953.c:1082
int ade7953_version_product(struct ade7953_dev *dev, uint32_t *data_read)
Version product.
Definition ade7953.c:387
ade7953_cfsel_e
ADE7953 configuration of output signal on CF1/CF2 pin.
Definition ade7953.h:338
@ CF_IRMSA_IRMSB
Definition ade7953.h:357
@ CF_APPB
Definition ade7953.h:352
@ CF_BPB
Definition ade7953.h:348
@ CF_IRMSB
Definition ade7953.h:354
@ CF_RPA
Definition ade7953.h:342
@ CF_APA_APB
Definition ade7953.h:360
@ CF_RPB
Definition ade7953.h:350
@ CF_APA
Definition ade7953.h:340
@ CF_APPA
Definition ade7953.h:344
@ CF_IRMSA
Definition ade7953.h:346
ade7953_i_ch_e
ADE7953 current channel.
Definition ade7953.h:282
@ ADE7953_I_CH2
Definition ade7953.h:287
@ ADE7953_I_CH1
Definition ade7953.h:285
int ade7953_revp_pin_config(struct ade7953_dev *dev, enum ade7953_revp_alt_e sel)
Configure of REVP pin (Pin20)
Definition ade7953.c:802
int ade7953_reset_iapk_val(struct ade7953_dev *dev, uint32_t *val)
reset IApeak val
Definition ade7953.c:411
ade7953_avaracc_e
ADE7953 Current Channel A and B reactive energy accumulation mode.
Definition ade7953.h:473
@ ADE7953_ANTITAMP_ACC_MODE
Definition ade7953.h:477
@ ADE7953_ABSOLUTE_ACC_MODE_AVAR
Definition ade7953.h:479
@ ADE7953_NORMAL_ACC_MODE_AVAR
Definition ade7953.h:475
int ade7953_power_vals(struct ade7953_dev *dev, struct ade7953_power_values *data, enum ade7953_i_ch_e channel)
Read power values.
Definition ade7953.c:988
int ade7953_cf_output_set(struct ade7953_dev *dev, enum ade7953_cfsel_e sel, enum ade7953_cf_pin_e cf_pin)
Configure output signal on CF1/CF2 pin.
Definition ade7953.c:622
int ade7953_acc_reactive_engy_mode(struct ade7953_dev *dev, enum ade7953_avaracc_e mode, enum ade7953_i_ch_e channel)
ACC mode selection for reactive energy.
Definition ade7953.c:899
ade7953_cf_pin_e
ADE7953 cf pin selection.
Definition ade7953.h:294
@ ADE7953_CF2_PIN
Definition ade7953.h:299
@ ADE7953_CF1_PIN
Definition ade7953.h:297
int ade7953_clear_irq_stata(struct ade7953_dev *dev)
Clear irq stata flags.
Definition ade7953.c:531
int ade7953_enable_int_b(struct ade7953_dev *dev, uint32_t msk, uint8_t en)
Enable/disable interrupt voltage ch and current ch B.
Definition ade7953.c:574
int ade7953_remove(struct ade7953_dev *dev)
Remove the device and release resources.
Definition ade7953.c:273
int ade7953_energy_vals(struct ade7953_dev *dev, struct ade7953_energy_values *data, enum ade7953_i_ch_e channel)
Read energy values.
Definition ade7953.c:938
int ade7953_wr_lock_8bit(struct ade7953_dev *dev, enum ade7953_write_protect_e regs_select)
Lock write to registers.
Definition ade7953.c:354
int ade7953_hw_reset(struct ade7953_dev *dev)
Reset the device using HW reset.
Definition ade7953.c:326
int ade7953_read(struct ade7953_dev *dev, uint16_t reg_addr, int32_t *reg_data)
Read device register.
Definition ade7953.c:126
int ade7953_get_int_stata(struct ade7953_dev *dev, uint32_t msk, uint8_t *status)
Get interrupt indicator from STATA register.
Definition ade7953.c:481
int ade7953_zxi_config_pin(struct ade7953_dev *dev, enum ade7953_zxi_alt_e sel)
Configure of ZXI pin (Pin21)
Definition ade7953.c:745
Error macro definition for ARM Compiler.
Header file of CRC-16 computation.
Header file of Delay functions.
Header file of GPIO Interface.
Header file of IRQ interface.
Print messages helpers.
Header file of SPI Interface.
Header file of Units.
Header file of utility functions.
ADE7953 Device structure.
Definition ade7953.h:520
struct no_os_irq_ctrl_desc * zx_ctrl
Definition ade7953.h:528
struct no_os_gpio_desc * gpio_reset
Definition ade7953.h:524
uint8_t en_24_bit
Definition ade7953.h:530
struct no_os_spi_desc * spi_desc
Definition ade7953.h:522
struct no_os_irq_ctrl_desc * irq_ctrl
Definition ade7953.h:526
ADE7953 energy registers values.
Definition ade7953.h:537
int32_t fundamental_reactive_energy_reg_val
Definition ade7953.h:541
int32_t active_energy_reg_val
Definition ade7953.h:539
int32_t apparent_energy_reg_val
Definition ade7953.h:543
ADE7953 Device initialization parameters.
Definition ade7953.h:505
uint8_t en_24_bit
Definition ade7953.h:511
struct no_os_gpio_init_param * gpio_reset
Definition ade7953.h:509
struct no_os_spi_init_param * spi_init
Definition ade7953.h:507
struct no_os_irq_ctrl_desc * irq_ctrl
Definition ade7953.h:513
ADE7953 power registers values.
Definition ade7953.h:550
int32_t apparent_power_reg_val
Definition ade7953.h:556
int32_t active_power_reg_val
Definition ade7953.h:552
int32_t reactive_power_reg_val
Definition ade7953.h:554
ADE7953 power quality registers values.
Definition ade7953.h:576
int32_t power_factor_reg_val
Definition ade7953.h:578
int32_t period_reg_val
Definition ade7953.h:580
ADE7953 rms registers values.
Definition ade7953.h:563
int32_t current_chA_rms_reg_val
Definition ade7953.h:565
int32_t voltage_rms_reg_val
Definition ade7953.h:569
int32_t current_chB_rms_reg_val
Definition ade7953.h:567
Definition ad9361_util.h:63
Structure holding the GPIO descriptor.
Definition no_os_gpio.h:84
Structure holding the parameters for GPIO initialization.
Definition no_os_gpio.h:67
Definition no_os_irq.h:117
Structure holding SPI descriptor.
Definition no_os_spi.h:180
Structure holding the parameters for SPI initialization.
Definition no_os_spi.h:128