Compare commits
3
Commits
247700fee2
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
07795a2b20 | ||
|
|
21d3baec98 | ||
|
|
ad0d589141 |
@@ -28,28 +28,33 @@
|
||||
#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_LOWAPOWER 0x04
|
||||
#define ANT_MODE_STANDBY 0x0F
|
||||
#define ATN_MODE_DEFAULT (ANT_MODE_WIDE_BEAM_1 | ANT_MODE_LOWAPOWER)
|
||||
#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
|
||||
#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 MODECTRL_DEFAULT 0x00
|
||||
#define RF_CTRL_DEFAULT 0x00
|
||||
|
||||
// Pair by regex
|
||||
// Regex: (([0-9]+, ){8})
|
||||
@@ -119,63 +124,6 @@ uint16_t hopPattern_1M2BPS_5MS[L1_FRAME_1M2BPS_5MS_HOPS] =
|
||||
// Pair by regex
|
||||
// Regex: ((\{\.oaxis = [0-9]+[ ,]+\.raxis = [0-9]+[ ]*\}, ){2})
|
||||
#if defined(PHY_BEAM_SET_PRESET)
|
||||
PHY_ANT_ANGLE antSubnrrwPattern[L1_NUM_ANT_SUBNRRW_PATTERN] =
|
||||
{
|
||||
{.oaxis = 0 , .raxis = 222}, {.oaxis = 10, .raxis = 85 },
|
||||
{.oaxis = 14, .raxis = 307}, {.oaxis = 17, .raxis = 170},
|
||||
{.oaxis = 19, .raxis = 32 }, {.oaxis = 21, .raxis = 255},
|
||||
{.oaxis = 24, .raxis = 117}, {.oaxis = 25, .raxis = 340},
|
||||
{.oaxis = 27, .raxis = 202}, {.oaxis = 29, .raxis = 65 },
|
||||
{.oaxis = 31, .raxis = 287}, {.oaxis = 32, .raxis = 150},
|
||||
{.oaxis = 34, .raxis = 12 }, {.oaxis = 35, .raxis = 235},
|
||||
{.oaxis = 36, .raxis = 97 }, {.oaxis = 38, .raxis = 320},
|
||||
{.oaxis = 39, .raxis = 182}, {.oaxis = 40, .raxis = 45 },
|
||||
{.oaxis = 41, .raxis = 267}, {.oaxis = 43, .raxis = 130},
|
||||
{.oaxis = 44, .raxis = 352}, {.oaxis = 45, .raxis = 215},
|
||||
{.oaxis = 46, .raxis = 77 }, {.oaxis = 47, .raxis = 300},
|
||||
{.oaxis = 48, .raxis = 162}, {.oaxis = 49, .raxis = 25 },
|
||||
{.oaxis = 50, .raxis = 247}, {.oaxis = 51, .raxis = 110},
|
||||
{.oaxis = 52, .raxis = 332}, {.oaxis = 53, .raxis = 195},
|
||||
{.oaxis = 54, .raxis = 57 }, {.oaxis = 55, .raxis = 280},
|
||||
{.oaxis = 56, .raxis = 142}, {.oaxis = 57, .raxis = 5 },
|
||||
{.oaxis = 58, .raxis = 227}, {.oaxis = 59, .raxis = 90 },
|
||||
{.oaxis = 60, .raxis = 312}
|
||||
};
|
||||
PHY_ANT_ANGLE antNrrwPattern[L1_NUM_ANT_NRRW_PATTERN] =
|
||||
{
|
||||
{.oaxis = 0 , .raxis = 222}, {.oaxis = 7 , .raxis = 85 },
|
||||
{.oaxis = 10, .raxis = 307}, {.oaxis = 13, .raxis = 170},
|
||||
{.oaxis = 15, .raxis = 32 }, {.oaxis = 17, .raxis = 255},
|
||||
{.oaxis = 18, .raxis = 117}, {.oaxis = 20, .raxis = 340},
|
||||
{.oaxis = 21, .raxis = 202}, {.oaxis = 22, .raxis = 65 },
|
||||
{.oaxis = 24, .raxis = 287}, {.oaxis = 25, .raxis = 150},
|
||||
{.oaxis = 26, .raxis = 12 }, {.oaxis = 27, .raxis = 235},
|
||||
{.oaxis = 28, .raxis = 97 }, {.oaxis = 29, .raxis = 320},
|
||||
{.oaxis = 30, .raxis = 182}, {.oaxis = 31, .raxis = 45 },
|
||||
{.oaxis = 32, .raxis = 267}, {.oaxis = 33, .raxis = 130},
|
||||
{.oaxis = 34, .raxis = 352}, {.oaxis = 34, .raxis = 215},
|
||||
{.oaxis = 35, .raxis = 77 }, {.oaxis = 36, .raxis = 300},
|
||||
{.oaxis = 37, .raxis = 162}, {.oaxis = 38, .raxis = 25 },
|
||||
{.oaxis = 38, .raxis = 247}, {.oaxis = 39, .raxis = 110},
|
||||
{.oaxis = 40, .raxis = 332}, {.oaxis = 41, .raxis = 195},
|
||||
{.oaxis = 41, .raxis = 57 }, {.oaxis = 42, .raxis = 280},
|
||||
{.oaxis = 43, .raxis = 142}, {.oaxis = 44, .raxis = 5 },
|
||||
{.oaxis = 44, .raxis = 227}, {.oaxis = 45, .raxis = 90 },
|
||||
{.oaxis = 46, .raxis = 312}, {.oaxis = 46, .raxis = 175},
|
||||
{.oaxis = 47, .raxis = 37 }, {.oaxis = 48, .raxis = 260},
|
||||
{.oaxis = 48, .raxis = 122}, {.oaxis = 49, .raxis = 345},
|
||||
{.oaxis = 49, .raxis = 207}, {.oaxis = 50, .raxis = 70 },
|
||||
{.oaxis = 51, .raxis = 292}, {.oaxis = 51, .raxis = 155},
|
||||
{.oaxis = 52, .raxis = 17 }, {.oaxis = 53, .raxis = 240},
|
||||
{.oaxis = 53, .raxis = 102}, {.oaxis = 54, .raxis = 325},
|
||||
{.oaxis = 54, .raxis = 187}, {.oaxis = 55, .raxis = 50 },
|
||||
{.oaxis = 55, .raxis = 272}, {.oaxis = 56, .raxis = 135},
|
||||
{.oaxis = 57, .raxis = 357}, {.oaxis = 57, .raxis = 220},
|
||||
{.oaxis = 58, .raxis = 82 }, {.oaxis = 58, .raxis = 305},
|
||||
{.oaxis = 59, .raxis = 167}, {.oaxis = 59, .raxis = 30 },
|
||||
{.oaxis = 60, .raxis = 252}
|
||||
};
|
||||
#elif defined(PHY_BEAM_SET_PRESET_LSX)
|
||||
ANT_ANGLE antSubnrrwPattern[L1_NUM_ANT_SUBNRRW_PATTERN] = {
|
||||
{.oaxis = 0 , .raxis =2225},{.oaxis = 96 , .raxis =850 },
|
||||
{.oaxis = 135, .raxis =3075},{.oaxis = 166, .raxis =1700},
|
||||
@@ -252,14 +200,8 @@ PHY_ANT_ANGLE antNrrwPattern[L1_NUM_ANT_NRRW_PATTERN] =
|
||||
void Phy_AntConfigInit(PHY_ANT_CONFIG *antConfig)
|
||||
{
|
||||
ASSERT(antConfig != NULL);
|
||||
antConfig->head = ANT_COINFO_HEAD;
|
||||
antConfig->tail = ANT_COINFO_TAIL;
|
||||
antConfig->ctrlWord = 0x00;
|
||||
#ifdef ANT_HIGH_POWER
|
||||
antConfig->antMode = ATN_MODE_HIGH;
|
||||
#else
|
||||
antConfig->ctrlWord = CTRL_WORD_DEFAULT;
|
||||
antConfig->antMode = ATN_MODE_DEFAULT;
|
||||
#endif
|
||||
|
||||
// FIXME: Dummy default value.
|
||||
// off axis angle setting
|
||||
@@ -268,52 +210,120 @@ void Phy_AntConfigInit(PHY_ANT_CONFIG *antConfig)
|
||||
// round axis angle setting
|
||||
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->torMode = TORMODE_DEFAULT;
|
||||
antConfig->caliMode = CALIMODE_NORMAL;
|
||||
antConfig->antReserved = 0x00;
|
||||
// ***********************
|
||||
|
||||
antConfig->rxtxMode = RXTXMODE_RX;
|
||||
antConfig->calibrMode = CALIBRMODE_NORMAL;
|
||||
|
||||
// FIXME: Dummy default value.
|
||||
// DD enable
|
||||
antConfig->ddEn = 0;
|
||||
// DD mgc
|
||||
antConfig->ddMgc = 0;
|
||||
// RF mode control
|
||||
antConfig->rfCtrl = 0;
|
||||
antConfig->rfCtrl = RF_CTRL_DEFAULT;
|
||||
// RF frequency
|
||||
antConfig->rfFreq[0] = (uint8_t)(DEFAULT_CARRIER_FREQ);
|
||||
antConfig->rfFreq[1] = (uint8_t)(DEFAULT_CARRIER_FREQ >> 8);
|
||||
// RF MGC control
|
||||
antConfig->rfMgc = 0;
|
||||
antConfig->rfTxMgc = 0;
|
||||
// RF channel 1&2 calibration mgc
|
||||
antConfig->rf12CalMgc = 0;
|
||||
// RF channel 2&3 calibration mgc
|
||||
antConfig->rf34CalMgc = 0;
|
||||
// Receive channel 1 MGC
|
||||
antConfig->rcv1Mgc = 0;
|
||||
// Receive channel 2 MGC
|
||||
antConfig->rcv2Mgc = 0;
|
||||
// Receive channel 3 MGC
|
||||
antConfig->rcv3Mgc = 0;
|
||||
// Receive channel 4 MGC
|
||||
antConfig->rcv4Mgc = 0;
|
||||
// ***********************
|
||||
|
||||
memset(antConfig->dummy, 0x00, sizeof(antConfig->dummy));
|
||||
// Receive channel 1-4 MGC
|
||||
antConfig->rfRxMgc = 0;
|
||||
antConfig->rfReserved0 = 0x00;
|
||||
antConfig->rfReserved1 = 0x00;
|
||||
}
|
||||
|
||||
int32_t Phy_SetBeamNo(PHY_INST *instPtr, int32_t beamNo)
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @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)
|
||||
{
|
||||
if (instPtr->beamWd.next == PHY_ANT_BEAM_8)
|
||||
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)
|
||||
{
|
||||
if (beamNo >= L1_NUM_ANT_NRRW_PATTERN)
|
||||
{
|
||||
@@ -329,7 +339,7 @@ int32_t Phy_SetBeamNo(PHY_INST *instPtr, int32_t beamNo)
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
else if (instPtr->beamWd.next == PHY_ANT_BEAM_25)
|
||||
else if (beamWidth == PHY_ANT_BEAM_25)
|
||||
{
|
||||
if (beamNo >= L1_NUM_ANT_SUBNRRW_PATTERN)
|
||||
{
|
||||
@@ -345,7 +355,7 @@ int32_t Phy_SetBeamNo(PHY_INST *instPtr, int32_t beamNo)
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
else
|
||||
else if(beamWidth == PHY_ANT_BEAM_120)
|
||||
{
|
||||
// Beam number assign not support.
|
||||
// Assign default angle (0,0)
|
||||
@@ -357,27 +367,42 @@ int32_t Phy_SetBeamNo(PHY_INST *instPtr, int32_t beamNo)
|
||||
DBG_WARNING("Using default beam number...\n");
|
||||
return SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @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);
|
||||
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;
|
||||
case PHY_ANT_BEAM_16:
|
||||
beamConfig |= ANT_BEAM_NARROR;
|
||||
break;
|
||||
default:
|
||||
DBG_ERROR("Beam width code: 0x%08X is illegal.\n\r", beamWidth);
|
||||
DBG_ERROR("Beam width code: 0x%08X is illegal.\n", beamWidth);
|
||||
return EPARAM;
|
||||
break;
|
||||
}
|
||||
@@ -386,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;
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
#define L1_FRAME_200KBPS_5MS_COMP 22493 // *10ns(Timer_L)
|
||||
#define L1_FRAME_1M2BPS_5MS_COMP 22493 // *10ns(Timer_L)
|
||||
|
||||
#define ANT_CONFIG_LEN 32 // bytes
|
||||
#define L1_ANTCONFIG_MAX_LEN 8192
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
@@ -61,7 +62,19 @@ static int32_t Phy_SetSendData(PHY_INST *instPtr, L1_FRAME_TYPE frameType, uint8
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
extern uint16_t hopPattern_Config[L1_FRAME_MAX_HOPS];
|
||||
extern uint16_t hopPattern_2KBPS_20MS[L1_FRAME_2KBPS_20MS_HOPS];
|
||||
extern uint16_t hopPattern_2KBPS_100MS[L1_FRAME_2KBPS_100MS_HOPS];
|
||||
extern uint16_t hopPattern_10KBPS_10MS[L1_FRAME_10KBPS_10MS_HOPS];
|
||||
extern uint16_t hopPattern_10KBPS_20MS[L1_FRAME_10KBPS_20MS_HOPS];
|
||||
extern uint16_t hopPattern_40KBPS_10MS[L1_FRAME_40KBPS_10MS_HOPS];
|
||||
extern uint16_t hopPattern_40KBPS_20MS[L1_FRAME_40KBPS_20MS_HOPS];
|
||||
|
||||
extern uint16_t hopPattern_200KBPS_5MS[L1_FRAME_200KBPS_5MS_HOPS];
|
||||
extern uint16_t hopPattern_1M2BPS_5MS[L1_FRAME_1M2BPS_5MS_HOPS];
|
||||
|
||||
extern PHY_ANT_ANGLE antSubnrrwPattern[L1_NUM_ANT_SUBNRRW_PATTERN];
|
||||
extern PHY_ANT_ANGLE antNrrwPattern[L1_NUM_ANT_NRRW_PATTERN];
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Setup data will be sent in next slot.
|
||||
@@ -647,19 +660,17 @@ int32_t Phy_SetupNextSlot(PHY_INST *instPtr, PHY_TOR_TYPE txrxMode,
|
||||
uint8_t *dataSrcPtr = (uint8_t *)(&(instPtr->antConfig));
|
||||
for (int32_t i = 0; i < hopNum; i++)
|
||||
{
|
||||
instPtr->antConfig.antFreq[1] = (uint8_t)(hopPattern[i] & 0x00FF);
|
||||
instPtr->antConfig.antFreq[0] = (uint8_t)((hopPattern[i] >> 8) & 0x00FF);
|
||||
instPtr->antConfig.antFreq[1] = (uint8_t)hopPattern[i];
|
||||
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 * sizeof(PHY_ANT_CONFIG)),
|
||||
dataSrcPtr, sizeof(PHY_ANT_CONFIG));
|
||||
dataSrcPtr, ANT_CONFIG_LEN);
|
||||
}
|
||||
uint32_t antCtrl = (instPtr->antConfigOffset & ANT_CONFIG_OFFSET_MASK) | ((hopNum << ANT_CONFIG_NUM_SHIFT) & ANT_CONFIG_NUM_MASK) | ((sizeof(PHY_ANT_CONFIG) << ANT_CONFIG_LEN_SHIFT) & ANT_CONFIG_LEN_MASK);
|
||||
|
||||
/*
|
||||
memcpy((uint8_t*)antConfigDataAddr, hopPattern, hopNum*sizeof(uint16_t));
|
||||
uint32_t antCtrl = (instPtr->antCoinfigOffset & ANT_CONFIG_OFFSET_MASK)
|
||||
uint32_t antCtrl = (instPtr->antConfigOffset & ANT_CONFIG_OFFSET_MASK)
|
||||
| ((hopNum << ANT_CONFIG_NUM_SHIFT) & ANT_CONFIG_NUM_MASK)
|
||||
| ((sizeof(uint16_t) << ANT_CONFIG_LEN_SHIFT) & ANT_CONFIG_LEN_MASK);
|
||||
*/
|
||||
| ((ANT_CONFIG_LEN << ANT_CONFIG_LEN_SHIFT) & ANT_CONFIG_LEN_MASK);
|
||||
|
||||
|
||||
PhyWrite(instPtr, ANT_CONFIG, antCtrl);
|
||||
|
||||
|
||||
@@ -27,17 +27,25 @@
|
||||
#include "phy_reg.h"
|
||||
#include "../common.h"
|
||||
#include "../time_ctrl/time_ctrl.h"
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
/************************** Constant Definitions *****************************/
|
||||
/**
|
||||
* @name PhysicalLayer_Common_Constant
|
||||
* @{
|
||||
*/
|
||||
#define L1_NUM_ANT_SUBNRRW_PATTERN 37
|
||||
#define L1_NUM_ANT_NRRW_PATTERN 61
|
||||
#define L1_INIT_BEAM_NO 0
|
||||
#define L1_INIT_ANT_WD PHY_ANT_BEAM_120
|
||||
#define L1_INIT_ANT_NO 0
|
||||
|
||||
#define L1_ANT_NUM_CH 4
|
||||
#define L1_TXRXDATA_MAX_LEN 2048
|
||||
|
||||
#define L1_FRAME_NONE_LEN UINT32_MAX // byte
|
||||
#define L1_FRAME_NONE_COMP UINT32_MAX // *10ns(Timer_L)
|
||||
#define L1_FRAME_NONE_HOPS UINT32_MAX
|
||||
#define L1_TXRXDATA_MAX_LEN 2048
|
||||
#define L1_FRAME_MAX_HOPS 81
|
||||
#define L1_FRAME_2KBPS_20MS_HOPS 1
|
||||
#define L1_FRAME_2KBPS_100MS_HOPS 81
|
||||
@@ -47,10 +55,12 @@
|
||||
#define L1_FRAME_40KBPS_10MS_HOPS 9
|
||||
#define L1_FRAME_200KBPS_5MS_HOPS 20
|
||||
#define L1_FRAME_1M2BPS_5MS_HOPS 20
|
||||
|
||||
/** @} */
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
/**
|
||||
* @enum L1_FRAME_TYPE
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
L1_NONE_FRAME = 0,
|
||||
@@ -64,75 +74,67 @@ typedef enum
|
||||
L1_1M2BPS_5MS_FRAME = 8
|
||||
} L1_FRAME_TYPE;
|
||||
|
||||
/**
|
||||
* @struct PHY_ANT_CONFIG
|
||||
* @brief PhysicalLayer antenna config
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/* Antenna control frame head 0xAA */
|
||||
uint8_t head;
|
||||
/* default 0, reserved for further use */
|
||||
uint8_t ctrlWord;
|
||||
/* high 4 bits specified beam mode.
|
||||
* low 4 bits specified power control */
|
||||
uint8_t antMode;
|
||||
/* off-axis angle range is 0~60,
|
||||
* 0.1 degree each LSB */
|
||||
uint8_t oaxis[2];
|
||||
/* round-axis angle range is 0~360,
|
||||
* 0.1 degree each LSB */
|
||||
uint8_t raxis[2];
|
||||
/* 0~3500Mhz, step 1MHz */
|
||||
uint8_t antFreq[2];
|
||||
/* in single tr mode, 0~63 specified tr channel
|
||||
* in single subarray mode, 0~3 specified the subarray
|
||||
* Only in debug mode*/
|
||||
uint8_t trSlect;
|
||||
/* Antenna attenuation 0~31, 0.5dB each LSB, Only in debug mode */
|
||||
uint8_t antAtt;
|
||||
/* 0~63, 5.625 degree each LSB, Only in debug mode*/
|
||||
uint8_t phase;
|
||||
/* 0x00 Nromal RX, 0x01 Normal TX
|
||||
* 0x11~0xA1 beam debug mode (TR duty 1%~10%)*/
|
||||
uint8_t rxtxMode;
|
||||
/* 0x00 Normal, 0x01 single tr calibration */
|
||||
uint8_t calibrMode;
|
||||
/* reserved for further use */
|
||||
uint8_t reserved;
|
||||
/* DD enable */
|
||||
uint8_t ddEn;
|
||||
/* DD mgc */
|
||||
uint8_t ddMgc;
|
||||
/* [7:4]RF enable: 0-On, 1-Off(Default); [3:0]Work mode: 0(default) */
|
||||
uint8_t rfCtrl;
|
||||
/* RF MGC control: 0~31, 1dB each LSB*/
|
||||
uint8_t rfMgc;
|
||||
/* RF channel 1&2 calibration mgc: [7:4] Channle1 - max 15db, 1dB each LSB
|
||||
* [3:0] Channle2 - max 15db, 1dB each LSB*/
|
||||
uint8_t rf12CalMgc;
|
||||
/* RF channel 3&4 calibration mgc: [7:4] Channle3 - max 15db, 1dB each LSB
|
||||
* [3:0] Channle4 - max 15db, 1dB each LSB*/
|
||||
uint8_t rf34CalMgc;
|
||||
/* Receive channel 1 MGC: 0~31, 1dB each LSB */
|
||||
uint8_t rcv1Mgc;
|
||||
/* Receive channel 2 MGC: 0~31, 1dB each LSB */
|
||||
uint8_t rcv2Mgc;
|
||||
/* Receive channel 3 MGC: 0~31, 1dB each LSB */
|
||||
uint8_t rcv3Mgc;
|
||||
/* Receive channel 4 MGC: 0~31, 1dB each LSB */
|
||||
uint8_t rcv4Mgc;
|
||||
/* Antenna control frame tail 0xCC */
|
||||
uint8_t tail;
|
||||
uint8_t dummy[6];
|
||||
/*** Ant Control ***/
|
||||
uint8_t ctrlWord; ///< Antenna control frame head 0xAA\n
|
||||
/// default 0, reserved for further use
|
||||
uint8_t antMode; ///< high 4 bits specified beam mode.\n
|
||||
/// low 4 bits specified power control
|
||||
uint8_t oaxis[2]; ///< off-axis angle range is 0~60 \n
|
||||
/// 0.1 degree each LSB
|
||||
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 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 torMode; ///< Only for debug \n
|
||||
/// default 0x00
|
||||
uint8_t caliMode; ///< 0x00 Normal, 0x01 single tr calibration
|
||||
uint8_t antReserved; ///< reserved for further use
|
||||
|
||||
/*** RF Control ***/
|
||||
uint8_t rfCtrl; ///< [7:4]RF enable: 0-On, 1-Off(Default); [3:0]Work mode: 0(default)
|
||||
uint8_t rfFreq[2]; ///< 0~3500Mhz, step 1MHz
|
||||
uint8_t rfTxMgc; ///< RF MGC control: 0~31, 1dB each LSB
|
||||
uint8_t rf12CalMgc; ///< RF channel 1&2 calibration mgc\n
|
||||
/// [7:4] Channle1 - max 15db, 1dB each LSB \n
|
||||
/// [3:0] Channle2 - max 15db, 1dB each LSB
|
||||
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 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
|
||||
uint8_t ch0Cal[2];
|
||||
uint8_t ch1Cal[2];
|
||||
uint8_t ch2Cal[2];
|
||||
uint8_t ch3Cal[2];
|
||||
} PHY_ANT_CONFIG;
|
||||
|
||||
/**
|
||||
* @struct PHY_ANT_ANGLE
|
||||
* @brief Describe the PhysicalLayer antenna angle
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/* off-axis angle range is 0~60,
|
||||
* 0.1 degree each LSB */
|
||||
uint16_t oaxis;
|
||||
/* round-axis angle range is 0~360,
|
||||
* 0.1 degree each LSB */
|
||||
uint16_t raxis;
|
||||
uint16_t oaxis; ///< off-axis angle range is 0~60
|
||||
/// 0.1 degree each LSB
|
||||
uint16_t raxis; ///< round-axis angle range is 0~360
|
||||
/// 0.1 degree each LSB
|
||||
} PHY_ANT_ANGLE;
|
||||
|
||||
/**
|
||||
* @enum PHY_TIME_WORD_TYPE
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PHY_TIME_WORD_NONE = 0,
|
||||
@@ -140,15 +142,21 @@ typedef enum
|
||||
PHY_TIME_WORD_LISTEN_TIMEOUT = 2
|
||||
} PHY_TIME_WORD_TYPE;
|
||||
|
||||
/**
|
||||
* @enum PHY_ANT_BEAM_WIDTH
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PHY_ANT_BEAM_NONE = 0,
|
||||
PHY_ANT_BEAM_120 = 1,
|
||||
PHY_ANT_BEAM_60 = 2,
|
||||
PHY_ANT_BEAM_25 = 3,
|
||||
PHY_ANT_BEAM_8 = 4
|
||||
PHY_ANT_BEAM_16 = 4
|
||||
} PHY_ANT_BEAM_WIDTH;
|
||||
|
||||
/**
|
||||
* @enum PHY_TOR_TYPE
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PHY_TOR_SUSPEND = 0,
|
||||
@@ -156,6 +164,9 @@ typedef enum
|
||||
PHY_TOR_RX = 2
|
||||
} PHY_TOR_TYPE;
|
||||
|
||||
/**
|
||||
* @enum PHY_MODE
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PHY_MODE_NONE = 0,
|
||||
@@ -164,6 +175,32 @@ typedef enum
|
||||
PHY_MODE_PULL = 3
|
||||
} PHY_MODE;
|
||||
|
||||
/**
|
||||
* @enum PHY_ANT_MODE
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PHY_ANT_MODE_NONE = 0,
|
||||
PHY_ANT_MODE_STANDBY = 1,
|
||||
PHY_ANT_MODE_POWER_LOW = 2,
|
||||
PHY_ANT_MODE_POWER_FULL = 3,
|
||||
} PHY_ANT_MODE;
|
||||
|
||||
/**
|
||||
* @struct PHY_RCD
|
||||
* @brief Physical Layer recode buffer
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int32_t last;
|
||||
int32_t curr;
|
||||
int32_t next;
|
||||
} PHY_RCD;
|
||||
|
||||
/**
|
||||
* @struct PHY_CONFIG
|
||||
* @brief struct holds all physical layer initialization parameters
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t devId;
|
||||
@@ -173,13 +210,10 @@ typedef struct
|
||||
uintptr_t baseAddr;
|
||||
} PHY_CONFIG;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32_t last;
|
||||
int32_t curr;
|
||||
int32_t next;
|
||||
} PHY_RCD;
|
||||
|
||||
/**
|
||||
* @struct PHY_INST
|
||||
* @brief Physical Layer operating instance
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
PHY_CONFIG phyCofig; // Device address configs
|
||||
@@ -204,52 +238,28 @@ typedef struct
|
||||
PHY_ANT_CONFIG antConfig; // antenna configuration pointer
|
||||
} PHY_INST;
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
extern uint16_t hopPattern_Config[L1_FRAME_MAX_HOPS];
|
||||
extern uint16_t hopPattern_2KBPS_20MS[L1_FRAME_2KBPS_20MS_HOPS];
|
||||
extern uint16_t hopPattern_2KBPS_100MS[L1_FRAME_2KBPS_100MS_HOPS];
|
||||
extern uint16_t hopPattern_10KBPS_10MS[L1_FRAME_10KBPS_10MS_HOPS];
|
||||
extern uint16_t hopPattern_10KBPS_20MS[L1_FRAME_10KBPS_20MS_HOPS];
|
||||
extern uint16_t hopPattern_40KBPS_10MS[L1_FRAME_40KBPS_10MS_HOPS];
|
||||
extern uint16_t hopPattern_40KBPS_20MS[L1_FRAME_40KBPS_20MS_HOPS];
|
||||
|
||||
extern uint16_t hopPattern_200KBPS_5MS[L1_FRAME_200KBPS_5MS_HOPS];
|
||||
extern uint16_t hopPattern_1M2BPS_5MS[L1_FRAME_1M2BPS_5MS_HOPS];
|
||||
|
||||
extern PHY_ANT_ANGLE antSubnrrwPattern[L1_NUM_ANT_SUBNRRW_PATTERN];
|
||||
extern PHY_ANT_ANGLE antNrrwPattern[L1_NUM_ANT_NRRW_PATTERN];
|
||||
|
||||
/************************** 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);
|
||||
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);
|
||||
@@ -258,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)
|
||||
|
||||
@@ -130,7 +130,7 @@ static int32_t EvalPhyConfig(INTER_COMM_INST* instPtr, uint8_t* msgPtr){
|
||||
torState = PHY_TOR_RX;
|
||||
}
|
||||
else{
|
||||
DBG_ERROR("[PHY Control] Tx/Rx state cannot be recognized...\n\r");
|
||||
DBG_ERROR("[PHY Control] Tx/Rx state cannot be recognized...\n");
|
||||
return EIGNORE;
|
||||
}
|
||||
instPtr->lastCtrlTimeTag = GetTimeWord(msgPtr+CTRL_TIME_OFFSET);
|
||||
@@ -165,7 +165,7 @@ static int32_t EvalPhyConfig(INTER_COMM_INST* instPtr, uint8_t* msgPtr){
|
||||
frameType = L1_40KBPS_20MS_FRAME;
|
||||
break;
|
||||
default:
|
||||
DBG_ERROR("[PHY Control] Frame Type cannot be recognized...\n\r");
|
||||
DBG_ERROR("[PHY Control] Frame Type cannot be recognized...\n");
|
||||
return EIGNORE;
|
||||
break;
|
||||
}
|
||||
@@ -187,8 +187,8 @@ static int32_t EvalPhyConfig(INTER_COMM_INST* instPtr, uint8_t* msgPtr){
|
||||
phyRef->isPresetHop = false;
|
||||
}
|
||||
else{
|
||||
DBG_ERROR("[PHY Control] Hopping Pattern Configure cannot be recognized...\n\r");
|
||||
DBG_WARNING("[PHY Control] Using default preset hopping pattern instead...\n\r");
|
||||
DBG_ERROR("[PHY Control] Hopping Pattern Configure cannot be recognized...\n");
|
||||
DBG_WARNING("[PHY Control] Using default preset hopping pattern instead...\n");
|
||||
return EIGNORE;
|
||||
}
|
||||
if(phyRef->isPresetHop == false){
|
||||
@@ -205,11 +205,11 @@ static int32_t EvalPhyConfig(INTER_COMM_INST* instPtr, uint8_t* msgPtr){
|
||||
beamWidth = PHY_ANT_BEAM_25;
|
||||
}
|
||||
else if(msgPtr[INTER_MSG_CTRL_BEAM_MODE_OFFSET] == BEAM_MODE_NRW){
|
||||
beamWidth = PHY_ANT_BEAM_8;
|
||||
beamWidth = PHY_ANT_BEAM_16;
|
||||
}
|
||||
else{
|
||||
DBG_ERROR("[PHY Control] Beam Width Configure cannot be recognized...\n\r");
|
||||
DBG_WARNING("[PHY Control] Using default WILD beam (120 deg) instead...\n\r");
|
||||
DBG_ERROR("[PHY Control] Beam Width Configure cannot be recognized...\n");
|
||||
DBG_WARNING("[PHY Control] Using default WILD beam (120 deg) instead...\n");
|
||||
return EIGNORE;
|
||||
}
|
||||
Status = Phy_SetBeamWidth(phyRef, beamWidth);
|
||||
@@ -218,14 +218,14 @@ static int32_t EvalPhyConfig(INTER_COMM_INST* instPtr, uint8_t* msgPtr){
|
||||
}
|
||||
beamNo = (uint32_t)msgPtr[INTER_MSG_CTRL_BEAM_NO_OFFSET];
|
||||
if((beamNo<L1_NUM_ANT_SUBNRRW_PATTERN && beamWidth == PHY_ANT_BEAM_25)
|
||||
||(beamNo<L1_NUM_ANT_NRRW_PATTERN && beamWidth == PHY_ANT_BEAM_8)
|
||||
||(beamNo<L1_NUM_ANT_NRRW_PATTERN && beamWidth == PHY_ANT_BEAM_16)
|
||||
|| (beamNo == 0 && beamWidth == PHY_ANT_BEAM_120)){
|
||||
Phy_SetBeamNo(phyRef, beamNo);
|
||||
Phy_SetBeamNo(phyRef, beamNo, beamWidth);
|
||||
}
|
||||
else{
|
||||
if(beamNo != 0x000000FF){
|
||||
DBG_ERROR("[PHY Control] Beam Number Configure cannot be recognized...\n\r");
|
||||
DBG_WARNING("[PHY Control] Using Beam Angle configure instead...\n\r");
|
||||
DBG_ERROR("[PHY Control] Beam Number Configure cannot be recognized...\n");
|
||||
DBG_WARNING("[PHY Control] Using Beam Angle configure instead...\n");
|
||||
return EIGNORE;
|
||||
}
|
||||
// the angle config is a 16 bit fixed point data
|
||||
@@ -242,6 +242,35 @@ static int32_t EvalPhyConfig(INTER_COMM_INST* instPtr, uint8_t* msgPtr){
|
||||
}
|
||||
}
|
||||
|
||||
// Power Mode and Attenuation control
|
||||
if (msgPtr[INTER_MSG_CTRL_POWER_OFFSET] == CTRL_POWER_LOW)
|
||||
{
|
||||
Phy_AntConfigMode(phyRef, PHY_ANT_MODE_POWER_LOW);
|
||||
}
|
||||
else if (msgPtr[INTER_MSG_CTRL_POWER_OFFSET] == CTRL_POWER_FULL)
|
||||
{
|
||||
Phy_AntConfigMode(phyRef, PHY_ANT_MODE_POWER_FULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG_ERROR("[PHY Control] Unsupported power mode [0x%02X]\n",
|
||||
msgPtr[INTER_MSG_CTRL_POWER_OFFSET]);
|
||||
return FAILURE;
|
||||
}
|
||||
if(msgPtr[INTER_MSG_CTRL_RXATT_OFFSET] <= INTER_MSG_CTRL_RXATT_MAX
|
||||
&& msgPtr[INTER_MSG_CTRL_TXATT_OFFSET] <= INTER_MSG_CTRL_TXATT_MAX)
|
||||
{
|
||||
Phy_AntConfigAttenuation(phyRef,
|
||||
msgPtr[INTER_MSG_CTRL_RXATT_OFFSET],
|
||||
msgPtr[INTER_MSG_CTRL_TXATT_OFFSET]
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG_ERROR("[PHY Control] Attenuation exceeds max range.\n");
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
TIME_WORD tmWord = {0};
|
||||
tmWord.int_part = (uint32_t)(instPtr->lastCtrlTimeTag >> 32);
|
||||
tmWord.frac_part = (uint32_t)(instPtr->lastCtrlTimeTag);
|
||||
@@ -499,16 +528,42 @@ int32_t InterComm_MsgHandler(INTER_COMM_INST* instPtr){
|
||||
break;
|
||||
}
|
||||
case INTER_MSG_MODESW_CODE:{
|
||||
if(msgRecvPtr[MODESW_MODE_OFFSET] == MODESW_MODE_NORMAL){
|
||||
if(msgRecvPtr[MODESW_MODE_OFFSET] == MODESW_MODE_NORMAL)
|
||||
{
|
||||
Phy_SetMode(instPtr->phyInstPtr, PHY_MODE_PULL);
|
||||
}
|
||||
else if(msgRecvPtr[MODESW_MODE_OFFSET] == MODESW_MODE_NETSET){
|
||||
else if(msgRecvPtr[MODESW_MODE_OFFSET] == MODESW_MODE_NETSET)
|
||||
{
|
||||
PHY_INST* phyRef = instPtr->phyInstPtr;
|
||||
// Power Mode and Attenuation control
|
||||
if (msgRecvPtr[MODESW_POWER_OFFSET] == CTRL_POWER_LOW)
|
||||
{
|
||||
Phy_AntConfigMode(phyRef, PHY_ANT_MODE_POWER_LOW);
|
||||
}
|
||||
else if (msgRecvPtr[MODESW_POWER_OFFSET] == CTRL_POWER_FULL)
|
||||
{
|
||||
Phy_AntConfigMode(phyRef, PHY_ANT_MODE_POWER_FULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG_ERROR("[PHY Control] Unsupported power mode [0x%02X]\n",
|
||||
msgRecvPtr[MODESW_POWER_OFFSET]);
|
||||
break;
|
||||
}
|
||||
if(msgRecvPtr[MODESW_RXATT_OFFSET] <= MODESW_RXATT_MAX)
|
||||
{
|
||||
Phy_AntConfigAttenuation(phyRef, msgRecvPtr[MODESW_RXATT_OFFSET], MODESW_TXATT_SKIP);
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG_ERROR("[PHY Control] Attenuation exceeds max range.\n");
|
||||
}
|
||||
uint64_t timeTemp;
|
||||
TIME_WORD tmWord;
|
||||
timeTemp = GetTimeWord(msgRecvPtr + MODESW_START_TIME_OFFSET);
|
||||
tmWord.int_part = (uint32_t)(timeTemp>>32);;
|
||||
tmWord.frac_part = (uint32_t)(timeTemp);
|
||||
Status = Phy_SetTimeWord(instPtr->phyInstPtr, &tmWord, PHY_TIME_WORD_POLL);
|
||||
Status = Phy_SetTimeWord(phyRef, &tmWord, PHY_TIME_WORD_POLL);
|
||||
if(Status != SUCCESS){
|
||||
return EPARAM;
|
||||
}
|
||||
@@ -516,7 +571,7 @@ int32_t InterComm_MsgHandler(INTER_COMM_INST* instPtr){
|
||||
if(timeTemp == 0){
|
||||
tmWord.frac_part = 0;
|
||||
tmWord.int_part = 0;
|
||||
Status = Phy_SetTimeWord(instPtr->phyInstPtr, &tmWord, PHY_TIME_WORD_LISTEN_TIMEOUT);
|
||||
Status = Phy_SetTimeWord(phyRef, &tmWord, PHY_TIME_WORD_LISTEN_TIMEOUT);
|
||||
if(Status != SUCCESS){
|
||||
return EPARAM;
|
||||
}
|
||||
@@ -526,14 +581,14 @@ int32_t InterComm_MsgHandler(INTER_COMM_INST* instPtr){
|
||||
tmWord.int_part += (uint32_t)(timeTemp>>32);
|
||||
tmWord.int_part = (tmWord.frac_part >= TIME_FRAC_MAX) ? tmWord.int_part + 1:tmWord.int_part;
|
||||
tmWord.frac_part %= TIME_FRAC_MAX;
|
||||
Status = Phy_SetTimeWord(instPtr->phyInstPtr, &tmWord, PHY_TIME_WORD_LISTEN_TIMEOUT);
|
||||
Status = Phy_SetTimeWord(phyRef, &tmWord, PHY_TIME_WORD_LISTEN_TIMEOUT);
|
||||
if(Status != SUCCESS){
|
||||
return EPARAM;
|
||||
}
|
||||
}
|
||||
instPtr->phyInstPtr->isPresetHop = true ;
|
||||
Status = Phy_SetMode(instPtr->phyInstPtr, PHY_MODE_LISTEN);
|
||||
Status = Phy_SetupNextSlot(instPtr->phyInstPtr, PHY_TOR_RX, L1_10KBPS_20MS_FRAME, NULL);
|
||||
phyRef->isPresetHop = true ;
|
||||
Status = Phy_SetMode(phyRef, PHY_MODE_LISTEN);
|
||||
Status = Phy_SetupNextSlot(phyRef, PHY_TOR_RX, L1_10KBPS_20MS_FRAME, NULL);
|
||||
}
|
||||
else{
|
||||
return EPARAM;
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
#define WAKE_CMD_LPW_UP 0xCCCC
|
||||
|
||||
// mode swicth command
|
||||
#define INTER_MSG_MODESW_LEN 0x0016 // 20byte + crc
|
||||
#define INTER_MSG_MODESW_LEN 0x0018 // 22byte + crc
|
||||
#define INTER_MSG_MODESW_CODE 0x0041
|
||||
#define MODESW_START_TIME_OFFSET 0x0002
|
||||
#define MODESW_START_TIME_LEN 0x0008
|
||||
@@ -75,6 +75,14 @@
|
||||
#define MODESW_MODE_LEN 0x0002
|
||||
#define MODESW_MODE_NORMAL 0x0001
|
||||
#define MODESW_MODE_NETSET 0x0002
|
||||
#define MODESW_POWER_OFFSET 0x0014
|
||||
#define MODESW_POWER_LEN 0x0001
|
||||
#define MODESW_POWER_LOW 0xAA
|
||||
#define MODESW_POWER_FULL 0xCC
|
||||
#define MODESW_RXATT_OFFSET 0x0015
|
||||
#define MODESW_RXATT_LEN 0x0001
|
||||
#define MODESW_RXATT_MAX 0x1F
|
||||
#define MODESW_TXATT_SKIP 0xFF
|
||||
|
||||
// physical layer control
|
||||
#define INTER_MSG_CTRL_LEN 0x00BC // 186byte + 2byte crc
|
||||
@@ -108,11 +116,10 @@
|
||||
#define CTRL_TOR_TX 0xAA
|
||||
#define CTRL_TOR_RX 0xCC
|
||||
|
||||
#define INTER_MSG_CTRL_SW_OFFSET 0x000D
|
||||
#define INTER_MSG_CTRL_SW_LEN 0x0001
|
||||
#define CTRL_SW_PW BIT(0)
|
||||
#define CTRL_SW_TR BIT(1)
|
||||
#define CTRL_SW_TOR BIT(2)
|
||||
#define INTER_MSG_CTRL_POWER_OFFSET 0x000D
|
||||
#define INTER_MSG_CTRL_POWER_LEN 0x0001
|
||||
#define CTRL_POWER_LOW 0xAA
|
||||
#define CTRL_POWER_FULL 0xCC
|
||||
|
||||
#define INTER_MSG_CTRL_HOP_MODE_OFFSET 0x000E
|
||||
#define INTER_MSG_CTRL_HOP_MODE_LEN 0x0002
|
||||
@@ -132,8 +139,12 @@
|
||||
#define INTER_MSG_CTRL_BEAM_NO_OFFSET 0x00B3
|
||||
#define INTER_MSG_CTRL_BEAM_NO_LEN 0x0001
|
||||
|
||||
#define INTER_MSG_CTRL_AMP_WT_OFFSET 0x00B4
|
||||
#define INTER_MSG_CTRL_AMP_WT_LEN 0x0002
|
||||
#define INTER_MSG_CTRL_RXATT_OFFSET 0x00B4
|
||||
#define INTER_MSG_CTRL_RXATT_LEN 0x0001
|
||||
#define INTER_MSG_CTRL_RXATT_MAX 0x1F
|
||||
#define INTER_MSG_CTRL_TXATT_OFFSET 0x00B5
|
||||
#define INTER_MSG_CTRL_TXATT_LEN 0x0001
|
||||
#define INTER_MSG_CTRL_TXATT_MAX 0x1F
|
||||
|
||||
#define INTER_MSG_CTRL_OFFAX_OFFSET 0x00B6
|
||||
#define INTER_MSG_CTRL_OFFAX_LEN 0x0002
|
||||
|
||||
@@ -747,7 +747,7 @@ int main(void) {
|
||||
else{
|
||||
Status = InterComm_MsgHandler(intrCommInstPtr);
|
||||
if(Status != SUCCESS){
|
||||
DBG_PRINT("####\tInterComm message handler finished with code: %d\n\r", Status);
|
||||
DBG_PRINT("####\tInterComm message handler finished with code: %d\n", Status);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user