Go to the documentation of this file.
52 #define ADE7880_SPI_READ_CMD 0x01
53 #define ADE7880_SPI_WRITE_CMD 0x00
56 #define DISABLE 0x0000
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
117 #define ADE7880_REG_RUN 0xE228
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
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
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
407 #define ADE7880_PHCALVAL NO_OS_GENMASK(9, 0)
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)
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)
433 #define ADE7880_PEAKSEL2 NO_OS_BIT(4)
434 #define ADE7880_PEAKSEL1 NO_OS_BIT(3)
435 #define ADE7880_PEAKSEL0 NO_OS_BIT(2)
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)
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)
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)
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)
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)
474 #define ADE7880_LPLINE NO_OS_GENMASK(7, 3)
475 #define ADE7880_LPOIL NO_OS_GENMASK(2, 0)
478 #define ADE7880_I2C_LOCK NO_OS_BIT(1)
479 #define ADE7880_EXTREFEN NO_OS_BIT(0)
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
494 #define ADE7880_DICOEFF 0x00000000
495 #define ADE7880_VLEVEL_VAL 0x007A1200
498 #define ADE7880_RUN_ON 0x0001
502 #define ADE7880_RMS_FS_CODES 5326737
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)
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)
514 #define ADE7880_FS_VOLTAGE 3535
843 uint32_t mask, uint32_t reg_data);
862 #endif // __ADE7880_H__
#define ADE7880_REG_CIRMS
Definition: ade7880.h:111
#define ADE7880_REG_HCONFIG
Definition: ade7880.h:222
@ ADE7880_HXFER_7
Definition: ade7880.h:673
#define ADE7880_RAM_PROTECTION2
Definition: ade7880.h:485
@ ADE7880_ACTPHSEL_B
Definition: ade7880.h:743
struct no_os_spi_desc * spi_desc
Definition: ade7880.h:811
void no_os_put_unaligned_be16(uint16_t val, uint8_t *buf)
#define ADE7880_REG_CONFIG3
Definition: ade7880.h:234
@ ADE7880_WATTACC_POSITIVE_ACC
Definition: ade7880.h:623
#define ADE7880_RAM_PROT_VAL1
Definition: ade7880.h:486
@ ADE7880_HRATE_62_5
Definition: ade7880.h:724
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
Definition: ade7880.h:726
@ ADE7880_HRATE_1K
Definition: ade7880.h:722
ADE7880 Device structure.
Definition: ade7880.h:809
#define ADE7880_REG_LAST_RWDATA8
Definition: ade7880.h:189
@ ADE7880_HSTIM_1000
Definition: ade7880.h:707
@ ADE7880_VTOIC_A
Definition: ade7880.h:610
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
#define ADE7880_REG_STATUS0
Definition: ade7880.h:136
struct no_os_spi_init_param * spi_init
Definition: ade7880.h:794
@ ADE7880_PGAGAIN_1
Definition: ade7880.h:542
Header file of ADE7816 Driver.
#define ADE7880_REG_GAIN
Definition: ade7880.h:170
#define ADE7816_FIRST_BYTE_MASK
Definition: ade7816.h:177
#define ADE7880_REG_DICOEFF
Definition: ade7880.h:66
#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
@ ADE7880_VTOIB_C
Definition: ade7880.h:596
@ ADE7880_HSTIM_700
Definition: ade7880.h:705
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
int ade7880_remove(struct ade7880_dev *dev)
Remove the device and release resources.
Definition: ade7880.c:467
Header file of SPI Interface.
@ ADE7880_CFXSEL_3
Definition: ade7880.h:570
#define ADE7816_LSB_REG_MASK
Definition: ade7816.h:171
struct no_os_spi_desc * spi_desc
Definition: ade7816.h:328
int ade7880_init(struct ade7880_dev **device, struct ade7880_init_param init_param)
Initialize the device.
Definition: ade7880.c:322
@ ADE7880_VTOIA_C
Definition: ade7880.h:584
struct no_os_i2c_desc * i2c_desc
Definition: ade7816.h:329
#define ADE7880_PGA3
Definition: ade7880.h:390
#define pr_err(fmt, args...)
Definition: no_os_print_log.h:88
@ ADE7880_SELFREQ_60
Definition: ade7880.h:758
ade7880_hphase_e
ADE7880 These bits decide what phase or neutral is analyzed by the harmonic calculations block.
Definition: ade7880.h:685
#define ADE7816_ZSPE_MASK
Definition: ade7816.h:183
@ ADE7880_WATTACC_SIGNED_ACC
Definition: ade7880.h:621
Header file of Delay functions.
uint32_t vrms_val
Definition: ade7880.h:821
#define ADE7880_VLEVEL_VAL
Definition: ade7880.h:495
#define ADE7880_I2C_LOCK
Definition: ade7880.h:478
ade7880_vtoia_e
ADE7880 These bits decide what phase voltage is considered together with Phase A current in the power...
Definition: ade7880.h:578
Definition: ade7816.h:327
ade7880_power_mode_e
ADE7880 Power mode selection.
Definition: ade7880.h:775
@ ADE7880_VTOIB_B
Definition: ade7880.h:594
#define ENABLE
Definition: ad77681.h:339
Definition: ad9361_util.h:69
@ NO_OS_GPIO_HIGH
Definition: no_os_gpio.h:117
int ade7880_remove(struct ade7880_dev *dev)
Remove the device and release resources.
Definition: ade7880.c:467
#define ADE7816_MSB_REG_MASK
Definition: ade7816.h:172
ade7880_hrate_e
ADE7880 These bits manage the update rate of the harmonic registers.
Definition: ade7880.h:716
#define ADE7816_THIRD_BYTE_MASK
Definition: ade7816.h:175
int ade7880_write(struct ade7880_dev *dev, uint16_t reg_addr, uint32_t reg_data)
Write device register.
Definition: ade7880.c:108
#define ADE7816_CONFIG2_REG
Definition: ade7816.h:168
@ ADE7880_PHASE_C
Definition: ade7880.h:768
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
#define ADE7880_RMS_FS_CODES
Definition: ade7880.h:502
@ ADE7880_ANGLESEL_V_I
Definition: ade7880.h:526
int ade7880_read(struct ade7880_dev *dev, uint16_t reg_addr, uint32_t *reg_data)
Read device register.
Definition: ade7880.c:55
#define ADE7816_FVAROS_REG
Definition: ade7816.h:87
#define ADE7880_SET_SPI_ADDR
Definition: ade7880.h:488
#define ADE7816_VGAIN_REG
Definition: ade7816.h:47
@ ADE7880_PGAGAIN_8
Definition: ade7880.h:548
@ NO_OS_GPIO_LOW
Definition: no_os_gpio.h:115
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
Definition: ade7880.h:656
@ ADE7880_VARACC_SIGNED_ACC
Definition: ade7880.h:636
#define ADE7816_MMODE_REG
Definition: ade7816.h:159
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
Definition: ade7880.h:580
@ SLEEP_MODE
Definition: ade7880.h:785
void no_os_mdelay(uint32_t msecs)
Wait until msecs milliseconds passed.
Definition: aducm3029_delay.c:126
@ ADE7880_HPHASE_C
Definition: ade7880.h:691
ade7880_wattacc_e
ADE7880 These bits decide the accumulation mode of fundamental active powers.
Definition: ade7880.h:619
@ REDUCED_POWER_MODE
Definition: ade7880.h:781
@ ADE7880_HSTIM_1250
Definition: ade7880.h:709
ade7880_anglesel_e
ADE7880 angles measurement.
Definition: ade7880.h:524
struct no_os_gpio_desc * psm0_desc
Definition: ade7880.h:813
#define ADE7816_SECOND_BYTE_MASK
Definition: ade7816.h:176
#define ADE7880_SPI_WRITE_CMD
Definition: ade7880.h:53
#define ADE7880_RAM_PROT_VAL2
Definition: ade7880.h:487
struct no_os_gpio_desc * reset_desc
Definition: ade7880.h:817
@ ADE7880_ANGLESEL_I
Definition: ade7880.h:530
@ ADE7880_CONSEL_3P_4W_DELTA
Definition: ade7880.h:660
@ ADE7880_HRATE_DISABLED
Definition: ade7880.h:732
#define ADE7880_REG_RUN
Definition: ade7880.h:117
@ ADE7880_CFXSEL_2
Definition: ade7880.h:567
@ ADE7880_PGAGAIN_16
Definition: ade7880.h:550
int ade7880_read_data_ph(struct ade7880_dev *dev, enum ade7880_phase phase)
Read the power/energy for specific phase.
Definition: ade7880.c:261
#define ADE7880_SPI_READ_CMD
Definition: ade7880.h:52
@ ADE7880_VTOIC_C
Definition: ade7880.h:608
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
#define ADE7880_CHIP_ID
Definition: ade7880.h:482
void no_os_put_unaligned_be32(uint32_t val, uint8_t *buf)
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
Definition: ade7880.h:658
Header file of ADE7880 Driver.
@ ADE7880_PHASE_B
Definition: ade7880.h:767
@ ADE7880_HPHASE_A
Definition: ade7880.h:687
ade7880_hxfer_e
ADE7880 These bits select the data transmitted on HSDC.
Definition: ade7880.h:667
#define ADE7880_FS_VOLTAGE
Definition: ade7880.h:514
@ ADE7880_ANGLESEL_V
Definition: ade7880.h:528
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
Definition: ade7880.h:643
@ ADE7880_VARACC_SIGN_WATTACC
Definition: ade7880.h:641
#define ADE7880_PGA1
Definition: ade7880.h:392
@ ADE7880_PGAGAIN_2
Definition: ade7880.h:544
@ ADE7880_HPHASE_B
Definition: ade7880.h:689
#define ADE7880_REG_PHSTATUS
Definition: ade7880.h:162
@ ADE7880_CONSEL_3P_3W
Definition: ade7880.h:653
struct no_os_gpio_desc * psm0_desc
Definition: ade7880.h:796
@ ADE7880_ACTPHSEL_A
Definition: ade7880.h:741
@ ADE7880_HXFER_RESERVED
Definition: ade7880.h:678
@ ADE7880_VTOIA_B
Definition: ade7880.h:582
#define ADE7880_RAM_PROTECTION1
Definition: ade7880.h:484
#define ADE7880_RUN_ON
Definition: ade7880.h:498
Structure holding SPI descriptor.
Definition: no_os_spi.h:192
struct no_os_gpio_desc * psm1_desc
Definition: ade7880.h:815
#define ADE7880_REG_BIRMS
Definition: ade7880.h:109
ade7880_varacc_e
ADE7880 These bits decide the accumulation mode of funamental reactive powers.
Definition: ade7880.h:634
uint8_t power_mode
Definition: ade7880.h:823
@ ADE7880_HPHASE_N
Definition: ade7880.h:693
ade7880_cfxsel_e
ADE7880 These bits indicate the value the CFx frequency is proportional to.
Definition: ade7880.h:558
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
Definition: ade7880.h:612
Structure holding the GPIO descriptor.
Definition: no_os_gpio.h:96
@ ADE7880_ACTPHSEL_RESERVED
Definition: ade7880.h:747
@ ADE7880_VARACC_RESERVED
Definition: ade7880.h:638
ade7880_consel_e
ADE7880 These bits select the inputs to the energy accumulation registers. IA’, IB’,...
Definition: ade7880.h:651
@ ADE7880_HRATE_0_9765625
Definition: ade7880.h:730
uint32_t irms_val
Definition: ade7880.h:819
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
Definition: ade7880.h:676
@ ADE7880_PHASE_A
Definition: ade7880.h:766
@ ADE7880_SELFREQ_50
Definition: ade7880.h:756
Header file of I2C Interface.
@ ADE7880_WATTACC_ABSOLUTE_ACC
Definition: ade7880.h:627
@ ADE7880_HSTIM_500
Definition: ade7880.h:703
#define ADE7816_CHSTATUS_REG
Definition: ade7816.h:143
#define ADE7880_RESET_RECOVER
Definition: ade7880.h:483
@ ADE7880_VTOIB_A
Definition: ade7880.h:598
uint32_t no_os_field_get(uint32_t mask, uint32_t word)
#define ADE7880_REG_MMODE
Definition: ade7880.h:180
struct no_os_gpio_desc * reset_desc
Definition: ade7880.h:800
@ LOW_POWER_MODE
Definition: ade7880.h:783
struct no_os_gpio_desc * psm1_desc
Definition: ade7880.h:798
#define ADE7880_REG_LAST_RWDATA16
Definition: ade7880.h:233
#define ADE7880_REG_BVRMS
Definition: ade7880.h:110
int ade7880_setup(struct ade7880_dev *dev)
Setup the device.
Definition: ade7880.c:410
ade7880_actphsel_e
ADE7880 These bits select the phase voltage used as time base for harmonic calculations.
Definition: ade7880.h:739
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
ade7880_freq_sel_e
ADE7880 Freq value.
Definition: ade7880.h:754
#define ADE7880_REG_CFMODE
Definition: ade7880.h:171
#define ADE7880_REG_AIRMS
Definition: ade7880.h:107
#define ADE7880_REG_VLEVEL
Definition: ade7880.h:82
ade7880_pga_gain_e
ADE7880 phase currents/neutral current/phase voltages gain selection is currently being used.
Definition: ade7880.h:540
int ade7880_setup(struct ade7880_dev *dev)
Setup the device.
Definition: ade7880.c:410
int ade7880_read_data_ph(struct ade7880_dev *dev, enum ade7880_phase phase)
Read the power/energy for specific phase.
Definition: ade7880.c:261
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
uint8_t power_mode
Definition: ade7880.h:802
@ ADE7880_HRATE_8K
Definition: ade7880.h:718
@ ADE7880_HRATE_4K
Definition: ade7880.h:720
#define ADE7816_FOURTH_BYTE_MASK
Definition: ade7816.h:174
@ ADE7880_HRATE_1_953125
Definition: ade7880.h:728
int ade7880_write(struct ade7880_dev *dev, uint16_t reg_addr, uint32_t reg_data)
Write device register.
Definition: ade7880.c:108
#define ADE7880_VOLTAGE_TR_FCN
Definition: ade7880.h:511
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
uint32_t no_os_get_unaligned_be32(uint8_t *buf)
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
#define ADE7880_SELFREQ
Definition: ade7880.h:374
int ade7880_set_power_mode(struct ade7880_dev *dev)
Set power mode.
Definition: ade7880.c:148
@ ADE7880_NO_ANGLESEL
Definition: ade7880.h:532
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
#define ADE7880_REG_AVRMS
Definition: ade7880.h:108
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 ade7880_set_power_mode(struct ade7880_dev *dev)
Set power mode.
Definition: ade7880.c:148
Header file of GPIO Interface.
int ade7880_init(struct ade7880_dev **device, struct ade7880_init_param init_param)
Initialize the device.
Definition: ade7880.c:322
#define ADE7880_REG_CONFIG2
Definition: ade7880.h:243
@ ADE7880_PGAGAIN_4
Definition: ade7880.h:546
#define ADE7880_REG_CVRMS
Definition: ade7880.h:112
@ NORMAL_MODE
Definition: ade7880.h:778
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)
ADE7880 Device initialization parameters.
Definition: ade7880.h:792
@ ADE7880_WATTACC_RESERVED
Definition: ade7880.h:625
Header file of utility functions.
uint32_t no_os_find_first_set_bit(uint32_t word)
@ ADE7880_ACTPHSEL_C
Definition: ade7880.h:745
int32_t no_os_sign_extend32(uint32_t value, int index)
ade7880_phase
ADE7880 available phases.
Definition: ade7880.h:765
#define ADE7880_DUMB_VAL
Definition: ade7880.h:489
@ ADE7880_CFXSEL_1
Definition: ade7880.h:564
#define ADE7816_VARNOLOAD_REG
Definition: ade7816.h:94
#define ADE7880_REG_COMPMODE
Definition: ade7880.h:169
@ ADE7880_HXFER_16
Definition: ade7880.h:670
int no_os_test_bit(int pos, const volatile void *addr)
Definition: no_os_util.h:132
#define ADE7880_PGA2
Definition: ade7880.h:391
@ ADE7880_CFXSEL_0
Definition: ade7880.h:561
#define ADE7880_DICOEFF
Definition: ade7880.h:494
#define ADE7880_REG_CONFIG
Definition: ade7880.h:179
#define ADE7880_CURRENT_TR_FCN
Definition: ade7880.h:507
Error macro definition for ARM Compiler.
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
Definition: ad9172.h:51
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:140