Files
kunlun/export/inc/bsp/iot_energe_meter_api_v2.h
2024-09-28 14:24:04 +08:00

704 lines
25 KiB
C
Executable File

/****************************************************************************
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
be copied by any method or incorporated into another program without
the express written consent of Aerospace C.Power. This Information or any portion
thereof remains the property of Aerospace C.Power. The Information contained herein
is believed to be accurate and Aerospace C.Power assumes no responsibility or
liability for its use in any way and conveys no license or title under
any patent or copyright and makes no representation or warranty that this
Information is free from patent or copyright infringement.
****************************************************************************/
#ifndef IOT_ENERGE_METER_API_V2_H
#define IOT_ENERGE_METER_API_V2_H
#ifdef __cplusplus
extern "C" {
#endif
#include "os_types_api.h"
/* Chip type: kunlun1. */
#define IOT_EM_WQ3011 (1)
/* Chip type: kunlun2. */
#define IOT_EM_WQ3021 (2)
/* Times of harmonic analysis. */
#define IOT_EM_HARMONIC_ANALYSIS_TIMES (21)
/**
* @brief Chip info that custom can get when using energy meter module.
*/
typedef struct _iot_em_chip_info_t {
/* Type of chip, kunlun1/kunlun2, read only, can not set. */
uint8_t chip_type;
} iot_em_chip_info_t;
/**
* @brief Standard level data stored in each phase.
* The metering function is divided into three different API levels:
* 1.Standard level API:
* Only return energy number.
* 2.Professional level API:
* Increase the amplitude of harmonic analysis,
* and assist function to judge harmonic amplitude changes.
* 3.Industrial grade API:
* Increase the angle of harmonic analysis, namely vector signal.
* When naming functions, structs, using different suffixes to distinguish their level.
* Standard level API: xxx_st;
* Professional level API: xxx_pro;
* Industrial grade API: xxx_ind;
* If a standard chip is purchased and an industrial-grade API is invoked,
* the software returns the status word - unauthorized.
*/
typedef struct _iot_em_phase_data_std_t {
/* Signal frequency, unit is 0.01Hz. */
uint32_t signal_freq_perc;
/* Current value, mA. */
int32_t current_ma;
/* Slide current value, mA. */
int32_t slide_current_ma;
/* Voltage value, mV. */
int32_t voltage_mv;
/* Slide voltage value, mA. */
int32_t slide_voltage_mv;
/* Power value, mW. */
int32_t power_mw;
/* Slide power value, mW. */
int32_t slide_power_mw;
/* Apparent power value, mW. */
int32_t apparent_pwr_mw;
/* Power factor value, 0.01. */
int32_t factor_perc;
/* The energy increment in a certain period of time, unit is 1mWs=1mW*1s,
* since unit of energy in SI is Joule, 1J=1W*1s, so developer need store
* and convert the energy increment to the total energy value wanted.
* Convert method: 1mWs=1mW*1s=0.001J, 1KWH=1000W*3600s=3600000J.
*/
int32_t energy_inc_mws;
} iot_em_phase_data_std_t;
/**
* @brief Professional level data stored in each phase.
*/
typedef struct _iot_em_phase_data_pro_t {
/* Harmonic analysis amplitude variation threshold. */
int32_t harmonic_ampl_thr;
/* Harmonic analysis amplitude of all times harmonics in each phase. */
int32_t harmonic_ampl[IOT_EM_HARMONIC_ANALYSIS_TIMES];
} iot_em_phase_data_pro_t;
/**
* @brief Industrial grade data stored in each phase.
*/
typedef struct _iot_em_phase_data_ind_t {
/* Harmonic analysis angle of all times harmonics in each phase. */
int32_t harmonic_angle[IOT_EM_HARMONIC_ANALYSIS_TIMES];
} iot_em_phase_data_ind_t;
/**
* @brief Get Standard level data of each phase callback function.
*/
typedef void (*iot_em_phase_get_data_std_cb)(iot_em_phase_data_std_t *p_phase_data);
/**
* @brief Get Professional level data of each phase callback function.
*/
typedef void (*iot_em_phase_get_data_pro_cb)(iot_em_phase_data_pro_t *p_phase_data);
/**
* @brief Get Industrial grade data of each phase callback function.
*/
typedef void (*iot_em_phase_get_data_ind_cb)(iot_em_phase_data_ind_t *p_phase_data);
/**
* @brief Energy meter ADC pin, per adc internal channel connects to chip pin directly.
* So, developer can take pin same as internal channel. Here has two ADC modules in
* kunlun2, include ADC0 and ADC1, ADC0 has 8 channels: 0~7, ADC1 has 7 channels: 0~6.
* The number of encapsulated pin is different in different versions of packaging.
* Please confirm the information of the encapsulated pin before specific application.
* Ex, current packaging version chip pin used for ADC0 has 8 pins:AD0_CH1~AD7_CH1;
* ADC1 has 5 pins: AD0_CH2~AD4_CH2. Their channel, pin, phase need to be used separately.
* ADC0 channel can only use pin and phase for ADC0.
* When using differential channel-pin, the two channel-pins act as one
* differential pair input, it only uses one phase to sample and store.
* Ex, when using ADC1 channel 3 and channel 2 as one differential pair input,
* developer need to config the adc pin filed as EM_ADC_PIN_DIFF_CH2_32.
*/
typedef enum {
/* PIN for ADC0 single ended channel-pin. */
EM_ADC_PIN_SING_CH1_0 = 0,
EM_ADC_PIN_SING_CH1_1 = 1,
EM_ADC_PIN_SING_CH1_2 = 2,
EM_ADC_PIN_SING_CH1_3 = 3,
EM_ADC_PIN_SING_CH1_4 = 4,
EM_ADC_PIN_SING_CH1_5 = 5,
EM_ADC_PIN_SING_CH1_6 = 6,
EM_ADC_PIN_SING_CH1_7 = 7,
/* PIN for ADC0 differential channel-pin. */
EM_ADC_PIN_DIFF_CH1_10 = 8,
EM_ADC_PIN_DIFF_CH1_32 = 9,
EM_ADC_PIN_DIFF_CH1_54 = 10,
EM_ADC_PIN_DIFF_CH1_76 = 11,
/* PIN for ADC1 single ended channel-pin. */
EM_ADC_PIN_SING_CH2_0 = 12,
EM_ADC_PIN_SING_CH2_1 = 13,
EM_ADC_PIN_SING_CH2_2 = 14,
EM_ADC_PIN_SING_CH2_3 = 15,
EM_ADC_PIN_SING_CH2_4 = 16,
EM_ADC_PIN_SING_CH2_5 = 17,
EM_ADC_PIN_SING_CH2_6 = 18,
/* PIN for ADC1 differential channel-pin. */
EM_ADC_PIN_DIFF_CH2_10 = 19,
EM_ADC_PIN_DIFF_CH2_32 = 20,
EM_ADC_PIN_DIFF_CH2_54 = 21,
/* Special configured channel-pin. */
EM_ADC_PIN_SING_CH1_UNUSED = 22,
EM_ADC_PIN_SING_CH2_UNUSED = 23,
EM_ADC_PIN_VCM_VCM = 24,
} iot_em_adc_pin_e;
/**
* @brief Energy meter DMA phase, each ADC module has 7 phases: 0, 1, 2,
* 3.0, 3.1, 3.2, 3.3, max number of all ADC module's phases is 7 + 7 = 14.
* ADC0 and ADC1 phase need to be used separately. Phase is used to store adc
* channel data, one channel data can be stored in one phase or multiple phases.
* Developer need to specify the phase and channel correspondence.
*/
typedef enum {
/* ADC0 DMA phase 0. */
EM_ADC0_DMA_PHASE_0 = 0,
EM_ADC0_DMA_PHASE_1 = 1,
EM_ADC0_DMA_PHASE_2 = 2,
/* ADC0 DMA phase 3.0. */
EM_ADC0_DMA_PHASE_3_0 = 3,
EM_ADC0_DMA_PHASE_3_1 = 4,
EM_ADC0_DMA_PHASE_3_2 = 5,
EM_ADC0_DMA_PHASE_3_3 = 6,
/* ADC1 DMA phase 0. */
EM_ADC1_DMA_PHASE_0 = 7,
EM_ADC1_DMA_PHASE_1 = 8,
EM_ADC1_DMA_PHASE_2 = 9,
/* ADC1 DMA phase 3.0. */
EM_ADC1_DMA_PHASE_3_0 = 10,
EM_ADC1_DMA_PHASE_3_1 = 11,
EM_ADC1_DMA_PHASE_3_2 = 12,
EM_ADC1_DMA_PHASE_3_3 = 13,
EM_ADC_DMA_PHASE_MAX_NUM = 14,
} iot_em_dma_phase_e;
/**
* @brief Energy meter ADC pin signal type.
*/
typedef enum {
EM_ADC_PIN_SIGNAL_SINGLE_ENDED = 0,
EM_ADC_PIN_SIGNAL_DIFFERENTIAL = 1,
} iot_em_adc_pin_signal_type;
/**
* @brief Energy meter ADC sample wave type.
*/
typedef enum {
EM_ADC_SAMP_WAVE_AC_SINE = 0,
EM_ADC_SAMP_WAVE_DC = 1,
EM_ADC_SAMP_WAVE_PULSE = 2,
EM_ADC_SAMP_WAVE_RAMP = 3,
EM_ADC_SAMP_WAVE_SQUARE = 4,
} iot_em_adc_sample_wave_type;
/**
* @brief Energy meter ADC sample meter type.
*/
typedef enum {
/* Meter voltage. */
EM_ADC_SAMP_METER_VOLTAGE = 0,
/* Meter current. */
EM_ADC_SAMP_METER_CURRENT = 1,
/* Meter leak current. */
EM_ADC_SAMP_METER_LEAK_CURRENT = 2,
} iot_em_adc_sample_meter_type;
/**
* @brief Energy meter ADC sample wire id, when calculate power, need
* ensure volate and current is on the same wire. The wire id is used for
* mark whether the phase sample voltage and the phase sample current is
* on the same wire. If the two phase use same wire id, it indicates the
* two phase is on the same wire, the calculated power makes sense.
* All ADC module's phases is 14, only supports 7 pairs of voltage and current.
*/
typedef enum {
EM_ADC_SAMP_WIRE_ID_0 = 0,
EM_ADC_SAMP_WIRE_ID_1 = 1,
EM_ADC_SAMP_WIRE_ID_2 = 2,
EM_ADC_SAMP_WIRE_ID_3 = 3,
EM_ADC_SAMP_WIRE_ID_4 = 4,
EM_ADC_SAMP_WIRE_ID_5 = 5,
EM_ADC_SAMP_WIRE_ID_6 = 6,
EM_ADC_SAMP_WIRE_ID_MAX = 7,
EM_ADC_SAMP_WIRE_ID_UNUSE = 8,
} iot_em_adc_sample_wire_id_e;
/**
* @brief Energy meter ADC sample frequency.
*/
typedef enum {
/* The clock of the chip ADC is 12.5MHz, after the reduction of sampling,
* filter and other processing, the value 2232Hz is obtained.
* Suitable for phase 0,1,2.
*/
EM_ADC_SAMPLE_FREQ_2232HZ = 0,
/* Suitable for phase 3.0,3.1,3.2,3.3. */
EM_ADC_SAMPLE_FREQ_558HZ = 1,
} iot_em_adc_sample_freq_e;
/**
* @brief Energy meter phase data analysis method type.
*/
typedef enum {
EM_PHASE_ANALY_TIME_DOMAIN = 0,
EM_PHASE_ANALY_FREQ_DOMAIN = 1,
} iot_em_phase_analy_method_type;
/**
* @brief Energy meter phase data time domain analysis method type.
*/
typedef enum {
/* Using frequency domain method, ignore time domain method config. */
EM_PHASE_ANALY_TD_INVALID = 0,
EM_PHASE_ANALY_TD_PP = 1,
EM_PHASE_ANALY_TD_RMS = 2,
} iot_em_phase_td_analy_method_type;
/**
* @brief Softdware calibration param of each phase.
*/
typedef struct _iot_em_phase_sw_calibration_t {
/* Scale liner. */
int32_t scale_liner;
/* Scale offset. */
int32_t scale_offset;
/* Scale multiple, should not be set to 0. */
int32_t scale_mul;
} iot_em_phase_sw_cali_t;
/**
* @brief Sample source threshold of each phase, using for take actions.
* Ex, when sampling leak current, if value over 30mA -> close relay,
* developer can set max=30, ingore min.
*/
typedef struct _iot_em_sample_source_threshold_t {
/* Sampling meter current/leak current, uint is mA; for meter voltage is mV. */
uint32_t max;
uint32_t min;
} iot_em_sample_source_threshold_t;
/**
* @brief Led pulse config of each phase.
*/
typedef struct _iot_em_phase_led_pulse_cfg_t {
/* Mark whether the pahse led pulse is working. */
bool_t pulse_on;
/* Config GPIO for led pulse. */
uint8_t gpio;
/* Frequency of pulse per second, uint is Hz. */
uint32_t freq_hz;
} iot_em_phase_led_pulse_cfg_t;
/**
* @brief Hardware config of each phase.
*/
typedef struct _iot_em_phase_hw_cfg_t {
/* ADC pin select. */
iot_em_adc_pin_e pin_sel;
/* ADC pin signal type. */
iot_em_adc_pin_signal_type signal_type;
/* ADC sample meter type.*/
iot_em_adc_sample_meter_type meter_type;
/* ADC sample wire id. */
iot_em_adc_sample_wire_id_e wire_id;
/* Paired phase used for calculate power, calc power need a pair of phase
* that meter type is current and voltage.
* If one phase meter type is current,
* here need the other one phase which meter type is voltage to paired.
* If this phase no need to calculate power,
* please choose the max phase num: EM_ADC_DMA_PHASE_MAX_NUM.
*/
iot_em_dma_phase_e paired_phase;
/* ADC sample wave type.*/
iot_em_adc_sample_wave_type wave_type;
/* Scale of divider resistance.
* Ex, when measure voltage, may use 3 resistors with 360K ohm
* and one resistor with 510ohm, the scale = (3*360*1000+510)/510,
* Times this scale, the unit of voltage is V.
* The numerator: (3*360*1000+510); denominator: 510.
* When measure current, may use 1 resistors with 50mohm,
* the scale = 1/(50/1000) = 20, times this scale, the unit of current is A.
* The numerator is 20 , denominator is 1.
*/
uint32_t scale_div_res_numer;
uint32_t scale_div_res_denom;
/* Min voltage on ADC pin, used for calculate adc gain, enlarge
* or reduce the input signal to the adc reference voltage range.
* Ex, reference voltage:0.35V, adc resolution was 0.1483mV.
* When measure voltage, min voltage on ADC pin:0.2659mV,
* 0.2659mV calculate method: 1V times scale of divider resistance,
* 1V * 50 / (4*47*1000+50).
* we should select the gain suitable for 0.2659mV voltage,
* choose gain 1 is ok.
*
* When measure current, min voltage on ADC pin:0.01mV,
* 0.01mV calculate method: current is 10mA, divider resistance is 1mohm,
* 10mA * 1mohm = 10uV = 0.01mV,
* so, should select the gain suitable for 0.01mV voltage,
* choose gain 32 is ok.
* In order to avoid using float data, V times 1000000, now unit is uV.
*/
uint32_t pin_min_volt_uv;
/* Sample frequency. */
iot_em_adc_sample_freq_e sample_freq;
} iot_em_phase_hw_cfg_t;
/**
* @brief Softdware config of each phase.
*/
typedef struct _iot_em_phase_sw_cfg_t {
/* Phase data analysis method type. */
iot_em_phase_analy_method_type analy_method_type;
/* Phase data time domain analysis method type. */
iot_em_phase_td_analy_method_type td_analy_method_type;
/* Harmonic analysis amplitude threshold. */
int32_t harmonic_ampl_thr;
/* Softdware calibration param. */
iot_em_phase_sw_cali_t cali_param;
/* Power softdware calibration param, when using current phase, must be
configured, otherwise will not be used. */
iot_em_phase_sw_cali_t power_cali_param;
/* Sample source threshold. */
iot_em_sample_source_threshold_t samp_src_thr;
/* Led pulse config. */
iot_em_phase_led_pulse_cfg_t led_pulse;
/* Get Standard level data callback function. */
iot_em_phase_get_data_std_cb data_std_cb;
/* Get Professional level data callback function. */
iot_em_phase_get_data_pro_cb data_pro_cb;
/* Get Industrial grade data callback function. */
iot_em_phase_get_data_ind_cb data_ind_cb;
} iot_em_phase_sw_cfg_t;
/**
* @brief Profile information of each phase.
*/
typedef struct _iot_em_phase_profile_info_t {
/* Mark whether the pahse is working. */
bool_t phase_on;
/* Mark whether the pahse's config is valid. */
bool_t phase_valid;
/* Hardware config of phase. */
iot_em_phase_hw_cfg_t hw_cfg;
/* Software config of phase. */
iot_em_phase_sw_cfg_t sw_cfg;
} iot_em_phase_profile_info_t;
/**
* @brief Customer id type.
* 1.one-phase meter;
* 2.three-phase meter;
* 3.charing pile.
*/
typedef enum {
CUST_CHARGE_PILE = 0,
CUST_ONE_PHASE_METER = 1,
CUST_THREE_PHASE_METER = 2,
CUST_NUM_MAX = 3,
} iot_em_cust_id_type;
/**
* @brief Control information of each customer info.
*/
typedef struct _iot_em_cust_ctrl_info_t {
/* Customer id type. */
iot_em_cust_id_type cust_id;
/* Mark whether the customer's config is valid.
* Only one customer information is allowed to be config valid by app.
*/
bool_t cust_valid;
} iot_em_cust_ctrl_info_t;
/* Customer info used for config energy meter module. */
typedef struct _iot_em_customer_info_t {
/* Chip info. */
iot_em_chip_info_t chip_info;
/* Control info. */
iot_em_cust_ctrl_info_t ctrl_info;
/* Profile information of each phase. */
iot_em_phase_profile_info_t phase_cfg[EM_ADC_DMA_PHASE_MAX_NUM];
/* Standard level data stored in each phase. */
iot_em_phase_data_std_t phase_data_std[EM_ADC_DMA_PHASE_MAX_NUM];
/* Professional level data stored in each phase. */
iot_em_phase_data_pro_t phase_data_pro[EM_ADC_DMA_PHASE_MAX_NUM];
/* Industrial grade data stored in each phase. */
iot_em_phase_data_ind_t phase_data_ind[EM_ADC_DMA_PHASE_MAX_NUM];
} iot_em_cust_info_t;
#if 0
/* Max number of customer info.
* 1.one-phase;
* 2.three-phase;
* 3.charing pile.
*/
#define IOT_EM_CUST_INFO_MAX_NUM (3)
iot_em_cust_info_t g_em_cust_info[IOT_EM_CUST_INFO_MAX_NUM] = {
/*************************************************************************/
/* Charging pile customer info.
* ADC0 and ADC1 module's channel-pin and phase table:
* -----------------------------------------------------------------
* | module | channel-pin | phase | function | description |
* | ADC0 | AD0_CH1 | phase0 | I0 | meter current |
* | ADC0 | AD1_CH1 | phase1 | I1 | meter current |
* | ADC0 | AD2_CH1 | unused | unused | unused |
* | ADC0 | AD3_CH1 | phase3.0 | U0 | switch voltage |
* | ADC0 | AD4_CH1 | phase3.1 | U1 | switch voltage |
* | ADC0 | AD5_CH1 | phase3.2 | U2 | switch voltage |
* | ADC0 | AD6_CH1 | phase3.3 | U3 | switch voltage |
* | ADC0 | AD7_CH1 | phase2 | I2 | meter current |
* | ADC1 | AD0_CH2 | phase0 | I3 | meter current |
* | ADC1 | AD1_CH2 | phase1 | Up | meter voltage |
* | ADC1 | AD2_CH2 | phase2 | I1 | leak current |
* | ADC1 | AD3_CH2 | phase2 | I1 | leak current |
* | ADC1 | AD4_CH2 | phase3.0 | GND | switch voltage |
* | ADC1 | AD4_CH2 | phase3.1 | GND | gnd |
* | ADC1 | AD4_CH2 | phase3.2 | GND | gnd |
* | ADC1 | AD4_CH2 | phase3.3 | GND | gnd |
* -----------------------------------------------------------------
*/
{
/* Chip info. */
.chip_info.chip_type = IOT_EM_WQ30x2,
/***********************************************************/
/* Profile information of adc0 phase0. */
/* Mark whether the pahse is working. */
.phase_cfg[0].phase_on = false,
/* Mark whether the pahse's config is valid. */
.phase_cfg[0].phase_valid = false,
/*************************************************/
/* Hardware config of phase. */
/* ADC pin select. */
.phase_cfg[0].hw_cfg.pin_sel = EM_ADC_PIN_SING_CH1_0,
/* ADC pin signal type. */
.phase_cfg[0].hw_cfg.signal_type = EM_ADC_PIN_SIGNAL_SINGLE_ENDED,
/* ADC sample wave type.*/
.phase_cfg[0].hw_cfg.wave_type =EM_ADC_SAMP_WAVE_AC_SINE,
/* Scale of divider resistance.
* Meause voltage, use 4 resistors with 47K ohm and one resistor
* with 50ohm, the scale = (3*47*1000+50)/50.
* Times this scale, the unit of voltage is V.
* The numerator: (4*47*1000+50); denominator: 50.
*/
.phase_cfg[0].hw_cfg.scale_div_res_numer = (4 * 47 * 1000 + 50),
.phase_cfg[0].hw_cfg.scale_div_res_denom = 50,
/* Max voltage on ADC pin, used for calculate adc gain, enlarge
* or reduce the input signal to the adc reference voltage range.
* Ex, reference voltage:0.35V, max voltage on ADC pin:0.058V,
* 0.058V calculate method: 220V times scale of divider resistance,
* 220V * 50 / (4*47*1000+50).
* we should select the gain suitable for 0.058V voltage.
* In order to avoid using float data, V times 1000, now unit is mV.
*/
.phase_cfg[0].hw_cfg.pin_volt_max_mv = 58,
/* Sample frequency. */
.phase_cfg[0].hw_cfg.sample_freq = EM_ADC_SAMPLE_FREQ_2232HZ,
/*************************************************/
/* Software config of phase. */
/* Phase data analysis method type. */
.phase_cfg[0].sw_cfg.analy_method_type = EM_PHASE_ANALY_FREQ_DOMAIN,
/* Phase data time domain analysis method type. */
.phase_cfg[0].sw_cfg.td_analy_method_type = EM_PHASE_ANALY_TD_INVALID,
/* Harmonic analysis amplitude threshold. */
.phase_cfg[0].sw_cfg.harmonic_ampl_thr = 0,
/* Softdware calibration param. */
/* Scale liner. */
.phase_cfg[0].sw_cfg.cali_param.scale_liner = 1,
/* Scale offset. */
.phase_cfg[0].sw_cfg.cali_param.scale_offset = 0,
/* Scale multiple. */
.phase_cfg[0].sw_cfg.cali_param.scale_mul =1,
/* Sample source threshold. */
/* Sampling meter current/leak current, uint is mA; for meter voltage is mV. */
.phase_cfg[0].sw_cfg.samp_src_thr.max = 30,
.phase_cfg[0].sw_cfg.samp_src_thr.min = 5,
/* Led pulse config. */
/* Mark whether the pahse led pulse is working. */
.phase_cfg[0].sw_cfg.led_pulse.pulse_on = false,
/* Config GPIO for led pulse. */
.phase_cfg[0].sw_cfg.led_pulse.gpio = 43,
/* Frequency of pulse per second. */
.phase_cfg[0].sw_cfg.led_pulse.freq_hz = 0,
/* Get Standard level data callback function. */
.phase_cfg[0].sw_cfg.data_std_cb = NULL,
/* Get Professional level data callback function. */
.phase_cfg[0].sw_cfg.data_pro_cb = NULL,
/* Get Industrial grade data callback function. */
.phase_cfg[0].sw_cfg.data_ind_cb = NULL,
/***********************************************************/
/* Other profile information. */
},
/*******************************************************************/
/* Other customer info. */
};
#endif
/** \defgroup ENERGE_METER_APIs ENERGE_METER APIs
* @brief ENERGE_METER APIs
*
*
*/
/** @addtogroup ENERGE_METER_APIs
* @{
*
*/
/**
* @brief iot_em_module_open() - open energy meter module.
* @param p_cust_info pointer to customer info.
* @return ERR_OK/ERR_FAIL.
*
*/
uint32_t iot_em_module_open(iot_em_cust_info_t *p_cust_info);
/**
* @brief iot_em_phase_enable() - enable/disable each phase.
* @param phase_id id of phase.
* @param enable true: enable; false: disable.
* @return ERR_OK/ERR_FAIL.
*
*/
uint32_t iot_em_phase_enable(uint32_t phase_id, bool_t enable);
/**
* @brief iot_em_phase_correction_set_std() - set correction param of each phase.
* @param phase_id id of phase.
* @param analy_method_sel phase data analysis method select.
* @param td_analy_method phase data time domain analysis method select.
* @param cali_param softdware calibration param.
* @return ERR_OK/ERR_FAIL.
*
*/
uint32_t iot_em_phase_correction_set_std(uint32_t phase_id,
iot_em_phase_analy_method_type analy_method_sel,
iot_em_phase_td_analy_method_type td_analy_method,
iot_em_phase_sw_cali_t cali_param);
/**
* @brief iot_em_phase_scale_div_res_set_std() -
* set scale of divider resistance of each phase.
* @param phase_id id of phase.
* @param scale_div_res_numer the numerator of scale.
* @param scale_div_res_denom the denominator of scale.
* @return ERR_OK/ERR_FAIL.
*
*/
uint32_t iot_em_phase_scale_div_res_set_std(uint32_t phase_id,
uint32_t scale_div_res_numer, uint32_t scale_div_res_denom);
/**
* @brief iot_em_phase_pulse_set_std() - set meter pulse of each phase.
* @param phase_id id of phase.
* @param p_led_pulse pointer to led pulse config.
* @return ERR_OK/ERR_FAIL.
*
*/
uint32_t iot_em_phase_pulse_set_std(uint32_t phase_id,
iot_em_phase_led_pulse_cfg_t *p_led_pulse);
/**
* @brief iot_em_phase_pin_signal_type_get_std() -
* get pin signal type of each phase.
* @param p_data pointer to phase data buffer.
* @return pin signal type.
*
*/
iot_em_adc_pin_signal_type iot_em_phase_pin_signal_type_get_std(
uint32_t phase_id);
/**
* @brief iot_em_phase_harmonic_ampl_thr_set_pro() -
* set harmonic amplitude threshold of each phase.
* @param phase_id id of phase.
* @param ampl_thr harmonic amplitude threshold.
* @return ERR_OK/ERR_FAIL.
*
*/
uint32_t iot_em_phase_harmonic_ampl_thr_set_pro(uint32_t phase_id,
int32_t ampl_thr);
/**
* @brief iot_em_phase_data_get_std() - get standard level data of each phase.
* @param p_phase_data pointer to phase data buffer.
* @return ERR_OK/ERR_FAIL.
*
*/
uint32_t iot_em_phase_data_get_std(uint32_t phase_id,
iot_em_phase_data_std_t *p_phase_data);
/**
* @brief iot_em_phase_data_get_pro() - get professional level data of each phase.
* @param p_phase_data pointer to phase data buffer.
* @return ERR_OK/ERR_FAIL.
*
*/
uint32_t iot_em_phase_data_get_pro(uint32_t phase_id,
iot_em_phase_data_pro_t *p_phase_data);
/**
* @brief iot_em_phase_data_get_ind() - get industrial grade data of each phase.
* @param p_phase_data pointer to phase data buffer.
* @return ERR_OK/ERR_FAIL.
*
*/
uint32_t iot_em_phase_data_get_ind(uint32_t phase_id,
iot_em_phase_data_ind_t *p_phase_data);
/**
* @brief iot_em_phase_get_data_cb_register_std() -
* register get standard level data of each phase callback function.
* @param phase_id id of phase.
* @param cb callback function.
* @return ERR_OK/ERR_FAIL.
*
*/
uint32_t iot_em_phase_get_data_cb_register_std(uint32_t phase_id,
iot_em_phase_get_data_std_cb cb);
/**
* @brief iot_em_phase_get_data_cb_register_pro() -
* register get professional level data of each phase callback function.
* @param phase_id id of phase.
* @param cb callback function.
* @return ERR_OK/ERR_FAIL.
*
*/
uint32_t iot_em_phase_get_data_cb_register_pro(uint32_t phase_id,
iot_em_phase_get_data_pro_cb cb);
/**
* @brief iot_em_phase_get_data_cb_register_ind() -
* register get industrial grade data of each phase callback function.
* @param phase_id id of phase.
* @param cb callback function.
* @return ERR_OK/ERR_FAIL.
*
*/
uint32_t iot_em_phase_get_data_cb_register_ind(uint32_t phase_id,
iot_em_phase_get_data_ind_cb cb);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /*IOT_ENERGE_METER_API_V2_H*/