no-OS
ade7880.h
Go to the documentation of this file.
1 /***************************************************************************/
33 #ifndef __ADE7880_H__
34 #define __ADE7880_H__
35 
36 /******************************************************************************/
37 /***************************** Include Files **********************************/
38 /******************************************************************************/
39 #include <stdbool.h>
40 #include <stdint.h>
41 #include <string.h>
42 #include "no_os_util.h"
43 #include "no_os_spi.h"
44 #include "no_os_gpio.h"
45 #include "no_os_print_log.h"
46 
47 /******************************************************************************/
48 /********************** Macros and Constants Definitions **********************/
49 /******************************************************************************/
50 
51 /* SPI commands */
52 #define ADE7880_SPI_READ_CMD 0x01
53 #define ADE7880_SPI_WRITE_CMD 0x00
54 
55 #define ENABLE 0x0001
56 #define DISABLE 0x0000
57 
58 /* ADE7880 Register Map */
59 #define ADE7880_REG_AIGAIN 0x4380
60 #define ADE7880_REG_AVGAIN 0x4381
61 #define ADE7880_REG_BIGAIN 0x4382
62 #define ADE7880_REG_BVGAIN 0x4383
63 #define ADE7880_REG_CIGAIN 0x4384
64 #define ADE7880_REG_CVGAIN 0x4385
65 #define ADE7880_REG_NIGAIN 0x4386
66 #define ADE7880_REG_DICOEFF 0x4388
67 #define ADE7880_REG_APGAIN 0x4389
68 #define ADE7880_REG_AWATTOS 0x438A
69 #define ADE7880_REG_BPGAIN 0x438B
70 #define ADE7880_REG_BWATTOS 0x438C
71 #define ADE7880_REG_CPGAIN 0x438D
72 #define ADE7880_REG_CWATTOS 0x438E
73 #define ADE7880_REG_AIRMSOS 0x438F
74 #define ADE7880_REG_AVRMSOS 0x4390
75 #define ADE7880_REG_BIRMSOS 0x4391
76 #define ADE7880_REG_BVRMSOS 0x4392
77 #define ADE7880_REG_CIRMSOS 0x4393
78 #define ADE7880_REG_CVRMSOS 0x4394
79 #define ADE7880_REG_NIRMSOS 0x4395
80 #define ADE7880_REG_HPGAIN 0x4398
81 #define ADE7880_REG_ISUMLVL 0x4399
82 #define ADE7880_REG_VLEVEL 0x439F
83 #define ADE7880_REG_AFWATTOS 0x43A2
84 #define ADE7880_REG_BFWATTOS 0x43A3
85 #define ADE7880_REG_CFWATTOS 0x43A4
86 #define ADE7880_REG_AFVAROS 0x43A5
87 #define ADE7880_REG_BFVAROS 0x43A6
88 #define ADE7880_REG_CFVAROS 0x43A7
89 #define ADE7880_REG_AFIRMSOS 0x43A8
90 #define ADE7880_REG_BFIRMSOS 0x43A9
91 #define ADE7880_REG_CFIRMSOS 0x43AA
92 #define ADE7880_REG_AFVRMSOS 0x43AB
93 #define ADE7880_REG_BFVRMSOS 0x43AC
94 #define ADE7880_REG_CFVRMSOS 0x43AD
95 #define ADE7880_REG_HXWATTOS 0x43AE
96 #define ADE7880_REG_HYWATTOS 0x43AF
97 #define ADE7880_REG_HZWATTOS 0x43B0
98 #define ADE7880_REG_HXVAROS 0x43B1
99 #define ADE7880_REG_HYVAROS 0x43B2
100 #define ADE7880_REG_HZVAROS 0x43B3
101 #define ADE7880_REG_HXIRMSOS 0x43B4
102 #define ADE7880_REG_HYIRMSOS 0x43B5
103 #define ADE7880_REG_HZIRMSOS 0x43B6
104 #define ADE7880_REG_HXVRMSOS 0x43B7
105 #define ADE7880_REG_HYVRMSOS 0x43B8
106 #define ADE7880_REG_HZVRMSOS 0x43B9
107 #define ADE7880_REG_AIRMS 0x43C0
108 #define ADE7880_REG_AVRMS 0x43C1
109 #define ADE7880_REG_BIRMS 0x43C2
110 #define ADE7880_REG_BVRMS 0x43C3
111 #define ADE7880_REG_CIRMS 0x43C4
112 #define ADE7880_REG_CVRMS 0x43C5
113 #define ADE7880_REG_NIRMS 0x43C6
114 #define ADE7880_REG_ISUM 0x43C7
115 
116 /* Internal DSP memory RAM registers*/
117 #define ADE7880_REG_RUN 0xE228
118 
119 /* Billable registers*/
120 #define ADE7880_REG_AWATTHR 0xE400
121 #define ADE7880_REG_BWATTHR 0xE401
122 #define ADE7880_REG_CWATTHR 0xE402
123 #define ADE7880_REG_AFWATTHR 0xE403
124 #define ADE7880_REG_BFWATTHR 0xE404
125 #define ADE7880_REG_CFWATTHR 0xE405
126 #define ADE7880_REG_AFVARHR 0xE409
127 #define ADE7880_REG_BFVARHR 0xE40A
128 #define ADE7880_REG_CFVARHR 0xE40B
129 #define ADE7880_REG_AVAHR 0xE40C
130 #define ADE7880_REG_BVAHR 0xE40D
131 #define ADE7880_REG_CVAHR 0xE40E
132 
133 /* Configuration and PQ registers */
134 #define ADE7880_REG_IPEAK 0xE500
135 #define ADE7880_REG_VPEAK 0xE501
136 #define ADE7880_REG_STATUS0 0xE502
137 #define ADE7880_REG_STATUS1 0xE503
138 #define ADE7880_REG_AIMAV 0xE504
139 #define ADE7880_REG_BIMAV 0xE505
140 #define ADE7880_REG_CIMAV 0xE506
141 #define ADE7880_REG_OILVL 0xE507
142 #define ADE7880_REG_OVLVL 0xE508
143 #define ADE7880_REG_SAGLVL 0xE509
144 #define ADE7880_REG_MASK0 0xE50A
145 #define ADE7880_REG_MASK1 0xE50B
146 #define ADE7880_REG_IAWV 0xE50C
147 #define ADE7880_REG_IBWV 0xE50D
148 #define ADE7880_REG_ICWV 0xE50E
149 #define ADE7880_REG_INWV 0xE50F
150 #define ADE7880_REG_VAWV 0xE510
151 #define ADE7880_REG_VBWV 0xE511
152 #define ADE7880_REG_VCWV 0xE512
153 #define ADE7880_REG_AWATT 0xE513
154 #define ADE7880_REG_BWATT 0xE514
155 #define ADE7880_REG_CWATT 0xE515
156 #define ADE7880_REG_AVA 0xE519
157 #define ADE7880_REG_BVA 0xE51A
158 #define ADE7880_REG_CVA 0xE51B
159 #define ADE7880_REG_CHECKSUM 0xE51F
160 #define ADE7880_REG_VNOM 0xE520
161 #define ADE7880_REG_LAST_RWDATA32 0xE5FF
162 #define ADE7880_REG_PHSTATUS 0xE600
163 #define ADE7880_REG_ANGLE0 0xE601
164 #define ADE7880_REG_ANGLE1 0xE602
165 #define ADE7880_REG_ANGLE2 0xE603
166 #define ADE7880_REG_PHNOLOAD 0xE608
167 #define ADE7880_REG_LINECYC 0xE60C
168 #define ADE7880_REG_ZXTOUT 0xE60D
169 #define ADE7880_REG_COMPMODE 0xE60E
170 #define ADE7880_REG_GAIN 0xE60F
171 #define ADE7880_REG_CFMODE 0xE610
172 #define ADE7880_REG_CF1DEN 0xE611
173 #define ADE7880_REG_CF2DEN 0xE612
174 #define ADE7880_REG_CF3DEN 0xE613
175 #define ADE7880_REG_APHCAL 0xE614
176 #define ADE7880_REG_BPHCAL 0xE615
177 #define ADE7880_REG_CPHCAL 0xE616
178 #define ADE7880_REG_PHSIGN 0xE617
179 #define ADE7880_REG_CONFIG 0xE618
180 #define ADE7880_REG_MMODE 0xE700
181 #define ADE7880_REG_ACCMODE 0xE701
182 #define ADE7880_REG_LCYCMODE 0xE702
183 #define ADE7880_REG_PEAKCYC 0xE703
184 #define ADE7880_REG_SAGCYC 0xE704
185 #define ADE7880_REG_CFCYC 0xE705
186 #define ADE7880_REG_HSDC_CFG 0xE706
187 #define ADE7880_REG_VERSION 0xE707
188 #define ADE7880_REG_RESERVED 0xE7E4
189 #define ADE7880_REG_LAST_RWDATA8 0xE7FD
190 #define ADE7880_REG_FVRMS 0xE880
191 #define ADE7880_REG_FIRMS 0xE881
192 #define ADE7880_REG_FWATT 0xE882
193 #define ADE7880_REG_FVAR 0xE883
194 #define ADE7880_REG_FVA 0xE884
195 #define ADE7880_REG_FPF 0xE885
196 #define ADE7880_REG_VTHD 0xE886
197 #define ADE7880_REG_ITHD 0xE887
198 #define ADE7880_REG_HXVRMS 0xE888
199 #define ADE7880_REG_HXIRMS 0xE889
200 #define ADE7880_REG_HXWATT 0xE88A
201 #define ADE7880_REG_HXVAR 0xE88B
202 #define ADE7880_REG_HXVA 0xE88C
203 #define ADE7880_REG_HXPF 0xE88D
204 #define ADE7880_REG_HXVHD 0xE88E
205 #define ADE7880_REG_HXIHD 0xE88F
206 #define ADE7880_REG_HYVRMS 0xE890
207 #define ADE7880_REG_HYIRMS 0xE891
208 #define ADE7880_REG_HYWATT 0xE892
209 #define ADE7880_REG_HFVAR 0xE893
210 #define ADE7880_REG_HYVA 0xE894
211 #define ADE7880_REG_HYPF 0xE895
212 #define ADE7880_REG_HYVHD 0xE896
213 #define ADE7880_REG_HYIHD 0xE897
214 #define ADE7880_REG_HZVRMS 0xE898
215 #define ADE7880_REG_HZIRMS 0xE899
216 #define ADE7880_REG_HZWATT 0xE89A
217 #define ADE7880_REG_HZVAR 0xE89B
218 #define ADE7880_REG_HZVA 0xE89C
219 #define ADE7880_REG_HZPF 0xE89D
220 #define ADE7880_REG_HZVHD 0xE89E
221 #define ADE7880_REG_HZIHD 0xE89F
222 #define ADE7880_REG_HCONFIG 0xE900
223 #define ADE7880_REG_APF 0xE902
224 #define ADE7880_REG_BPF 0xE903
225 #define ADE7880_REG_CPF 0xE904
226 #define ADE7880_REG_APERIOD 0xE905
227 #define ADE7880_REG_BPERIOD 0xE906
228 #define ADE7880_REG_CPERIOD 0xE907
229 #define ADE7880_REG_APNOLOAD 0xE908
230 #define ADE7880_REG_VARNOLOAD 0xE909
231 #define ADE7880_REG_VANOLOAD 0xE90A
232 #define ADE7880_REG_LAST_ADD 0xE9FE
233 #define ADE7880_REG_LAST_RWDATA16 0xE9FF
234 #define ADE7880_REG_CONFIG3 0xEA00
235 #define ADE7880_REG_LAST_OP 0xEA01
236 #define ADE7880_REG_WTHR 0xEA02
237 #define ADE7880_REG_VARTHR 0xEA03
238 #define ADE7880_REG_VATHR 0xEA04
239 #define ADE7880_REG_HX 0xEA08
240 #define ADE7880_REG_HY 0xEA09
241 #define ADE7880_REG_HZ 0xEA0A
242 #define ADE7880_REG_LPOILVL 0xEC00
243 #define ADE7880_REG_CONFIG2 0xEC01
244 
245 /* ADE7880_REG_IPEAK Bit Definition */
246 #define ADE7880_IPPHASE2 NO_OS_BIT(26)
247 #define ADE7880_IPPHASE1 NO_OS_BIT(25)
248 #define ADE7880_IPPHASE0 NO_OS_BIT(24)
249 #define ADE7880_IPEAKVAL NO_OS_GENMASK(23, 0)
250 
251 /* ADE7880_REG_VPEAK Bit Definition */
252 #define ADE7880_VPPHASE2 NO_OS_BIT(26)
253 #define ADE7880_VPPHASE1 NO_OS_BIT(25)
254 #define ADE7880_VPPHASE0 NO_OS_BIT(24)
255 #define ADE7880_VPEAKVAL NO_OS_GENMASK(23, 0)
256 
257 /* ADE7880_REG_STATUS0 Bit Definition */
258 #define ADE7880_STATUS0_HREADY NO_OS_BIT(19)
259 #define ADE7880_STATUS0_REVPSUM3 NO_OS_BIT(18)
260 #define ADE7880_STATUS0_DREADY NO_OS_BIT(17)
261 #define ADE7880_STATUS0_CF3 NO_OS_BIT(16)
262 #define ADE7880_STATUS0_CF2 NO_OS_BIT(15)
263 #define ADE7880_STATUS0_CF1 NO_OS_BIT(14)
264 #define ADE7880_STATUS0_REVPSUM2 NO_OS_BIT(13)
265 #define ADE7880_STATUS0_REVFRPC NO_OS_BIT(12)
266 #define ADE7880_STATUS0_REVFRPB NO_OS_BIT(11)
267 #define ADE7880_STATUS0_REVFRPA NO_OS_BIT(10)
268 #define ADE7880_STATUS0_REVPSUM1 NO_OS_BIT(9)
269 #define ADE7880_STATUS0_REVAPC NO_OS_BIT(8)
270 #define ADE7880_STATUS0_REVAPB NO_OS_BIT(7)
271 #define ADE7880_STATUS0_REVAPA NO_OS_BIT(6)
272 #define ADE7880_STATUS0_LENERGY NO_OS_BIT(5)
273 #define ADE7880_STATUS0_VAEHF NO_OS_BIT(4)
274 #define ADE7880_STATUS0_FREHF NO_OS_BIT(3)
275 #define ADE7880_STATUS0_FAEHF NO_OS_BIT(1)
276 #define ADE7880_STATUS0_AEHF NO_OS_BIT(0)
277 
278 /* ADE7880_REG_STATUS1 Bit Definition */
279 #define ADE7880_STATUS1_CRC NO_OS_BIT(25)
280 #define ADE7880_STATUS1_PKV NO_OS_BIT(24)
281 #define ADE7880_STATUS1_PKI NO_OS_BIT(23)
282 #define ADE7880_STATUS1_MISMTCH NO_OS_BIT(20)
283 #define ADE7880_STATUS1_SEQERR NO_OS_BIT(19)
284 #define ADE7880_STATUS1_OV NO_OS_BIT(18)
285 #define ADE7880_STATUS1_OI NO_OS_BIT(17)
286 #define ADE7880_STATUS1_SAG NO_OS_BIT(16)
287 #define ADE7880_STATUS1_RSTDONE NO_OS_BIT(15)
288 #define ADE7880_STATUS1_ZXIC NO_OS_BIT(14)
289 #define ADE7880_STATUS1_ZXIB NO_OS_BIT(13)
290 #define ADE7880_STATUS1_ZXIA NO_OS_BIT(12)
291 #define ADE7880_STATUS1_ZXVC NO_OS_BIT(11)
292 #define ADE7880_STATUS1_ZXVB NO_OS_BIT(10)
293 #define ADE7880_STATUS1_ZXVA NO_OS_BIT(9)
294 #define ADE7880_STATUS1_ZXTOIC NO_OS_BIT(8)
295 #define ADE7880_STATUS1_ZXTOIB NO_OS_BIT(7)
296 #define ADE7880_STATUS1_ZXTOIA NO_OS_BIT(6)
297 #define ADE7880_STATUS1_ZXTOVC NO_OS_BIT(5)
298 #define ADE7880_STATUS1_ZXTOVB NO_OS_BIT(4)
299 #define ADE7880_STATUS1_ZXTOVA NO_OS_BIT(3)
300 #define ADE7880_STATUS1_VANLOAD NO_OS_BIT(2)
301 #define ADE7880_STATUS1_FNLOAD NO_OS_BIT(1)
302 #define ADE7880_STATUS1_NLOAD NO_OS_BIT(0)
303 
304 /* ADE7880_REG_MASK0 Bit Definition */
305 #define ADE7880_MASK0_HREADY NO_OS_BIT(19)
306 #define ADE7880_MASK0_REVPSUM3 NO_OS_BIT(18)
307 #define ADE7880_MASK0_DREADY NO_OS_BIT(17)
308 #define ADE7880_MASK0_CF3 NO_OS_BIT(16)
309 #define ADE7880_MASK0_CF2 NO_OS_BIT(15)
310 #define ADE7880_MASK0_CF1 NO_OS_BIT(14)
311 #define ADE7880_MASK0_REVPSUM2 NO_OS_BIT(13)
312 #define ADE7880_MASK0_REVFRPC NO_OS_BIT(12)
313 #define ADE7880_MASK0_REVFRPB NO_OS_BIT(11)
314 #define ADE7880_MASK0_REVFRPA NO_OS_BIT(10)
315 #define ADE7880_MASK0_REVPSUM1 NO_OS_BIT(9)
316 #define ADE7880_MASK0_REVAPC NO_OS_BIT(8)
317 #define ADE7880_MASK0_REVAPB NO_OS_BIT(7)
318 #define ADE7880_MASK0_REVAPA NO_OS_BIT(6)
319 #define ADE7880_MASK0_LENERGY NO_OS_BIT(5)
320 #define ADE7880_MASK0_VAEHF NO_OS_BIT(4)
321 #define ADE7880_MASK0_FREHF NO_OS_BIT(3)
322 #define ADE7880_MASK0_FAEHF NO_OS_BIT(1)
323 #define ADE7880_MASK0_AEHF NO_OS_BIT(0)
324 
325 /* ADE7880_REG_MASK1 Bit Definition */
326 #define ADE7880_MASK1_CRC NO_OS_BIT(25)
327 #define ADE7880_MASK1_PKV NO_OS_BIT(24)
328 #define ADE7880_MASK1_PKI NO_OS_BIT(23)
329 #define ADE7880_MASK1_MISMTCH NO_OS_BIT(20)
330 #define ADE7880_MASK1_SEQERR NO_OS_BIT(19)
331 #define ADE7880_MASK1_OV NO_OS_BIT(18)
332 #define ADE7880_MASK1_OI NO_OS_BIT(17)
333 #define ADE7880_MASK1_SAG NO_OS_BIT(16)
334 #define ADE7880_MASK1_RSTDONE NO_OS_BIT(15)
335 #define ADE7880_MASK1_ZXIC NO_OS_BIT(14)
336 #define ADE7880_MASK1_ZXIB NO_OS_BIT(13)
337 #define ADE7880_MASK1_ZXIA NO_OS_BIT(12)
338 #define ADE7880_MASK1_ZXVC NO_OS_BIT(11)
339 #define ADE7880_MASK1_ZXVB NO_OS_BIT(10)
340 #define ADE7880_MASK1_ZXVA NO_OS_BIT(9)
341 #define ADE7880_MASK1_ZXTOIC NO_OS_BIT(8)
342 #define ADE7880_MASK1_ZXTOIB NO_OS_BIT(7)
343 #define ADE7880_MASK1_ZXTOIA NO_OS_BIT(6)
344 #define ADE7880_MASK1_ZXTOVC NO_OS_BIT(5)
345 #define ADE7880_MASK1_ZXTOVB NO_OS_BIT(4)
346 #define ADE7880_MASK1_ZXTOVA NO_OS_BIT(3)
347 #define ADE7880_MASK1_VANLOAD NO_OS_BIT(2)
348 #define ADE7880_MASK1_FNLOAD NO_OS_BIT(1)
349 #define ADE7880_MASK1_NLOAD NO_OS_BIT(0)
350 
351 /* ADE7880_REG_PHSTATUS Bit Definition */
352 #define ADE7880_VSPHASE2 NO_OS_BIT(14)
353 #define ADE7880_VSPHASE1 NO_OS_BIT(13)
354 #define ADE7880_VSPHASE0 NO_OS_BIT(12)
355 #define ADE7880_OVPHASE2 NO_OS_BIT(11)
356 #define ADE7880_OVPHASE1 NO_OS_BIT(10)
357 #define ADE7880_OVPHASE0 NO_OS_BIT(9)
358 #define ADE7880_OIPHASE2 NO_OS_BIT(5)
359 #define ADE7880_OIPHASE1 NO_OS_BIT(4)
360 #define ADE7880_OIPHASE0 NO_OS_BIT(3)
361 
362 /* ADE7880_REG_PHNOLOAD Bit Definition */
363 #define ADE7880_VANLPHASE2 NO_OS_BIT(8)
364 #define ADE7880_VANLPHASE1 NO_OS_BIT(7)
365 #define ADE7880_VANLPHASE0 NO_OS_BIT(6)
366 #define ADE7880_FNLPHASE2 NO_OS_BIT(5)
367 #define ADE7880_FNLPHASE1 NO_OS_BIT(4)
368 #define ADE7880_FNLPHASE0 NO_OS_BIT(3)
369 #define ADE7880_NLPHASE2 NO_OS_BIT(2)
370 #define ADE7880_NLPHASE1 NO_OS_BIT(1)
371 #define ADE7880_NLPHASE0 NO_OS_BIT(0)
372 
373 /* ADE7880_REG_COMPMODE Bit Definition */
374 #define ADE7880_SELFREQ NO_OS_BIT(14)
375 #define ADE7880_VNOMCEN NO_OS_BIT(13)
376 #define ADE7880_VNOMBEN NO_OS_BIT(12)
377 #define ADE7880_VNOMAEN NO_OS_BIT(11)
378 #define ADE7880_ANGLESEL NO_OS_GENMASK(10, 9)
379 #define ADE7880_TERMSEL3_2 NO_OS_BIT(8)
380 #define ADE7880_TERMSEL3_1 NO_OS_BIT(7)
381 #define ADE7880_TERMSEL3_0 NO_OS_BIT(6)
382 #define ADE7880_TERMSEL2_2 NO_OS_BIT(5)
383 #define ADE7880_TERMSEL2_1 NO_OS_BIT(4)
384 #define ADE7880_TERMSEL2_0 NO_OS_BIT(3)
385 #define ADE7880_TERMSEL1_2 NO_OS_BIT(2)
386 #define ADE7880_TERMSEL1_1 NO_OS_BIT(1)
387 #define ADE7880_TERMSEL1_0 NO_OS_BIT(0)
388 
389 /* ADE7880_REG_GAIN Bit Definition */
390 #define ADE7880_PGA3 NO_OS_GENMASK(8, 6)
391 #define ADE7880_PGA2 NO_OS_GENMASK(5, 3)
392 #define ADE7880_PGA1 NO_OS_GENMASK(2, 0)
393 
394 /* ADE7880_REG_CFMODE Bit Definition */
395 #define ADE7880_CF3LATCH NO_OS_BIT(14)
396 #define ADE7880_CF2LATCH NO_OS_BIT(13)
397 #define ADE7880_CF1LATCH NO_OS_BIT(12)
398 #define ADE7880_CF3DIS NO_OS_BIT(11)
399 #define ADE7880_CF2DIS NO_OS_BIT(10)
400 #define ADE7880_CF1DIS NO_OS_BIT(9)
401 #define ADE7880_CF3SEL NO_OS_GENMASK(8, 6)
402 #define ADE7880_CF2SEL NO_OS_GENMASK(5, 3)
403 #define ADE7880_CF1SEL NO_OS_GENMASK(2, 0)
404 
405 /* ADE7880_REG_APHCAL, ADE7880_REG_BPHCAL,
406 ADE7880_REG_CPHCAL, Bit Definition */
407 #define ADE7880_PHCALVAL NO_OS_GENMASK(9, 0)
408 
409 /* ADE7880_REG_PHSIGN Bit Definition */
410 #define ADE7880_SUM3SIGN NO_OS_BIT(8)
411 #define ADE7880_SUM2SIGN NO_OS_BIT(7)
412 #define ADE7880_CFVARSIGN NO_OS_BIT(6)
413 #define ADE7880_BFVARSIGN NO_OS_BIT(5)
414 #define ADE7880_AFVARSIGN NO_OS_BIT(4)
415 #define ADE7880_SUM1SIGN NO_OS_BIT(3)
416 #define ADE7880_CWSIGN NO_OS_BIT(2)
417 #define ADE7880_BWSIGN NO_OS_BIT(1)
418 #define ADE7880_AWSIGN NO_OS_BIT(0)
419 
420 /* ADE7880_REG_CONFIG Bit Definition */
421 #define ADE7880_VTOIC NO_OS_GENMASK(13, 12)
422 #define ADE7880_VTOIB NO_OS_GENMASK(11, 10)
423 #define ADE7880_VTOIA NO_OS_GENMASK(9, 8)
424 #define ADE7880_SWRST NO_OS_BIT(7)
425 #define ADE7880_HSDCEN NO_OS_BIT(6)
426 #define ADE7880_MOD2SHORT NO_OS_BIT(5)
427 #define ADE7880_MOD1SHORT NO_OS_BIT(4)
428 #define ADE7880_SWAP NO_OS_BIT(3)
429 #define ADE7880_CF2DIS NO_OS_BIT(2)
430 #define ADE7880_INTEN NO_OS_BIT(0)
431 
432 /* ADE7880_REG_MMODE Bit Definition */
433 #define ADE7880_PEAKSEL2 NO_OS_BIT(4)
434 #define ADE7880_PEAKSEL1 NO_OS_BIT(3)
435 #define ADE7880_PEAKSEL0 NO_OS_BIT(2)
436 
437 /* ADE7880_REG_ACCMODE Bit Definition */
438 #define ADE7880_REVAPSEL NO_OS_BIT(6)
439 #define ADE7880_CONSEL NO_OS_GENMASK(5, 4)
440 #define ADE7880_VARACC NO_OS_GENMASK(3, 2)
441 #define ADE7880_WATTACC NO_OS_GENMASK(1, 0)
442 
443 /* ADE7880_REG_LCYCMODE Bit Definition */
444 #define ADE7880_PFMODE NO_OS_BIT(7)
445 #define ADE7880_RSTREAD NO_OS_BIT(6)
446 #define ADE7880_ZXSEL2 NO_OS_BIT(5)
447 #define ADE7880_ZXSEL1 NO_OS_BIT(4)
448 #define ADE7880_ZXSEL0 NO_OS_BIT(3)
449 #define ADE7880_LVA NO_OS_BIT(2)
450 #define ADE7880_LVAR NO_OS_BIT(1)
451 #define ADE7880_LWATT NO_OS_BIT(0)
452 
453 /* ADE7880_REG_HSDC_CFG Bit Definition */
454 #define ADE7880_HSAPOL NO_OS_BIT(5)
455 #define ADE7880_HXFER NO_OS_GENMASK(4, 3)
456 #define ADE7880_HGAP NO_OS_BIT(2)
457 #define ADE7880_HSIZE NO_OS_BIT(1)
458 #define ADE7880_HCLK NO_OS_BIT(0)
459 
460 /* ADE7880_REG_CONFIG3 Bit Definition */
461 #define ADE7880_ININTEN NO_OS_BIT(3)
462 #define ADE7880_INSEL NO_OS_BIT(2)
463 #define ADE7880_LPFSEL NO_OS_BIT(1)
464 #define ADE7880_HPFEN NO_OS_BIT(0)
465 
466 /* ADE7880_REG_HCONFIG Bit Definition */
467 #define ADE7880_ACTPHSEL NO_OS_GENMASK(9, 8)
468 #define ADE7880_HRATE NO_OS_GENMASK(7, 5)
469 #define ADE7880_HSTIME NO_OS_GENMASK(4, 3)
470 #define ADE7880_HPHASE NO_OS_GENMASK(2, 1)
471 #define ADE7880_HRCFG NO_OS_BIT(0)
472 
473 /* ADE7880_REG_LPOILVL Bit Definition */
474 #define ADE7880_LPLINE NO_OS_GENMASK(7, 3)
475 #define ADE7880_LPOIL NO_OS_GENMASK(2, 0)
476 
477 /* ADE7880_REG_CONFIG2 Bit Definition */
478 #define ADE7880_I2C_LOCK NO_OS_BIT(1)
479 #define ADE7880_EXTREFEN NO_OS_BIT(0)
480 
481 /* Miscellaneous Definitions */
482 #define ADE7880_CHIP_ID 0x0EA0
483 #define ADE7880_RESET_RECOVER 100
484 #define ADE7880_RAM_PROTECTION1 0xE7FE
485 #define ADE7880_RAM_PROTECTION2 0xE7E3
486 #define ADE7880_RAM_PROT_VAL1 0xAD
487 #define ADE7880_RAM_PROT_VAL2 0x80
488 #define ADE7880_SET_SPI_ADDR 0xEBFF
489 #define ADE7880_DUMB_VAL 0x01
490 
491 
492 /*Configuration registers*/
493 /* Set DICOEFF= 0xFFFF8000 when integrator is enabled*/
494 #define ADE7880_DICOEFF 0x00000000
495 #define ADE7880_VLEVEL_VAL 0x007A1200
496 /*Constant Definitions***/
497 /*DSP ON*/
498 #define ADE7880_RUN_ON 0x0001
499 // /*Full scale Codes (FS) referred from Datasheet.*/
500 // /*Respective digital codes are produced when ADC inputs*/
501 // /*are at full scale. Do not Change. */
502 #define ADE7880_RMS_FS_CODES 5326737
503 
504 /* Assuming a transformer ratio of 1000:1 and 10 ohms burden resistance value */
505 #define ADE7880_BURDEN_RES 10
506 #define ADE7880_CURRENT_TR_RATIO 1000
507 #define ADE7880_CURRENT_TR_FCN (ADE7880_CURRENT_TR_RATIO / ADE7880_BURDEN_RES)
508 /* Assuming a voltage divider with Rlow 1k and Rup 1MEG */
509 #define ADE7880_UP_RES 1000000
510 #define ADE7880_DOWN_RES 1000
511 #define ADE7880_VOLTAGE_TR_FCN ((ADE7880_DOWN_RES + ADE7880_UP_RES) / ADE7880_DOWN_RES)
512 
513 // 0.5V full scale * 0.707 * 10000 for mili units
514 #define ADE7880_FS_VOLTAGE 3535
515 
516 /******************************************************************************/
517 /*************************** Types Declarations *******************************/
518 /******************************************************************************/
519 
525  /* The angles between phase voltages and phase currents are measured. */
527  /* The angles between phase voltages are measured */
529  /* The angles between phase currents are measured. */
531  /* no angles are measured. */
533 };
534 
541  /* gain 1 */
543  /* gain 2 */
545  /* gain 4 */
547  /* gain 8 */
549  /* gain 16 */
551 };
552 
559  /* the CFx frequency is proportional to the sum of total active powers on
560  each phase */
562  /* the CFx frequency is proportional to the sum of apparent powers on
563  each phase */
565  /* the CFx frequency is proportional to the sum of fundamental active
566  powers on each phase */
568  /* the CFx frequency is proportional to the sum of fundamental reactive
569  powers on each phase */
571 };
572 
579  /* Phase A voltage */
581  /* Phase B voltage */
583  /* Phase C voltage */
585 };
586 
593  /* Phase B voltage */
595  /* Phase C voltage */
597  /* Phase A voltage */
599 };
600 
607  /* Phase C voltage */
609  /* Phase A voltage */
611  /* Phase B voltage */
613 };
614 
620  /* Signed accumulation mode of the total and fundamental active powers */
622  /* Positive only accumulation mode of the total and fundamental active powers */
624  /* Reserved. When set, the device behaves like WATTACC[1:0] = 00. */
626  /* Absolute accumulation mode of the total and fundamental active powers */
628 };
629 
635  /* Signed accumulation mode of the fundamental reactive powers */
637  /* reserved. When set, the device behaves like VARACC[1:0] = 00. */
639  /* The fundamental reactive power is accumulated, depending on the sign of the
640  fundamental active power */
642  /* Absolute accumulation mode of the fundamental reactive powers */
644 };
645 
652  /* 3-phase four wires with three voltage sensors */
654  /* 3-phase three wires delta connection. In this mode, BVRMS register contains the rms
655  value of VA-VC */
657  /* 3-phase four wires with two voltage sensors. */
659  /* 3-phase four wires delta connection. */
661 };
662 
668  /* HSDC transmits sixteen 32-bit words in the following order: IAWV, VAWV, IBWV, VBWV, ICWV,
669  VCWV, INWV, AVA, BVA, CVA, AWATT, BWATT, CWATT, AFVAR, BFVAR, and CFVAR. */
671  /* HSDC transmits seven instantaneous values of currents and voltages: IAWV, VAWV,
672  IBWV, VBWV, ICWV, VCWV, and INWV. */
674  /* HSDC transmits nine instantaneous values of phase powers: AVA, BVA, CVA, AWATT,
675  BWATT, CWATT, AFVAR, BFVAR, and CFVAR. */
677  /* 11 = reserved. If set, the ADE7880 behaves as if HXFER[1:0] = 00. */
679 };
680 
686  /* Phase A voltage and current */
688  /* Phase B voltage and current */
690  /* Phase C voltage and current */
692  /* Neutral current */
694 };
695 
702  /* 500 ms */
704  /* 750 ms */
706  /* 1000 ms */
708  /* 1250 ms */
710 };
711 
717  /* 125 µs (8 kHz rate) */
719  /* 250 µs (4 kHz rate) */
721  /* 1 ms (1 kHz rate) */
723  /* 16 ms (62.5 Hz rate) */
725  /* 128 ms (7.8125 Hz rate) */
727  /* 512 ms (1.953125 Hz rate) */
729  /* 1.024 sec (0.9765625 Hz rate) */
731  /* harmonic calculations disabled */
733 };
734 
740  /* Phase A voltage */
742  /* Phase B voltage */
744  /* Phase C voltage */
746  /* reserved. If selected, phase C voltage is used */
748 };
749 
755  /* 50 Hz */
757  /* 60 Hz */
759 };
760 
769 };
770 
776  /* SPI is not available in PSM2 & PSM3*/
777  /* PSM0 normal mode */
779  /* PSM1 measure the mean absolute values (mav)
780  of the 3-phase currents */
782  /* PSM2 Current peak detect mode */
784  /* PSM3 Sleep mode */
786 };
787 
795  /* psm0 descriptor */
797  /* psm1 descriptor */
799  /* reset descriptor */
801  /* Variable for mode selection */
802  uint8_t power_mode;
803 };
804 
809 struct ade7880_dev {
812  /* psm0 descriptor */
814  /* psm1 descriptor */
816  /* reset descriptor */
818  /* Variable storing the IRMS value */
819  uint32_t irms_val;
820  /* Variable storing the VRMS value */
821  uint32_t vrms_val;
822  /* Variable for mode selection */
823  uint8_t power_mode;
824 };
825 
826 /******************************************************************************/
827 /************************ Functions Declarations ******************************/
828 /******************************************************************************/
829 
830 /* Read device register. */
831 int ade7880_read(struct ade7880_dev *dev, uint16_t reg_addr,
832  uint32_t *reg_data);
833 
834 /* Write device register. */
835 int ade7880_write(struct ade7880_dev *dev, uint16_t reg_addr,
836  uint32_t reg_data);
837 
838 /* Set power mode */
839 int ade7880_set_power_mode(struct ade7880_dev *dev);
840 
841 /* Update specific register bits. */
842 int ade7880_update_bits(struct ade7880_dev *dev, uint16_t reg_addr,
843  uint32_t mask, uint32_t reg_data);
844 
845 /* Read Energy/Power for specific phase */
846 int ade7880_read_data_ph(struct ade7880_dev *dev, enum ade7880_phase phase);
847 
848 /* Initialize the device. */
849 int ade7880_init(struct ade7880_dev **device,
851 
852 /* Setup the device */
853 int ade7880_setup(struct ade7880_dev *dev);
854 
855 /* Remove the device and release resources. */
856 int ade7880_remove(struct ade7880_dev *dev);
857 
858 /* Get interrupt indicator from STATUS0 register. */
859 int ade7880_get_int_status0(struct ade7880_dev *dev, uint32_t msk,
860  uint8_t *status);
861 
862 #endif // __ADE7880_H__
ADE7880_REG_CIRMS
#define ADE7880_REG_CIRMS
Definition: ade7880.h:111
ADE7880_REG_HCONFIG
#define ADE7880_REG_HCONFIG
Definition: ade7880.h:222
ADE7880_HXFER_7
@ ADE7880_HXFER_7
Definition: ade7880.h:673
ADE7880_RAM_PROTECTION2
#define ADE7880_RAM_PROTECTION2
Definition: ade7880.h:485
ADE7880_ACTPHSEL_B
@ ADE7880_ACTPHSEL_B
Definition: ade7880.h:743
ade7880_dev::spi_desc
struct no_os_spi_desc * spi_desc
Definition: ade7880.h:811
no_os_put_unaligned_be16
void no_os_put_unaligned_be16(uint16_t val, uint8_t *buf)
ADE7880_REG_CONFIG3
#define ADE7880_REG_CONFIG3
Definition: ade7880.h:234
ADE7880_WATTACC_POSITIVE_ACC
@ ADE7880_WATTACC_POSITIVE_ACC
Definition: ade7880.h:623
ADE7880_RAM_PROT_VAL1
#define ADE7880_RAM_PROT_VAL1
Definition: ade7880.h:486
ADE7880_HRATE_62_5
@ ADE7880_HRATE_62_5
Definition: ade7880.h:724
no_os_alloc.h
ade7880_vtoic_e
ade7880_vtoic_e
ADE7880 These bits decide what phase voltage is considered together with Phase C current in the power...
Definition: ade7880.h:606
ADE7880_HRATE_7_8125
@ ADE7880_HRATE_7_8125
Definition: ade7880.h:726
ADE7880_HRATE_1K
@ ADE7880_HRATE_1K
Definition: ade7880.h:722
ade7880_dev
ADE7880 Device structure.
Definition: ade7880.h:809
ADE7880_REG_LAST_RWDATA8
#define ADE7880_REG_LAST_RWDATA8
Definition: ade7880.h:189
ADE7880_HSTIM_1000
@ ADE7880_HSTIM_1000
Definition: ade7880.h:707
ADE7880_VTOIC_A
@ ADE7880_VTOIC_A
Definition: ade7880.h:610
no_os_i2c_write
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
ADE7816_CONFIG_REG
#define ADE7816_CONFIG_REG
Definition: ade7816.h:157
ADE7880_REG_STATUS0
#define ADE7880_REG_STATUS0
Definition: ade7880.h:136
ade7880_init_param::spi_init
struct no_os_spi_init_param * spi_init
Definition: ade7880.h:794
ADE7880_PGAGAIN_1
@ ADE7880_PGAGAIN_1
Definition: ade7880.h:542
ade7816.h
Header file of ADE7816 Driver.
ADE7880_REG_GAIN
#define ADE7880_REG_GAIN
Definition: ade7880.h:170
ADE7816_FIRST_BYTE_MASK
#define ADE7816_FIRST_BYTE_MASK
Definition: ade7816.h:177
ADE7880_REG_DICOEFF
#define ADE7880_REG_DICOEFF
Definition: ade7880.h:66
NO_OS_GENMASK
#define NO_OS_GENMASK(h, l)
Definition: no_os_util.h:82
no_os_spi_write_and_read
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
ADE7880_VTOIB_C
@ ADE7880_VTOIB_C
Definition: ade7880.h:596
ADE7880_HSTIM_700
@ ADE7880_HSTIM_700
Definition: ade7880.h:705
ade7880_update_bits
int ade7880_update_bits(struct ade7880_dev *dev, uint16_t reg_addr, uint32_t mask, uint32_t reg_data)
Update specific register bits.
Definition: ade7880.c:207
ade7880_remove
int ade7880_remove(struct ade7880_dev *dev)
Remove the device and release resources.
Definition: ade7880.c:467
no_os_spi.h
Header file of SPI Interface.
ADE7880_CFXSEL_3
@ ADE7880_CFXSEL_3
Definition: ade7880.h:570
ADE7816_LSB_REG_MASK
#define ADE7816_LSB_REG_MASK
Definition: ade7816.h:171
ade7816_desc::spi_desc
struct no_os_spi_desc * spi_desc
Definition: ade7816.h:328
ade7880_init
int ade7880_init(struct ade7880_dev **device, struct ade7880_init_param init_param)
Initialize the device.
Definition: ade7880.c:322
ADE7880_VTOIA_C
@ ADE7880_VTOIA_C
Definition: ade7880.h:584
no_os_units.h
Header file of Units.
ade7816_desc::i2c_desc
struct no_os_i2c_desc * i2c_desc
Definition: ade7816.h:329
ADE7880_PGA3
#define ADE7880_PGA3
Definition: ade7880.h:390
pr_err
#define pr_err(fmt, args...)
Definition: no_os_print_log.h:88
ADE7880_SELFREQ_60
@ ADE7880_SELFREQ_60
Definition: ade7880.h:758
ade7880_hphase_e
ade7880_hphase_e
ADE7880 These bits decide what phase or neutral is analyzed by the harmonic calculations block.
Definition: ade7880.h:685
ADE7816_ZSPE_MASK
#define ADE7816_ZSPE_MASK
Definition: ade7816.h:183
ADE7880_WATTACC_SIGNED_ACC
@ ADE7880_WATTACC_SIGNED_ACC
Definition: ade7880.h:621
no_os_delay.h
Header file of Delay functions.
ade7880_dev::vrms_val
uint32_t vrms_val
Definition: ade7880.h:821
ADE7880_VLEVEL_VAL
#define ADE7880_VLEVEL_VAL
Definition: ade7880.h:495
ADE7880_I2C_LOCK
#define ADE7880_I2C_LOCK
Definition: ade7880.h:478
ade7880_vtoia_e
ade7880_vtoia_e
ADE7880 These bits decide what phase voltage is considered together with Phase A current in the power...
Definition: ade7880.h:578
ade7816_desc
Definition: ade7816.h:327
ade7880_power_mode_e
ade7880_power_mode_e
ADE7880 Power mode selection.
Definition: ade7880.h:775
ADE7880_VTOIB_B
@ ADE7880_VTOIB_B
Definition: ade7880.h:594
ENABLE
#define ENABLE
Definition: ad77681.h:339
device
Definition: ad9361_util.h:69
NO_OS_GPIO_HIGH
@ NO_OS_GPIO_HIGH
Definition: no_os_gpio.h:117
no_os_print_log.h
Print messages helpers.
ade7880_remove
int ade7880_remove(struct ade7880_dev *dev)
Remove the device and release resources.
Definition: ade7880.c:467
ADE7816_MSB_REG_MASK
#define ADE7816_MSB_REG_MASK
Definition: ade7816.h:172
ade7880_hrate_e
ade7880_hrate_e
ADE7880 These bits manage the update rate of the harmonic registers.
Definition: ade7880.h:716
ADE7816_THIRD_BYTE_MASK
#define ADE7816_THIRD_BYTE_MASK
Definition: ade7816.h:175
ade7880_write
int ade7880_write(struct ade7880_dev *dev, uint16_t reg_addr, uint32_t reg_data)
Write device register.
Definition: ade7880.c:108
ADE7816_CONFIG2_REG
#define ADE7816_CONFIG2_REG
Definition: ade7816.h:168
ADE7880_PHASE_C
@ ADE7880_PHASE_C
Definition: ade7880.h:768
no_os_calloc
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
ADE7880_RMS_FS_CODES
#define ADE7880_RMS_FS_CODES
Definition: ade7880.h:502
ADE7880_ANGLESEL_V_I
@ ADE7880_ANGLESEL_V_I
Definition: ade7880.h:526
ade7880_read
int ade7880_read(struct ade7880_dev *dev, uint16_t reg_addr, uint32_t *reg_data)
Read device register.
Definition: ade7880.c:55
ADE7816_FVAROS_REG
#define ADE7816_FVAROS_REG
Definition: ade7816.h:87
ADE7880_SET_SPI_ADDR
#define ADE7880_SET_SPI_ADDR
Definition: ade7880.h:488
ADE7816_VGAIN_REG
#define ADE7816_VGAIN_REG
Definition: ade7816.h:47
ADE7880_PGAGAIN_8
@ ADE7880_PGAGAIN_8
Definition: ade7880.h:548
NO_OS_GPIO_LOW
@ NO_OS_GPIO_LOW
Definition: no_os_gpio.h:115
ade7880_vtoib_e
ade7880_vtoib_e
ADE7880 These bits decide what phase voltage is considered together with Phase B current in the power...
Definition: ade7880.h:592
ADE7880_CONSEL_3P_3W_DELTA
@ ADE7880_CONSEL_3P_3W_DELTA
Definition: ade7880.h:656
ADE7880_VARACC_SIGNED_ACC
@ ADE7880_VARACC_SIGNED_ACC
Definition: ade7880.h:636
ADE7816_MMODE_REG
#define ADE7816_MMODE_REG
Definition: ade7816.h:159
ade7880_read
int ade7880_read(struct ade7880_dev *dev, uint16_t reg_addr, uint32_t *reg_data)
Read device register.
Definition: ade7880.c:55
ADE7880_VTOIA_A
@ ADE7880_VTOIA_A
Definition: ade7880.h:580
SLEEP_MODE
@ SLEEP_MODE
Definition: ade7880.h:785
no_os_mdelay
void no_os_mdelay(uint32_t msecs)
Wait until msecs milliseconds passed.
Definition: aducm3029_delay.c:126
ADE7880_HPHASE_C
@ ADE7880_HPHASE_C
Definition: ade7880.h:691
ade7880_wattacc_e
ade7880_wattacc_e
ADE7880 These bits decide the accumulation mode of fundamental active powers.
Definition: ade7880.h:619
REDUCED_POWER_MODE
@ REDUCED_POWER_MODE
Definition: ade7880.h:781
ADE7880_HSTIM_1250
@ ADE7880_HSTIM_1250
Definition: ade7880.h:709
ade7880_anglesel_e
ade7880_anglesel_e
ADE7880 angles measurement.
Definition: ade7880.h:524
ade7880_dev::psm0_desc
struct no_os_gpio_desc * psm0_desc
Definition: ade7880.h:813
no_os_error.h
Error codes definition.
ADE7816_SECOND_BYTE_MASK
#define ADE7816_SECOND_BYTE_MASK
Definition: ade7816.h:176
ADE7880_SPI_WRITE_CMD
#define ADE7880_SPI_WRITE_CMD
Definition: ade7880.h:53
ADE7880_RAM_PROT_VAL2
#define ADE7880_RAM_PROT_VAL2
Definition: ade7880.h:487
ade7880_dev::reset_desc
struct no_os_gpio_desc * reset_desc
Definition: ade7880.h:817
ADE7880_ANGLESEL_I
@ ADE7880_ANGLESEL_I
Definition: ade7880.h:530
ADE7880_CONSEL_3P_4W_DELTA
@ ADE7880_CONSEL_3P_4W_DELTA
Definition: ade7880.h:660
ADE7880_HRATE_DISABLED
@ ADE7880_HRATE_DISABLED
Definition: ade7880.h:732
ADE7880_REG_RUN
#define ADE7880_REG_RUN
Definition: ade7880.h:117
ADE7880_CFXSEL_2
@ ADE7880_CFXSEL_2
Definition: ade7880.h:567
ADE7880_PGAGAIN_16
@ ADE7880_PGAGAIN_16
Definition: ade7880.h:550
ade7880_read_data_ph
int ade7880_read_data_ph(struct ade7880_dev *dev, enum ade7880_phase phase)
Read the power/energy for specific phase.
Definition: ade7880.c:261
ADE7880_SPI_READ_CMD
#define ADE7880_SPI_READ_CMD
Definition: ade7880.h:52
ADE7880_VTOIC_C
@ ADE7880_VTOIC_C
Definition: ade7880.h:608
ade7816_i2c_reg_read
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
ADE7880_CHIP_ID
#define ADE7880_CHIP_ID
Definition: ade7880.h:482
no_os_put_unaligned_be32
void no_os_put_unaligned_be32(uint32_t val, uint8_t *buf)
ade7880_get_int_status0
int ade7880_get_int_status0(struct ade7880_dev *dev, uint32_t msk, uint8_t *status)
Get interrupt indicator from STATUS0 register.
Definition: ade7880.c:234
ADE7880_CONSEL_3P_4W
@ ADE7880_CONSEL_3P_4W
Definition: ade7880.h:658
ade7880.h
Header file of ADE7880 Driver.
ADE7880_PHASE_B
@ ADE7880_PHASE_B
Definition: ade7880.h:767
ADE7880_HPHASE_A
@ ADE7880_HPHASE_A
Definition: ade7880.h:687
ade7880_hxfer_e
ade7880_hxfer_e
ADE7880 These bits select the data transmitted on HSDC.
Definition: ade7880.h:667
ADE7880_FS_VOLTAGE
#define ADE7880_FS_VOLTAGE
Definition: ade7880.h:514
ADE7880_ANGLESEL_V
@ ADE7880_ANGLESEL_V
Definition: ade7880.h:528
ade7880_hstime_e
ade7880_hstime_e
ADE7880 These bits decide the delay period after which, if HRCFG bit is set to 0, Bit 19 (HREADY) in ...
Definition: ade7880.h:701
ADE7880_VARACC_ABSOLUTE_ACC
@ ADE7880_VARACC_ABSOLUTE_ACC
Definition: ade7880.h:643
ADE7880_VARACC_SIGN_WATTACC
@ ADE7880_VARACC_SIGN_WATTACC
Definition: ade7880.h:641
ADE7880_PGA1
#define ADE7880_PGA1
Definition: ade7880.h:392
ADE7880_PGAGAIN_2
@ ADE7880_PGAGAIN_2
Definition: ade7880.h:544
ADE7880_HPHASE_B
@ ADE7880_HPHASE_B
Definition: ade7880.h:689
ADE7880_REG_PHSTATUS
#define ADE7880_REG_PHSTATUS
Definition: ade7880.h:162
ADE7880_CONSEL_3P_3W
@ ADE7880_CONSEL_3P_3W
Definition: ade7880.h:653
ade7880_init_param::psm0_desc
struct no_os_gpio_desc * psm0_desc
Definition: ade7880.h:796
ADE7880_ACTPHSEL_A
@ ADE7880_ACTPHSEL_A
Definition: ade7880.h:741
ADE7880_HXFER_RESERVED
@ ADE7880_HXFER_RESERVED
Definition: ade7880.h:678
ADE7880_VTOIA_B
@ ADE7880_VTOIA_B
Definition: ade7880.h:582
ADE7880_RAM_PROTECTION1
#define ADE7880_RAM_PROTECTION1
Definition: ade7880.h:484
ADE7880_RUN_ON
#define ADE7880_RUN_ON
Definition: ade7880.h:498
no_os_spi_desc
Structure holding SPI descriptor.
Definition: no_os_spi.h:192
ade7880_dev::psm1_desc
struct no_os_gpio_desc * psm1_desc
Definition: ade7880.h:815
ADE7880_REG_BIRMS
#define ADE7880_REG_BIRMS
Definition: ade7880.h:109
ade7880_varacc_e
ade7880_varacc_e
ADE7880 These bits decide the accumulation mode of funamental reactive powers.
Definition: ade7880.h:634
ade7880_dev::power_mode
uint8_t power_mode
Definition: ade7880.h:823
ADE7880_HPHASE_N
@ ADE7880_HPHASE_N
Definition: ade7880.h:693
ade7880_cfxsel_e
ade7880_cfxsel_e
ADE7880 These bits indicate the value the CFx frequency is proportional to.
Definition: ade7880.h:558
ade7880_get_int_status0
int ade7880_get_int_status0(struct ade7880_dev *dev, uint32_t msk, uint8_t *status)
Get interrupt indicator from STATUS0 register.
Definition: ade7880.c:234
ADE7880_VTOIC_B
@ ADE7880_VTOIC_B
Definition: ade7880.h:612
no_os_gpio_desc
Structure holding the GPIO descriptor.
Definition: no_os_gpio.h:96
ADE7880_ACTPHSEL_RESERVED
@ ADE7880_ACTPHSEL_RESERVED
Definition: ade7880.h:747
ADE7880_VARACC_RESERVED
@ ADE7880_VARACC_RESERVED
Definition: ade7880.h:638
ade7880_consel_e
ade7880_consel_e
ADE7880 These bits select the inputs to the energy accumulation registers. IA’, IB’,...
Definition: ade7880.h:651
ADE7880_HRATE_0_9765625
@ ADE7880_HRATE_0_9765625
Definition: ade7880.h:730
ade7880_dev::irms_val
uint32_t irms_val
Definition: ade7880.h:819
no_os_i2c_read
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
ADE7880_HXFER_9
@ ADE7880_HXFER_9
Definition: ade7880.h:676
ADE7880_PHASE_A
@ ADE7880_PHASE_A
Definition: ade7880.h:766
ADE7880_SELFREQ_50
@ ADE7880_SELFREQ_50
Definition: ade7880.h:756
no_os_i2c.h
Header file of I2C Interface.
ADE7880_WATTACC_ABSOLUTE_ACC
@ ADE7880_WATTACC_ABSOLUTE_ACC
Definition: ade7880.h:627
ADE7880_HSTIM_500
@ ADE7880_HSTIM_500
Definition: ade7880.h:703
ADE7816_CHSTATUS_REG
#define ADE7816_CHSTATUS_REG
Definition: ade7816.h:143
ADE7880_RESET_RECOVER
#define ADE7880_RESET_RECOVER
Definition: ade7880.h:483
ADE7880_VTOIB_A
@ ADE7880_VTOIB_A
Definition: ade7880.h:598
no_os_field_get
uint32_t no_os_field_get(uint32_t mask, uint32_t word)
ADE7880_REG_MMODE
#define ADE7880_REG_MMODE
Definition: ade7880.h:180
ade7880_init_param::reset_desc
struct no_os_gpio_desc * reset_desc
Definition: ade7880.h:800
LOW_POWER_MODE
@ LOW_POWER_MODE
Definition: ade7880.h:783
ade7880_init_param::psm1_desc
struct no_os_gpio_desc * psm1_desc
Definition: ade7880.h:798
ADE7880_REG_LAST_RWDATA16
#define ADE7880_REG_LAST_RWDATA16
Definition: ade7880.h:233
ADE7880_REG_BVRMS
#define ADE7880_REG_BVRMS
Definition: ade7880.h:110
ade7880_setup
int ade7880_setup(struct ade7880_dev *dev)
Setup the device.
Definition: ade7880.c:410
ade7880_actphsel_e
ade7880_actphsel_e
ADE7880 These bits select the phase voltage used as time base for harmonic calculations.
Definition: ade7880.h:739
no_os_free
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
ade7816_i2c_reg_write
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
ade7880_freq_sel_e
ade7880_freq_sel_e
ADE7880 Freq value.
Definition: ade7880.h:754
ADE7880_REG_CFMODE
#define ADE7880_REG_CFMODE
Definition: ade7880.h:171
ADE7880_REG_AIRMS
#define ADE7880_REG_AIRMS
Definition: ade7880.h:107
ADE7880_REG_VLEVEL
#define ADE7880_REG_VLEVEL
Definition: ade7880.h:82
ade7880_pga_gain_e
ade7880_pga_gain_e
ADE7880 phase currents/neutral current/phase voltages gain selection is currently being used.
Definition: ade7880.h:540
ade7880_setup
int ade7880_setup(struct ade7880_dev *dev)
Setup the device.
Definition: ade7880.c:410
ade7880_read_data_ph
int ade7880_read_data_ph(struct ade7880_dev *dev, enum ade7880_phase phase)
Read the power/energy for specific phase.
Definition: ade7880.c:261
ade7816_spi_reg_write
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
ade7880_init_param::power_mode
uint8_t power_mode
Definition: ade7880.h:802
ADE7880_HRATE_8K
@ ADE7880_HRATE_8K
Definition: ade7880.h:718
ADE7880_HRATE_4K
@ ADE7880_HRATE_4K
Definition: ade7880.h:720
ADE7816_FOURTH_BYTE_MASK
#define ADE7816_FOURTH_BYTE_MASK
Definition: ade7816.h:174
ADE7880_HRATE_1_953125
@ ADE7880_HRATE_1_953125
Definition: ade7880.h:728
ade7880_write
int ade7880_write(struct ade7880_dev *dev, uint16_t reg_addr, uint32_t reg_data)
Write device register.
Definition: ade7880.c:108
ADE7880_VOLTAGE_TR_FCN
#define ADE7880_VOLTAGE_TR_FCN
Definition: ade7880.h:511
no_os_gpio_set_value
int32_t no_os_gpio_set_value(struct no_os_gpio_desc *desc, uint8_t value)
Set the value of the specified GPIO.
Definition: no_os_gpio.c:197
no_os_get_unaligned_be32
uint32_t no_os_get_unaligned_be32(uint8_t *buf)
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
ADE7880_SELFREQ
#define ADE7880_SELFREQ
Definition: ade7880.h:374
ade7880_set_power_mode
int ade7880_set_power_mode(struct ade7880_dev *dev)
Set power mode.
Definition: ade7880.c:148
ADE7880_NO_ANGLESEL
@ ADE7880_NO_ANGLESEL
Definition: ade7880.h:532
ade7880_update_bits
int ade7880_update_bits(struct ade7880_dev *dev, uint16_t reg_addr, uint32_t mask, uint32_t reg_data)
Update specific register bits.
Definition: ade7880.c:207
ADE7880_REG_AVRMS
#define ADE7880_REG_AVRMS
Definition: ade7880.h:108
no_os_spi_remove
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
ade7880_set_power_mode
int ade7880_set_power_mode(struct ade7880_dev *dev)
Set power mode.
Definition: ade7880.c:148
no_os_gpio.h
Header file of GPIO Interface.
ade7880_init
int ade7880_init(struct ade7880_dev **device, struct ade7880_init_param init_param)
Initialize the device.
Definition: ade7880.c:322
ADE7880_REG_CONFIG2
#define ADE7880_REG_CONFIG2
Definition: ade7880.h:243
ADE7880_PGAGAIN_4
@ ADE7880_PGAGAIN_4
Definition: ade7880.h:546
ADE7880_REG_CVRMS
#define ADE7880_REG_CVRMS
Definition: ade7880.h:112
NORMAL_MODE
@ NORMAL_MODE
Definition: ade7880.h:778
no_os_spi_init
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
no_os_get_unaligned_be16
uint16_t no_os_get_unaligned_be16(uint8_t *buf)
ade7880_init_param
ADE7880 Device initialization parameters.
Definition: ade7880.h:792
ADE7880_WATTACC_RESERVED
@ ADE7880_WATTACC_RESERVED
Definition: ade7880.h:625
no_os_util.h
Header file of utility functions.
no_os_find_first_set_bit
uint32_t no_os_find_first_set_bit(uint32_t word)
ADE7880_ACTPHSEL_C
@ ADE7880_ACTPHSEL_C
Definition: ade7880.h:745
no_os_sign_extend32
int32_t no_os_sign_extend32(uint32_t value, int index)
ade7880_phase
ade7880_phase
ADE7880 available phases.
Definition: ade7880.h:765
ADE7880_DUMB_VAL
#define ADE7880_DUMB_VAL
Definition: ade7880.h:489
ADE7880_CFXSEL_1
@ ADE7880_CFXSEL_1
Definition: ade7880.h:564
ADE7816_VARNOLOAD_REG
#define ADE7816_VARNOLOAD_REG
Definition: ade7816.h:94
ADE7880_REG_COMPMODE
#define ADE7880_REG_COMPMODE
Definition: ade7880.h:169
ADE7880_HXFER_16
@ ADE7880_HXFER_16
Definition: ade7880.h:670
no_os_test_bit
int no_os_test_bit(int pos, const volatile void *addr)
Definition: no_os_util.h:132
ADE7880_PGA2
#define ADE7880_PGA2
Definition: ade7880.h:391
ADE7880_CFXSEL_0
@ ADE7880_CFXSEL_0
Definition: ade7880.h:561
ADE7880_DICOEFF
#define ADE7880_DICOEFF
Definition: ade7880.h:494
ADE7880_REG_CONFIG
#define ADE7880_REG_CONFIG
Definition: ade7880.h:179
ADE7880_CURRENT_TR_FCN
#define ADE7880_CURRENT_TR_FCN
Definition: ade7880.h:507
errno.h
Error macro definition for ARM Compiler.
ade7816_spi_reg_read
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
chip_id
chip_id
Definition: ad9172.h:51
no_os_spi_init_param
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:140