187 lines
5.6 KiB
C
Executable File
187 lines
5.6 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 __PHY_TOOLS_H
|
|
#define __PHY_TOOLS_H
|
|
|
|
#include "phy_bb.h"
|
|
#include "phy_phase.h"
|
|
#include "phy_ada_dump.h"
|
|
#include "hw_phy_api.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define PHY_DUMP_PKT_RSSI_THD (40)
|
|
#define ADA_TONE_CYCLE_NUM (1024)
|
|
#define ADA_DUMP_INIT_DLY_CNT (12000)
|
|
#define VPP_CNT_VOL_A (6)
|
|
#define VPP_CNT_VOL_B (12482)
|
|
#define TONE_MAX_NUM (1536)
|
|
#define MAC_TX_BACK_MAX_LEN (48)
|
|
#define MAC_CSI_BACK_MAX_LEN (1536)
|
|
#define PHY_CSI_DUMP_TRIG_FC_OK (1 << 0)
|
|
#define PHY_CSI_DUMP_TRIG_FC_FAIL (1 << 1)
|
|
#define PHY_CSI_DUMP_TRIG_FC_THD (1 << 2)
|
|
|
|
#define TICKS_UNIT_MS (25000) // 1000us / 0.04us
|
|
|
|
#define BW_LOW (1000000)
|
|
#define BW_HIGH (30000000)
|
|
#define ADA_SAMP_FREQ (75000000)
|
|
#define SNR_FREQ_NUM (1)
|
|
#define SNR_NOISE_NUM (3)
|
|
#define PHY_TX_TONE_REST_TIME (1000)
|
|
|
|
/* freq@MHz */
|
|
#define TONE_ID_CAL(freq) (freq*1024/75)
|
|
|
|
/* ftm cmd tx back content */
|
|
typedef struct _mac_tx_back {
|
|
/* packet len*/
|
|
uint8_t len;
|
|
/* packrt content array */
|
|
uint8_t info_arry[MAC_TX_BACK_MAX_LEN];
|
|
} mac_tx_back_t;
|
|
|
|
typedef struct _mac_csi_back {
|
|
/* packet len*/
|
|
uint16_t len;
|
|
/* packrt content array */
|
|
uint16_t *info_arry;
|
|
} mac_csi_back_t;
|
|
|
|
/* dump condition */
|
|
typedef struct _csi_est_dump_cond {
|
|
uint8_t trig_id;
|
|
uint8_t para;
|
|
uint8_t nid;
|
|
} csi_est_dump_cond;
|
|
|
|
/* dump condition */
|
|
typedef struct _phy_trig_dump_cond {
|
|
/* phy trig id */
|
|
uint8_t trig_id :8;
|
|
/* trig level */
|
|
uint32_t thd :16,
|
|
/* source tei */
|
|
stei :12,
|
|
resv1 :4;
|
|
/* trig nid */
|
|
uint32_t nid :24,
|
|
/* destination tei */
|
|
dtei :3,
|
|
/* enable stei filter */
|
|
stei_en :1,
|
|
/* enable dtei filter */
|
|
dtei_en :1,
|
|
/* enable nid filter */
|
|
nid_en :1,
|
|
resv2 :2;
|
|
} phy_trig_dump_cond;
|
|
|
|
/**
|
|
*@brief ada_common_init.
|
|
* initialize the common configrations for dump phy raw data.
|
|
*
|
|
*@param tone_id [tone number.]
|
|
*@param b_size [ada bufer size.]
|
|
*@param s_size [ada sample size.]
|
|
*@exception [none.]
|
|
*@return [none.]
|
|
*/
|
|
void ada_common_init(uint16_t tone_id, uint32_t b_size, uint32_t s_size);
|
|
|
|
/**
|
|
*@brief phy_dump_from_ada.
|
|
* The API function is designed for dump adc raw data. You can choose
|
|
* dump mode such as ada origin dump or trig fc.
|
|
*
|
|
*@param b_size [buffer size to dump, uint is 1 word(4 byte)]
|
|
*@param s_size [sample size to dump, uint is 1 word(4 byte)]
|
|
*@param tone_id [tone num if loopback.]
|
|
*@param mode [AUTO, FORCE, PHY etc.]
|
|
*@param phase [rx phase such as A/B/C/ALL.]
|
|
*@param trig_offset [trig address after dump.]
|
|
*@param adc_buf [ada dump buffer pointer.]
|
|
*@param speed [dump speed.]
|
|
*@param trig_cond [trig dump condition.]
|
|
*@exception [none.]
|
|
*@return [ERR_OK, others ERR_FAIL.]
|
|
*/
|
|
int phy_dump_from_ada(uint32_t b_size, \
|
|
uint32_t s_size, \
|
|
uint16_t tone_id, \
|
|
ADC_DUMP_MODE mode, \
|
|
PHY_PHASE_OVR_ID phase, \
|
|
uint32_t *trig_offset, \
|
|
uint8_t *adc_buf, \
|
|
uint32_t speed, \
|
|
phy_trig_dump_cond *trig_cond);
|
|
|
|
/**
|
|
*@brief mac_rx_csi_dump.
|
|
* get fft dump raw data depend on fc ok or fail signal.
|
|
* there will be a normal tx/rx channel in the system.
|
|
*
|
|
*@param info [raw data that need return back to caller.]
|
|
*@param cond [dump condition, uint8_t trig id and parameter.]
|
|
*@param p_num [packets number, send in batches.]
|
|
*@exception [none.]
|
|
*@return variance [calibrated from csi dump data.]
|
|
*/
|
|
float mac_rx_csi_dump(mac_csi_back_t *info, \
|
|
csi_est_dump_cond *cond, \
|
|
uint16_t p_num);
|
|
|
|
/**
|
|
*@brief dumpMem.
|
|
* print dump buffer.
|
|
*
|
|
*@param mem_buf [print buffer pointer.]
|
|
*@param st_offset [start offset.]
|
|
*@param b_size [buffer size.]
|
|
*@exception [none.]
|
|
*@return [none.]
|
|
*/
|
|
void dumpMem(uint8_t *mem_buf, int32_t st_offset, uint32_t b_size);
|
|
|
|
/**
|
|
*@brief phy_fft_flash_dump.
|
|
* write all the dump data to flash and read after reset.
|
|
*
|
|
*@param buf_ptr [buffer pointer.]
|
|
*@exception [none.]
|
|
*@return [none.]
|
|
*/
|
|
uint32_t phy_fft_flash_dump(uint32_t *buf_ptr);
|
|
|
|
/**
|
|
*@brief iot_phy_auto_tone_tx_start.
|
|
*
|
|
* start generating tone .
|
|
*
|
|
*@param tx_tone_ptr [iot_phy_tone_param_ctxt_t.]
|
|
*@exception [none.]
|
|
*@return [none.]
|
|
*/
|
|
void phy_auto_tone_tx_start(iot_phy_tone_param_ctxt_t *tx_tone_ptr);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|