328 lines
9.9 KiB
C
328 lines
9.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 __PHY_CHN_H
|
|
#define __PHY_CHN_H
|
|
|
|
#include "os_types.h"
|
|
#include "plc_protocol.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef enum {
|
|
TONE_MASK_ID_NULL = 0,
|
|
TONE_MASK_ID_SG0 = 1,
|
|
TONE_MASK_ID_SG1 = 2,
|
|
TONE_MASK_ID_SG2 = 3,
|
|
TONE_MASK_ID_SG3 = 4,
|
|
TONE_MASK_ID_GP = 5,
|
|
TONE_MASK_ID_CUS = 6,
|
|
TONE_MASK_ID_TIDE = 7,
|
|
/* ce cert tone mask */
|
|
TONE_MASK_ID_CE = 8,
|
|
} plc_tone_mask_id;
|
|
|
|
typedef enum _phy_sg_band_id_range_t {
|
|
IOT_SUPPORT_TONE_80_490 = 0, /* 2M to 12M */
|
|
IOT_SUPPORT_TONE_100_230 = 1, /* 2.4M to 5.6M */
|
|
IOT_SUPPORT_TONE_32_120 = 2, /* 700K to 3M */
|
|
IOT_SUPPORT_TONE_72_120 = 3, /* 1.7M to 3M */
|
|
IOT_SUPPORT_TONE_231_490 = 4, /* 5.6M to 12M */
|
|
IOT_SUPPORT_TONE_240_370 = 8, /* 5.8M to 9M */
|
|
IOT_SUPPORT_TONE_200_1000 = 9, /* 4.9M to 24.4M */
|
|
IOT_SUPPORT_TONE_1160_1415 = 10,/* 28.3M to 34.5M */
|
|
IOT_SUPPORT_TONE_200_500 = 11, /* 4.9M to 12.2M */
|
|
/* below tide band special id */
|
|
IOT_SUPPORT_TONE_TIDE = 12, /* 1.6M to 5M */
|
|
/* below ningbo sanxing band special id */
|
|
IOT_SUPPORT_TONE_100_230_CE = 13, /* 2.4M to 5.6 M */
|
|
IOT_SUPPORT_TONE_80_490_CE = 14, /* 2M to 12M */
|
|
IOT_SUPPORT_TONE_231_490_CE = 15, /* 5.6M to 12M */
|
|
/* below HT BUS band */
|
|
IOT_SUPPORT_TONE_100_400 = 17, /* 3M to 14.3M */
|
|
IOT_SUPPORT_TONE_850_1150 = 18, /* 19.4M to 30.7M */
|
|
/* below multi-band specail id*/
|
|
IOT_SUPPORT_TONE_MULTI_BAND021 = 128,
|
|
IOT_SUPPORT_TONE_MULTI_MAX,
|
|
} phy_sg_band_id_range_t;
|
|
|
|
typedef enum _phy_gp_band_id_range_t {
|
|
IOT_SUPPORT_TONE_80_1228 = 0,
|
|
IOT_SUPPORT_TONE_80_743,
|
|
IOT_SUPPORT_TONE_80_600
|
|
} phy_gp_band_id_range_t;
|
|
|
|
typedef enum _phy_proto_band_range_id_t {
|
|
/* sg or nsg only, multi-band */
|
|
IOT_SUPPORT_PROTO_SG_NSG_BAND = 0,
|
|
/* greephy only, multi-band */
|
|
IOT_SUPPORT_PROTO_GP_BAND,
|
|
/* max range id */
|
|
IOT_SUPPORT_PROTO_BAND_MAX
|
|
} phy_proto_band_range_id_t;
|
|
|
|
/* for power grid, sg, spg, htbus */
|
|
#define IOT_PLC_PHY_BAND_RANGE_DFT IOT_SUPPORT_PROTO_SG_NSG_BAND
|
|
#if (IOT_POWER_GRID_CONFIG)
|
|
#if IOT_HTBUS_EN
|
|
#define IOT_PLC_PHY_BAND_DFT IOT_SUPPORT_TONE_100_400
|
|
#else /* IOT_HTBUS_EN */
|
|
#if SUPPORT_SOUTHERN_POWER_GRID
|
|
#if ENABLE_MULTIBAND && PLC_SUPPORT_CCO_ROLE
|
|
#define IOT_PLC_PHY_BAND_DFT IOT_SUPPORT_TONE_MULTI_BAND021
|
|
#else /* single band default band */
|
|
#define IOT_PLC_PHY_BAND_DFT IOT_SUPPORT_TONE_32_120
|
|
#endif /* ENABLE_MULTIBAND END */
|
|
#else /* SUPPORT_SMART_GRID */
|
|
#if SUPPORT_IEEE_1901
|
|
#define IOT_PLC_PHY_BAND_DFT IOT_SUPPORT_TONE_100_230
|
|
#else /* SUPPORT_IEEE_1901 */
|
|
#define IOT_PLC_PHY_BAND_DFT IOT_SUPPORT_TONE_32_120
|
|
#endif
|
|
#endif /* SUPPORT_SOUTHERN_POWER_GRID END */
|
|
#endif /* IOT_HTBUS_EN */
|
|
#else /* IOT default band */
|
|
#define IOT_PLC_PHY_BAND_DFT IOT_SUPPORT_TONE_100_230
|
|
#endif /* IOT_POWER_GRID_CONFIG END */
|
|
|
|
/* for MP mode band define */
|
|
#if (1 == K48_STA_MULTI_CHANNEL_SELECT_ENABLE || \
|
|
1 == K48_CCO_MULTI_CHANNEL_SELECT_ENABLE)
|
|
#define IOT_PLC_PHY_MP_BAND IOT_SUPPORT_TONE_200_1000
|
|
#else
|
|
#define IOT_PLC_PHY_MP_BAND IOT_SUPPORT_TONE_32_120
|
|
#endif
|
|
|
|
#define PHY_SCAN_DUMP_BITMAP_SIZE (PLC_BAND_BITMAP_SIZE)
|
|
|
|
/* band ctxt */
|
|
typedef struct _iot_phy_chn_ctxt {
|
|
/* current protocol type */
|
|
uint32_t phy_proto :3,
|
|
/* current band */
|
|
band_id :8,
|
|
/* next reboot protocol type */
|
|
phy_proto_tobe :3,
|
|
/* next reboot band */
|
|
band_id_tobe :8,
|
|
/* current mask */
|
|
mask_id :4,
|
|
/* next reboot mask */
|
|
mask_id_tobe :4,
|
|
/* rise tx power */
|
|
is_pwr_rise :1,
|
|
/* reserved */
|
|
rsvd : 1;
|
|
|
|
uint8_t scan_band_bitmap[PHY_SCAN_DUMP_BITMAP_SIZE];
|
|
} iot_phy_chn_ctxt_t;
|
|
|
|
/**
|
|
*@brief phy_proto_type_to_set, apply after phy reinit
|
|
*
|
|
* set global variable phy info.
|
|
*
|
|
*@param phy_proto [phy current protocol type]
|
|
*@exception [none.]
|
|
*@return [none.]
|
|
*/
|
|
void phy_proto_type_to_set(uint32_t phy_proto);
|
|
|
|
/**
|
|
*@brief phy_proto_type_set, record the cur value
|
|
*
|
|
* set global variable phy info.
|
|
*
|
|
*@param phy_proto [phy current protocol type]
|
|
*@exception [none.]
|
|
*@return [none.]
|
|
*/
|
|
void phy_proto_type_set(uint32_t phy_proto);
|
|
|
|
/**
|
|
*@brief phy_proto_type_get.
|
|
*@param phy_proto [phy current protocol type]
|
|
*@exception [none.]
|
|
*@return [none.]
|
|
*/
|
|
uint32_t phy_proto_type_get(void);
|
|
|
|
/**
|
|
*@brief phy_proto_type_is_i1901.
|
|
* get current phy hw ptotocol is ieee1901 or not.
|
|
*
|
|
*@exception [none.]
|
|
*@return [0 - not ieee1901, 1 - ieee1901 proto]
|
|
*/
|
|
uint8_t phy_proto_type_is_i1901(void);
|
|
|
|
/**
|
|
*@brief phy_band_id_to_set, apply after phy reinit
|
|
*@param band_id [band id]
|
|
*@exception [none.]
|
|
*@return [none.]
|
|
*/
|
|
void phy_band_id_to_set(uint32_t band_id);
|
|
|
|
/**
|
|
*@brief phy_proto_type_to_get.
|
|
*@param [none]
|
|
*@exception [none.]
|
|
*@return mac_proto [mac proto will be set.]
|
|
*/
|
|
uint32_t phy_proto_type_to_get();
|
|
|
|
/**
|
|
*@brief phy_band_id_set, record the cur value
|
|
*@param band_id [band id]
|
|
*@exception [none.]
|
|
*@return [none.]
|
|
*/
|
|
void phy_band_id_set(uint32_t band_id);
|
|
|
|
/**
|
|
*@brief phy_band_id_get.
|
|
*@param band_id [band id]
|
|
*@exception [none.]
|
|
*@return [none.]
|
|
*/
|
|
uint32_t phy_band_id_get(void);
|
|
|
|
/**
|
|
*@brief phy_mask_id_to_set, apply after phy reinit
|
|
*@param mask_id [mask id]
|
|
*@exception [none.]
|
|
*@return [none.]
|
|
*/
|
|
void phy_mask_id_to_set(plc_tone_mask_id mask_id);
|
|
|
|
/**
|
|
*@brief phy_mask_id_set, record the cur value
|
|
*@param mask_id [mask id]
|
|
*@exception [none.]
|
|
*@return [none.]
|
|
*/
|
|
void phy_mask_id_set(plc_tone_mask_id mask_id);
|
|
|
|
/**
|
|
*@brief sg_tonemask_to_hw_tonemask sw tonemask to hw tonemask
|
|
*@param sw_tonemask [mask id]
|
|
*@exception [none.]
|
|
*@return [hw tonemask]
|
|
*/
|
|
uint32_t sg_tonemask_to_hw_tonemask(uint32_t sw_tonemask);
|
|
|
|
/**
|
|
*@brief phy_support_band_table_get get current phy support band table
|
|
*@param proto [protocol id]
|
|
*@param band_tbl [support band table]
|
|
*@exception [none.]
|
|
*@return [hw tonemask]
|
|
*/
|
|
uint32_t phy_support_band_table_get(uint32_t proto, void **band_tbl);
|
|
|
|
/**
|
|
*@brief phy_band_to_tonemask_id_get base on band id get tonemask id
|
|
*@param band_id [phy band id]
|
|
*@exception [none.]
|
|
*@return [tonemask id]
|
|
*/
|
|
uint8_t phy_band_to_tonemask_id_get(uint8_t band_id);
|
|
|
|
/**
|
|
*@brief phy_mask_id_get.
|
|
*@param mask_id [mask id]
|
|
*@exception [none.]
|
|
*@return [none.]
|
|
*/
|
|
plc_tone_mask_id phy_mask_id_get(void);
|
|
|
|
/**
|
|
*@brief phy_ra_tbl_band_range_init.
|
|
*@param [none]
|
|
*@exception [none.]
|
|
*@return [0 true and other false.]
|
|
*/
|
|
uint32_t phy_ra_tbl_band_range_init();
|
|
|
|
/**
|
|
*@brief phy_ra_tbl_band_range_get.
|
|
* get global rate table range pointer.
|
|
*@param proto_band_id [current proto band index.]
|
|
*@param start_idx [range start index.]
|
|
*@param ed_idx [range end index.]
|
|
*@exception [none.]
|
|
*@return [0 true and other false.]
|
|
*/
|
|
uint32_t phy_ra_tbl_band_range_get(uint32_t proto_band_id, \
|
|
uint32_t* start_idx, uint32_t* ed_idx);
|
|
|
|
/**
|
|
*@brief phy_multi_band_opt_ena.
|
|
* multi-band need special config to increase transmit success rate.
|
|
*@param proto_band_id [proto band id]
|
|
*@exception [none.]
|
|
*@return [none.]
|
|
*/
|
|
void phy_multi_band_opt_ena(uint32_t proto_band_id);
|
|
|
|
/**
|
|
*@brief phy_multi_band_opt_dis.
|
|
* clear multi-band special config.
|
|
*@param proto_band_id [proto band id]
|
|
*@exception [none.]
|
|
*@return [none.]
|
|
*/
|
|
void phy_multi_band_opt_dis(uint32_t proto_band_id);
|
|
|
|
/**
|
|
*@brief phy_hw_band_to_proto_band.
|
|
* switch proto band to hw band id.
|
|
*@param hw_band [rx hw band id]
|
|
*@exception [none.]
|
|
*@return [proto band id.]
|
|
*/
|
|
uint32_t phy_hw_band_to_proto_band(uint32_t hw_band);
|
|
|
|
/**
|
|
*@brief phy_proto_band_to_hw_band.
|
|
* switch hw band to proto band id.
|
|
*@param proto_band [proto band id]
|
|
*@exception [none.]
|
|
*@return [proto band id.]
|
|
*/
|
|
uint32_t phy_proto_band_to_hw_band(uint32_t proto_single_band);
|
|
|
|
/**
|
|
*@brief phy_def_hw_band_id_get get default hw band id
|
|
*
|
|
*@return default hw band id
|
|
*/
|
|
uint32_t phy_def_hw_band_id_get(void);
|
|
|
|
/**
|
|
*@brief phy_proto_single_band_id_get get single protocol band id
|
|
*
|
|
*@return single protocol band id
|
|
*/
|
|
uint32_t phy_proto_single_band_id_get(void);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|