no-OS
ade7816.h
Go to the documentation of this file.
1 /***************************************************************************/
33 #ifndef __ADE7816_H__
34 #define __ADE7816_H__
35 
36 #include <stdbool.h>
37 #include <stdint.h>
38 #include <string.h>
39 #include <stdio.h>
40 #include "no_os_util.h"
41 #include "no_os_spi.h"
42 #include "no_os_gpio.h"
43 #include "no_os_irq.h"
44 #include "no_os_error.h"
45 #include "no_os_i2c.h"
46 
47 #define ADE7816_VGAIN_REG 0x4380
48 #define ADE7816_IAGAIN_REG 0x4381
49 #define ADE7816_IBGAIN_REG 0x4382
50 #define ADE7816_ICGAIN_REG 0x4383
51 #define ADE7816_IDGAIN_REG 0x4384
52 #define ADE7816_IEGAIN_REG 0x4385
53 #define ADE7816_IFGAIN_REG 0x4386
54 
55 #define ADE7816_DICOEFF_REG 0x4388
56 #define ADE7816_HPFDIS_REG 0x4389
57 #define ADE7816_VRMSOS_REG 0x438A
58 #define ADE7816_IARMSOS_REG 0x438B
59 #define ADE7816_IBRMSOS_REG 0x438C
60 #define ADE7816_ICRMSOS_REG 0x438D
61 #define ADE7816_IDRMSOS_REG 0x438E
62 #define ADE7816_IERMSOS_REG 0x438F
63 #define ADE7816_IFRMSOS_REG 0x4390
64 #define ADE7816_AWGAIN_REG 0x4391
65 #define ADE7816_AWATTOS_REG 0x4392
66 #define ADE7816_BWGAIN_REG 0x4393
67 #define ADE7816_BWATTOS_REG 0x4394
68 #define ADE7816_CWGAIN_REG 0x4395
69 #define ADE7816_CWATTOS_REG 0x4396
70 #define ADE7816_DWGAIN_REG 0x4397
71 #define ADE7816_DWATTOS_REG 0x4398
72 #define ADE7816_EWGAIN_REG 0x4399
73 #define ADE7816_EWATTOS_REG 0x439A
74 #define ADE7816_FWGAIN_REG 0x439B
75 #define ADE7816_FWATTOS_REG 0x439C
76 #define ADE7816_AVARGAIN_REG 0x439D
77 #define ADE7816_AVAROS_REG 0x439E
78 #define ADE7816_BVARGAIN_REG 0x439F
79 #define ADE7816_BVAROS_REG 0x43A0
80 #define ADE7816_CVARGAIN_REG 0x43A1
81 #define ADE7816_CVAROS_REG 0x43A2
82 #define ADE7816_DVARGAIN_REG 0x43A3
83 #define ADE7816_DVAROS_REG 0x43A4
84 #define ADE7816_EVARGAIN_REG 0x43A5
85 #define ADE7816_EVAROS_REG 0x43A6
86 #define ADE7816_FVARGAIN_REG 0x43A7
87 #define ADE7816_FVAROS_REG 0x43A8
88 
89 #define ADE7816_WTHR1_REG 0x43AB
90 #define ADE7816_WTHR0_REG 0x43AC
91 #define ADE7816_VARTHR1_REG 0x43AD
92 #define ADE7816_VARTHR0_REG 0x43AE
93 #define ADE7816_APNOLOAD_REG 0x43AF
94 #define ADE7816_VARNOLOAD_REG 0x43B0
95 #define ADE7816_PCF_A_COEFF_REG 0x43B1
96 #define ADE7816_PCF_B_COEFF_REG 0x43B3
97 #define ADE7816_PCF_C_COEFF_REG 0x43B4
98 #define ADE7816_PCF_D_COEFF_REG 0x43B5
99 #define ADE7816_PCF_E_COEFF_REG 0x43B6
100 #define ADE7816_PCF_F_COEFF_REG 0x43B7
101 
102 #define ADE7816_VRMS_REG 0x43C0
103 #define ADE7816_IARMS_REG 0x43C1
104 #define ADE7816_IBRMS_REG 0x43C2
105 #define ADE7816_ICRMS_REG 0x43C3
106 #define ADE7816_IDRMS_REG 0x43C4
107 #define ADE7816_IERMS_REG 0x43C5
108 #define ADE7816_IFRMS_REG 0x43C6
109 
110 #define ADE7816_RUN_REG 0xE228
111 
112 #define ADE7816_AWATTHR_REG 0xE400
113 #define ADE7816_BWATTHR_REG 0xE401
114 #define ADE7816_CWATTHR_REG 0xE402
115 #define ADE7816_DWATTHR_REG 0xE403
116 #define ADE7816_EWATTHR_REG 0xE404
117 #define ADE7816_FWATTHR_REG 0xE405
118 #define ADE7816_AVARHR_REG 0xE406
119 #define ADE7816_BVARHR_REG 0xE407
120 #define ADE7816_CVARHR_REG 0xE408
121 #define ADE7816_DVARHR_REG 0xE409
122 #define ADE7816_EVARHR_REG 0xE40A
123 #define ADE7816_FVARHR_REG 0xE40B
124 
125 #define ADE7816_IPEAK_REG 0xE500
126 #define ADE7816_VPEAK_REG 0xE501
127 #define ADE7816_STATUS0_REG 0xE502
128 #define ADE7816_STATUS1_REG 0xE503
129 
130 #define ADE7816_OIVL_REG 0xE507
131 #define ADE7816_OVLVL_REG 0xE508
132 #define ADE7816_SAGLVL_REG 0xE509
133 #define ADE7816_MASK0_REG 0xE50A
134 #define ADE7816_MASK1_REG 0xE50B
135 #define ADE7816_IAVW_IDVW_REG 0xE50C
136 #define ADE7816_IBVW_IEVW_REG 0xE50D
137 #define ADE7816_ICVW_IFVW_REG 0xE50E
138 
139 #define ADE7816_VWV_REG 0xE510
140 
141 #define ADE7816_CHECKSUM_REG 0xE51F
142 
143 #define ADE7816_CHSTATUS_REG 0xE600
144 #define ADE7816_ANGLE0_REG 0xE601
145 #define ADE7816_ANGLE1_REG 0xE602
146 #define ADE7816_ANGLE2_REG 0xE603
147 
148 #define ADE7816_PERIOD_REG 0xE607
149 #define ADE7816_CHNOLOAD_REG 0xE608
150 
151 #define ADE7816_LINECYC_REG 0xE60C
152 #define ADE7816_ZXTOUT_REG 0xE60D
153 #define ADE7816_COMPMODE_REG 0xE60E
154 #define ADE7816_GAIN_REG 0xE60F
155 
156 #define ADE7816_CHSIGN_REG 0xE617
157 #define ADE7816_CONFIG_REG 0xE618
158 
159 #define ADE7816_MMODE_REG 0xE700
160 #define ADE7816_ACCMODE_REG 0xE701
161 #define ADE7816_LCYCMODE_REG 0xE702
162 #define ADE7816_PEAKCYC_REG 0xE703
163 #define ADE7816_SAGCYC_REG 0xE704
164 
165 #define ADE7816_HSDC_CFG_REG 0xE706
166 #define ADE7816_VERSION_REG 0xE707
167 
168 #define ADE7816_CONFIG2_REG 0xEC01
169 
170 //MASK MACROS
171 #define ADE7816_LSB_REG_MASK NO_OS_GENMASK(7, 0)
172 #define ADE7816_MSB_REG_MASK NO_OS_GENMASK(15, 8)
173 
174 #define ADE7816_FOURTH_BYTE_MASK NO_OS_GENMASK(31, 24)
175 #define ADE7816_THIRD_BYTE_MASK NO_OS_GENMASK(23, 16)
176 #define ADE7816_SECOND_BYTE_MASK NO_OS_GENMASK(15, 8)
177 #define ADE7816_FIRST_BYTE_MASK NO_OS_GENMASK(7, 0)
178 
179 #define ADE7816_SWRST_MASK NO_OS_BIT(7)
180 
181 #define ADE7816_I2C_LOCK_MASK NO_OS_BIT(1)
182 
183 #define ADE7816_ZSPE_MASK NO_OS_GENMASK(27, 0)
184 
185 #define ADE7816_THR_MSB_MASK NO_OS_GENMASK(31, 24)
186 #define ADE7816_THR_LSB_MASK NO_OS_GENMASK(23, 0)
187 
188 #define ADE7816_RSTREAD_MASK NO_OS_BIT(6)
189 
190 #define ADE7816_LMASK NO_OS_GENMASK(1, 0)
191 #define ADE7816_ZX_SEL_MASK NO_OS_BIT(3)
192 
193 #define ADE7816_LENERGY_MASK NO_OS_BIT(5)
194 
195 #define ADE7816_CHANNEL_SEL_MASK NO_OS_BIT(14)
196 
197 #define ADE7816_DREADY_MASK NO_OS_BIT(17)
198 
199 #define ADE7816_MMODE_MASK NO_OS_GENMASK(4, 2)
200 
201 #define ADE7816_REVSEL_MASK NO_OS_GENMASK(7, 6)
202 
203 #define ADE7816_ANGLESEL_MASK NO_OS_GENMASK(10, 9)
204 
205 #define ADE7816_SIGN_MASK(x) (((x) > 3) ? ((x) - 4) : (x))
206 
207 #define ADE7816_INT_MASK(x) NO_OS_BIT(x)
208 
209 #define ADE7816_INIT_DELAY 40
210 #define ADE7816_HWRST_DELAY 10
211 
212 #define ADE7816_LINECYC_VAL(enable) ((enable) ? 0x11 : 0x00)
213 
214 #define ADE7816_CHECKSUM_VAL 0x33666787
215 
219 };
220 
229 };
230 
235 };
236 
241 };
242 
246 };
247 
277 };
278 
284 };
285 
287  ADE7816_PCF_50HZ = 0x400CA4,
288  ADE7816_PCF_60HZ = 0x401235,
289 };
290 
291 struct ade7816_desc;
292 
293 typedef int (*ade7816_reg_read)(struct ade7816_desc *desc, uint16_t reg,
294  uint32_t *val);
295 typedef int (*ade7816_reg_write)(struct ade7816_desc *desc, uint16_t reg,
296  uint32_t val);
297 
305 
307 
310 
311  uint32_t irq0_priority;
312  uint32_t irq1_priority;
313 
314  void *handle_irq0;
315  void *handle_irq1;
316 
317  /* External callback used to handle interrupt routine for GPIO
318  * IRQ0/IRQ1.
319  *
320  * Setting one of it to NULL means driver defined callback is used for
321  * it.
322  */
323  void (*irq0_callback)(void *context);
324  void (*irq1_callback)(void *context);
325 };
326 
327 struct ade7816_desc {
330 
338 
341 
345 
346  uint32_t status0;
347  uint32_t status1;
348 
350 };
351 
353 int ade7816_spi_reg_read(struct ade7816_desc *desc, uint16_t reg,
354  uint32_t *val);
355 
357 int ade7816_spi_reg_write(struct ade7816_desc *desc, uint16_t reg,
358  uint32_t val);
359 
361 int ade7816_i2c_reg_read(struct ade7816_desc *desc, uint16_t reg,
362  uint32_t *val);
363 
365 int ade7816_i2c_reg_write(struct ade7816_desc *desc, uint16_t reg,
366  uint32_t val);
367 
369 int ade7816_read_reg(struct ade7816_desc *desc, uint16_t reg, uint32_t *val);
370 
372 int ade7816_write_reg(struct ade7816_desc *desc, uint16_t reg, uint32_t val);
373 
375 int ade7816_reg_update(struct ade7816_desc *desc, uint16_t reg, uint32_t mask,
376  uint32_t val);
377 
379 int ade7816_sw_reset(struct ade7816_desc *desc);
380 
382 int ade7816_hw_reset(struct ade7816_desc *desc);
383 
385 int ade7816_set_comm(struct ade7816_desc *desc, enum ade7816_comm_type type);
386 
389  enum ade7816_channel chan, int32_t *val);
390 
392 int ade7816_set_active_thr(struct ade7816_desc *desc, uint16_t freq);
393 
395 int ade7816_get_active_thr(struct ade7816_desc *desc, uint16_t *freq);
396 
399  enum ade7816_channel chan, int32_t *val);
400 
402 int ade7816_set_reactive_thr(struct ade7816_desc *desc, uint16_t freq);
403 
405 int ade7816_get_reactive_thr(struct ade7816_desc *desc, uint16_t *freq);
406 
408 int ade7816_set_lcycle_mode(struct ade7816_desc *desc, bool enable,
409  uint16_t cycles, bool lenergy);
410 
412 int ade7816_read_rms(struct ade7816_desc *desc, enum ade7816_channel chan,
413  uint32_t *rms);
414 
416 int ade7816_set_no_load(struct ade7816_desc *desc, uint16_t voltage,
417  uint16_t current, bool enable);
418 
420 int ade7816_set_gain(struct ade7816_desc *desc, enum ade7816_channel chan,
421  int16_t scale, enum ade7816_gain_type gain);
422 
424 int ade7816_get_gain(struct ade7816_desc *desc, enum ade7816_channel chan,
425  int16_t *scale, enum ade7816_gain_type gain);
426 
428 int ade7816_set_offset(struct ade7816_desc *desc, enum ade7816_channel chan,
429  int16_t scale, enum ade7816_gain_type gain);
430 
432 int ade7816_get_offset(struct ade7816_desc *desc, enum ade7816_channel chan,
433  int16_t *scale, enum ade7816_gain_type gain);
434 
436 int ade7816_set_phase(struct ade7816_desc *desc, enum ade7816_channel chan,
437  enum ade7816_pcf_coeff pcf_coeff);
438 
440 int ade7816_calib_rms(struct ade7816_desc *desc, enum ade7816_channel chan,
441  int32_t rms);
442 
444 int ade7816_group_sel(struct ade7816_desc *desc, enum ade7816_channel chan);
445 
447 int ade7816_zx_detect(struct ade7816_desc *desc, enum ade7816_channel chan);
448 
450 int ade7816_zx_timeout(struct ade7816_desc *desc, uint32_t timeout_us);
451 
453 int ade7816_peak_detect(struct ade7816_desc *desc, enum ade7816_channel chan,
454  enum ade7816_mmode_sel mmode, uint8_t no_of_cycles);
455 
457 int ade7816_power_dir(struct ade7816_desc *desc, enum ade7816_channel chan);
458 
460 int ade7816_read_dir(struct ade7816_desc *desc, enum ade7816_channel chan,
461  bool *sign);
462 
464 int ade7816_angle_meas(struct ade7816_desc *desc, enum ade7816_channel chan,
465  enum ade7816_angle_sel sel);
466 
468 int ade7816_read_period(struct ade7816_desc *desc, uint32_t *period_us);
469 
471 int ade7816_set_interrupt(struct ade7816_desc *desc,
472  enum ade7816_status_int status_int, bool enable);
473 
475 int ade7816_get_interrupt(struct ade7816_desc *desc,
476  enum ade7816_status_int status_int, bool *enable);
477 
481 int ade7816_rms_to_micro(struct ade7816_desc *desc, enum ade7816_channel chan,
482  uint32_t rms, uint32_t *micro);
483 
485 int ade7816_init(struct ade7816_desc **desc,
487 
489 int ade7816_remove(struct ade7816_desc *desc);
490 
491 #endif /* __ADE7816_H__ */
ade7816_init_param
Definition: ade7816.h:298
ADE7816_CHANNEL_A
@ ADE7816_CHANNEL_A
Definition: ade7816.h:223
ade7816_desc::reset_desc
struct no_os_gpio_desc * reset_desc
Definition: ade7816.h:331
ADE7816_HWRST_DELAY
#define ADE7816_HWRST_DELAY
Definition: ade7816.h:210
ADE7816_PCF_E_COEFF_REG
#define ADE7816_PCF_E_COEFF_REG
Definition: ade7816.h:99
ADE7816_IERMSOS_REG
#define ADE7816_IERMSOS_REG
Definition: ade7816.h:62
MILLI
#define MILLI
Definition: no_os_units.h:48
ADE7816_IDGAIN_REG
#define ADE7816_IDGAIN_REG
Definition: ade7816.h:51
no_os_alloc.h
no_os_gpio_init_param
Structure holding the parameters for GPIO initialization.
Definition: no_os_gpio.h:79
ADE7816_CVAROS_REG
#define ADE7816_CVAROS_REG
Definition: ade7816.h:81
ade7816_set_reactive_thr
int ade7816_set_reactive_thr(struct ade7816_desc *desc, uint16_t freq)
ADE7816 set reactive energy threshold value function.
Definition: ade7816.c:358
ADE7816_IBGAIN_REG
#define ADE7816_IBGAIN_REG
Definition: ade7816.h:49
ADE7816_REVSEL_MASK
#define ADE7816_REVSEL_MASK
Definition: ade7816.h:201
ADE7816_DREADY_INT
@ ADE7816_DREADY_INT
Definition: ade7816.h:260
ade7816_set_comm
int ade7816_set_comm(struct ade7816_desc *desc, enum ade7816_comm_type type)
ADE7816 set communication function.
Definition: ade7816.c:136
ADE7816_COMPMODE_REG
#define ADE7816_COMPMODE_REG
Definition: ade7816.h:153
ADE7816_CONFIG_REG
#define ADE7816_CONFIG_REG
Definition: ade7816.h:157
no_os_i2c_init
int32_t no_os_i2c_init(struct no_os_i2c_desc **desc, const struct no_os_i2c_init_param *param)
Initialize the I2C communication peripheral.
Definition: no_os_i2c.c:52
ade7816_init_param::active_irq
enum ade7816_active_irq active_irq
Definition: ade7816.h:308
ADE7816_DVARGAIN_REG
#define ADE7816_DVARGAIN_REG
Definition: ade7816.h:82
ade7816_get_interrupt
int ade7816_get_interrupt(struct ade7816_desc *desc, enum ade7816_status_int status_int, bool *enable)
ADE7816 get interrupts function.
Definition: ade7816.c:1251
ADE7816_REVRP3_INT
@ ADE7816_REVRP3_INT
Definition: ade7816.h:259
ade7816_desc::status0
uint32_t status0
Definition: ade7816.h:346
ade7816_read_active_energy
int ade7816_read_active_energy(struct ade7816_desc *desc, enum ade7816_channel chan, int32_t *val)
ADE7816 read active energy function.
Definition: ade7816.c:172
ade7816_get_reactive_thr
int ade7816_get_reactive_thr(struct ade7816_desc *desc, uint16_t *freq)
ADE7816 get reactive energy threshold value function.
Definition: ade7816.c:384
ade7816_group_sel
int ade7816_group_sel(struct ade7816_desc *desc, enum ade7816_channel chan)
ADE7816 group selection for channels function.
Definition: ade7816.c:1039
ade7816_set_gain
int ade7816_set_gain(struct ade7816_desc *desc, enum ade7816_channel chan, int16_t scale, enum ade7816_gain_type gain)
ADE7816 set gain value for channel function.
Definition: ade7816.c:513
ade7816_set_active_thr
int ade7816_set_active_thr(struct ade7816_desc *desc, uint16_t freq)
ADE7816 set active energy threshold value function.
Definition: ade7816.c:238
ADE7816_VARTHR1_REG
#define ADE7816_VARTHR1_REG
Definition: ade7816.h:91
ADE7816_THR_MSB_MASK
#define ADE7816_THR_MSB_MASK
Definition: ade7816.h:185
ade7816.h
Header file of ADE7816 Driver.
ADE7816_PKI_INT
@ ADE7816_PKI_INT
Definition: ade7816.h:275
ADE7816_FIRST_BYTE_MASK
#define ADE7816_FIRST_BYTE_MASK
Definition: ade7816.h:177
ADE7816_ZXI2_INT
@ ADE7816_ZXI2_INT
Definition: ade7816.h:269
ade7816_init_param::gpio_irq1_param
struct no_os_gpio_init_param * gpio_irq1_param
Definition: ade7816.h:304
no_os_callback_desc
Structure describing a callback to be registered.
Definition: no_os_irq.h:142
ADE7816_EWGAIN_REG
#define ADE7816_EWGAIN_REG
Definition: ade7816.h:72
ADE7816_PEAKCYC_REG
#define ADE7816_PEAKCYC_REG
Definition: ade7816.h:162
ade7816_init_param::handle_irq0
void * handle_irq0
Definition: ade7816.h:314
ADE7816_REVAP2_INT
@ ADE7816_REVAP2_INT
Definition: ade7816.h:255
ade7816_hw_reset
int ade7816_hw_reset(struct ade7816_desc *desc)
ADE7816 hardware reset function.
Definition: ade7816.c:111
ADE7816_CURRENT_GAIN
@ ADE7816_CURRENT_GAIN
Definition: ade7816.h:232
ADE7816_NLOAD1_INT
@ ADE7816_NLOAD1_INT
Definition: ade7816.h:261
ADE7816_PCF_A_COEFF_REG
#define ADE7816_PCF_A_COEFF_REG
Definition: ade7816.h:95
ADE7816_AVAROS_REG
#define ADE7816_AVAROS_REG
Definition: ade7816.h:77
ADE7816_CHSIGN_REG
#define ADE7816_CHSIGN_REG
Definition: ade7816.h:156
ADE7816_FWATTOS_REG
#define ADE7816_FWATTOS_REG
Definition: ade7816.h:75
no_os_spi.h
Header file of SPI Interface.
ADE7816_PCF_F_COEFF_REG
#define ADE7816_PCF_F_COEFF_REG
Definition: ade7816.h:100
no_os_irq.h
Header file of IRQ interface.
ADE7816_IDRMSOS_REG
#define ADE7816_IDRMSOS_REG
Definition: ade7816.h:61
no_os_irq_register_callback
int32_t no_os_irq_register_callback(struct no_os_irq_ctrl_desc *desc, uint32_t irq_id, struct no_os_callback_desc *callback_desc)
Register a callback to handle the irq events.
Definition: no_os_irq.c:92
ADE7816_SWRST_MASK
#define ADE7816_SWRST_MASK
Definition: ade7816.h:179
ADE7816_REVAP1_INT
@ ADE7816_REVAP1_INT
Definition: ade7816.h:254
ade7816_init_param::ss_param
struct no_os_gpio_init_param * ss_param
Definition: ade7816.h:302
ade7816_desc::spi_desc
struct no_os_spi_desc * spi_desc
Definition: ade7816.h:328
ADE7816_PCF_B_COEFF_REG
#define ADE7816_PCF_B_COEFF_REG
Definition: ade7816.h:96
ADE7816_CHANNEL_F
@ ADE7816_CHANNEL_F
Definition: ade7816.h:228
no_os_i2c_remove
int32_t no_os_i2c_remove(struct no_os_i2c_desc *desc)
Free the resources allocated by no_os_i2c_init().
Definition: no_os_i2c.c:113
ade7816_rms_to_micro
int ade7816_rms_to_micro(struct ade7816_desc *desc, enum ade7816_channel chan, uint32_t rms, uint32_t *micro)
ADE7816 root mean square measurement value conversion to microunits function.
Definition: ade7816.c:1279
no_os_units.h
Header file of Units.
ADE7816_REVRP2_INT
@ ADE7816_REVRP2_INT
Definition: ade7816.h:258
ade7816_desc::i2c_desc
struct no_os_i2c_desc * i2c_desc
Definition: ade7816.h:329
ADE7816_REVAP3_INT
@ ADE7816_REVAP3_INT
Definition: ade7816.h:256
ade7816_active_irq
ade7816_active_irq
Definition: ade7816.h:279
ADE7816_IARMSOS_REG
#define ADE7816_IARMSOS_REG
Definition: ade7816.h:58
ADE7816_DWGAIN_REG
#define ADE7816_DWGAIN_REG
Definition: ade7816.h:70
ADE7816_IEGAIN_REG
#define ADE7816_IEGAIN_REG
Definition: ade7816.h:52
ade7816_set_reactive_thr
int ade7816_set_reactive_thr(struct ade7816_desc *desc, uint16_t freq)
ADE7816 set reactive energy threshold value function.
Definition: ade7816.c:358
ADE7816_PEAKSEL_0_AD
@ ADE7816_PEAKSEL_0_AD
Definition: ade7816.h:238
ade7816_desc::reg_read
ade7816_reg_read reg_read
Definition: ade7816.h:339
ade7816_desc::irq_ctrl
struct no_os_irq_ctrl_desc * irq_ctrl
Definition: ade7816.h:335
ADE7816_PEAKSEL_1_BE
@ ADE7816_PEAKSEL_1_BE
Definition: ade7816.h:239
ade7816_reg_update
int ade7816_reg_update(struct ade7816_desc *desc, uint16_t reg, uint32_t mask, uint32_t val)
Register update function.
Definition: ade7816.c:71
no_os_delay.h
Header file of Delay functions.
ADE7816_AWATTOS_REG
#define ADE7816_AWATTOS_REG
Definition: ade7816.h:65
ade7816_get_active_thr
int ade7816_get_active_thr(struct ade7816_desc *desc, uint16_t *freq)
ADE7816 get active energy threshold value function.
Definition: ade7816.c:264
ade7816_init_param::irq1_callback
void(* irq1_callback)(void *context)
Definition: ade7816.h:324
ADE7816_LINECYC_REG
#define ADE7816_LINECYC_REG
Definition: ade7816.h:151
ADE7816_CWGAIN_REG
#define ADE7816_CWGAIN_REG
Definition: ade7816.h:68
ADE7816_CWATTHR_REG
#define ADE7816_CWATTHR_REG
Definition: ade7816.h:114
NO_OS_DIV_ROUND_CLOSEST_ULL
#define NO_OS_DIV_ROUND_CLOSEST_ULL(x, y)
Definition: no_os_util.h:56
ADE7816_CHANNEL_VOLTAGE
@ ADE7816_CHANNEL_VOLTAGE
Definition: ade7816.h:222
ade7816_set_active_thr
int ade7816_set_active_thr(struct ade7816_desc *desc, uint16_t freq)
ADE7816 set active energy threshold value function.
Definition: ade7816.c:238
ade7816_desc
Definition: ade7816.h:327
ade7816_read_period
int ade7816_read_period(struct ade7816_desc *desc, uint32_t *period_us)
ADE7816 read period value function.
Definition: ade7816.c:1203
ade7816_reg_update
int ade7816_reg_update(struct ade7816_desc *desc, uint16_t reg, uint32_t mask, uint32_t val)
Register update function.
Definition: ade7816.c:71
ade7816_zx_detect
int ade7816_zx_detect(struct ade7816_desc *desc, enum ade7816_channel chan)
ADE7816 zero-crossing detection for channel function.
Definition: ade7816.c:1067
ADE7816_AVARGAIN_REG
#define ADE7816_AVARGAIN_REG
Definition: ade7816.h:76
ADE7816_EWATTOS_REG
#define ADE7816_EWATTOS_REG
Definition: ade7816.h:73
NO_OS_GPIO_HIGH
@ NO_OS_GPIO_HIGH
Definition: no_os_gpio.h:117
ade7816_power_dir
int ade7816_power_dir(struct ade7816_desc *desc, enum ade7816_channel chan)
ADE7816 set power direction for channel function.
Definition: ade7816.c:1127
ADE7816_EVAROS_REG
#define ADE7816_EVAROS_REG
Definition: ade7816.h:85
ADE7816_OV_INT
@ ADE7816_OV_INT
Definition: ade7816.h:274
ADE7816_REHF1_INT
@ ADE7816_REHF1_INT
Definition: ade7816.h:251
ADE7816_I2C_LOCK_MASK
#define ADE7816_I2C_LOCK_MASK
Definition: ade7816.h:181
ade7816_init_param::irq0_priority
uint32_t irq0_priority
Definition: ade7816.h:311
ADE7816_CONFIG2_REG
#define ADE7816_CONFIG2_REG
Definition: ade7816.h:168
ade7816_desc::reg_write
ade7816_reg_write reg_write
Definition: ade7816.h:340
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
no_os_gpio_direction_input
int32_t no_os_gpio_direction_input(struct no_os_gpio_desc *desc)
Enable the input direction of the specified GPIO.
Definition: no_os_gpio.c:124
ADE7816_ZXI3_INT
@ ADE7816_ZXI3_INT
Definition: ade7816.h:270
NO_OS_IRQ_EDGE_FALLING
@ NO_OS_IRQ_EDGE_FALLING
Definition: no_os_irq.h:79
ADE7816_BWATTOS_REG
#define ADE7816_BWATTOS_REG
Definition: ade7816.h:67
ade7816_set_phase
int ade7816_set_phase(struct ade7816_desc *desc, enum ade7816_channel chan, enum ade7816_pcf_coeff pcf_coeff)
ADE7816 set phase calibration coefficient function.
Definition: ade7816.c:960
ade7816_zx_timeout
int ade7816_zx_timeout(struct ade7816_desc *desc, uint32_t timeout_us)
ADE7816 zero-crossing detection timeout value function.
Definition: ade7816.c:1089
ADE7816_THR_LSB_MASK
#define ADE7816_THR_LSB_MASK
Definition: ade7816.h:186
ade7816_desc::active_irq
enum ade7816_active_irq active_irq
Definition: ade7816.h:342
ade7816_init_param::gpio_irq0_param
struct no_os_gpio_init_param * gpio_irq0_param
Definition: ade7816.h:303
ade7816_desc::status1
uint32_t status1
Definition: ade7816.h:347
ade7816_init_param::i2c_param
struct no_os_i2c_init_param * i2c_param
Definition: ade7816.h:300
ADE7816_VRMS_REG
#define ADE7816_VRMS_REG
Definition: ade7816.h:102
ADE7816_IBRMS_REG
#define ADE7816_IBRMS_REG
Definition: ade7816.h:104
ADE7816_CVARGAIN_REG
#define ADE7816_CVARGAIN_REG
Definition: ade7816.h:80
no_os_callback_desc::peripheral
enum no_os_irq_peripheral peripheral
Definition: no_os_irq.h:150
ADE7816_FVAROS_REG
#define ADE7816_FVAROS_REG
Definition: ade7816.h:87
ADE7816_IFRMSOS_REG
#define ADE7816_IFRMSOS_REG
Definition: ade7816.h:63
MICRO
#define MICRO
Definition: no_os_units.h:49
ADE7816_VGAIN_REG
#define ADE7816_VGAIN_REG
Definition: ade7816.h:47
ADE7816_ZXV_INT
@ ADE7816_ZXV_INT
Definition: ade7816.h:267
ade7816_desc::chan
enum ade7816_channel chan
Definition: ade7816.h:344
NO_OS_GPIO_LOW
@ NO_OS_GPIO_LOW
Definition: no_os_gpio.h:115
ade7816_init_param::spi_param
struct no_os_spi_init_param * spi_param
Definition: ade7816.h:299
ade7816_set_offset
int ade7816_set_offset(struct ade7816_desc *desc, enum ade7816_channel chan, int16_t scale, enum ade7816_gain_type gain)
ADE7816 set offset value for channel function.
Definition: ade7816.c:758
ADE7816_MMODE_REG
#define ADE7816_MMODE_REG
Definition: ade7816.h:159
ADE7816_CHANNEL_E
@ ADE7816_CHANNEL_E
Definition: ade7816.h:227
ADE7816_BVARGAIN_REG
#define ADE7816_BVARGAIN_REG
Definition: ade7816.h:78
ADE7816_SPI
@ ADE7816_SPI
Definition: ade7816.h:218
ADE7816_SAG_INT
@ ADE7816_SAG_INT
Definition: ade7816.h:272
ADE7816_MMODE_MASK
#define ADE7816_MMODE_MASK
Definition: ade7816.h:199
ADE7816_LMASK
#define ADE7816_LMASK
Definition: ade7816.h:190
ADE7816_REHF2_INT
@ ADE7816_REHF2_INT
Definition: ade7816.h:252
ade7816_get_offset
int ade7816_get_offset(struct ade7816_desc *desc, enum ade7816_channel chan, int16_t *scale, enum ade7816_gain_type gain)
ADE7816 get offset value for channel function.
Definition: ade7816.c:857
ADE7816_IERMS_REG
#define ADE7816_IERMS_REG
Definition: ade7816.h:107
no_os_mdelay
void no_os_mdelay(uint32_t msecs)
Wait until msecs milliseconds passed.
Definition: aducm3029_delay.c:126
ade7816_read_period
int ade7816_read_period(struct ade7816_desc *desc, uint32_t *period_us)
ADE7816 read period value function.
Definition: ade7816.c:1203
no_os_field_prep
uint32_t no_os_field_prep(uint32_t mask, uint32_t val)
ade7816_init_param::irq_ctrl
struct no_os_irq_ctrl_desc * irq_ctrl
Definition: ade7816.h:306
no_os_irq_set_priority
int32_t no_os_irq_set_priority(struct no_os_irq_ctrl_desc *desc, uint32_t irq_id, uint32_t priority_level)
Set the priority for an interrupt.
Definition: no_os_irq.c:216
ade7816_set_comm
int ade7816_set_comm(struct ade7816_desc *desc, enum ade7816_comm_type type)
ADE7816 set communication function.
Definition: ade7816.c:136
ade7816_desc::irq0_cb
struct no_os_callback_desc irq0_cb
Definition: ade7816.h:336
ade7816_read_reactive_energy
int ade7816_read_reactive_energy(struct ade7816_desc *desc, enum ade7816_channel chan, int32_t *val)
ADE7816 read reactive energy value function.
Definition: ade7816.c:292
ade7816_init_param::irq1_priority
uint32_t irq1_priority
Definition: ade7816.h:312
ADE7816_CHANNEL_B
@ ADE7816_CHANNEL_B
Definition: ade7816.h:224
ade7816_power_dir
int ade7816_power_dir(struct ade7816_desc *desc, enum ade7816_channel chan)
ADE7816 set power direction for channel function.
Definition: ade7816.c:1127
no_os_error.h
Error codes definition.
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
ADE7816_SECOND_BYTE_MASK
#define ADE7816_SECOND_BYTE_MASK
Definition: ade7816.h:176
ade7816_get_interrupt
int ade7816_get_interrupt(struct ade7816_desc *desc, enum ade7816_status_int status_int, bool *enable)
ADE7816 get interrupts function.
Definition: ade7816.c:1251
ADE7816_OI_INT
@ ADE7816_OI_INT
Definition: ade7816.h:273
ade7816_group_sel
int ade7816_group_sel(struct ade7816_desc *desc, enum ade7816_channel chan)
ADE7816 group selection for channels function.
Definition: ade7816.c:1039
ADE7816_DVAROS_REG
#define ADE7816_DVAROS_REG
Definition: ade7816.h:83
ade7816_set_no_load
int ade7816_set_no_load(struct ade7816_desc *desc, uint16_t voltage, uint16_t current, bool enable)
ADE7816 set no load condition function.
Definition: ade7816.c:484
ADE7816_DVARHR_REG
#define ADE7816_DVARHR_REG
Definition: ade7816.h:121
ade7816_hw_reset
int ade7816_hw_reset(struct ade7816_desc *desc)
ADE7816 hardware reset function.
Definition: ade7816.c:111
ADE7816_FVARHR_REG
#define ADE7816_FVARHR_REG
Definition: ade7816.h:123
ADE7816_SIGN_MASK
#define ADE7816_SIGN_MASK(x)
Definition: ade7816.h:205
ADE7816_VRMSOS_REG
#define ADE7816_VRMSOS_REG
Definition: ade7816.h:57
ADE7816_ZXTOUT_REG
#define ADE7816_ZXTOUT_REG
Definition: ade7816.h:152
ADE7816_CHANNEL_D
@ ADE7816_CHANNEL_D
Definition: ade7816.h:226
ADE7816_PERIOD_REG
#define ADE7816_PERIOD_REG
Definition: ade7816.h:148
ade7816_desc::irq1_cb
struct no_os_callback_desc irq1_cb
Definition: ade7816.h:337
ADE7816_IFRMS_REG
#define ADE7816_IFRMS_REG
Definition: ade7816.h:108
no_os_callback_desc::ctx
void * ctx
Definition: no_os_irq.h:146
ADE7816_STATUS0_REG
#define ADE7816_STATUS0_REG
Definition: ade7816.h:127
ADE7816_ICRMSOS_REG
#define ADE7816_ICRMSOS_REG
Definition: ade7816.h:60
ade7816_set_offset
int ade7816_set_offset(struct ade7816_desc *desc, enum ade7816_channel chan, int16_t scale, enum ade7816_gain_type gain)
ADE7816 set offset value for channel function.
Definition: ade7816.c:758
ADE7816_PKV_INT
@ ADE7816_PKV_INT
Definition: ade7816.h:276
ADE7816_LENERGY_MASK
#define ADE7816_LENERGY_MASK
Definition: ade7816.h:193
no_os_irq_unregister_callback
int32_t no_os_irq_unregister_callback(struct no_os_irq_ctrl_desc *desc, uint32_t irq_id, struct no_os_callback_desc *callback_desc)
Unregisters a generic IRQ handling function.
Definition: no_os_irq.c:112
ade7816_desc::comm_type
enum ade7816_comm_type comm_type
Definition: ade7816.h:343
ade7816_calib_rms
int ade7816_calib_rms(struct ade7816_desc *desc, enum ade7816_channel chan, int32_t rms)
ADE7816 root mean square measurement calibration function.
Definition: ade7816.c:988
ade7816_init_param::irq0_callback
void(* irq0_callback)(void *context)
Definition: ade7816.h:323
ADE7816_BVAROS_REG
#define ADE7816_BVAROS_REG
Definition: ade7816.h:79
ADE7816_AEHF2_INT
@ ADE7816_AEHF2_INT
Definition: ade7816.h:250
ADE7816_CHANNEL_SEL_MASK
#define ADE7816_CHANNEL_SEL_MASK
Definition: ade7816.h:195
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
ADE7816_REACTIVE_POWER_GAIN
@ ADE7816_REACTIVE_POWER_GAIN
Definition: ade7816.h:234
ade7816_channel
ade7816_channel
Definition: ade7816.h:221
ADE7816_EVARGAIN_REG
#define ADE7816_EVARGAIN_REG
Definition: ade7816.h:84
ade7816_angle_meas
int ade7816_angle_meas(struct ade7816_desc *desc, enum ade7816_channel chan, enum ade7816_angle_sel sel)
ADE7816 angle measurement function.
Definition: ade7816.c:1183
ADE7816_I2C
@ ADE7816_I2C
Definition: ade7816.h:217
ADE7816_DWATTOS_REG
#define ADE7816_DWATTOS_REG
Definition: ade7816.h:71
ade7816_set_no_load
int ade7816_set_no_load(struct ade7816_desc *desc, uint16_t voltage, uint16_t current, bool enable)
ADE7816 set no load condition function.
Definition: ade7816.c:484
ade7816_reg_write
int(* ade7816_reg_write)(struct ade7816_desc *desc, uint16_t reg, uint32_t val)
Definition: ade7816.h:295
ADE7816_REVRP1_INT
@ ADE7816_REVRP1_INT
Definition: ade7816.h:257
ADE7816_EWATTHR_REG
#define ADE7816_EWATTHR_REG
Definition: ade7816.h:116
ADE7816_MASK1_REG
#define ADE7816_MASK1_REG
Definition: ade7816.h:134
no_os_gpio_remove
int32_t no_os_gpio_remove(struct no_os_gpio_desc *desc)
Free the resources allocated by no_os_gpio_get().
Definition: no_os_gpio.c:104
ADE7816_PCF_60HZ
@ ADE7816_PCF_60HZ
Definition: ade7816.h:288
no_os_spi_desc
Structure holding SPI descriptor.
Definition: no_os_spi.h:192
ADE7816_AWATTHR_REG
#define ADE7816_AWATTHR_REG
Definition: ade7816.h:112
ADE7816_FVARGAIN_REG
#define ADE7816_FVARGAIN_REG
Definition: ade7816.h:86
ADE7816_IAGAIN_REG
#define ADE7816_IAGAIN_REG
Definition: ade7816.h:48
ade7816_init_param::reset_param
struct no_os_gpio_init_param * reset_param
Definition: ade7816.h:301
ADE7816_IRQ1
@ ADE7816_IRQ1
Definition: ade7816.h:282
no_os_callback_desc::handle
void * handle
Definition: no_os_irq.h:152
ade7816_angle_meas
int ade7816_angle_meas(struct ade7816_desc *desc, enum ade7816_channel chan, enum ade7816_angle_sel sel)
ADE7816 angle measurement function.
Definition: ade7816.c:1183
no_os_callback_desc::callback
void(* callback)(void *context)
Definition: no_os_irq.h:144
ADE7816_VOLTAGE_CURRENT
@ ADE7816_VOLTAGE_CURRENT
Definition: ade7816.h:244
no_os_gpio_desc
Structure holding the GPIO descriptor.
Definition: no_os_gpio.h:96
ADE7816_ZXI1_INT
@ ADE7816_ZXI1_INT
Definition: ade7816.h:268
ade7816_remove
int ade7816_remove(struct ade7816_desc *desc)
Free the resources allocated during init.
Definition: ade7816.c:1657
ade7816_peak_detect
int ade7816_peak_detect(struct ade7816_desc *desc, enum ade7816_channel chan, enum ade7816_mmode_sel mmode, uint8_t no_of_cycles)
ADE7816 set peak detection for channel function.
Definition: ade7816.c:1104
ADE7816_BVARHR_REG
#define ADE7816_BVARHR_REG
Definition: ade7816.h:119
ADE7816_AVARHR_REG
#define ADE7816_AVARHR_REG
Definition: ade7816.h:118
ade7816_read_reg
int ade7816_read_reg(struct ade7816_desc *desc, uint16_t reg, uint32_t *val)
Register read wrapper function.
Definition: ade7816.c:45
ade7816_read_rms
int ade7816_read_rms(struct ade7816_desc *desc, enum ade7816_channel chan, uint32_t *rms)
ADE7816 read root mean square measurement value function.
Definition: ade7816.c:452
ADE7816_ACTIVE_POWER_GAIN
@ ADE7816_ACTIVE_POWER_GAIN
Definition: ade7816.h:233
ADE7816_PCF_D_COEFF_REG
#define ADE7816_PCF_D_COEFF_REG
Definition: ade7816.h:98
no_os_i2c_desc
Structure holding I2C address descriptor.
Definition: no_os_i2c.h:101
ade7816_init_param::comm_type
enum ade7816_comm_type comm_type
Definition: ade7816.h:309
ade7816_angle_sel
ade7816_angle_sel
Definition: ade7816.h:243
no_os_gpio_get
int32_t no_os_gpio_get(struct no_os_gpio_desc **desc, const struct no_os_gpio_init_param *param)
Obtain the GPIO decriptor.
Definition: no_os_gpio.c:49
ade7816_mmode_sel
ade7816_mmode_sel
Definition: ade7816.h:237
no_os_callback_desc::event
enum no_os_irq_event event
Definition: no_os_irq.h:148
no_os_i2c.h
Header file of I2C Interface.
ADE7816_ACCMODE_REG
#define ADE7816_ACCMODE_REG
Definition: ade7816.h:160
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
ade7816_read_reg
int ade7816_read_reg(struct ade7816_desc *desc, uint16_t reg, uint32_t *val)
Register read wrapper function.
Definition: ade7816.c:45
ade7816_set_interrupt
int ade7816_set_interrupt(struct ade7816_desc *desc, enum ade7816_status_int status_int, bool enable)
ADE7816 set interrupts function.
Definition: ade7816.c:1229
ADE7816_AWGAIN_REG
#define ADE7816_AWGAIN_REG
Definition: ade7816.h:64
ade7816_init_param::handle_irq1
void * handle_irq1
Definition: ade7816.h:315
ade7816_get_offset
int ade7816_get_offset(struct ade7816_desc *desc, enum ade7816_channel chan, int16_t *scale, enum ade7816_gain_type gain)
ADE7816 get offset value for channel function.
Definition: ade7816.c:857
no_os_field_get
uint32_t no_os_field_get(uint32_t mask, uint32_t word)
ADE7816_CHANNEL_C
@ ADE7816_CHANNEL_C
Definition: ade7816.h:225
ADE7816_NO_IRQ
@ ADE7816_NO_IRQ
Definition: ade7816.h:280
ADE7816_ZXTOI2_INT
@ ADE7816_ZXTOI2_INT
Definition: ade7816.h:265
ade7816_get_active_thr
int ade7816_get_active_thr(struct ade7816_desc *desc, uint16_t *freq)
ADE7816 get active energy threshold value function.
Definition: ade7816.c:264
ADE7816_PEAKSEL_2_CF
@ ADE7816_PEAKSEL_2_CF
Definition: ade7816.h:240
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_NLOAD2_INT
@ ADE7816_NLOAD2_INT
Definition: ade7816.h:262
ade7816_get_gain
int ade7816_get_gain(struct ade7816_desc *desc, enum ade7816_channel chan, int16_t *scale, enum ade7816_gain_type gain)
ADE7816 get gain value for channel function.
Definition: ade7816.c:633
ADE7816_RSTREAD_MASK
#define ADE7816_RSTREAD_MASK
Definition: ade7816.h:188
ADE7816_FWATTHR_REG
#define ADE7816_FWATTHR_REG
Definition: ade7816.h:117
ade7816_write_reg
int ade7816_write_reg(struct ade7816_desc *desc, uint16_t reg, uint32_t val)
Register write wrapper function.
Definition: ade7816.c:57
ade7816_remove
int ade7816_remove(struct ade7816_desc *desc)
Free the resources allocated during init.
Definition: ade7816.c:1657
ADE7816_INIT_DELAY
#define ADE7816_INIT_DELAY
Definition: ade7816.h:209
ade7816_zx_detect
int ade7816_zx_detect(struct ade7816_desc *desc, enum ade7816_channel chan)
ADE7816 zero-crossing detection for channel function.
Definition: ade7816.c:1067
no_os_udelay
void no_os_udelay(uint32_t usecs)
Wait until usecs microseconds passed.
Definition: aducm3029_delay.c:114
no_os_i2c_init_param
Structure holding the parameters for I2C initialization.
Definition: no_os_i2c.h:64
NULL
#define NULL
Definition: wrapper.h:64
ade7816_init
int ade7816_init(struct ade7816_desc **desc, struct ade7816_init_param *init_param)
Initialize and configure the ADE7816 device.
Definition: ade7816.c:1417
ade7816_get_gain
int ade7816_get_gain(struct ade7816_desc *desc, enum ade7816_channel chan, int16_t *scale, enum ade7816_gain_type gain)
ADE7816 get gain value for channel function.
Definition: ade7816.c:633
no_os_irq_ctrl_desc::irq_ctrl_id
uint32_t irq_ctrl_id
Definition: no_os_irq.h:125
ADE7816_VARTHR0_REG
#define ADE7816_VARTHR0_REG
Definition: ade7816.h:92
ade7816_pcf_coeff
ade7816_pcf_coeff
Definition: ade7816.h:286
ADE7816_LCYCMODE_REG
#define ADE7816_LCYCMODE_REG
Definition: ade7816.h:161
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
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
ade7816_get_reactive_thr
int ade7816_get_reactive_thr(struct ade7816_desc *desc, uint16_t *freq)
ADE7816 get reactive energy threshold value function.
Definition: ade7816.c:384
NO_OS_EVT_GPIO
@ NO_OS_EVT_GPIO
Definition: no_os_irq.h:62
ADE7816_STATUS1_REG
#define ADE7816_STATUS1_REG
Definition: ade7816.h:128
ADE7816_IARMS_REG
#define ADE7816_IARMS_REG
Definition: ade7816.h:103
ade7816_set_phase
int ade7816_set_phase(struct ade7816_desc *desc, enum ade7816_channel chan, enum ade7816_pcf_coeff pcf_coeff)
ADE7816 set phase calibration coefficient function.
Definition: ade7816.c:960
ade7816_set_lcycle_mode
int ade7816_set_lcycle_mode(struct ade7816_desc *desc, bool enable, uint16_t cycles, bool lenergy)
ADE7816 set line cycle mode function.
Definition: ade7816.c:414
ade7816_zx_timeout
int ade7816_zx_timeout(struct ade7816_desc *desc, uint32_t timeout_us)
ADE7816 zero-crossing detection timeout value function.
Definition: ade7816.c:1089
ADE7816_IFGAIN_REG
#define ADE7816_IFGAIN_REG
Definition: ade7816.h:53
ade7816_desc::ss_desc
struct no_os_gpio_desc * ss_desc
Definition: ade7816.h:332
ade7816_reg_read
int(* ade7816_reg_read)(struct ade7816_desc *desc, uint16_t reg, uint32_t *val)
Definition: ade7816.h:293
ade7816_init
int ade7816_init(struct ade7816_desc **desc, struct ade7816_init_param *init_param)
Initialize and configure the ADE7816 device.
Definition: ade7816.c:1417
ADE7816_LENERGY_INT
@ ADE7816_LENERGY_INT
Definition: ade7816.h:253
ade7816_set_interrupt
int ade7816_set_interrupt(struct ade7816_desc *desc, enum ade7816_status_int status_int, bool enable)
ADE7816 set interrupts function.
Definition: ade7816.c:1229
ADE7816_MASK0_REG
#define ADE7816_MASK0_REG
Definition: ade7816.h:133
ADE7816_BWGAIN_REG
#define ADE7816_BWGAIN_REG
Definition: ade7816.h:66
ade7816_gain_type
ade7816_gain_type
Definition: ade7816.h:231
ade7816_sw_reset
int ade7816_sw_reset(struct ade7816_desc *desc)
ADE7816 software reset function.
Definition: ade7816.c:92
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
ADE7816_IDRMS_REG
#define ADE7816_IDRMS_REG
Definition: ade7816.h:106
ADE7816_PCF_C_COEFF_REG
#define ADE7816_PCF_C_COEFF_REG
Definition: ade7816.h:97
no_os_irq_enable
int32_t no_os_irq_enable(struct no_os_irq_ctrl_desc *desc, uint32_t irq_id)
Enable specific interrupt.
Definition: no_os_irq.c:181
ADE7816_AEHF1_INT
@ ADE7816_AEHF1_INT
Definition: ade7816.h:249
ADE7816_LINECYC_VAL
#define ADE7816_LINECYC_VAL(enable)
Definition: ade7816.h:212
ADE7816_BWATTHR_REG
#define ADE7816_BWATTHR_REG
Definition: ade7816.h:113
ADE7816_CWATTOS_REG
#define ADE7816_CWATTOS_REG
Definition: ade7816.h:69
no_os_gpio.h
Header file of GPIO Interface.
ADE7816_INT_MASK
#define ADE7816_INT_MASK(x)
Definition: ade7816.h:207
ade7816_rms_to_micro
int ade7816_rms_to_micro(struct ade7816_desc *desc, enum ade7816_channel chan, uint32_t rms, uint32_t *micro)
ADE7816 root mean square measurement value conversion to microunits function.
Definition: ade7816.c:1279
ADE7816_ZXTOI3_INT
@ ADE7816_ZXTOI3_INT
Definition: ade7816.h:266
ADE7816_CURRENT_CURRENT
@ ADE7816_CURRENT_CURRENT
Definition: ade7816.h:245
NO_OS_GPIO_IRQ
@ NO_OS_GPIO_IRQ
Definition: no_os_irq.h:85
ADE7816_ICRMS_REG
#define ADE7816_ICRMS_REG
Definition: ade7816.h:105
ade7816_desc::gpio_irq0_desc
struct no_os_gpio_desc * gpio_irq0_desc
Definition: ade7816.h:333
ADE7816_ANGLESEL_MASK
#define ADE7816_ANGLESEL_MASK
Definition: ade7816.h:203
ADE7816_WTHR1_REG
#define ADE7816_WTHR1_REG
Definition: ade7816.h:89
ADE7816_DWATTHR_REG
#define ADE7816_DWATTHR_REG
Definition: ade7816.h:115
ade7816_write_reg
int ade7816_write_reg(struct ade7816_desc *desc, uint16_t reg, uint32_t val)
Register write wrapper function.
Definition: ade7816.c:57
ade7816_read_dir
int ade7816_read_dir(struct ade7816_desc *desc, enum ade7816_channel chan, bool *sign)
ADE7816 get power direction for channel function.
Definition: ade7816.c:1158
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
ade7816_desc::lcycle_mode
bool lcycle_mode
Definition: ade7816.h:349
ADE7816_ZX_SEL_MASK
#define ADE7816_ZX_SEL_MASK
Definition: ade7816.h:191
ade7816_read_reactive_energy
int ade7816_read_reactive_energy(struct ade7816_desc *desc, enum ade7816_channel chan, int32_t *val)
ADE7816 read reactive energy value function.
Definition: ade7816.c:292
ADE7816_WTHR0_REG
#define ADE7816_WTHR0_REG
Definition: ade7816.h:90
ADE7816_RUN_REG
#define ADE7816_RUN_REG
Definition: ade7816.h:110
ade7816_desc::gpio_irq1_desc
struct no_os_gpio_desc * gpio_irq1_desc
Definition: ade7816.h:334
ADE7816_ZXTOV_INT
@ ADE7816_ZXTOV_INT
Definition: ade7816.h:263
no_os_util.h
Header file of utility functions.
no_os_sign_extend32
int32_t no_os_sign_extend32(uint32_t value, int index)
ADE7816_RSTDONE_INT
@ ADE7816_RSTDONE_INT
Definition: ade7816.h:271
no_os_irq_trigger_level_set
int32_t no_os_irq_trigger_level_set(struct no_os_irq_ctrl_desc *desc, uint32_t irq_id, enum no_os_irq_trig_level trig)
Set interrupt trigger level.
Definition: no_os_irq.c:162
ADE7816_IBRMSOS_REG
#define ADE7816_IBRMSOS_REG
Definition: ade7816.h:59
no_os_irq_disable
int32_t no_os_irq_disable(struct no_os_irq_ctrl_desc *desc, uint32_t irq_id)
Disable specific interrupt.
Definition: no_os_irq.c:198
ade7816_read_dir
int ade7816_read_dir(struct ade7816_desc *desc, enum ade7816_channel chan, bool *sign)
ADE7816 get power direction for channel function.
Definition: ade7816.c:1158
ade7816_peak_detect
int ade7816_peak_detect(struct ade7816_desc *desc, enum ade7816_channel chan, enum ade7816_mmode_sel mmode, uint8_t no_of_cycles)
ADE7816 set peak detection for channel function.
Definition: ade7816.c:1104
ade7816_set_lcycle_mode
int ade7816_set_lcycle_mode(struct ade7816_desc *desc, bool enable, uint16_t cycles, bool lenergy)
ADE7816 set line cycle mode function.
Definition: ade7816.c:414
ADE7816_VARNOLOAD_REG
#define ADE7816_VARNOLOAD_REG
Definition: ade7816.h:94
no_os_irq_ctrl_desc
Definition: no_os_irq.h:123
no_os_gpio_direction_output
int32_t no_os_gpio_direction_output(struct no_os_gpio_desc *desc, uint8_t value)
Enable the output direction of the specified GPIO.
Definition: no_os_gpio.c:147
ADE7816_APNOLOAD_REG
#define ADE7816_APNOLOAD_REG
Definition: ade7816.h:93
ADE7816_PCF_50HZ
@ ADE7816_PCF_50HZ
Definition: ade7816.h:287
ade7816_read_rms
int ade7816_read_rms(struct ade7816_desc *desc, enum ade7816_channel chan, uint32_t *rms)
ADE7816 read root mean square measurement value function.
Definition: ade7816.c:452
ADE7816_CVARHR_REG
#define ADE7816_CVARHR_REG
Definition: ade7816.h:120
ADE7816_ZXTOI1_INT
@ ADE7816_ZXTOI1_INT
Definition: ade7816.h:264
no_os_gpio_desc::number
int32_t number
Definition: no_os_gpio.h:100
ADE7816_ICGAIN_REG
#define ADE7816_ICGAIN_REG
Definition: ade7816.h:50
ade7816_read_active_energy
int ade7816_read_active_energy(struct ade7816_desc *desc, enum ade7816_channel chan, int32_t *val)
ADE7816 read active energy function.
Definition: ade7816.c:172
ade7816_set_gain
int ade7816_set_gain(struct ade7816_desc *desc, enum ade7816_channel chan, int16_t scale, enum ade7816_gain_type gain)
ADE7816 set gain value for channel function.
Definition: ade7816.c:513
ade7816_comm_type
ade7816_comm_type
Definition: ade7816.h:216
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
ad7616_init_param::spi_param
struct no_os_spi_init_param * spi_param
Definition: ad7616.h:204
ade7816_sw_reset
int ade7816_sw_reset(struct ade7816_desc *desc)
ADE7816 software reset function.
Definition: ade7816.c:92
ADE7816_IRQ0
@ ADE7816_IRQ0
Definition: ade7816.h:281
ADE7816_FWGAIN_REG
#define ADE7816_FWGAIN_REG
Definition: ade7816.h:74
NO_OS_DIV_ROUND_CLOSEST
#define NO_OS_DIV_ROUND_CLOSEST(x, y)
Definition: no_os_util.h:54
ADE7816_EVARHR_REG
#define ADE7816_EVARHR_REG
Definition: ade7816.h:122
ADE7816_IRQ0_IRQ1
@ ADE7816_IRQ0_IRQ1
Definition: ade7816.h:283
ade7816_calib_rms
int ade7816_calib_rms(struct ade7816_desc *desc, enum ade7816_channel chan, int32_t rms)
ADE7816 root mean square measurement calibration function.
Definition: ade7816.c:988
no_os_spi_init_param
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:140
ade7816_status_int
ade7816_status_int
Definition: ade7816.h:248
no_os_gpio_get_optional
int32_t no_os_gpio_get_optional(struct no_os_gpio_desc **desc, const struct no_os_gpio_init_param *param)
Get the value of an optional GPIO.
Definition: no_os_gpio.c:75