misc update
This commit is contained in:
@@ -42,15 +42,17 @@
|
||||
#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
|
||||
#define ATN_ATTENUATION_MAX 0x1F
|
||||
#define ATN_ATTENUATION_SKIP 0xFF
|
||||
|
||||
#define RXTXMODE_RX 0x00
|
||||
#define RXTXMODE_TX 0x01
|
||||
#define DEFAULT_CARRIER_FREQ 0x06D7 // 26.25GHz
|
||||
|
||||
#define RXTXMODE_DEFAULT 0x00
|
||||
#define TORMODE_RX 0x00
|
||||
#define TORMODE_TX 0x01
|
||||
#define TORMODE_DEFAULT 0x00
|
||||
|
||||
#define CALIBRMODE_NORMAL 0x00
|
||||
#define CALIBRMODE_SINGLE_TR_CAL 0x01
|
||||
#define CALIMODE_NORMAL 0x00
|
||||
#define CALIMODE_SINGLE_TR_CAL 0x01
|
||||
|
||||
#define RF_CTRL_DEFAULT 0x00
|
||||
|
||||
@@ -209,19 +211,19 @@ void Phy_AntConfigInit(PHY_ANT_CONFIG *antConfig)
|
||||
antConfig->raxis[0] = 0;
|
||||
antConfig->raxis[1] = 0;
|
||||
|
||||
antConfig->antFreq[0] = (uint8_t)(DEFAULT_CENTRTAL_FREQ);
|
||||
antConfig->antFreq[1] = (uint8_t)(DEFAULT_CENTRTAL_FREQ >> 8);
|
||||
antConfig->antFreq[0] = (uint8_t)(DEFAULT_CARRIER_FREQ);
|
||||
antConfig->antFreq[1] = (uint8_t)(DEFAULT_CARRIER_FREQ >> 8);
|
||||
|
||||
// FIXME: Dummy default value.
|
||||
// trSelect
|
||||
antConfig->trSlect = 0;
|
||||
antConfig->trSelect = 0;
|
||||
// Antenna attenuation setting
|
||||
antConfig->antAtt = 20;
|
||||
// phase setting
|
||||
antConfig->phase = 0;
|
||||
|
||||
antConfig->rxtxMode = RXTXMODE_DEFAULT;
|
||||
antConfig->calibrMode = CALIBRMODE_NORMAL;
|
||||
antConfig->torMode = TORMODE_DEFAULT;
|
||||
antConfig->caliMode = CALIMODE_NORMAL;
|
||||
antConfig->antReserved = 0x00;
|
||||
// ***********************
|
||||
|
||||
@@ -229,8 +231,8 @@ void Phy_AntConfigInit(PHY_ANT_CONFIG *antConfig)
|
||||
// RF mode control
|
||||
antConfig->rfCtrl = RF_CTRL_DEFAULT;
|
||||
// RF frequency
|
||||
antConfig->rfFreq[0] = (uint8_t)(DEFAULT_CENTRTAL_FREQ);
|
||||
antConfig->rfFreq[1] = (uint8_t)(DEFAULT_CENTRTAL_FREQ >> 8);
|
||||
antConfig->rfFreq[0] = (uint8_t)(DEFAULT_CARRIER_FREQ);
|
||||
antConfig->rfFreq[1] = (uint8_t)(DEFAULT_CARRIER_FREQ >> 8);
|
||||
// RF MGC control
|
||||
antConfig->rfTxMgc = 0;
|
||||
// RF channel 1&2 calibration mgc
|
||||
@@ -238,11 +240,87 @@ void Phy_AntConfigInit(PHY_ANT_CONFIG *antConfig)
|
||||
// RF channel 2&3 calibration mgc
|
||||
antConfig->rf34CalMgc = 0;
|
||||
// Receive channel 1-4 MGC
|
||||
antConfig->rcvMgc = 0;
|
||||
antConfig->rfRxMgc = 0;
|
||||
antConfig->rfReserved0 = 0x00;
|
||||
antConfig->rfReserved1 = 0x00;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @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_STANDBY:
|
||||
config |= ANT_POWER_STANDBY;
|
||||
break;
|
||||
case PHY_ANT_MODE_POWER_LOW:
|
||||
config |= ANT_POWER_LOW;
|
||||
break;
|
||||
case PHY_ANT_MODE_POWER_FULL:
|
||||
config |= ANT_POWER_FULL;
|
||||
break;
|
||||
default:
|
||||
DBG_ERROR("Unknown antenna mode: %" PRIu8 ", remain previous mode.\n", mode);
|
||||
return;
|
||||
}
|
||||
instPtr->antConfig.antMode = config;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Update antenna attenuation
|
||||
*
|
||||
* @param instPtr pointer to physical layer instance
|
||||
* @param rxAtt rx attenuation
|
||||
* @param txAtt tx attenuation
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
******************************************************************************/
|
||||
void Phy_AntConfigAttenuation(PHY_INST *instPtr, uint8_t rxAtt, uint8_t txAtt)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
if(rxAtt <= ATN_ATTENUATION_MAX)
|
||||
{
|
||||
instPtr->antConfig.rfRxMgc = rxAtt;
|
||||
}
|
||||
else if(rxAtt != ATN_ATTENUATION_SKIP)
|
||||
{
|
||||
DBG_ERROR("RX Attenuation exceeds range, %u.", rxAtt);
|
||||
}
|
||||
|
||||
if(txAtt <= ATN_ATTENUATION_MAX)
|
||||
{
|
||||
instPtr->antConfig.rfTxMgc = txAtt;
|
||||
}
|
||||
else if(txAtt != ATN_ATTENUATION_SKIP)
|
||||
{
|
||||
DBG_ERROR("TX Attenuation exceeds range, %u.", txAtt);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @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, PHY_ANT_BEAM_WIDTH beamWidth)
|
||||
{
|
||||
if (beamWidth == PHY_ANT_BEAM_16)
|
||||
@@ -295,6 +373,17 @@ int32_t Phy_SetBeamNo(PHY_INST *instPtr, int32_t beamNo, PHY_ANT_BEAM_WIDTH beam
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Update antenna beam width setting
|
||||
*
|
||||
* @param instPtr pointer to physical layer instance
|
||||
* @param beamWidth new beam width
|
||||
*
|
||||
* @return SUCCESS.
|
||||
* EPARAM
|
||||
*
|
||||
******************************************************************************/
|
||||
int32_t Phy_SetBeamWidth(PHY_INST *instPtr, PHY_ANT_BEAM_WIDTH beamWidth)
|
||||
{
|
||||
uint8_t beamConfig = instPtr->antConfig.antMode & (~ANT_MODE_BEAM_MASK);
|
||||
@@ -322,7 +411,19 @@ 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)
|
||||
{
|
||||
uint16_t offAxDeg = 0;
|
||||
|
||||
@@ -664,7 +664,7 @@ int32_t Phy_SetupNextSlot(PHY_INST *instPtr, PHY_TOR_TYPE txrxMode,
|
||||
instPtr->antConfig.antFreq[0] = (uint8_t)(hopPattern[i] >> 8);
|
||||
instPtr->antConfig.rfFreq[1] = (uint8_t)hopPattern[i];
|
||||
instPtr->antConfig.rfFreq[0] = (uint8_t)(hopPattern[i] >> 8);
|
||||
memcpy((uint8_t *)(antConfigAddr + i * ANT_CONFIG_LEN),
|
||||
memcpy((uint8_t *)(antConfigAddr + i * sizeof(PHY_ANT_CONFIG)),
|
||||
dataSrcPtr, ANT_CONFIG_LEN);
|
||||
}
|
||||
uint32_t antCtrl = (instPtr->antConfigOffset & ANT_CONFIG_OFFSET_MASK)
|
||||
|
||||
@@ -90,14 +90,14 @@ typedef struct
|
||||
uint8_t raxis[2]; ///< round-axis angle range is 0~360, \n
|
||||
/// 0.1 degree each LSB
|
||||
uint8_t antFreq[2]; ///< 0~3500Mhz, step 1MHz
|
||||
uint8_t trSlect; ///< in single tr mode, 0~63 specified tr channel \n
|
||||
uint8_t trSelect; ///< in single tr mode, 0~63 specified tr channel \n
|
||||
/// in single subarray mode, 0~3 specified the subarray
|
||||
/// ! Only in debug mode!
|
||||
uint8_t antAtt; ///< Antenna attenuation 0~31, 0.5dB each LSB, Only in debug mode
|
||||
uint8_t phase; ///< 0~63, 5.625 degree each LSB, Only in debug mode
|
||||
uint8_t rxtxMode; ///< Only for debug \n
|
||||
uint8_t torMode; ///< Only for debug \n
|
||||
/// default 0x00
|
||||
uint8_t calibrMode; ///< 0x00 Normal, 0x01 single tr calibration
|
||||
uint8_t caliMode; ///< 0x00 Normal, 0x01 single tr calibration
|
||||
uint8_t antReserved; ///< reserved for further use
|
||||
|
||||
/*** RF Control ***/
|
||||
@@ -110,7 +110,7 @@ typedef struct
|
||||
uint8_t rf34CalMgc; ///< RF channel 3&4 calibration mgc\n
|
||||
/// [7:4] Channle3 - max 15db, 1dB each LSB
|
||||
/// [3:0] Channle4 - max 15db, 1dB each LSB
|
||||
uint8_t rcvMgc; ///< Receive channel 1-4 MGC: 0~31, 1dB each LSB
|
||||
uint8_t rfRxMgc; ///< Receive channel 1-4 MGC: 0~31, 1dB each LSB
|
||||
uint8_t rfMonitor; ///< Receive monitor, 0-normal, 1-switch to monitor port
|
||||
uint8_t rfReserved0; ///< reserved for further use
|
||||
uint8_t rfReserved1; ///< reserved for further use
|
||||
@@ -241,34 +241,25 @@ typedef struct
|
||||
/************************** Function Prototypes ******************************/
|
||||
int32_t Phy_InstInit(PHY_INST **instPtr, PHY_CONFIG *phyConfig);
|
||||
void Phy_Destroy(PHY_INST *instPtr);
|
||||
|
||||
void Phy_UpdateState(PHY_INST *instPtr);
|
||||
|
||||
void Phy_Start(PHY_INST *instPtr);
|
||||
void Phy_Halt(PHY_INST *instPtr);
|
||||
int32_t Phy_SetMode(PHY_INST *instPtr, PHY_MODE modeCod);
|
||||
|
||||
int32_t Phy_SetMode(PHY_INST *instPtr, PHY_MODE modeCod);
|
||||
int32_t Phy_SetTimeWord(PHY_INST *instPtr, const TIME_WORD *tmWord, PHY_TIME_WORD_TYPE tmType);
|
||||
int32_t Phy_SetupNextSlot(PHY_INST *instPtr, PHY_TOR_TYPE txrxMode, L1_FRAME_TYPE frameType, uint8_t *dataBuff);
|
||||
void Phy_UpdateState(PHY_INST *instPtr);
|
||||
void Phy_PeekRecvData(PHY_INST *instPtr, uint8_t *dataBuff);
|
||||
void Phy_RetrieveRecvData(PHY_INST *instPtr, uint8_t *dataBuff);
|
||||
|
||||
bool Phy_IsFrameDetected(PHY_INST *instPtr);
|
||||
bool Phy_IsFrameReceived(PHY_INST *instPtr);
|
||||
bool Phy_IsFrameValid(PHY_INST *instPtr);
|
||||
uint32_t Phy_GetFrameLen(L1_FRAME_TYPE frameType);
|
||||
|
||||
L1_FRAME_TYPE Phy_GetLastRecvFrameType(PHY_INST *instPtr);
|
||||
L1_FRAME_TYPE Phy_GetLastSendFrameType(PHY_INST *instPtr);
|
||||
|
||||
int32_t Phy_SetHopPattern(void *patternBuff, uint32_t patternLen);
|
||||
uint32_t Phy_GetHopLength(L1_FRAME_TYPE frameType);
|
||||
uint32_t Phy_GetTimeComp(L1_FRAME_TYPE frameType);
|
||||
|
||||
void Phy_AntConfigInit(PHY_ANT_CONFIG *antConfig);
|
||||
int32_t Phy_SetBeamWidth(PHY_INST *instPtr, PHY_ANT_BEAM_WIDTH beamWidth);
|
||||
int32_t Phy_SetBeamNo(PHY_INST *instPtr, int32_t beamNo, PHY_ANT_BEAM_WIDTH beamWidth);
|
||||
int32_t Phy_SetBeamAngle(PHY_INST *phyInstPtr, double offAx, double rndAx);
|
||||
int32_t Phy_SetTimeWord(PHY_INST *instPtr, const TIME_WORD *tmWord, PHY_TIME_WORD_TYPE tmType);
|
||||
uint32_t Phy_GetFrameLen(L1_FRAME_TYPE frameType);
|
||||
L1_FRAME_TYPE Phy_GetLastRecvFrameType(PHY_INST *instPtr);
|
||||
L1_FRAME_TYPE Phy_GetLastSendFrameType(PHY_INST *instPtr);
|
||||
|
||||
double Phy_GetFreqEst(PHY_INST *instPtr);
|
||||
double Phy_GetCoarseFreqEst(PHY_INST *instPtr);
|
||||
@@ -277,4 +268,12 @@ void Phy_GetFrameSyncTimeStamp(PHY_INST *instPtr, TIME_WORD *frameSyncT);
|
||||
void Phy_GetLastReceivedFrameSyncTimeStamp(PHY_INST *instPtr, TIME_WORD *frameSyncT);
|
||||
void Phy_GetSlotStartTimeStamp(PHY_INST *instPtr, TIME_WORD *slotStart);
|
||||
void Phy_GetLastReceivedSlotStartTimeStamp(PHY_INST *instPtr, TIME_WORD *slotStart);
|
||||
|
||||
void Phy_AntConfigInit(PHY_ANT_CONFIG *antConfig);
|
||||
void Phy_AntConfigMode(PHY_INST *instPtr, PHY_ANT_MODE mode);
|
||||
void Phy_AntConfigAttenuation(PHY_INST *instPtr, uint8_t rxAtt, uint8_t txAtt);
|
||||
int32_t Phy_SetBeamWidth(PHY_INST *instPtr, PHY_ANT_BEAM_WIDTH beamWidth);
|
||||
int32_t Phy_SetBeamNo(PHY_INST *instPtr, int32_t beamNo, PHY_ANT_BEAM_WIDTH beamWidth);
|
||||
int32_t Phy_SetBeamAngle(PHY_INST *phyInstPtr, double offAx, double rndAx);
|
||||
|
||||
#endif /* PHY_CTRL_H_ */
|
||||
|
||||
@@ -398,7 +398,6 @@ TEST(linklayer_reconfig)
|
||||
TEST(linklayer_master_routine)
|
||||
{
|
||||
int32_t Status;
|
||||
Linklayer_Start(linkInstPtr);
|
||||
TIME_WORD timeStampA, timeStampB, timeGap;
|
||||
uint32_t timeDiff;
|
||||
l2Config.myType = L2_NODE_HEAD;
|
||||
@@ -406,6 +405,7 @@ TEST(linklayer_master_routine)
|
||||
Status = Linklayer_Reconfig(linkInstPtr, &l2Config);
|
||||
ASSERT_EQUAL(SUCCESS, Status);
|
||||
// 30 seconds
|
||||
Linklayer_Start(linkInstPtr);
|
||||
for (int i = 0; i < 30 * L2_SLOTS_PER_FRAME; i++)
|
||||
{
|
||||
tmcReg[TIME_INT_REG]++;
|
||||
@@ -486,7 +486,6 @@ TEST(linklayer_master_routine)
|
||||
TEST(linklayer_slave_netsetup)
|
||||
{
|
||||
int32_t Status;
|
||||
Linklayer_Start(linkInstPtr);
|
||||
TIME_WORD timeStampA, timeStampB, timeGap;
|
||||
TIME_WORD bmTime;
|
||||
uint32_t netStart, timeDiff;
|
||||
@@ -502,6 +501,7 @@ TEST(linklayer_slave_netsetup)
|
||||
// 74 is the index of bm frame in routine table.
|
||||
netStart = bmTime.int_part % L2_SLOTS_PER_FRAME + rand_range(-12, 12);
|
||||
|
||||
Linklayer_Start(linkInstPtr);
|
||||
for (int i = 0; i < 12 * L2_SLOTS_PER_FRAME * TIME_FRAC_MAX; i++)
|
||||
{
|
||||
tmcReg[TIME_FRAC_REG]++;
|
||||
@@ -596,8 +596,8 @@ TEST_SUITE(linklayer_unit_test)
|
||||
{
|
||||
TEST_SUITE_CONFIGURE(linklayer_setup, linklayer_teardown);
|
||||
RUN_TEST(linklayer_reconfig);
|
||||
RUN_TEST(linklayer_slave_netsetup);
|
||||
RUN_TEST(linklayer_master_routine);
|
||||
RUN_TEST(linklayer_slave_netsetup);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
|
||||
Reference in New Issue
Block a user