no-OS
|
Source file of ADE7816 Driver. More...
Functions | |
int | ade7816_read_reg (struct ade7816_desc *desc, uint16_t reg, uint32_t *val) |
Register read wrapper function. More... | |
int | ade7816_write_reg (struct ade7816_desc *desc, uint16_t reg, uint32_t val) |
Register write wrapper function. More... | |
int | ade7816_reg_update (struct ade7816_desc *desc, uint16_t reg, uint32_t mask, uint32_t val) |
Register update function. More... | |
int | ade7816_sw_reset (struct ade7816_desc *desc) |
ADE7816 software reset function. More... | |
int | ade7816_hw_reset (struct ade7816_desc *desc) |
ADE7816 hardware reset function. More... | |
int | ade7816_set_comm (struct ade7816_desc *desc, enum ade7816_comm_type type) |
ADE7816 set communication function. More... | |
int | ade7816_read_active_energy (struct ade7816_desc *desc, enum ade7816_channel chan, int32_t *val) |
ADE7816 read active energy function. More... | |
int | ade7816_set_active_thr (struct ade7816_desc *desc, uint16_t freq) |
ADE7816 set active energy threshold value function. More... | |
int | ade7816_get_active_thr (struct ade7816_desc *desc, uint16_t *freq) |
ADE7816 get active energy threshold value function. More... | |
int | ade7816_read_reactive_energy (struct ade7816_desc *desc, enum ade7816_channel chan, int32_t *val) |
ADE7816 read reactive energy value function. More... | |
int | ade7816_set_reactive_thr (struct ade7816_desc *desc, uint16_t freq) |
ADE7816 set reactive energy threshold value function. More... | |
int | ade7816_get_reactive_thr (struct ade7816_desc *desc, uint16_t *freq) |
ADE7816 get reactive energy threshold value function. More... | |
int | ade7816_set_lcycle_mode (struct ade7816_desc *desc, bool enable, uint16_t cycles, bool lenergy) |
ADE7816 set line cycle mode function. More... | |
int | ade7816_read_rms (struct ade7816_desc *desc, enum ade7816_channel chan, uint32_t *rms) |
ADE7816 read root mean square measurement value function. More... | |
int | ade7816_set_no_load (struct ade7816_desc *desc, uint16_t voltage, uint16_t current, bool enable) |
ADE7816 set no load condition function. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
int | ade7816_set_phase (struct ade7816_desc *desc, enum ade7816_channel chan, enum ade7816_pcf_coeff pcf_coeff) |
ADE7816 set phase calibration coefficient function. More... | |
int | ade7816_calib_rms (struct ade7816_desc *desc, enum ade7816_channel chan, int32_t rms) |
ADE7816 root mean square measurement calibration function. More... | |
int | ade7816_group_sel (struct ade7816_desc *desc, enum ade7816_channel chan) |
ADE7816 group selection for channels function. More... | |
int | ade7816_zx_detect (struct ade7816_desc *desc, enum ade7816_channel chan) |
ADE7816 zero-crossing detection for channel function. More... | |
int | ade7816_zx_timeout (struct ade7816_desc *desc, uint32_t timeout_us) |
ADE7816 zero-crossing detection timeout value function. More... | |
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. More... | |
int | ade7816_power_dir (struct ade7816_desc *desc, enum ade7816_channel chan) |
ADE7816 set power direction for channel function. More... | |
int | ade7816_read_dir (struct ade7816_desc *desc, enum ade7816_channel chan, bool *sign) |
ADE7816 get power direction for channel function. More... | |
int | ade7816_angle_meas (struct ade7816_desc *desc, enum ade7816_channel chan, enum ade7816_angle_sel sel) |
ADE7816 angle measurement function. More... | |
int | ade7816_read_period (struct ade7816_desc *desc, uint32_t *period_us) |
ADE7816 read period value function. More... | |
int | ade7816_set_interrupt (struct ade7816_desc *desc, enum ade7816_status_int status_int, bool enable) |
ADE7816 set interrupts function. More... | |
int | ade7816_get_interrupt (struct ade7816_desc *desc, enum ade7816_status_int status_int, bool *enable) |
ADE7816 get interrupts function. More... | |
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. More... | |
int | ade7816_init (struct ade7816_desc **desc, struct ade7816_init_param *init_param) |
Initialize and configure the ADE7816 device. More... | |
int | ade7816_remove (struct ade7816_desc *desc) |
Free the resources allocated during init. More... | |
Source file of ADE7816 Driver.
Copyright 2024(c) Analog Devices, Inc.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
int ade7816_angle_meas | ( | struct ade7816_desc * | desc, |
enum ade7816_channel | chan, | ||
enum ade7816_angle_sel | sel | ||
) |
ADE7816 angle measurement function.
desc | - ADE7816 device descriptor. |
chan | - Channel number. |
sel | - Angle selection value. |
int ade7816_calib_rms | ( | struct ade7816_desc * | desc, |
enum ade7816_channel | chan, | ||
int32_t | rms | ||
) |
ADE7816 root mean square measurement calibration function.
desc | - ADE7816 device descriptor. |
chan | - Channel number. |
rms | - Expected root mean square measurement value. |
int ade7816_get_active_thr | ( | struct ade7816_desc * | desc, |
uint16_t * | freq | ||
) |
ADE7816 get active energy threshold value function.
desc | - ADE7816 device descriptor. |
freq | - Update rate frequency. |
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.
desc | - ADE7816 device descriptor. |
chan | - Channel number. |
scale | - Scale percentage of full-scale (100.00% = 10000) |
gain | - Gain type. |
int ade7816_get_interrupt | ( | struct ade7816_desc * | desc, |
enum ade7816_status_int | status_int, | ||
bool * | enable | ||
) |
ADE7816 get interrupts function.
desc- | ADE7816 device descriptor. |
status_int | - Interrupt selection value. |
enable | - False = Disable True = Enable |
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.
desc | - ADE7816 device descriptor. |
chan | - Channel number. |
scale | - Scale percentage value (100.00% = 10000) |
gain | - Gain type. |
int ade7816_get_reactive_thr | ( | struct ade7816_desc * | desc, |
uint16_t * | freq | ||
) |
ADE7816 get reactive energy threshold value function.
desc | - ADE7816 device descriptor. |
freq | - Update rate frequency. |
int ade7816_group_sel | ( | struct ade7816_desc * | desc, |
enum ade7816_channel | chan | ||
) |
ADE7816 group selection for channels function.
desc | - ADE7816 device descriptor. |
chan | - Channel number. |
int ade7816_hw_reset | ( | struct ade7816_desc * | desc | ) |
ADE7816 hardware reset function.
desc | - ADE7816 device descriptor |
int ade7816_init | ( | struct ade7816_desc ** | desc, |
struct ade7816_init_param * | init_param | ||
) |
Initialize and configure the ADE7816 device.
desc | - device descriptor for the ADE7816 that will be initialized. |
init_param | - initialization parameter for the device. |
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.
desc- | ADE7816 device descriptor. |
chan | - Channel number. |
mmode | - Measurement mode selection value. |
no_of_cycles | - Set the line cycles number over which peak measurements are performed. |
int ade7816_power_dir | ( | struct ade7816_desc * | desc, |
enum ade7816_channel | chan | ||
) |
ADE7816 set power direction for channel function.
desc | - ADE7816 device descriptor. |
chan | - Channel number. |
int ade7816_read_active_energy | ( | struct ade7816_desc * | desc, |
enum ade7816_channel | chan, | ||
int32_t * | val | ||
) |
ADE7816 read active energy function.
desc | - ADE7816 device descriptor |
chan | - Channel number. |
val | - Active energy value. |
int ade7816_read_dir | ( | struct ade7816_desc * | desc, |
enum ade7816_channel | chan, | ||
bool * | sign | ||
) |
ADE7816 get power direction for channel function.
desc | - ADE7816 device descriptor. |
chan | - Channel number. |
sign | - Power direction sign. |
int ade7816_read_period | ( | struct ade7816_desc * | desc, |
uint32_t * | period_us | ||
) |
ADE7816 read period value function.
desc | - ADE7816 device descriptor. |
period_us | - Period value in microseconds. |
int ade7816_read_reactive_energy | ( | struct ade7816_desc * | desc, |
enum ade7816_channel | chan, | ||
int32_t * | val | ||
) |
ADE7816 read reactive energy value function.
desc | - ADE7816 device descriptor. |
chan | - Channel number. |
val | - Reactive energy value. |
int ade7816_read_reg | ( | struct ade7816_desc * | desc, |
uint16_t | reg, | ||
uint32_t * | val | ||
) |
Register read wrapper function.
desc | - ADE7816 device descriptor. |
reg | - Register Address value. |
val | - Register Value to be read. |
int ade7816_read_rms | ( | struct ade7816_desc * | desc, |
enum ade7816_channel | chan, | ||
uint32_t * | rms | ||
) |
ADE7816 read root mean square measurement value function.
desc | - ADE7816 device descriptor. |
chan | - Channel number. |
rms | - RMS value. |
int ade7816_reg_update | ( | struct ade7816_desc * | desc, |
uint16_t | reg, | ||
uint32_t | mask, | ||
uint32_t | val | ||
) |
Register update function.
desc | - ADE7816 device descriptor. |
reg | - address of the register. |
mask | - bit mask of the field to be updated. |
val | - value of the masked field. Should be bit shifted by using no_os_field_prep(mask, val). |
int ade7816_remove | ( | struct ade7816_desc * | desc | ) |
Free the resources allocated during init.
desc | - device descriptor for the ADE7816 that will be initialized. |
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.
desc | - ADE7816 device descriptor. |
chan | - Channel number. |
rms | - RMS value. |
micro | - RMs value in microunits. |
int ade7816_set_active_thr | ( | struct ade7816_desc * | desc, |
uint16_t | freq | ||
) |
ADE7816 set active energy threshold value function.
desc | - ADE7816 device descriptor. |
freq | - Update rate frequency. |
int ade7816_set_comm | ( | struct ade7816_desc * | desc, |
enum ade7816_comm_type | type | ||
) |
ADE7816 set communication function.
desc | - ADE7816 device descriptor |
type | - Communication type. |
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.
desc | - ADE7816 device descriptor. |
chan | - Channel number. |
scale | - Scale percentage of full-scale (100.00% = 10000) |
gain | - Gain type. |
int ade7816_set_interrupt | ( | struct ade7816_desc * | desc, |
enum ade7816_status_int | status_int, | ||
bool | enable | ||
) |
ADE7816 set interrupts function.
desc- | ADE7816 device descriptor. |
status_int | - Interrupt selection value. |
enable | - False = Disable True = Enable |
int ade7816_set_lcycle_mode | ( | struct ade7816_desc * | desc, |
bool | enable, | ||
uint16_t | cycles, | ||
bool | lenergy | ||
) |
ADE7816 set line cycle mode function.
desc | - ADE7816 device descriptor. |
enable | - False = Disable True = Enable |
cycles | - Cycle lines number. |
lenergy | - Set lenergy bit. |
int ade7816_set_no_load | ( | struct ade7816_desc * | desc, |
uint16_t | voltage, | ||
uint16_t | current, | ||
bool | enable | ||
) |
ADE7816 set no load condition function.
desc | - ADE7816 device descriptor. |
voltage | - Voltage percent of the full-scale (100.00% = 10000). |
current | - Current percent of the full-scale (100.00% = 10000). |
enable | - False = Disable True = Enable |
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.
desc | - ADE7816 device descriptor. |
chan | - Channel number. |
scale | - Scale percentage value (100.00% = 10000) |
gain | - Gain type. |
int ade7816_set_phase | ( | struct ade7816_desc * | desc, |
enum ade7816_channel | chan, | ||
enum ade7816_pcf_coeff | pcf_coeff | ||
) |
ADE7816 set phase calibration coefficient function.
desc | - ADE7816 device descriptor. |
chan | - Channel number. |
pcf_coeff | - Phase coefficient value. |
int ade7816_set_reactive_thr | ( | struct ade7816_desc * | desc, |
uint16_t | freq | ||
) |
ADE7816 set reactive energy threshold value function.
desc | - ADE7816 device descriptor. |
freq | - Update rate frequency. |
int ade7816_sw_reset | ( | struct ade7816_desc * | desc | ) |
ADE7816 software reset function.
desc | - ADE7816 device descriptor. |
int ade7816_write_reg | ( | struct ade7816_desc * | desc, |
uint16_t | reg, | ||
uint32_t | val | ||
) |
Register write wrapper function.
desc | - ADE7816 device descriptor |
reg | - Register Address value. |
val | - Register Value to be written. |
int ade7816_zx_detect | ( | struct ade7816_desc * | desc, |
enum ade7816_channel | chan | ||
) |
ADE7816 zero-crossing detection for channel function.
desc | - ADE7816 device descriptor. |
chan | - Channel number. |
int ade7816_zx_timeout | ( | struct ade7816_desc * | desc, |
uint32_t | timeout_us | ||
) |
ADE7816 zero-crossing detection timeout value function.
desc | - ADE7816 device descriptor. |
timeout_us | - Timeout value in microseconds. |