265 lines
8.5 KiB
C
265 lines
8.5 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 HW_TONEMASK_H
|
|
#define HW_TONEMASK_H
|
|
#include "os_types.h"
|
|
#include "hw_tonemap.h"
|
|
#include "iot_bitops.h"
|
|
#include "phy_bb.h"
|
|
#include "phy_chn.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define BITS_PER_TONEMASK 1
|
|
#define BITS_PER_TONEAMP 4
|
|
#define BITS_PER_DWORD 32
|
|
#define TOTAL_TX_PHASE_DW_NUM 64
|
|
#define TOTAL_GAIN_NUM 85
|
|
#define TOTAL_NB_GAIN_NUM 85
|
|
#define TOTAL_TX_DC_NUM 4
|
|
#define TONEMASK_RMS_NUM 9
|
|
|
|
#define MASK_AMP_MAX 0xa0
|
|
#define MASK_AMP_STEP 0x20
|
|
|
|
#pragma pack(push) /* save the pack status */
|
|
#pragma pack(1) /* 1 byte align */
|
|
|
|
typedef struct _plc_band_table {
|
|
uint32_t valid_tone_number : 16,
|
|
fc_sym_num : 5,
|
|
rate_type : 2, // rate type
|
|
fd_rms_max : 9; // max rms number
|
|
uint32_t start_tone : 11, // first used tone id
|
|
resv1 : 5,
|
|
end_tone : 11, // last used tone id
|
|
resv2 : 5; // DW1
|
|
} plc_band_table_t;
|
|
|
|
typedef struct _plc_phy_band_table {
|
|
uint8_t band_id;
|
|
plc_band_table_t band_info;
|
|
} plc_phy_band_table_t;
|
|
|
|
typedef struct _plc_tonemask_rms_table {
|
|
uint32_t tonemask_id : 7,
|
|
valid_tone_number : 16,
|
|
fd_rms_max : 9;
|
|
} plc_tonemask_rms_table;
|
|
|
|
typedef struct _plc_tonemask_table {
|
|
uint32_t tone_mask_bitmap[TOTAL_TONE_MASK_NUM * BITS_PER_TONEMASK \
|
|
/ BITS_PER_DWORD]; // DW[0:47]
|
|
} plc_tonemask_table;
|
|
|
|
typedef struct _plc_tone_mask_amp_table {
|
|
uint8_t tone_mask : 1,
|
|
spur_filter : 3,
|
|
tone_amp : 4;
|
|
} plc_tone_mask_amp_table;
|
|
|
|
typedef struct _plc_tone_mask_amp_phase_table {
|
|
plc_tone_mask_amp_table tone_amp_tab[1];//TOTAL_TONE_MASK_NUM
|
|
uint32_t preamble_phase_tab[TOTAL_TX_PHASE_DW_NUM];
|
|
uint32_t fc_payload_phase_tab[TOTAL_TX_PHASE_DW_NUM];
|
|
} plc_tone_mask_amp_phase_table;
|
|
|
|
extern plc_band_table_t all_mask_band_table_r0_full;
|
|
extern plc_band_table_t all_mask_band_table_r0_low;
|
|
extern plc_band_table_t all_mask_band_table_r0_high;
|
|
extern plc_band_table_t all_mask_band_table_r1_full;
|
|
extern plc_band_table_t all_mask_band_table_r1_low;
|
|
extern plc_band_table_t all_mask_band_table_r1_high;
|
|
|
|
extern const plc_tonemask_rms_table iot_plc_tonemask_rms_all[TONEMASK_RMS_NUM];
|
|
extern const plc_tonemask_table all_mask_tone_mask_table;
|
|
extern const plc_tonemask_table all_mask_tone_mask_table_sg_band0;
|
|
extern const plc_tonemask_table all_mask_tone_mask_table_sg_band1;
|
|
extern const plc_tonemask_table all_mask_tone_mask_table_sg_band2;
|
|
extern const plc_tonemask_table all_mask_tone_mask_table_sg_band3;
|
|
#if (SUPPORT_GREEN_PHY || IOT_DTEST_ONLY_SUPPORT)
|
|
extern const plc_tonemask_table all_mask_tone_mask_table_gp;
|
|
#endif
|
|
extern const plc_tonemask_table all_mask_tone_mask_table_custom;
|
|
extern const plc_tonemask_table all_mask_tone_mask_table_sg_tide;
|
|
|
|
extern plc_band_table_t *g_plc_band_tbl_r0[MAX_HW_BAND];
|
|
extern plc_band_table_t *g_plc_band_tbl_r1[MAX_HW_BAND];
|
|
|
|
extern const plc_tone_mask_amp_phase_table all_mask_amp_phase_table;
|
|
|
|
#if SUPPORT_SOUTHERN_POWER_GRID
|
|
extern const uint32_t preamble_phase_tab_spg[TOTAL_TX_PHASE_DW_NUM];
|
|
|
|
extern const uint32_t fc_payload_phase_tab_spg[TOTAL_TX_PHASE_DW_NUM];
|
|
|
|
extern const uint32_t preamble_phase_tab_muti_band_spg[TOTAL_TX_PHASE_DW_NUM];
|
|
|
|
extern const uint32_t fc_payload_phase_tab_muti_band_spg[TOTAL_TX_PHASE_DW_NUM];
|
|
|
|
#endif
|
|
|
|
extern uint32_t all_mask_gain_table[];
|
|
|
|
/**
|
|
* @brief phy_get_plc_nsg_band_tab_info - get the iot_plc_nsg_band_all info
|
|
*
|
|
* @param band_tab [band table out pointer.]
|
|
* @return uint8_t IOT_ARRAY_CNT(iot_plc_nsg_band_all)
|
|
*/
|
|
uint8_t phy_get_plc_nsg_band_tab_info(const plc_phy_band_table_t **band_tab);
|
|
|
|
/**
|
|
* @brief phy_get_plc_gp_band_tab_info - get the iot_plc_gp_band_all info
|
|
*
|
|
* @param band_tab [band table out pointer.]
|
|
* @return uint8_t IOT_ARRAY_CNT(iot_plc_gp_band_all)
|
|
*/
|
|
uint8_t phy_get_plc_gp_band_tab_info(const plc_phy_band_table_t **band_tab);
|
|
|
|
/* caluculate how many valid tones in the band from a tone mask table.
|
|
* based on the iot_bitops.h utils
|
|
*/
|
|
uint32_t get_valid_tone_number(const plc_tonemask_table *tmt, \
|
|
uint32_t start_tone, uint32_t end_tone);
|
|
|
|
/* init the band table
|
|
* @band_start_tone - start tone id, 0 - 1535
|
|
* retrun 0 for success
|
|
*/
|
|
uint32_t init_band_table(plc_band_table_t *table, \
|
|
uint32_t band_id, \
|
|
const plc_tonemask_table *tmt, uint32_t fc_sym, \
|
|
uint32_t band_start_tone, uint32_t band_end_tone);
|
|
|
|
void print_band_table(plc_band_table_t *table);
|
|
void phy_tone_mask_amp_phase_tab_load( \
|
|
const plc_tone_mask_amp_phase_table *table, \
|
|
plc_tone_mask_id msk_id, \
|
|
uint32_t mac_proto);
|
|
|
|
/**
|
|
*@brief phy_spur_mask_set.
|
|
*
|
|
* Here is more APIs used to initialize phy configurations.
|
|
* spur mask is one of the ways to fit spur scenarios.
|
|
*@param center_idx [The index of spur siganl.]
|
|
*@param width [The total numbers which will be masked, exclude center.]
|
|
*@exception [none.]
|
|
*@return [none.]
|
|
*/
|
|
void phy_spur_mask_set(uint32_t center_idx, uint32_t width);
|
|
|
|
/**
|
|
*@brief phy_amp_mask_set.
|
|
*
|
|
* Here is more APIs used to initialize phy configurations.
|
|
* amplitude mask is one of the ways to modify used tone power.
|
|
*@param start_tone [start tone index.]
|
|
*@param start_tone [end tone index.]
|
|
*@exception [none.]
|
|
*@return [none.]
|
|
*/
|
|
void phy_amp_mask_set(uint32_t start_tone, uint32_t end_tone);
|
|
|
|
/**
|
|
*@brief phy_spur_mask_clr.
|
|
*
|
|
* used to clr phy spur mask configurations.
|
|
* spur mask is one of the ways to fit spur scenarios.
|
|
*@param center_idx [The index of spur siganl.]
|
|
*@param width [The total numbers which will be masked, exclude center.]
|
|
*@exception [none.]
|
|
*@return [none.]
|
|
*/
|
|
void phy_spur_mask_clr(uint32_t center_idx, uint32_t width);
|
|
|
|
/**
|
|
*@brief phy_band_info_get_by_id.
|
|
*
|
|
* get band info depend on band id.
|
|
*
|
|
*@param mac_proto [mac protocol.]
|
|
*@param range_id [band range id.]
|
|
*@param band_id [band id.]
|
|
*@param valid_tone_num [return valid tone number ref to band id.]
|
|
*@param fc_num [return fc number ref to band id.]
|
|
*@param start_tone [return start tone ref to band id.]
|
|
*@param end_tone [return end tone ref to band id.]
|
|
*@exception [none.]
|
|
*@return [0:success,others fail.]
|
|
*/
|
|
uint32_t phy_band_info_get_by_id( \
|
|
uint32_t mac_proto, \
|
|
uint32_t range_id, \
|
|
uint32_t band_id, \
|
|
volatile uint16_t *valid_tone_num, \
|
|
volatile uint8_t *fc_num, \
|
|
volatile uint16_t *start_tone, \
|
|
volatile uint16_t *end_tone);
|
|
|
|
/**
|
|
*@brief phy_tone_mask_ptr_get.
|
|
*
|
|
* get band tonemask array pointer id.
|
|
*
|
|
*@param mask_id [tone mask id.]
|
|
*@exception [none.]
|
|
*@return [band tonemask array pointer id.]
|
|
*/
|
|
const plc_tonemask_table *phy_tone_mask_ptr_get(plc_tone_mask_id mask_id);
|
|
|
|
/**
|
|
*@brief phy_update_tone_det_range.
|
|
*
|
|
* set tone detect range.
|
|
*
|
|
*@param [none.]
|
|
*@exception [none.]
|
|
*@return [none.]
|
|
*/
|
|
void phy_update_tone_det_range();
|
|
|
|
/**
|
|
*@brief phy_amp_mask_set_special_limit.
|
|
*
|
|
* set tone mask for special band.
|
|
*
|
|
*@param [none.]
|
|
*@exception [none.]
|
|
*@return [none.]
|
|
*/
|
|
void phy_amp_mask_set_special_limit();
|
|
|
|
/*
|
|
* @brief phy_band_tone_range_get() - get the start and end tones of the current
|
|
* band configuration
|
|
* @param start_tone: return start tone.
|
|
* @param end_tone: return end tone.
|
|
*/
|
|
void phy_band_tone_range_get(uint32_t *start_tone, uint32_t *end_tone);
|
|
|
|
#pragma pack(pop) /* restore the pack status */
|
|
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif // !HW_TONEMASK_H
|