96 lines
2.9 KiB
C
96 lines
2.9 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 IOT_PLC_HW_TSFM_H
|
||
|
#define IOT_PLC_HW_TSFM_H
|
||
|
|
||
|
#include "iot_config.h"
|
||
|
|
||
|
#ifdef __cplusplus
|
||
|
extern "C" {
|
||
|
#endif
|
||
|
|
||
|
/* define invalid energy of topo receive */
|
||
|
#define IOT_PLC_HW_INVALID_ENERGY 0xffff
|
||
|
|
||
|
#pragma pack(push) /* save the pack status */
|
||
|
#pragma pack(1) /* 1 byte align */
|
||
|
|
||
|
typedef struct _hw_topo_rx_info {
|
||
|
/* phase of topo data, see - IOT_PLC_PHASE_X */
|
||
|
uint8_t phase;
|
||
|
/* sub signal count
|
||
|
* for small load signal, it belongs to AM signal.
|
||
|
* it has two frequency points, (fc + 50)Hz and (fc- 50)Hz, which are
|
||
|
* two sub signals.
|
||
|
* for other ways, there is no sub signal
|
||
|
*/
|
||
|
uint8_t sub_sig_cnt;
|
||
|
/* energy:
|
||
|
* 1. for tsfm info, it's ZC average delta, unit: 1us.
|
||
|
* 2. for small load branch info, it's the intensity of current change,
|
||
|
* unit is 0.1mA.
|
||
|
* 3. for PA branch info, it's the energy that's quantified
|
||
|
*/
|
||
|
uint16_t energy;
|
||
|
/* noise:
|
||
|
* 1. for tsfm info, it's is invalid
|
||
|
* 2. for small load branch info, it's the intensity of current change,
|
||
|
* unit is 0.1mA.
|
||
|
* 3. for PA branch info, it's the energy that's quantified
|
||
|
*/
|
||
|
uint16_t noise;
|
||
|
/* sub signal info, only valid for small load branch signal */
|
||
|
struct {
|
||
|
/* sub singnal energy, unit is 0.1mA */
|
||
|
uint16_t energy;
|
||
|
/* sub singnal noise, unit is 0.1mA */
|
||
|
uint16_t noise;
|
||
|
} sub_sig_info[3];
|
||
|
/* received topo data */
|
||
|
uint8_t data[0];
|
||
|
} hw_topo_rx_info_t;
|
||
|
|
||
|
#pragma pack(pop) /* restore the pack status */
|
||
|
|
||
|
#if PLC_SUPPORT_HW_TSFM
|
||
|
|
||
|
/**
|
||
|
* @brief iot_plc_hw_tsfm_init() - init plc hardware transformer detection
|
||
|
* module
|
||
|
*/
|
||
|
void iot_plc_hw_tsfm_init();
|
||
|
|
||
|
/**
|
||
|
* @brief iot_plc_hw_tsfm_rec_from_topo() - receive topo data from topo task
|
||
|
* @param pkt: pkt data see hw_topo_rx_info_t.
|
||
|
*/
|
||
|
void iot_plc_hw_tsfm_rec_from_topo(iot_pkt_t *pkt);
|
||
|
|
||
|
#else /* PLC_SUPPORT_HW_TSFM */
|
||
|
|
||
|
#define iot_plc_hw_tsfm_init()
|
||
|
|
||
|
#define iot_plc_hw_tsfm_rec_from_topo(pkt)
|
||
|
|
||
|
#endif /* PLC_SUPPORT_HW_TSFM */
|
||
|
|
||
|
|
||
|
#ifdef __cplusplus
|
||
|
}
|
||
|
#endif
|
||
|
|
||
|
#endif /* IOT_PLC_HW_TSFM_H */
|