Compare commits
18
Commits
e55c135229
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
07795a2b20 | ||
|
|
21d3baec98 | ||
|
|
ad0d589141 | ||
|
|
247700fee2 | ||
|
|
31ec331464 | ||
|
|
297cd0d0da | ||
|
|
452df8ad81 | ||
|
|
966148ebef | ||
|
|
693a63a800 | ||
|
|
5745fef452 | ||
|
|
f4af6a1522 | ||
|
|
0f5526736d | ||
|
|
417e566e3d | ||
|
|
12fc651673 | ||
|
|
cb1e368b58 | ||
|
|
c9058b2c63 | ||
|
|
c722ba4277 | ||
|
|
6167475307 |
@@ -39,7 +39,6 @@ static void L2_SetSlotNum(L2_INST *instPtr, uint32_t newSlotNum);
|
||||
static void L2_SetFrameNum(L2_INST *instPtr, uint32_t newFrameNum);
|
||||
static void L2_UpdateSlotNum(L2_INST *instPtr);
|
||||
static void L2_DataAvailUpdate(L2_INST *instPtr, bool status);
|
||||
static L2_FRAME_TYPE L2_GetReceiveFrameType(L2_INST *instPtr);
|
||||
|
||||
/**
|
||||
* @brief helper function to update linkelayer state
|
||||
@@ -305,7 +304,7 @@ inline void L2_RcdShift(L2_RCD *rcd, int32_t netxVal)
|
||||
* @return L2_FRAME_TYPE.
|
||||
*
|
||||
******************************************************************************/
|
||||
static L2_FRAME_TYPE L2_GetReceiveFrameType(L2_INST *instPtr)
|
||||
L2_FRAME_TYPE L2_GetLastOptFrameType(L2_INST *instPtr)
|
||||
{
|
||||
if (instPtr->myInfo.nodeType == L2_NODE_HEAD || L2_isCxn2Net(instPtr))
|
||||
{
|
||||
@@ -351,7 +350,7 @@ void L2_FrameStateUpdate(L2_INST *instPtr)
|
||||
instPtr->log.frameRecv++;
|
||||
|
||||
// Update frame state.
|
||||
switch (L2_GetReceiveFrameType(instPtr))
|
||||
switch (L2_GetLastOptFrameType(instPtr))
|
||||
{
|
||||
case L2_INTRA_SCAN_FRAME:
|
||||
// INTRA_BM_FRAME could be received if current frame type is INTRA_BM_FRAME
|
||||
@@ -1228,15 +1227,6 @@ static int32_t Linklayer_Routine(L2_INST *instPtr)
|
||||
int32_t Status;
|
||||
uint32_t tableIndx, entryIndx;
|
||||
|
||||
// FIXME: Consider time wrapping.
|
||||
uint32_t nextTimeUnit = (TimeCtrl_GetIntCnt(instPtr->config.tmcInstPtr) + 1) / L2_SLOTS_PER_FRAME;
|
||||
if (nextTimeUnit < instPtr->netStartTime)
|
||||
{
|
||||
DBG_WARNING("Linklayer not start yet, next time unit: %u, start time unit: %u.\n",
|
||||
nextTimeUnit, instPtr->netStartTime);
|
||||
return EIGNORE;
|
||||
}
|
||||
|
||||
// Determine which routine entry is going to be performed.
|
||||
tableIndx = L2_GetNextFrameNum(instPtr) % instPtr->rtneConfig.rtnePrd;
|
||||
entryIndx = L2_GetNextSlotNum(instPtr);
|
||||
@@ -1318,6 +1308,15 @@ int32_t Linklayer_Proc(L2_INST *instPtr)
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// FIXME: Consider time wrapping.
|
||||
uint32_t nextTimeUnit = (TimeCtrl_GetIntCnt(instPtr->config.tmcInstPtr) + 1) / L2_SLOTS_PER_FRAME;
|
||||
if (nextTimeUnit < instPtr->netStartTime)
|
||||
{
|
||||
DBG_WARNING("Linklayer not start yet, next time unit: %u, start time unit: %u.\n",
|
||||
nextTimeUnit, instPtr->netStartTime);
|
||||
return EIGNORE;
|
||||
}
|
||||
|
||||
// Update slot number.
|
||||
L2_UpdateSlotNum(instPtr);
|
||||
|
||||
@@ -1330,9 +1329,9 @@ int32_t Linklayer_Proc(L2_INST *instPtr)
|
||||
// Handle frame received in last slot.
|
||||
if (L2_isDataAvail(instPtr) == true)
|
||||
{
|
||||
if (Linklayer_PktHandler(instPtr, L2_GetLastFrameType(instPtr)) != SUCCESS)
|
||||
if (Linklayer_PktHandler(instPtr, L2_GetLastOptFrameType(instPtr)) != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("Failed to handle last received frame: %ld.\n", instPtr->frame.last);
|
||||
DBG_ERROR("Failed to handle last received frame: %d.\n", instPtr->frame.last);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@ int32_t L2_RescheduleEventAfter(L2_INST *instPtr, L2_SCHD_EVENT *schdEvent, uint
|
||||
|
||||
// Framing
|
||||
void L2_FrameStateUpdate(L2_INST *instPtr);
|
||||
L2_FRAME_TYPE L2_GetLastRcvFrameType(L2_INST *instPtr);
|
||||
L2_FRAME_TYPE L2_GetLastOptFrameType(L2_INST *instPtr);
|
||||
L1_FRAME_TYPE L2_L2frame2L1frame(L2_FRAME_TYPE l2Frame);
|
||||
void FrameGetChunk(BIT_ARRAY *bitarr, uint32_t offset, uint32_t numBit, uint64_t *chunk);
|
||||
void FrameInsertChunk(BIT_ARRAY *bitarr, uint32_t offset, uint32_t numBit, uint64_t chunck);
|
||||
|
||||
@@ -641,7 +641,7 @@ int32_t L2_Mgmt_PktHandler(L2_INST *instPtr)
|
||||
DBG_INFO("Failed to start handling process...\n");
|
||||
return EALLOC;
|
||||
}
|
||||
switch (L2_GetLastFrameType(instPtr))
|
||||
switch (L2_GetLastOptFrameType(instPtr))
|
||||
{
|
||||
case L2_INTER_MGMT_FRAME:
|
||||
case L2_INTRA_MGMT_FRAME:
|
||||
|
||||
@@ -625,7 +625,7 @@ int32_t L2_Scan_PktHandler(L2_INST *instPtr)
|
||||
DBG_INFO("Failed to start handling process...\n");
|
||||
return EALLOC;
|
||||
}
|
||||
switch (L2_GetLastFrameType(instPtr))
|
||||
switch (L2_GetLastOptFrameType(instPtr))
|
||||
{
|
||||
case L2_INTER_SCAN_FRAME:
|
||||
case L2_INTRA_SCAN_FRAME:
|
||||
|
||||
@@ -224,7 +224,7 @@ int32_t RTT_FsmUpdate(L2_INST *instPtr, L2_TOR_TYPE torType)
|
||||
DBG_INFO("Preparing data for RTT REQ-2.\n");
|
||||
rttFsmPtr->isR2Valid = true;
|
||||
// Update doppler
|
||||
rttRecord->dopplerR2 = (int32_t)Phy_GetCoarseFreqEst(phyRef);
|
||||
rttRecord->dopplerR2 = (int32_t)Phy_GetFreqEst(phyRef);
|
||||
// Update Tr2
|
||||
RTT_GetFrameStart(instPtr, &(rttRecord->Tr2), torType);
|
||||
// Calculate TroundA
|
||||
@@ -292,7 +292,7 @@ int32_t RTT_FsmUpdate(L2_INST *instPtr, L2_TOR_TYPE torType)
|
||||
DBG_INFO("RTT RSP-2 have been received.\n");
|
||||
rttFsmPtr->isR4Valid = true;
|
||||
// Update doppler
|
||||
double doppler = Phy_GetCoarseFreqEst(phyRef);
|
||||
double doppler = Phy_GetFreqEst(phyRef);
|
||||
rttRecord->dopplerR2 = (int32_t)doppler;
|
||||
// Update Tr4
|
||||
RTT_GetFrameStart(instPtr, &(rttRecord->Tr4), torType);
|
||||
@@ -340,7 +340,7 @@ int32_t RTT_FsmUpdate(L2_INST *instPtr, L2_TOR_TYPE torType)
|
||||
DBG_INFO("Preparing data for RTT RSP-1.\n");
|
||||
rttFsmPtr->isR2Valid = true;
|
||||
// Update doppler
|
||||
rttRecord->dopplerR2 = (int32_t)Phy_GetCoarseFreqEst(phyRef);
|
||||
rttRecord->dopplerR2 = (int32_t)Phy_GetFreqEst(phyRef);
|
||||
// Update Tr1
|
||||
RTT_GetFrameStart(instPtr, &(rttRecord->Tr1), torType);
|
||||
}
|
||||
@@ -403,7 +403,7 @@ int32_t RTT_FsmUpdate(L2_INST *instPtr, L2_TOR_TYPE torType)
|
||||
DBG_INFO("Preparing data for RTT RSP-2.\n");
|
||||
rttFsmPtr->isR3Valid = true;
|
||||
// Update doppler
|
||||
rttRecord->dopplerR2 = (int32_t)Phy_GetCoarseFreqEst(phyRef);
|
||||
rttRecord->dopplerR2 = (int32_t)Phy_GetFreqEst(phyRef);
|
||||
// Update Tr3
|
||||
RTT_GetFrameStart(instPtr, &(rttRecord->Tr3), torType);
|
||||
// Calculate TroundB
|
||||
|
||||
@@ -51,9 +51,11 @@ int32_t L2_TimeAlign(L2_INST *instPtr, uint32_t frameNum, uint32_t slotNum, bool
|
||||
lastRecvdFrame = Phy_GetLastRecvFrameType(instPtr->config.phyInstPtr);
|
||||
if (lastRecvdFrame == L1_NONE_FRAME)
|
||||
{
|
||||
DBG_ERROR("Invalid TimeAlign operation, no frame was received.");
|
||||
return EIGNORE;
|
||||
}
|
||||
|
||||
DBG_INFO("Starting TimeAlign operation...\n");
|
||||
// read nextSendTime from physical layer
|
||||
uint64_t currTime, expctTime;
|
||||
int64_t timeDiff;
|
||||
|
||||
@@ -223,7 +223,7 @@ void MPC_IntrHandler(void *callBackRef)
|
||||
void PhysicalIntr_Handler(void *callBackRef)
|
||||
{
|
||||
Phy_UpdateState(phyInstPtr);
|
||||
if (phyInstPtr->TOR.curr == PHY_TOR_TX)
|
||||
if (phyInstPtr->tor.curr == PHY_TOR_TX)
|
||||
{
|
||||
switch (phyInstPtr->frameType.curr)
|
||||
{
|
||||
@@ -255,7 +255,7 @@ void PhysicalIntr_Handler(void *callBackRef)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (phyInstPtr->TOR.last == PHY_TOR_RX && phyInstPtr->isFrameSync)
|
||||
if (phyInstPtr->tor.last == PHY_TOR_RX && phyInstPtr->isFrameSync)
|
||||
{
|
||||
switch (phyInstPtr->frameType.last)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -32,6 +32,28 @@
|
||||
#endif
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
#define L1_FRAME_LEN_MAX (8192 / 8) // byte
|
||||
#define L1_FRAME_2KBPS_20MS_LEN 0 // byte
|
||||
#define L1_FRAME_2KBPS_100MS_LEN (312 / 8) // byte
|
||||
#define L1_FRAME_10KBPS_10MS_LEN 0 // byte
|
||||
#define L1_FRAME_10KBPS_20MS_LEN (232 / 8) // byte
|
||||
#define L1_FRAME_40KBPS_20MS_LEN (2152 / 8) // byte
|
||||
#define L1_FRAME_40KBPS_10MS_LEN (712 / 8) // byte
|
||||
#define L1_FRAME_200KBPS_5MS_LEN (2040 / 8) // byte
|
||||
#define L1_FRAME_1M2BPS_5MS_LEN (8176 / 8) // byte
|
||||
|
||||
#define L1_FRAME_2KBPS_20MS_COMP 1841158 // *10ns(Timer_L)
|
||||
#define L1_FRAME_2KBPS_100MS_COMP 1841158 // *10ns(Timer_L)
|
||||
#define L1_FRAME_10KBPS_10MS_COMP 850950 // *10ns(Timer_L)
|
||||
#define L1_FRAME_10KBPS_20MS_COMP 850950 // *10ns(Timer_L)
|
||||
#define L1_FRAME_40KBPS_20MS_COMP 111485 // *10ns(Timer_L)
|
||||
#define L1_FRAME_40KBPS_10MS_COMP 111485 // *10ns(Timer_L)
|
||||
#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 *********************/
|
||||
/************************** Function Prototypes ******************************/
|
||||
static void Phy_RcdShift(PHY_RCD *rcd, int32_t netxVal);
|
||||
@@ -40,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.
|
||||
@@ -156,12 +190,28 @@ inline L1_FRAME_TYPE Phy_GetLastRecvFrameType(PHY_INST *instPtr)
|
||||
{
|
||||
return L1_NONE_FRAME;
|
||||
}
|
||||
int32_t frame_type = (PhyRead(instPtr, PHY_MODE_CTRL) & PHY_MODE_CTRL_FRAME_MASK) >> PHY_MODE_CTRL_FRAME_SHIFT;
|
||||
if (frame_type < L1_1M2BPS_5MS_FRAME)
|
||||
return frame_type;
|
||||
else
|
||||
int32_t frame_type = (PhyRead(instPtr, COASE_FREQEST) & COASE_TYPE_MASK);
|
||||
switch (frame_type) {
|
||||
case COASE_TYPE_2KBPS_20MS:
|
||||
return L1_2KBPS_20MS_FRAME;
|
||||
case COASE_TYPE_2KBPS_100MS:
|
||||
return L1_2KBPS_100MS_FRAME;
|
||||
case COASE_TYPE_10KBPS_10MS:
|
||||
return L1_10KBPS_10MS_FRAME;
|
||||
case COASE_TYPE_10KBPS_20MS:
|
||||
return L1_10KBPS_20MS_FRAME;
|
||||
case COASE_TYPE_40KBPS_20MS:
|
||||
return L1_40KBPS_20MS_FRAME;
|
||||
case COASE_TYPE_40KBPS_10MS:
|
||||
return L1_40KBPS_10MS_FRAME;
|
||||
case COASE_TYPE_200KBPS_5MS:
|
||||
return L1_200KBPS_5MS_FRAME;
|
||||
case COASE_TYPE_1M2BPS_5MS:
|
||||
return L1_1M2BPS_5MS_FRAME;
|
||||
default:
|
||||
return L1_NONE_FRAME;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
@@ -175,7 +225,7 @@ inline L1_FRAME_TYPE Phy_GetLastRecvFrameType(PHY_INST *instPtr)
|
||||
inline L1_FRAME_TYPE Phy_GetLastSendFrameType(PHY_INST *instPtr)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
if (instPtr->TOR.last != PHY_TOR_TX)
|
||||
if (instPtr->tor.last != PHY_TOR_TX)
|
||||
{
|
||||
return L1_NONE_FRAME;
|
||||
}
|
||||
@@ -308,7 +358,7 @@ int32_t Phy_InstInit(PHY_INST **instPtr, PHY_CONFIG *phyConfig)
|
||||
(*instPtr)->sendDataOffset = 0;
|
||||
Phy_AntConfigInit(&((*instPtr)->antConfig));
|
||||
|
||||
memset(&((*instPtr))->TOR, PHY_TOR_SUSPEND, sizeof(PHY_RCD));
|
||||
memset(&((*instPtr))->tor, PHY_TOR_SUSPEND, sizeof(PHY_RCD));
|
||||
memset(&((*instPtr)->frameType), L1_NONE_FRAME, sizeof(PHY_RCD));
|
||||
memset(&((*instPtr)->antNo), (int32_t)L1_INIT_BEAM_NO, sizeof(PHY_RCD));
|
||||
memset(&((*instPtr)->beamNo), (int32_t)L1_INIT_ANT_NO, sizeof(PHY_RCD));
|
||||
@@ -539,9 +589,6 @@ int32_t Phy_SetupNextSlot(PHY_INST *instPtr, PHY_TOR_TYPE txrxMode,
|
||||
instPtr->antConfigOffset = (L1_ANTCONFIG_MAX_LEN >> 1) - instPtr->antConfigOffset;
|
||||
uint32_t antConfigAddr = instPtr->antConfigAddr + instPtr->antConfigOffset;
|
||||
|
||||
instPtr->TOR.next = txrxMode;
|
||||
instPtr->frameType.next = frameType;
|
||||
|
||||
switch (txrxMode)
|
||||
{
|
||||
case PHY_TOR_SUSPEND:
|
||||
@@ -613,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);
|
||||
|
||||
@@ -643,7 +688,7 @@ int32_t Phy_SetupNextSlot(PHY_INST *instPtr, PHY_TOR_TYPE txrxMode,
|
||||
// Indicate physical layer that all the configurations were done.
|
||||
PhyWrite(instPtr, SLOT_CMD, SLOT_CMD_KEY);
|
||||
|
||||
Phy_RcdShift(&(instPtr->TOR), txrxMode);
|
||||
Phy_RcdShift(&(instPtr->tor), txrxMode);
|
||||
Phy_RcdShift(&(instPtr->frameType), frameType);
|
||||
// TODO:
|
||||
Phy_RcdShift(&(instPtr->antNo), L1_INIT_ANT_NO);
|
||||
@@ -723,6 +768,59 @@ uint32_t Phy_GetTimeComp(L1_FRAME_TYPE frameType)
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Get frequency estimation of last valid frame.
|
||||
*
|
||||
* @param instPtr a pointer to physical instance
|
||||
*
|
||||
* @return frequency estimation
|
||||
*
|
||||
******************************************************************************/
|
||||
double Phy_GetFreqEst(PHY_INST *instPtr)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
uint32_t coarseReg, fineReg, estAbs;
|
||||
uint8_t acqFreqIdx;
|
||||
int8_t syncFreqIdx;
|
||||
L1_FRAME_TYPE frameType;
|
||||
double coarse, fine;
|
||||
|
||||
|
||||
frameType = Phy_GetLastRecvFrameType(instPtr);
|
||||
if (frameType > L1_1M2BPS_5MS_FRAME || frameType <= L1_NONE_FRAME)
|
||||
{
|
||||
return INFINITY; // FIXME
|
||||
}
|
||||
|
||||
coarseReg = PhyRead(instPtr, COASE_FREQEST);
|
||||
acqFreqIdx = (coarseReg & COASE_FREQEST_ACQ_MASK) >> COASE_FREQEST_ACQ_SHIFT;
|
||||
syncFreqIdx = (coarseReg & COASE_FREQEST_SYNC_MASK) >> COASE_FREQEST_SYNC_SHIFT;
|
||||
fineReg = PhyRead(instPtr, FINE_FREQEST);
|
||||
estAbs = fineReg & FINE_FREQEST_VAL_MASK;
|
||||
if (frameType >= L1_200KBPS_5MS_FRAME)
|
||||
{
|
||||
// 1.5M Rc
|
||||
coarse = (double)(80 - acqFreqIdx) * (31.25e3 / 4);
|
||||
coarse += (double)syncFreqIdx * 1.5e6 / 64 / 128;
|
||||
|
||||
fine = 12e6/2048*((double)estAbs)/8192.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 12M Rc
|
||||
coarse = (double)(8 - acqFreqIdx) * (250e3 / 4);
|
||||
coarse += (double)syncFreqIdx * 12e6 / 64 / 128;
|
||||
|
||||
fine = 48e6/2048*((double)estAbs)/8192.0;
|
||||
}
|
||||
|
||||
fine = ((fineReg & FINE_FREQEST_SIGN_MASK) == FINE_FREQEST_SIGN_NEG) ?
|
||||
-fine : fine;
|
||||
|
||||
return (coarse + fine);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Get coarse frequency estimation of last valid frame.
|
||||
@@ -742,7 +840,7 @@ double Phy_GetCoarseFreqEst(PHY_INST *instPtr)
|
||||
double freqEst;
|
||||
|
||||
frameType = Phy_GetLastRecvFrameType(instPtr);
|
||||
if (frameType > L1_1M2BPS_5MS_FRAME || frameType == L1_NONE_FRAME)
|
||||
if (frameType > L1_1M2BPS_5MS_FRAME || frameType <= L1_NONE_FRAME)
|
||||
{
|
||||
return INFINITY; // FIXME
|
||||
}
|
||||
@@ -776,8 +874,30 @@ double Phy_GetCoarseFreqEst(PHY_INST *instPtr)
|
||||
******************************************************************************/
|
||||
double Phy_GetFineFreqEst(PHY_INST *instPtr)
|
||||
{
|
||||
// TODO:
|
||||
return 0.0;
|
||||
uint32_t regValue, estAbs;
|
||||
double freqEst;
|
||||
L1_FRAME_TYPE frameType;
|
||||
frameType = Phy_GetLastRecvFrameType(instPtr);
|
||||
if (frameType > L1_1M2BPS_5MS_FRAME || frameType <= L1_NONE_FRAME)
|
||||
{
|
||||
return INFINITY; // FIXME
|
||||
}
|
||||
|
||||
regValue = PhyRead(instPtr, FINE_FREQEST);
|
||||
estAbs = regValue & FINE_FREQEST_VAL_MASK;
|
||||
if (frameType >= L1_200KBPS_5MS_FRAME)
|
||||
{
|
||||
// 1.5M Rc
|
||||
freqEst = 12e6/2048*((double)estAbs)/8192.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 12M Rc
|
||||
freqEst = 48e6/2048*((double)estAbs)/8192.0;
|
||||
}
|
||||
freqEst = ((regValue & FINE_FREQEST_SIGN_MASK) == FINE_FREQEST_SIGN_NEG) ?
|
||||
-freqEst : freqEst;
|
||||
return freqEst;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -817,7 +937,7 @@ int32_t Phy_SetHopPattern(void *patternBuff, uint32_t patternLen)
|
||||
int32_t Phy_SetTimeWord(PHY_INST *instPtr, const TIME_WORD *tmWord, PHY_TIME_WORD_TYPE tmType)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
if (tmWord->frac_part >= PHY_TIME_WORD_L_MAX)
|
||||
if (tmWord->frac_part >= TIME_FRAC_MAX)
|
||||
{
|
||||
return EPARAM;
|
||||
}
|
||||
|
||||
@@ -27,16 +27,24 @@
|
||||
#include "phy_reg.h"
|
||||
#include "../common.h"
|
||||
#include "../time_ctrl/time_ctrl.h"
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
/************************** Constant Definitions *****************************/
|
||||
#define L1_TMWORD_FRAC_MAX 500000
|
||||
#define L1_ANTCONFIG_MAX_LEN 8192
|
||||
#define L1_TXRXDATA_MAX_LEN 2048
|
||||
/**
|
||||
* @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_FRAME_MAX_HOPS 81
|
||||
#define L1_FRAME_2KBPS_20MS_HOPS 1
|
||||
@@ -47,34 +55,12 @@
|
||||
#define L1_FRAME_40KBPS_10MS_HOPS 9
|
||||
#define L1_FRAME_200KBPS_5MS_HOPS 20
|
||||
#define L1_FRAME_1M2BPS_5MS_HOPS 20
|
||||
|
||||
#define L1_FRAME_NONE_LEN UINT32_MAX // byte
|
||||
#define L1_FRAME_LEN_MAX (8192 / 8) // byte
|
||||
#define L1_FRAME_2KBPS_20MS_LEN 0 // byte
|
||||
#define L1_FRAME_2KBPS_100MS_LEN 312 / 8 // byte
|
||||
#define L1_FRAME_10KBPS_10MS_LEN 0 // byte
|
||||
#define L1_FRAME_10KBPS_20MS_LEN (232 / 8) // byte
|
||||
#define L1_FRAME_40KBPS_20MS_LEN (2152 / 8) // byte
|
||||
#define L1_FRAME_40KBPS_10MS_LEN (712 / 8) // byte
|
||||
#define L1_FRAME_200KBPS_5MS_LEN (2040 / 8) // byte
|
||||
#define L1_FRAME_1M2BPS_5MS_LEN (8176 / 8) // byte
|
||||
|
||||
#define L1_FRAME_NONE_COMP UINT32_MAX // *10ns(Timer_L)
|
||||
#define L1_FRAME_2KBPS_20MS_COMP 1841158 // *10ns(Timer_L)
|
||||
#define L1_FRAME_2KBPS_100MS_COMP 1841158 // *10ns(Timer_L)
|
||||
#define L1_FRAME_10KBPS_10MS_COMP 850950 // *10ns(Timer_L)
|
||||
#define L1_FRAME_10KBPS_20MS_COMP 850950 // *10ns(Timer_L)
|
||||
#define L1_FRAME_40KBPS_20MS_COMP 110667 // *10ns(Timer_L)
|
||||
#define L1_FRAME_40KBPS_10MS_COMP 110667 // *10ns(Timer_L)
|
||||
#define L1_FRAME_200KBPS_5MS_COMP 22493 // *10ns(Timer_L)
|
||||
#define L1_FRAME_1M2BPS_5MS_COMP 22493 // *10ns(Timer_L)
|
||||
|
||||
#define PHY_TIME_WORD_H_MAX UINT32_MAX
|
||||
#define PHY_TIME_WORD_L_MAX 0x0007A120 // 5ms/10ns
|
||||
|
||||
/** @} */
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
/**
|
||||
* @enum L1_FRAME_TYPE
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
L1_NONE_FRAME = 0,
|
||||
@@ -88,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,
|
||||
@@ -164,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,
|
||||
@@ -180,6 +164,9 @@ typedef enum
|
||||
PHY_TOR_RX = 2
|
||||
} PHY_TOR_TYPE;
|
||||
|
||||
/**
|
||||
* @enum PHY_MODE
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PHY_MODE_NONE = 0,
|
||||
@@ -188,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;
|
||||
@@ -197,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
|
||||
@@ -221,63 +231,49 @@ typedef struct
|
||||
PHY_RCD antNo; // antenna number record
|
||||
PHY_RCD beamNo; // beam number record
|
||||
PHY_RCD beamWd; // beam width record
|
||||
PHY_RCD TOR; // tx rx state record
|
||||
PHY_RCD tor; // tx rx state record
|
||||
PHY_RCD frameType; // frame type record
|
||||
uint32_t sendDataOffset; // antenna configuration bram offset (to implement ping-pong data flow)
|
||||
uint32_t antConfigOffset; // antenna configuration bram offset (to implement ping-pong data flow)
|
||||
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);
|
||||
uint32_t Phy_GetFrameLen(L1_FRAME_TYPE frameType);
|
||||
L1_FRAME_TYPE Phy_GetLastRecvFrameType(PHY_INST *instPtr);
|
||||
L1_FRAME_TYPE Phy_GetLastSendFrameType(PHY_INST *instPtr);
|
||||
|
||||
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);
|
||||
|
||||
double Phy_GetFreqEst(PHY_INST *instPtr);
|
||||
double Phy_GetCoarseFreqEst(PHY_INST *instPtr);
|
||||
double Phy_GetFineFreqEst(PHY_INST *instPtr);
|
||||
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_ */
|
||||
|
||||
@@ -228,15 +228,31 @@
|
||||
#define COASE_FREQEST_ACQ_MASK 0x000000FFU
|
||||
#define COASE_FREQEST_SYNC_SHIFT 8
|
||||
#define COASE_FREQEST_SYNC_WIDTH 8
|
||||
#define COASE_FREQEST_SYNC_MASK 0x000FF00U
|
||||
#define COASE_FREQEST_SYNC_MASK 0x0000FF00U
|
||||
#define COASE_TYPE_SHIFT 16
|
||||
#define COASE_TYPE_WIDTH 8
|
||||
#define COASE_TYPE_MASK 0x00FF0000U
|
||||
#define COASE_TYPE_2KBPS_20MS 0x00010000U
|
||||
#define COASE_TYPE_2KBPS_100MS 0x00020000U
|
||||
#define COASE_TYPE_10KBPS_10MS 0x00030000U
|
||||
#define COASE_TYPE_10KBPS_20MS 0x00040000U
|
||||
#define COASE_TYPE_40KBPS_20MS 0x00050000U
|
||||
#define COASE_TYPE_40KBPS_10MS 0x00060000U
|
||||
#define COASE_TYPE_200KBPS_5MS 0x00070000U
|
||||
#define COASE_TYPE_1M2BPS_5MS 0x00080000U
|
||||
|
||||
/**
|
||||
* Register: FINE_FREQEST
|
||||
*/
|
||||
#define FINE_FREQEST 0x00000040U
|
||||
#define FINE_FREQEST_SHIFT 0
|
||||
#define FINE_FREQEST_WIDTH 32
|
||||
#define FINE_FREQEST_MASK 0xFFFFFFFFU
|
||||
#define FINE_FREQEST_VAL_SHIFT 0
|
||||
#define FINE_FREQEST_VAL_WIDTH 24
|
||||
#define FINE_FREQEST_VAL_MASK 0x00FFFFFFU
|
||||
#define FINE_FREQEST_SIGN_SHIFT 24
|
||||
#define FINE_FREQEST_SIGN_WIDTH 8
|
||||
#define FINE_FREQEST_SIGN_MASK 0xFF000000U
|
||||
#define FINE_FREQEST_SIGN_POS 0x00000000U
|
||||
#define FINE_FREQEST_SIGN_NEG 0x01000000U
|
||||
|
||||
/**
|
||||
* Register: BEAM_SELECT
|
||||
|
||||
@@ -56,19 +56,19 @@ clist_new(void)
|
||||
|
||||
void clist_clear(clist_t *self)
|
||||
{
|
||||
uint32_t len = self->len;
|
||||
clist_node_t *next;
|
||||
clist_node_t *curr = self->head;
|
||||
|
||||
while (len)
|
||||
while (curr != NULL)
|
||||
{
|
||||
next = curr->next;
|
||||
if (self->free)
|
||||
self->free(curr->val);
|
||||
LIST_FREE(curr);
|
||||
curr = next;
|
||||
len--;
|
||||
}
|
||||
self->len = 0;
|
||||
self->head = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -524,16 +579,16 @@ int32_t InterComm_MsgHandler(INTER_COMM_INST* instPtr){
|
||||
else{
|
||||
tmWord.frac_part += (uint32_t)(timeTemp);
|
||||
tmWord.int_part += (uint32_t)(timeTemp>>32);
|
||||
tmWord.int_part = (tmWord.frac_part >= L1_TMWORD_FRAC_MAX) ? tmWord.int_part + 1:tmWord.int_part;
|
||||
tmWord.frac_part %= L1_TMWORD_FRAC_MAX;
|
||||
Status = Phy_SetTimeWord(instPtr->phyInstPtr, &tmWord, PHY_TIME_WORD_LISTEN_TIMEOUT);
|
||||
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(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;
|
||||
@@ -702,18 +757,18 @@ int32_t InterComm_PhyDataUpload(INTER_COMM_INST* instPtr){
|
||||
instPtr->lastPhyTimeTag = fsTimeL;
|
||||
instPtr->lastPhyTimeTag |= ((uint64_t)fsTimeH)<<32;
|
||||
uint32_t timeComp = Phy_GetTimeComp(lastFrameType);
|
||||
if(timeComp == L1_FRAME_NONE_COMP){
|
||||
if(timeComp == TIME_FRAC_MAX){
|
||||
return FAILURE;
|
||||
}
|
||||
fsTimeH -= timeComp/L1_TMWORD_FRAC_MAX;
|
||||
timeComp %= L1_TMWORD_FRAC_MAX;
|
||||
fsTimeH -= timeComp/TIME_FRAC_MAX;
|
||||
timeComp %= TIME_FRAC_MAX;
|
||||
fsTimeH = (fsTimeL < timeComp)?(fsTimeH - 1):fsTimeH;
|
||||
fsTimeL = (fsTimeL < timeComp)?(L1_TMWORD_FRAC_MAX + fsTimeL - timeComp) : (fsTimeL - timeComp);
|
||||
fsTimeL = (fsTimeL < timeComp)?(TIME_FRAC_MAX + fsTimeL - timeComp) : (fsTimeL - timeComp);
|
||||
memcpy(txMsgBuff+DSEGRD_TIME_OFFSET, &fsTimeL, DSEGRD_TIME_LEN/2);
|
||||
memcpy(txMsgBuff+DSEGRD_TIME_OFFSET + DSEGRD_TIME_LEN/2, &fsTimeH, DSEGRD_TIME_LEN/2);
|
||||
|
||||
// Doppler Estimate
|
||||
double doppler = Phy_GetCoarseFreqEst(instPtr->phyInstPtr);
|
||||
double doppler = Phy_GetFreqEst(instPtr->phyInstPtr);
|
||||
// LSB = 0.001Hz
|
||||
int64_t dopplerQnt = doppler*1000;
|
||||
memcpy(txMsgBuff+DSEGRD_DPL_OFFSET, &dopplerQnt, DSEGRD_DPL_LEN);
|
||||
|
||||
@@ -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