Go to the documentation of this file.
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
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
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
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
110 #define ADE7816_RUN_REG 0xE228
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
125 #define ADE7816_IPEAK_REG 0xE500
126 #define ADE7816_VPEAK_REG 0xE501
127 #define ADE7816_STATUS0_REG 0xE502
128 #define ADE7816_STATUS1_REG 0xE503
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
139 #define ADE7816_VWV_REG 0xE510
141 #define ADE7816_CHECKSUM_REG 0xE51F
143 #define ADE7816_CHSTATUS_REG 0xE600
144 #define ADE7816_ANGLE0_REG 0xE601
145 #define ADE7816_ANGLE1_REG 0xE602
146 #define ADE7816_ANGLE2_REG 0xE603
148 #define ADE7816_PERIOD_REG 0xE607
149 #define ADE7816_CHNOLOAD_REG 0xE608
151 #define ADE7816_LINECYC_REG 0xE60C
152 #define ADE7816_ZXTOUT_REG 0xE60D
153 #define ADE7816_COMPMODE_REG 0xE60E
154 #define ADE7816_GAIN_REG 0xE60F
156 #define ADE7816_CHSIGN_REG 0xE617
157 #define ADE7816_CONFIG_REG 0xE618
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
165 #define ADE7816_HSDC_CFG_REG 0xE706
166 #define ADE7816_VERSION_REG 0xE707
168 #define ADE7816_CONFIG2_REG 0xEC01
171 #define ADE7816_LSB_REG_MASK NO_OS_GENMASK(7, 0)
172 #define ADE7816_MSB_REG_MASK NO_OS_GENMASK(15, 8)
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)
179 #define ADE7816_SWRST_MASK NO_OS_BIT(7)
181 #define ADE7816_I2C_LOCK_MASK NO_OS_BIT(1)
183 #define ADE7816_ZSPE_MASK NO_OS_GENMASK(27, 0)
185 #define ADE7816_THR_MSB_MASK NO_OS_GENMASK(31, 24)
186 #define ADE7816_THR_LSB_MASK NO_OS_GENMASK(23, 0)
188 #define ADE7816_RSTREAD_MASK NO_OS_BIT(6)
190 #define ADE7816_LMASK NO_OS_GENMASK(1, 0)
191 #define ADE7816_ZX_SEL_MASK NO_OS_BIT(3)
193 #define ADE7816_LENERGY_MASK NO_OS_BIT(5)
195 #define ADE7816_CHANNEL_SEL_MASK NO_OS_BIT(14)
197 #define ADE7816_DREADY_MASK NO_OS_BIT(17)
199 #define ADE7816_MMODE_MASK NO_OS_GENMASK(4, 2)
201 #define ADE7816_REVSEL_MASK NO_OS_GENMASK(7, 6)
203 #define ADE7816_ANGLESEL_MASK NO_OS_GENMASK(10, 9)
205 #define ADE7816_SIGN_MASK(x) (((x) > 3) ? ((x) - 4) : (x))
207 #define ADE7816_INT_MASK(x) NO_OS_BIT(x)
209 #define ADE7816_INIT_DELAY 40
210 #define ADE7816_HWRST_DELAY 10
212 #define ADE7816_LINECYC_VAL(enable) ((enable) ? 0x11 : 0x00)
214 #define ADE7816_CHECKSUM_VAL 0x33666787
409 uint16_t cycles,
bool lenergy);
417 uint16_t current,
bool enable);
482 uint32_t rms, uint32_t *micro);
Definition: ade7816.h:298
@ ADE7816_CHANNEL_A
Definition: ade7816.h:223
struct no_os_gpio_desc * reset_desc
Definition: ade7816.h:331
#define ADE7816_HWRST_DELAY
Definition: ade7816.h:210
#define ADE7816_PCF_E_COEFF_REG
Definition: ade7816.h:99
#define ADE7816_IERMSOS_REG
Definition: ade7816.h:62
#define MILLI
Definition: no_os_units.h:48
#define ADE7816_IDGAIN_REG
Definition: ade7816.h:51
Structure holding the parameters for GPIO initialization.
Definition: no_os_gpio.h:79
#define ADE7816_CVAROS_REG
Definition: ade7816.h:81
int ade7816_set_reactive_thr(struct ade7816_desc *desc, uint16_t freq)
ADE7816 set reactive energy threshold value function.
Definition: ade7816.c:358
#define ADE7816_IBGAIN_REG
Definition: ade7816.h:49
#define ADE7816_REVSEL_MASK
Definition: ade7816.h:201
@ ADE7816_DREADY_INT
Definition: ade7816.h:260
int ade7816_set_comm(struct ade7816_desc *desc, enum ade7816_comm_type type)
ADE7816 set communication function.
Definition: ade7816.c:136
#define ADE7816_COMPMODE_REG
Definition: ade7816.h:153
#define ADE7816_CONFIG_REG
Definition: ade7816.h:157
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
enum ade7816_active_irq active_irq
Definition: ade7816.h:308
#define ADE7816_DVARGAIN_REG
Definition: ade7816.h:82
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
Definition: ade7816.h:259
uint32_t status0
Definition: ade7816.h:346
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
int ade7816_get_reactive_thr(struct ade7816_desc *desc, uint16_t *freq)
ADE7816 get reactive energy threshold value function.
Definition: ade7816.c:384
int ade7816_group_sel(struct ade7816_desc *desc, enum ade7816_channel chan)
ADE7816 group selection for channels function.
Definition: ade7816.c:1039
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
int ade7816_set_active_thr(struct ade7816_desc *desc, uint16_t freq)
ADE7816 set active energy threshold value function.
Definition: ade7816.c:238
#define ADE7816_VARTHR1_REG
Definition: ade7816.h:91
#define ADE7816_THR_MSB_MASK
Definition: ade7816.h:185
Header file of ADE7816 Driver.
@ ADE7816_PKI_INT
Definition: ade7816.h:275
#define ADE7816_FIRST_BYTE_MASK
Definition: ade7816.h:177
@ ADE7816_ZXI2_INT
Definition: ade7816.h:269
struct no_os_gpio_init_param * gpio_irq1_param
Definition: ade7816.h:304
Structure describing a callback to be registered.
Definition: no_os_irq.h:142
#define ADE7816_EWGAIN_REG
Definition: ade7816.h:72
#define ADE7816_PEAKCYC_REG
Definition: ade7816.h:162
void * handle_irq0
Definition: ade7816.h:314
@ ADE7816_REVAP2_INT
Definition: ade7816.h:255
int ade7816_hw_reset(struct ade7816_desc *desc)
ADE7816 hardware reset function.
Definition: ade7816.c:111
@ ADE7816_CURRENT_GAIN
Definition: ade7816.h:232
@ ADE7816_NLOAD1_INT
Definition: ade7816.h:261
#define ADE7816_PCF_A_COEFF_REG
Definition: ade7816.h:95
#define ADE7816_AVAROS_REG
Definition: ade7816.h:77
#define ADE7816_CHSIGN_REG
Definition: ade7816.h:156
#define ADE7816_FWATTOS_REG
Definition: ade7816.h:75
Header file of SPI Interface.
#define ADE7816_PCF_F_COEFF_REG
Definition: ade7816.h:100
Header file of IRQ interface.
#define ADE7816_IDRMSOS_REG
Definition: ade7816.h:61
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
#define ADE7816_SWRST_MASK
Definition: ade7816.h:179
@ ADE7816_REVAP1_INT
Definition: ade7816.h:254
struct no_os_gpio_init_param * ss_param
Definition: ade7816.h:302
struct no_os_spi_desc * spi_desc
Definition: ade7816.h:328
#define ADE7816_PCF_B_COEFF_REG
Definition: ade7816.h:96
@ ADE7816_CHANNEL_F
Definition: ade7816.h:228
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
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_REVRP2_INT
Definition: ade7816.h:258
struct no_os_i2c_desc * i2c_desc
Definition: ade7816.h:329
@ ADE7816_REVAP3_INT
Definition: ade7816.h:256
ade7816_active_irq
Definition: ade7816.h:279
#define ADE7816_IARMSOS_REG
Definition: ade7816.h:58
#define ADE7816_DWGAIN_REG
Definition: ade7816.h:70
#define ADE7816_IEGAIN_REG
Definition: ade7816.h:52
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
Definition: ade7816.h:238
ade7816_reg_read reg_read
Definition: ade7816.h:339
struct no_os_irq_ctrl_desc * irq_ctrl
Definition: ade7816.h:335
@ ADE7816_PEAKSEL_1_BE
Definition: ade7816.h:239
int ade7816_reg_update(struct ade7816_desc *desc, uint16_t reg, uint32_t mask, uint32_t val)
Register update function.
Definition: ade7816.c:71
Header file of Delay functions.
#define ADE7816_AWATTOS_REG
Definition: ade7816.h:65
int ade7816_get_active_thr(struct ade7816_desc *desc, uint16_t *freq)
ADE7816 get active energy threshold value function.
Definition: ade7816.c:264
void(* irq1_callback)(void *context)
Definition: ade7816.h:324
#define ADE7816_LINECYC_REG
Definition: ade7816.h:151
#define ADE7816_CWGAIN_REG
Definition: ade7816.h:68
#define ADE7816_CWATTHR_REG
Definition: ade7816.h:114
#define NO_OS_DIV_ROUND_CLOSEST_ULL(x, y)
Definition: no_os_util.h:56
@ ADE7816_CHANNEL_VOLTAGE
Definition: ade7816.h:222
int ade7816_set_active_thr(struct ade7816_desc *desc, uint16_t freq)
ADE7816 set active energy threshold value function.
Definition: ade7816.c:238
Definition: ade7816.h:327
int ade7816_read_period(struct ade7816_desc *desc, uint32_t *period_us)
ADE7816 read period value function.
Definition: ade7816.c:1203
int ade7816_reg_update(struct ade7816_desc *desc, uint16_t reg, uint32_t mask, uint32_t val)
Register update function.
Definition: ade7816.c:71
int ade7816_zx_detect(struct ade7816_desc *desc, enum ade7816_channel chan)
ADE7816 zero-crossing detection for channel function.
Definition: ade7816.c:1067
#define ADE7816_AVARGAIN_REG
Definition: ade7816.h:76
#define ADE7816_EWATTOS_REG
Definition: ade7816.h:73
@ NO_OS_GPIO_HIGH
Definition: no_os_gpio.h:117
int ade7816_power_dir(struct ade7816_desc *desc, enum ade7816_channel chan)
ADE7816 set power direction for channel function.
Definition: ade7816.c:1127
#define ADE7816_EVAROS_REG
Definition: ade7816.h:85
@ ADE7816_OV_INT
Definition: ade7816.h:274
@ ADE7816_REHF1_INT
Definition: ade7816.h:251
#define ADE7816_I2C_LOCK_MASK
Definition: ade7816.h:181
uint32_t irq0_priority
Definition: ade7816.h:311
#define ADE7816_CONFIG2_REG
Definition: ade7816.h:168
ade7816_reg_write reg_write
Definition: ade7816.h:340
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
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
Definition: ade7816.h:270
@ NO_OS_IRQ_EDGE_FALLING
Definition: no_os_irq.h:79
#define ADE7816_BWATTOS_REG
Definition: ade7816.h:67
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
int ade7816_zx_timeout(struct ade7816_desc *desc, uint32_t timeout_us)
ADE7816 zero-crossing detection timeout value function.
Definition: ade7816.c:1089
#define ADE7816_THR_LSB_MASK
Definition: ade7816.h:186
enum ade7816_active_irq active_irq
Definition: ade7816.h:342
struct no_os_gpio_init_param * gpio_irq0_param
Definition: ade7816.h:303
uint32_t status1
Definition: ade7816.h:347
struct no_os_i2c_init_param * i2c_param
Definition: ade7816.h:300
#define ADE7816_VRMS_REG
Definition: ade7816.h:102
#define ADE7816_IBRMS_REG
Definition: ade7816.h:104
#define ADE7816_CVARGAIN_REG
Definition: ade7816.h:80
enum no_os_irq_peripheral peripheral
Definition: no_os_irq.h:150
#define ADE7816_FVAROS_REG
Definition: ade7816.h:87
#define ADE7816_IFRMSOS_REG
Definition: ade7816.h:63
#define MICRO
Definition: no_os_units.h:49
#define ADE7816_VGAIN_REG
Definition: ade7816.h:47
@ ADE7816_ZXV_INT
Definition: ade7816.h:267
enum ade7816_channel chan
Definition: ade7816.h:344
@ NO_OS_GPIO_LOW
Definition: no_os_gpio.h:115
struct no_os_spi_init_param * spi_param
Definition: ade7816.h:299
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
#define ADE7816_MMODE_REG
Definition: ade7816.h:159
@ ADE7816_CHANNEL_E
Definition: ade7816.h:227
#define ADE7816_BVARGAIN_REG
Definition: ade7816.h:78
@ ADE7816_SPI
Definition: ade7816.h:218
@ ADE7816_SAG_INT
Definition: ade7816.h:272
#define ADE7816_MMODE_MASK
Definition: ade7816.h:199
#define ADE7816_LMASK
Definition: ade7816.h:190
@ ADE7816_REHF2_INT
Definition: ade7816.h:252
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
#define ADE7816_IERMS_REG
Definition: ade7816.h:107
void no_os_mdelay(uint32_t msecs)
Wait until msecs milliseconds passed.
Definition: aducm3029_delay.c:126
int ade7816_read_period(struct ade7816_desc *desc, uint32_t *period_us)
ADE7816 read period value function.
Definition: ade7816.c:1203
uint32_t no_os_field_prep(uint32_t mask, uint32_t val)
struct no_os_irq_ctrl_desc * irq_ctrl
Definition: ade7816.h:306
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
int ade7816_set_comm(struct ade7816_desc *desc, enum ade7816_comm_type type)
ADE7816 set communication function.
Definition: ade7816.c:136
struct no_os_callback_desc irq0_cb
Definition: ade7816.h:336
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
uint32_t irq1_priority
Definition: ade7816.h:312
@ ADE7816_CHANNEL_B
Definition: ade7816.h:224
int ade7816_power_dir(struct ade7816_desc *desc, enum ade7816_channel chan)
ADE7816 set power direction for channel function.
Definition: ade7816.c:1127
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
#define ADE7816_SECOND_BYTE_MASK
Definition: ade7816.h:176
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
Definition: ade7816.h:273
int ade7816_group_sel(struct ade7816_desc *desc, enum ade7816_channel chan)
ADE7816 group selection for channels function.
Definition: ade7816.c:1039
#define ADE7816_DVAROS_REG
Definition: ade7816.h:83
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
#define ADE7816_DVARHR_REG
Definition: ade7816.h:121
int ade7816_hw_reset(struct ade7816_desc *desc)
ADE7816 hardware reset function.
Definition: ade7816.c:111
#define ADE7816_FVARHR_REG
Definition: ade7816.h:123
#define ADE7816_SIGN_MASK(x)
Definition: ade7816.h:205
#define ADE7816_VRMSOS_REG
Definition: ade7816.h:57
#define ADE7816_ZXTOUT_REG
Definition: ade7816.h:152
@ ADE7816_CHANNEL_D
Definition: ade7816.h:226
#define ADE7816_PERIOD_REG
Definition: ade7816.h:148
struct no_os_callback_desc irq1_cb
Definition: ade7816.h:337
#define ADE7816_IFRMS_REG
Definition: ade7816.h:108
void * ctx
Definition: no_os_irq.h:146
#define ADE7816_STATUS0_REG
Definition: ade7816.h:127
#define ADE7816_ICRMSOS_REG
Definition: ade7816.h:60
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
Definition: ade7816.h:276
#define ADE7816_LENERGY_MASK
Definition: ade7816.h:193
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
enum ade7816_comm_type comm_type
Definition: ade7816.h:343
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
void(* irq0_callback)(void *context)
Definition: ade7816.h:323
#define ADE7816_BVAROS_REG
Definition: ade7816.h:79
@ ADE7816_AEHF2_INT
Definition: ade7816.h:250
#define ADE7816_CHANNEL_SEL_MASK
Definition: ade7816.h:195
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
Definition: ade7816.h:234
ade7816_channel
Definition: ade7816.h:221
#define ADE7816_EVARGAIN_REG
Definition: ade7816.h:84
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
Definition: ade7816.h:217
#define ADE7816_DWATTOS_REG
Definition: ade7816.h:71
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
int(* ade7816_reg_write)(struct ade7816_desc *desc, uint16_t reg, uint32_t val)
Definition: ade7816.h:295
@ ADE7816_REVRP1_INT
Definition: ade7816.h:257
#define ADE7816_EWATTHR_REG
Definition: ade7816.h:116
#define ADE7816_MASK1_REG
Definition: ade7816.h:134
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
Definition: ade7816.h:288
Structure holding SPI descriptor.
Definition: no_os_spi.h:192
#define ADE7816_AWATTHR_REG
Definition: ade7816.h:112
#define ADE7816_FVARGAIN_REG
Definition: ade7816.h:86
#define ADE7816_IAGAIN_REG
Definition: ade7816.h:48
struct no_os_gpio_init_param * reset_param
Definition: ade7816.h:301
@ ADE7816_IRQ1
Definition: ade7816.h:282
void * handle
Definition: no_os_irq.h:152
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
void(* callback)(void *context)
Definition: no_os_irq.h:144
@ ADE7816_VOLTAGE_CURRENT
Definition: ade7816.h:244
Structure holding the GPIO descriptor.
Definition: no_os_gpio.h:96
@ ADE7816_ZXI1_INT
Definition: ade7816.h:268
int ade7816_remove(struct ade7816_desc *desc)
Free the resources allocated during init.
Definition: ade7816.c:1657
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
#define ADE7816_BVARHR_REG
Definition: ade7816.h:119
#define ADE7816_AVARHR_REG
Definition: ade7816.h:118
int ade7816_read_reg(struct ade7816_desc *desc, uint16_t reg, uint32_t *val)
Register read wrapper function.
Definition: ade7816.c:45
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
Definition: ade7816.h:233
#define ADE7816_PCF_D_COEFF_REG
Definition: ade7816.h:98
Structure holding I2C address descriptor.
Definition: no_os_i2c.h:101
enum ade7816_comm_type comm_type
Definition: ade7816.h:309
ade7816_angle_sel
Definition: ade7816.h:243
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
Definition: ade7816.h:237
enum no_os_irq_event event
Definition: no_os_irq.h:148
Header file of I2C Interface.
#define ADE7816_ACCMODE_REG
Definition: ade7816.h:160
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
int ade7816_read_reg(struct ade7816_desc *desc, uint16_t reg, uint32_t *val)
Register read wrapper function.
Definition: ade7816.c:45
int ade7816_set_interrupt(struct ade7816_desc *desc, enum ade7816_status_int status_int, bool enable)
ADE7816 set interrupts function.
Definition: ade7816.c:1229
#define ADE7816_AWGAIN_REG
Definition: ade7816.h:64
void * handle_irq1
Definition: ade7816.h:315
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
uint32_t no_os_field_get(uint32_t mask, uint32_t word)
@ ADE7816_CHANNEL_C
Definition: ade7816.h:225
@ ADE7816_NO_IRQ
Definition: ade7816.h:280
@ ADE7816_ZXTOI2_INT
Definition: ade7816.h:265
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
Definition: ade7816.h:240
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
Definition: ade7816.h:262
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
#define ADE7816_RSTREAD_MASK
Definition: ade7816.h:188
#define ADE7816_FWATTHR_REG
Definition: ade7816.h:117
int ade7816_write_reg(struct ade7816_desc *desc, uint16_t reg, uint32_t val)
Register write wrapper function.
Definition: ade7816.c:57
int ade7816_remove(struct ade7816_desc *desc)
Free the resources allocated during init.
Definition: ade7816.c:1657
#define ADE7816_INIT_DELAY
Definition: ade7816.h:209
int ade7816_zx_detect(struct ade7816_desc *desc, enum ade7816_channel chan)
ADE7816 zero-crossing detection for channel function.
Definition: ade7816.c:1067
void no_os_udelay(uint32_t usecs)
Wait until usecs microseconds passed.
Definition: aducm3029_delay.c:114
Structure holding the parameters for I2C initialization.
Definition: no_os_i2c.h:64
#define NULL
Definition: wrapper.h:64
int ade7816_init(struct ade7816_desc **desc, struct ade7816_init_param *init_param)
Initialize and configure the ADE7816 device.
Definition: ade7816.c:1417
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
uint32_t irq_ctrl_id
Definition: no_os_irq.h:125
#define ADE7816_VARTHR0_REG
Definition: ade7816.h:92
ade7816_pcf_coeff
Definition: ade7816.h:286
#define ADE7816_LCYCMODE_REG
Definition: ade7816.h:161
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
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
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
Definition: no_os_irq.h:62
#define ADE7816_STATUS1_REG
Definition: ade7816.h:128
#define ADE7816_IARMS_REG
Definition: ade7816.h:103
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
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
int ade7816_zx_timeout(struct ade7816_desc *desc, uint32_t timeout_us)
ADE7816 zero-crossing detection timeout value function.
Definition: ade7816.c:1089
#define ADE7816_IFGAIN_REG
Definition: ade7816.h:53
struct no_os_gpio_desc * ss_desc
Definition: ade7816.h:332
int(* ade7816_reg_read)(struct ade7816_desc *desc, uint16_t reg, uint32_t *val)
Definition: ade7816.h:293
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
Definition: ade7816.h:253
int ade7816_set_interrupt(struct ade7816_desc *desc, enum ade7816_status_int status_int, bool enable)
ADE7816 set interrupts function.
Definition: ade7816.c:1229
#define ADE7816_MASK0_REG
Definition: ade7816.h:133
#define ADE7816_BWGAIN_REG
Definition: ade7816.h:66
ade7816_gain_type
Definition: ade7816.h:231
int ade7816_sw_reset(struct ade7816_desc *desc)
ADE7816 software reset function.
Definition: ade7816.c:92
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
#define ADE7816_IDRMS_REG
Definition: ade7816.h:106
#define ADE7816_PCF_C_COEFF_REG
Definition: ade7816.h:97
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
Definition: ade7816.h:249
#define ADE7816_LINECYC_VAL(enable)
Definition: ade7816.h:212
#define ADE7816_BWATTHR_REG
Definition: ade7816.h:113
#define ADE7816_CWATTOS_REG
Definition: ade7816.h:69
Header file of GPIO Interface.
#define ADE7816_INT_MASK(x)
Definition: ade7816.h:207
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
Definition: ade7816.h:266
@ ADE7816_CURRENT_CURRENT
Definition: ade7816.h:245
@ NO_OS_GPIO_IRQ
Definition: no_os_irq.h:85
#define ADE7816_ICRMS_REG
Definition: ade7816.h:105
struct no_os_gpio_desc * gpio_irq0_desc
Definition: ade7816.h:333
#define ADE7816_ANGLESEL_MASK
Definition: ade7816.h:203
#define ADE7816_WTHR1_REG
Definition: ade7816.h:89
#define ADE7816_DWATTHR_REG
Definition: ade7816.h:115
int ade7816_write_reg(struct ade7816_desc *desc, uint16_t reg, uint32_t val)
Register write wrapper function.
Definition: ade7816.c:57
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
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
bool lcycle_mode
Definition: ade7816.h:349
#define ADE7816_ZX_SEL_MASK
Definition: ade7816.h:191
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
#define ADE7816_WTHR0_REG
Definition: ade7816.h:90
#define ADE7816_RUN_REG
Definition: ade7816.h:110
struct no_os_gpio_desc * gpio_irq1_desc
Definition: ade7816.h:334
@ ADE7816_ZXTOV_INT
Definition: ade7816.h:263
Header file of utility functions.
int32_t no_os_sign_extend32(uint32_t value, int index)
@ ADE7816_RSTDONE_INT
Definition: ade7816.h:271
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
#define ADE7816_IBRMSOS_REG
Definition: ade7816.h:59
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
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
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
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
#define ADE7816_VARNOLOAD_REG
Definition: ade7816.h:94
Definition: no_os_irq.h:123
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
#define ADE7816_APNOLOAD_REG
Definition: ade7816.h:93
@ ADE7816_PCF_50HZ
Definition: ade7816.h:287
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
#define ADE7816_CVARHR_REG
Definition: ade7816.h:120
@ ADE7816_ZXTOI1_INT
Definition: ade7816.h:264
int32_t number
Definition: no_os_gpio.h:100
#define ADE7816_ICGAIN_REG
Definition: ade7816.h:50
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
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
Definition: ade7816.h:216
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
struct no_os_spi_init_param * spi_param
Definition: ad7616.h:204
int ade7816_sw_reset(struct ade7816_desc *desc)
ADE7816 software reset function.
Definition: ade7816.c:92
@ ADE7816_IRQ0
Definition: ade7816.h:281
#define ADE7816_FWGAIN_REG
Definition: ade7816.h:74
#define NO_OS_DIV_ROUND_CLOSEST(x, y)
Definition: no_os_util.h:54
#define ADE7816_EVARHR_REG
Definition: ade7816.h:122
@ ADE7816_IRQ0_IRQ1
Definition: ade7816.h:283
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
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:140
ade7816_status_int
Definition: ade7816.h:248
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