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

421 lines
13 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_TXRX_PWR_H
#define PHY_TXRX_PWR_H
#ifdef __cplusplus
extern "C" {
#endif
#define PHY_FULL_PWR_DBUV (137)
#define PHY_MP_PWR_REDUCE (30)
#define PHY_DEF_RMS (58)
#define PHY_PWR_ADJ_MAX (42)
#define PHY_PWR_DIG_ATT_MAX (12)
#define PHY_PWR_ANA_MAX (18)
#define PHY_PWR_ANA_STEP_LEN (6)
#define PHY_PWR_ANA_STEP_NUM (3)
#define PHY_CERT_DST_RMS (52)
#define PHY_PWR_TD_MIN (-12)
#define PHY_PWR_CTRL_THRESHHOLD (24)
#define MIN_TX_POWER (PHY_FULL_PWR_DBUV - PHY_PWR_ADJ_MAX)
typedef struct fd_td_ana_full{
uint8_t fd_pwr_int;
uint8_t fd_pwr_frac :5,
ana_pwr :3;
uint8_t fd_pwr_frac_lp; /* 4bit */
uint8_t td_pwr;
} fd_td_ana_full_t;
typedef struct phy_psd_full{
uint8_t full_dbuv;
uint8_t lp_dbuv;
} phy_psd_full_t;
typedef struct phy_fd_td_ana_full{
uint8_t band_id;
fd_td_ana_full_t fd_td_ana_full;
phy_psd_full_t psd_full;
} phy_fd_td_ana_full_t;
/**
*@brief phy_pgf_pga_dc_cal.
*
* config dc offset of pgf and pga moudle to analog register.
* update the tone mask table.
*@param gain_idx [The index of gain table.]
*@param pgf_offset [PGF DC offset.]
*@param pga_offset [PGA DC offset.]
*@exception [none.]
*@return [none.]
*/
void phy_pgf_pga_dc_cal(uint16_t gain_idx, \
uint16_t pgf_offset, uint16_t pga_offset);
/**
*@brief phy_pgf_pga_dc_cal_get.
*
* get dc offset of pgf and pga from gain table.
* update the tone mask table.
*@param gain_idx [The index of gain table.]
*@param pgf_offset [PGF DC offset.]
*@param pga_offset [PGA DC offset.]
*@exception [none.]
*@return [none.]
*/
void phy_pgf_pga_dc_cal_get(uint16_t gain_idx, \
volatile uint16_t *pgf_offset, volatile uint16_t *pga_offset);
/**
*@brief phy_pgf_bq_pga_gain_get.
*
* get gain info.
* update the tone mask table.
*@param gain_idx [The index of gain table.]
*@param pgf [PGF gain.]
*@param bq [bq gain.]
*@param pga [PGA gain.]
*@param lna [lna gain.]
*@param byphpf [bypass hpf.]
*@param enord2 [en 2ord hpf.]
*@param bq_qvalue [bq qvalue not use in kl1.]
*@exception [none.]
*@return [none.]
*/
void phy_pgf_bq_pga_gain_get(uint16_t gain_idx, \
volatile uint8_t *pgf, \
volatile uint8_t *bq, \
volatile uint8_t *pga, \
volatile uint8_t *lna, \
volatile uint8_t *byphpf, \
volatile uint8_t *enord2, \
volatile uint8_t *bq_qvalue);
/**
*@brief phy tone amplitue reduce(db) set.
*
*@param start_tone [The index of start tone.]
*@param end_tone [The index of end tone.]
*@param reduce_db [tx power reduce db]
*@exception [none.]
*@return [none]
*/
void phy_tone_amp_reduce_set(uint32_t start_tone, uint32_t end_tone,
uint8_t reduce_db);
/**
*@brief phy_amp_set.
*
* Here is more APIs used to initialize phy configurations.
* amptitude is one of the ways to fit CUSTOM0.
*@param start_tone [The index of start tone.]
*@param end_tone [The index of end tone.]
*@param amp_value [The amptitude value.]
*@exception [none.]
*@return [none.]
*/
void phy_tone_amp_set(uint32_t start_tone, uint32_t end_tone, uint8_t amp_value);
/**
*@brief phy_apm_clr.
*
* Here is more APIs used to initialize phy configurations.
* amptitude is one of the ways to fit CUSTOM0.
*@param start_tone [The index of start tone.]
*@param end_tone [The index of end tone.]
*@exception [none.]
*@return [none.]
*/
void phy_tone_apm_clr(uint32_t start_tone, uint32_t end_tone);
/**
*@brief phy_rms_get_by_valid_tone.
*
* get band max rms depend on valid tone number.
*
*@param valid_tone_num [valid tone number.]
*@param fd_rms [return max rms with specail band id.]
*@exception [none.]
*@return [0:success,others fail.]
*/
uint32_t phy_rms_get_by_valid_tone(uint16_t valid_tone_num, uint8_t *fd_rms);
/**
*@brief phy_gp_band_rms_get_by_valid_tone.
*
* get short band rms depend on valid tone number.
*
*@param valid_tone_num [valid tone number.]
*@param fd_rms [return max rms with specail band id.]
*@exception [none.]
*@return [0:success,others fail.]
*/
uint32_t phy_gp_band_rms_get_by_valid_tone(uint16_t valid_tone_num, uint8_t *fd_rms);
/**
*@brief phy_tone_msk_rms_get_by_valid_tone.
*
* get band rms with tone mask depend on valid tone number.
*
*@param valid_tone_num [valid tone number.]
*@param fd_rms [return max rms with specail band id.]
*@exception [none.]
*@return [0:success,others fail.]
*/
uint32_t phy_tone_msk_rms_get_by_valid_tone(uint16_t valid_tone_num, \
uint8_t *fd_rms);
/**
*@brief phy_time_rms_set.
*
* set time domain rms value.
*@param [none.]
*@exception [none.]
*@return [none.]
*/
void phy_time_rms_set(void);
/**
*@brief phy_fd_rms_get.
*
* get frequency domain rms value.
*@param valid_tone_num [valid tone number.]
*@param *para_int [integer part of rms.]
*@param *para_frac [fractional part of rms.]
*@exception [none.]
*@return [0:success,others fail.]
*/
uint32_t phy_fd_rms_get(uint32_t valid_tone_num, uint8_t *para_int, uint8_t *para_frac);
/**
*@brief phy_pwr_adjust_set.
*
* Max 42dB with 18dB ana pga and 24dB att
*
*@param uint_dbuv [target power dBuV.]
*@exception [none.]
*@return [ERR_OK and others ERR_FAIL.]
*/
uint32_t phy_pwr_adjust_set(uint8_t uint_dbuv);
/**
*@brief phy_high_perf_set.
*
* enable the best performance with spur and pulse.
*
*@param en [true: enable, false: disable.]
*@exception [none.]
*@return [none.]
*/
void phy_high_perf_set(bool_t en);
/**
*@brief phy_get_def_tx_power.
*
* get fd rms depend on valid tone number.
*
*@param hw_rate_id [hardware rate id.]
*@param hw_band_id [hardware band id.]
*@param para_int [return rms integer part.]
*@param para_frac [return rms fraction part.]
*@exception [none.]
*@return [0:success,others fail.]
*/
uint32_t phy_get_def_tx_power( \
uint32_t hw_rate_id, \
uint32_t hw_band_id, \
uint8_t *para_int, \
uint8_t *para_frac);
/**
*@brief phy_get_proto_band_fc_num_from_band_table.
*
* get proto band fc num .
*
*@param proto_band_id [proto band id]
*@return [0:fail ,others fc num.]
*/
uint32_t phy_get_proto_band_fc_num_from_band_table(uint32_t proto_band_id);
/**
*@brief phy_tx_pwr_to_fd_td_ana_value.
*
* get tx fd rms, td, analog power depend on rate and band id.
*
*@param hw_rate_id [hardware rate id.]
*@param band_id [proto band id.]
*@param uint_dbuv [tx total power.]
*@param fd_para_int [return fd rms integer part.]
*@param fd_para_frac [return fd rms fraction part.]
*@param td_pwr [return td power.]
*@param ana_pwr [return analog power.]
*@exception [none.]
*@return [0:success,others fail.]
*/
uint32_t phy_tx_pwr_to_fd_td_ana_value( \
uint32_t hw_rate_id, \
uint32_t band_id, \
uint8_t uint_dbuv, \
uint8_t *fd_pwr_int, \
uint8_t *fd_pwr_frac, \
uint8_t *td_pwr, \
uint8_t *ana_pwr);
/**
*@brief phy_tx_pwr_psd_to_dbuv.
*
* convert psd to dbuv depend on band id.
*
*@param band_id [proto band id.]
*@param tbl [tx full power table.]
*@param tbl_len [tx full power table length.]
*@param uint_psd [tx psd.]
*@param uint_dbuv [return tx power.]
*@exception [none.]
*@return [0:success,others fail.]
*/
uint32_t phy_tx_pwr_psd_to_dbuv( \
uint32_t band_id, \
const phy_fd_td_ana_full_t *tbl, \
uint16_t tbl_len, \
uint8_t uint_psd, \
uint8_t *uint_dbuv);
/**
*@brief phy_get_pwr_psd_fix_db. phy get psd.
*
*@exception [none.]
*@return [psd]
*/
uint32_t phy_get_pwr_psd_fix_db();
/**
*@brief phy_get_pwr_ctl_en. phy get power control enable.
*
*@exception [none.]
*@return [enable]
*/
uint32_t phy_get_pwr_ctl_en();
/**
*@brief phy_get_pwr_reduce_db. phy get power reduce db.
*
*@exception [none.]
*@return [reduce db]
*/
uint32_t phy_get_pwr_reduce_db();
/**
*@brief phy_get_tx_pwr_limit. phy get power limit.
*@param single_proto_band [single proto band.]
*@exception [none.]
*@return [tx power], KL1 device returns a fixed value
* of 0, indicating that the interface is not
* supported
*/
uint32_t phy_get_tx_pwr_limit(uint32_t single_proto_band);
/**
*@brief phy_set_tx_pwr_limit. phy set power limit.
*@param pwr_db [pwr_db.]
*@exception [none.]
*@return [0]
*/
uint32_t phy_set_tx_pwr_limit(uint32_t pwr_db);
/**
*@brief phy_fd_rms_update. phy_fd_rms_update.
*@exception [none.]
*@return [null]
*/
void phy_fd_rms_update(void);
/**
*@brief phy_tx_resp_pwr_ctl_en.
*
* control tx sack power.
*
*@param fd_int_en [fd int ctl.]
*@param fd_frac_en [fd frac ctl.]
*@param td_en [td ctl.]
*@param ana_en [ana ctl.]
*@exception [none.]
*@return [none.]
*/
void phy_tx_resp_pwr_ctl_en(
uint8_t fd_int_en, uint8_t fd_frac_en, uint8_t td_en, uint8_t ana_en);
/**
*@brief phy_set_tx_resp_pwr.
*
* control tx sack power value.
*
*@param fd_int [fd int value.]
*@param fd_frac [fd frac value.]
*@param td [td value.]
*@param ana [ana value.]
*@exception [none.]
*@return [none.]
*/
void phy_set_tx_resp_pwr(
uint8_t fd_int, uint8_t fd_frac, uint8_t td, uint8_t ana);
/**
*@brief phy_overstress_power_down. phy overstress power down.
*
*@param dowm_db [down power db]
*@exception [none.]
*@return [none.]
*/
void phy_overstress_power_down(uint32_t dowm_db);
/**
*@brief phy_get_default_tx_pwr. phy get default tx power.
*
*@param band_id [band id]
*@param uint_dbuv [set power dbuv]
*@param dlt_max [full power - lp power]
*@exception [none.]
*@return uint32_t [success or not]
*/
uint32_t phy_get_default_tx_pwr(uint32_t band_id, uint8_t *uint_dbuv,
uint8_t *dlt_max);
/**
*@brief phy_set_common_pwr_reg. phy set power by reg.
*
*@param pwr_db [power db]
*@exception [none.]
*@return uint32_t [success or not]
*/
uint32_t phy_set_common_pwr_reg(uint32_t pwr_db);
/**
*@brief phy_set_sack_tx_power. phy set sack power by reg.
*
*@param pwr_db [power db]
*@exception [none.]
*@return void [void]
*/
void phy_set_sack_tx_power(uint32_t pwr_db);
#ifdef __cplusplus
}
#endif
#endif // !HW_TONEMASK_H