Files
kunlun/plc/halphy/hw2/inc/phy_cal.h
2024-09-28 14:24:04 +08:00

149 lines
4.0 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 PHY_CAL_H
#define PHY_CAL_H
#include "os_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define PHY_CAL_PIB_SUPPORT (0)
#define PHY_GAIN_STEP_MAX (85)
#define PHY_GAIN_STEP_BEGIN (-24)
#define PHY_GAIN_STEP_END (60)
#define PHY_DC_CAL_CENTER (512)
#define PHY_DC_EST_RETRY_NUM (64)
#define PHY_DC_PGF_GOLDEN (50)
#define PHY_DC_PGA_GOLDEN (6)
#define PHY_RX_PGF_OFFSET_DFT (32)
#define PHY_RX_PGA_OFFSET_DFT (16)
#define PHY_TX_DC_CAL_LENGTH (8)
#define PHY_DAC_STEP (512)
#define TICKS_US (25)
#define PHY_SG_BAND0_TONE_20M (819)
#define PHY_SG_BAND0_TONE_15M (615)
#define PHY_SG_BAND0_TONE_12M (489)
#define PHY_SG_BAND0_TONE_8M (327)
#define PHY_SG_BAND1_TONE_5P6M (231)
#define TX_DC_THR (30)
#define RX_DC_RAW_THR (30)
#define RX_DC_FINAL_THR (10)
#define PHY_LNA_DC_CALI_EN (0)
/* pack for the structures in the whole file */
#pragma pack(push) // save the pack status
#pragma pack(1) // 1 byte align
typedef enum {
RX_BW_LIST_BAND0_20M,
RX_BW_LIST_BAND0_15M,
RX_BW_LIST_BAND0_12M,
RX_BW_LIST_BAND0_8M,
RX_BW_LIST_BAND1_5P6M
} RX_BW_LIST_ID;
typedef enum {
TXRX_LOOP_BACK_GRANITE,
TXRX_LOOP_BACK_GEODE,
} TXRX_LOOP_BACK_MODE_ID;
/**
*@brief phy_txrx_loop_back_begin.
*
* choose phase and loopback mode, initialize dfe and analog registers.
* after fft dump,call phy_txrx_loop_back_end.
*
*@param phase [A/B/C/ALL can chosed]
*@param mode [There are two mode between granite and geode.]
*@exception [none.]
*@return [none.]
*/
void phy_txrx_loop_back_begin(uint32_t phase, TXRX_LOOP_BACK_MODE_ID mode);
/**
*@brief phy_txrx_loop_back_end.
*
* revover to the state before ana loopback.
*
*@param void [none.]
*@exception [none.]
*@return [none.]
*/
void phy_txrx_loop_back_end();
/**
*@brief tx_dc_calibration.
*
* analog moudle calibration in tx direction.
*
*@param tx_dc [tx dc calibration array.]
*@exception [none.]
*@return [0:ok, others fail.]
*/
uint32_t tx_dc_calibration(uint16_t *tx_dc);
/**
*@brief rx_dc_calibration.
*
* analog moudle calibration in rx direction.
* [10:6] pga, [5:0] pgf
*
*@param rx_dc [rx dc calibration array.]
*@exception [none.]
*@return [0:ok, others fail.]
*/
uint32_t rx_dc_calibration(uint16_t *rx_dc);
/**
*@brief phy_rx_bw_filter.
*
* set bandwidth filter depend on frequency.
*
*@param freq_id [freq come from the end tone, maybe 5.6M or 12M.]
*@exception [none.]
*@return cap_id [capacitor setting.]
*/
uint16_t phy_rx_bw_filter(RX_BW_LIST_ID freq_id);
/**
*@brief phy_load_cal_cfg.
*
* get configuration from pib and update to hw.
* including chip id, ppm, dc calibration etc.
*
*@param void [none.]
*@exception [none.]
*@return [none.]
*/
void phy_load_cal_cfg(void);
#pragma pack(pop) // restore the pack status
#ifdef __cplusplus
}
#endif
#endif