159 lines
5.2 KiB
C
159 lines
5.2 KiB
C
/****************************************************************************
|
|
|
|
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 CVG_NWM_CCO_ZC_H
|
|
#define CVG_NWM_CCO_ZC_H
|
|
|
|
/* cvg module internal includes */
|
|
#include "cvg_nwm_cco_common.h"
|
|
|
|
/* public includes */
|
|
#include "plc_mme_zero_cross.h"
|
|
#include "plc_mme_diagnose.h"
|
|
#include "cvg_zc.h"
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#if (PLC_SUPPORT_CCO_ROLE && PLC_SUPPORT_PHY_PHASE_IDENT)
|
|
|
|
/*
|
|
* @brief cvg_nwm_cco_zc_collect_check() - check to see if need to collect
|
|
* zero-cross ntb from any peer.
|
|
* @param nwm: pointer to nwm
|
|
*/
|
|
void cvg_nwm_cco_zc_collect_check(cvg_nwm_vdev_t *nwm);
|
|
|
|
/*
|
|
* @brief cvg_nwm_cco_zc_ntb_rpt_calc() - calculate zc ntb report, get
|
|
* the physical phase from ntb_diff_val.
|
|
* @param nwm: pointer to nwm
|
|
* @param sta_tei: tei of the sta the NTB data come from
|
|
* @param clct_cnt: total NTB value count
|
|
* @param std_ntb: standard zero-cross NTB value
|
|
* @param phase_cnt: total NTB value count of each phase
|
|
* @param ntb_diff_val: pointer to ntb_diff_val data
|
|
* @param odd_check: flag to mark if the parity of reported count should be
|
|
* checked
|
|
* 0 - not checked
|
|
* 1 - checked
|
|
*/
|
|
void cvg_nwm_cco_zc_ntb_rpt_calc(cvg_nwm_vdev_t *nwm, tei_t sta_tei,
|
|
uint8_t clct_cnt, uint32_t std_ntb, uint8_t *phase_cnt,
|
|
ntb_diff_value_t *ntb_diff_val, uint8_t odd_check);
|
|
|
|
/*
|
|
* @brief cvg_nwm_cco_zc_ntb_rpt_v2_calc() - calculate zc ntb report, get
|
|
* the physical phase by mme_diag_zc_ntb_report_t.
|
|
* @param nwm: pointer to nwm
|
|
* @param zc_rpt: mme diagnose zc report
|
|
*/
|
|
void cvg_nwm_cco_zc_ntb_rpt_v2_calc(cvg_nwm_vdev_t *nwm,
|
|
mme_diag_zc_ntb_report_t *zc_rpt);
|
|
|
|
/*
|
|
* @brief cvg_nwm_cco_zc_ntb_phase_calc() - calculate the physical phase
|
|
* according to zc ntb.
|
|
* @param nwm: pointer to nwm
|
|
* @param zc_ntb: zero-cross ntb array
|
|
* @param count: array size
|
|
* @param phase: calculated physical phase
|
|
* @param opposite_phase: opposite phase flag
|
|
* return:
|
|
* 0 -- for success case
|
|
* othersie -- error code
|
|
*/
|
|
uint32_t cvg_nwm_cco_zc_ntb_phase_calc(cvg_nwm_vdev_t *nwm, uint32_t zc_ntb[],
|
|
uint8_t count, uint8_t phase[], uint8_t *opposite_phase);
|
|
|
|
/*
|
|
* @brief cvg_nwm_cco_zc_edge_vendor_add() - add the zc edge info of the vendor
|
|
* ID.
|
|
* @param nwm: pointer to nwm
|
|
* @param vendor_code: vendor code
|
|
* @param is_falling: zc edge, 0 is rising edge, 1 is falling edge.
|
|
* return:
|
|
* 1 -- for success case
|
|
* 0 -- failure
|
|
*/
|
|
uint8_t cvg_nwm_cco_zc_edge_vendor_add(cvg_nwm_vdev_t *nwm,
|
|
uint32_t vendor_code, uint8_t is_falling_edge);
|
|
|
|
/*
|
|
* @brief cvg_nwm_cco_zc_edge_vendor_get() - get the zc edge info of the
|
|
* vendor ID.
|
|
* @param nwm: pointer to nwm
|
|
* @param vendor_code: vendor code
|
|
* @param is_falling: as return value, whether the vendor edge type is
|
|
* the falling edge
|
|
* return:
|
|
* 1 -- exist vendor edge information
|
|
* 0 -- not exist vendor edge information
|
|
*/
|
|
uint8_t cvg_nwm_cco_zc_edge_vendor_get(cvg_nwm_vdev_t *nwm,
|
|
uint32_t vendor_code, uint8_t *is_falling);
|
|
|
|
/*
|
|
* @brief cvg_nwm_cco_zc_edge_vendor_init() - initialize default vendors zc edge
|
|
* info.
|
|
* @param nwm: pointer to nwm
|
|
*/
|
|
void cvg_nwm_cco_zc_edge_vendor_default_init(cvg_nwm_vdev_t *nwm);
|
|
|
|
#else /* PLC_SUPPORT_CCO_ROLE && PLC_SUPPORT_PHY_PHASE_IDENT */
|
|
|
|
#define cvg_nwm_cco_zc_collect_check(nwm)
|
|
|
|
#define cvg_nwm_cco_zc_ntb_rpt_v2_calc(nwm, zc_rpt)
|
|
|
|
#define cvg_nwm_cco_zc_edge_vendor_add(nwm, vendor_code, is_falling_edge) (0)
|
|
|
|
#define cvg_nwm_cco_zc_edge_vendor_get(nwm, vendor_code, is_falling) (0)
|
|
|
|
#define cvg_nwm_cco_zc_edge_vendor_default_init(nwm)
|
|
|
|
static inline void cvg_nwm_cco_zc_ntb_rpt_calc(cvg_nwm_vdev_t *nwm,
|
|
tei_t sta_tei, uint8_t clct_cnt, uint32_t std_ntb, uint8_t *phase_cnt,
|
|
ntb_diff_value_t *ntb_diff_val, uint8_t odd_check)
|
|
{
|
|
(void)nwm;
|
|
(void)sta_tei;
|
|
(void)clct_cnt;
|
|
(void)std_ntb;
|
|
(void)phase_cnt;
|
|
(void)ntb_diff_val;
|
|
(void)odd_check;
|
|
}
|
|
|
|
static inline uint32_t cvg_nwm_cco_zc_ntb_phase_calc(cvg_nwm_vdev_t *nwm,
|
|
uint32_t zc_ntb[], uint8_t count, uint8_t phase[], uint8_t *opposite_phase)
|
|
{
|
|
(void)nwm;
|
|
(void)zc_ntb;
|
|
(void)count;
|
|
(void)phase;
|
|
(void)opposite_phase;
|
|
return ERR_NOSUPP;
|
|
}
|
|
|
|
#endif /* PLC_SUPPORT_CCO_ROLE && PLC_SUPPORT_PHY_PHASE_IDENT */
|
|
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* CVG_NWM_CCO_ZC_H */
|