forked from gatsby/df_datalink
enhance code inherence
This commit is contained in:
@@ -29,16 +29,19 @@
|
||||
#define CTRL_WORD_DEFAULT 0x00
|
||||
|
||||
#define ANT_MODE_BEAM_MASK 0xF0
|
||||
#define ANT_MODE_NARROR_BEAM 0x00 // 8
|
||||
#define ANT_MODE_WIDE_BEAM_1 0x10 // 25
|
||||
#define ANT_MODE_WIDE_BEAM_2 0x20 // 60
|
||||
#define ANT_MODE_WIDE_BEAM_3 0x30 // 120
|
||||
#define ANT_BEAM_NARROR 0x00 // 8
|
||||
#define ANT_BEAM_SUBNARROR_0 0x10 // 25
|
||||
#define ANT_BEAM_SUBNARROR_1 0x20 // 60
|
||||
#define ANT_BEAM_WIDE 0x30 // 120
|
||||
|
||||
#define ANT_MODE_HIGH_POWER 0x00
|
||||
#define ANT_MODE_LOW_POWER 0x04
|
||||
#define ANT_MODE_STANDBY 0x0F
|
||||
#define ATN_MODE_DEFAULT (ANT_MODE_WIDE_BEAM_1 | ANT_MODE_LOW_POWER)
|
||||
#define ATN_MODE_HIGH (ANT_MODE_WIDE_BEAM_1 | ANT_MODE_HIGH_POWER)
|
||||
#define ANT_MODE_POWER_MASK 0x0F
|
||||
#define ANT_POWER_FULL 0x00
|
||||
#define ANT_POWER_LOW 0x04
|
||||
#define ANT_POWER_STANDBY 0x0F
|
||||
#define ATN_MODE_SILENT (ANT_BEAM_SUBNARROR_0 | ANT_POWER_STANDBY)
|
||||
#define ATN_MODE_LOWPOWER (ANT_BEAM_SUBNARROR_0 | ANT_POWER_LOW)
|
||||
#define ATN_MODE_FULLPOWER (ANT_BEAM_SUBNARROR_0 | ANT_POWER_FULL)
|
||||
#define ATN_MODE_DEFAULT ATN_MODE_SILENT
|
||||
|
||||
#define DEFAULT_CENTRTAL_FREQ 0x06D7 // 26.25GHz
|
||||
|
||||
@@ -186,13 +189,14 @@ PHY_ANT_ANGLE antNrrwPattern[L1_NUM_ANT_NRRW_PATTERN] =
|
||||
0
|
||||
};
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief
|
||||
* @brief Initialize antenna configurations (load preset values)
|
||||
*
|
||||
* @param antConfig
|
||||
* @param antConfig pointer to antenna configure
|
||||
*
|
||||
* @return
|
||||
* @return None.
|
||||
*
|
||||
******************************************************************************/
|
||||
void Phy_AntConfigInit(PHY_ANT_CONFIG *antConfig)
|
||||
@@ -246,20 +250,30 @@ void Phy_AntConfigInit(PHY_ANT_CONFIG *antConfig)
|
||||
// ***********************
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Update antenna power mode setting
|
||||
*
|
||||
* @param instPtr pointer to physical layer instance
|
||||
* @param mode new antenna mode
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
******************************************************************************/
|
||||
void Phy_AntConfigMode(PHY_INST *instPtr, PHY_ANT_MODE mode)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
uint8_t config = instPtr->antConfig.antMode & ANT_MODE_BEAM_MASK;
|
||||
switch (mode)
|
||||
{
|
||||
case PHY_ANT_MODE_SILENT:
|
||||
config |= ANT_MODE_STANDBY;
|
||||
case PHY_ANT_MODE_STANDBY:
|
||||
config |= ANT_POWER_STANDBY;
|
||||
break;
|
||||
case PHY_ANT_MODE_LOW_POWER:
|
||||
config |= ANT_MODE_LOW_POWER;
|
||||
case PHY_ANT_MODE_POWER_LOW:
|
||||
config |= ANT_POWER_LOW;
|
||||
break;
|
||||
case PHY_ANT_MODE_HIGH_POWER:
|
||||
config |= ANT_MODE_HIGH_POWER;
|
||||
case PHY_ANT_MODE_POWER_FULL:
|
||||
config |= ANT_POWER_FULL;
|
||||
break;
|
||||
default:
|
||||
DBG_ERROR("Unknown antenna mode: %" PRIu8 ", remain previous mode.\n", mode);
|
||||
@@ -269,6 +283,17 @@ void Phy_AntConfigMode(PHY_INST *instPtr, PHY_ANT_MODE mode)
|
||||
instPtr->antConfig.antMode = config;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Update antenna point direction using predefined beam table
|
||||
*
|
||||
* @param instPtr pointer to physical layer instance
|
||||
* @param beamNo new beam index
|
||||
*
|
||||
* @return SUCCESS.
|
||||
* FAILURE beamNo exceeds the table size
|
||||
*
|
||||
******************************************************************************/
|
||||
int32_t Phy_SetBeamNo(PHY_INST *instPtr, int32_t beamNo)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
@@ -318,6 +343,17 @@ int32_t Phy_SetBeamNo(PHY_INST *instPtr, int32_t beamNo)
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Update antenna beam width setting
|
||||
*
|
||||
* @param instPtr pointer to physical layer instance
|
||||
* @param beamWidth new beam width
|
||||
*
|
||||
* @return SUCCESS.
|
||||
* EPARAM - the direction is exceeds predefined range
|
||||
*
|
||||
******************************************************************************/
|
||||
int32_t Phy_SetBeamWidth(PHY_INST *instPtr, PHY_ANT_BEAM_WIDTH beamWidth)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
@@ -325,16 +361,16 @@ int32_t Phy_SetBeamWidth(PHY_INST *instPtr, PHY_ANT_BEAM_WIDTH beamWidth)
|
||||
switch (beamWidth)
|
||||
{
|
||||
case PHY_ANT_BEAM_120:
|
||||
beamConfig |= ANT_MODE_WIDE_BEAM_3;
|
||||
beamConfig |= ANT_BEAM_WIDE;
|
||||
break;
|
||||
case PHY_ANT_BEAM_60:
|
||||
beamConfig |= ANT_MODE_WIDE_BEAM_2;
|
||||
beamConfig |= ANT_BEAM_SUBNARROR_1;
|
||||
break;
|
||||
case PHY_ANT_BEAM_25:
|
||||
beamConfig |= ANT_MODE_WIDE_BEAM_1;
|
||||
beamConfig |= ANT_BEAM_SUBNARROR_0;
|
||||
break;
|
||||
case PHY_ANT_BEAM_8:
|
||||
beamConfig |= ANT_MODE_NARROR_BEAM;
|
||||
beamConfig |= ANT_BEAM_NARROR;
|
||||
break;
|
||||
default:
|
||||
DBG_ERROR("Beam width code: 0x%08X is illegal.\n\r", beamWidth);
|
||||
@@ -345,7 +381,18 @@ int32_t Phy_SetBeamWidth(PHY_INST *instPtr, PHY_ANT_BEAM_WIDTH beamWidth)
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// Common version radius double input
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Set antenna to a specific direction
|
||||
*
|
||||
* @param instPtr pointer to physical layer instance
|
||||
* @param offAx elevation angle
|
||||
* @param rndAx azimuth angle
|
||||
*
|
||||
* @return SUCCESS.
|
||||
* EPARAM - the direction is exceeds predefined range
|
||||
*
|
||||
******************************************************************************/
|
||||
int32_t Phy_SetBeamAngle(PHY_INST *instPtr, double offAx, double rndAx)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
|
||||
@@ -170,9 +170,9 @@ typedef enum
|
||||
typedef enum
|
||||
{
|
||||
PHY_ANT_MODE_NONE = 0,
|
||||
PHY_ANT_MODE_SILENT = 1,
|
||||
PHY_ANT_MODE_LOW_POWER = 2,
|
||||
PHY_ANT_MODE_HIGH_POWER = 3,
|
||||
PHY_ANT_MODE_STANDBY = 1,
|
||||
PHY_ANT_MODE_POWER_LOW = 2,
|
||||
PHY_ANT_MODE_POWER_FULL = 3,
|
||||
} PHY_ANT_MODE;
|
||||
|
||||
typedef struct
|
||||
|
||||
@@ -430,19 +430,19 @@ int32_t SystemBus_HandleCmd(SYSBUS *instPtr)
|
||||
if(data[WD_EN_CMD] == EN_CMD_ON_HIGH_POWER)
|
||||
{
|
||||
// high power config
|
||||
Phy_AntConfigMode(phyRef, PHY_ANT_MODE_HIGH_POWER);
|
||||
Phy_AntConfigMode(phyRef, PHY_ANT_MODE_POWER_FULL);
|
||||
}
|
||||
else if(data[WD_EN_CMD] == EN_CMD_ON_LOW_POWER)
|
||||
{
|
||||
// low power config
|
||||
Phy_AntConfigMode(phyRef, PHY_ANT_MODE_LOW_POWER);
|
||||
Phy_AntConfigMode(phyRef, PHY_ANT_MODE_POWER_LOW);
|
||||
}
|
||||
else if(data[WD_EN_CMD] == EN_CMD_SILENT)
|
||||
{
|
||||
// silence config
|
||||
// TODO: better approach?
|
||||
Linklayer_Halt(linkInstPtr);
|
||||
Phy_AntConfigMode(phyRef, PHY_ANT_MODE_SILENT);
|
||||
Phy_AntConfigMode(phyRef, PHY_ANT_MODE_STANDBY);
|
||||
TIME_WORD pullTime = {0, 0};
|
||||
pullTime.int_part = TimeCtrl_GetIntCnt(tmcRef) + 1;
|
||||
Status = Phy_SetTimeWord(phyRef, &pullTime, PHY_TIME_WORD_POLL);
|
||||
|
||||
Reference in New Issue
Block a user