From ad0d589141282830c01366d97dcbe54c6064df20 Mon Sep 17 00:00:00 2001 From: Gatsby Van Date: Mon, 29 Apr 2024 14:20:12 +0800 Subject: [PATCH] 20240429: physical layer update. --- datalink814_ge/src/phy_ctrl/phy_antenna.c | 186 +++++++------------ datalink814_ge/src/phy_ctrl/phy_ctrl.c | 49 +++-- datalink814_ge/src/phy_ctrl/phy_ctrl.h | 199 +++++++++++---------- datalink814_sp/src/inter_comm/inter_comm.c | 40 ++--- datalink814_sp/src/main.c | 4 +- 5 files changed, 222 insertions(+), 256 deletions(-) diff --git a/datalink814_ge/src/phy_ctrl/phy_antenna.c b/datalink814_ge/src/phy_ctrl/phy_antenna.c index dc3e475..b618f16 100644 --- a/datalink814_ge/src/phy_ctrl/phy_antenna.c +++ b/datalink814_ge/src/phy_ctrl/phy_antenna.c @@ -28,16 +28,19 @@ #define CTRL_WORD_DEFAULT 0x00 #define ANT_MODE_BEAM_MASK 0xF0 -#define ANT_MODE_NARROR_BEAM 0x00 // 8 -#define ANT_MODE_WIDE_BEAM_1 0x10 // 25 -#define ANT_MODE_WIDE_BEAM_2 0x20 // 60 -#define ANT_MODE_WIDE_BEAM_3 0x30 // 120 +#define ANT_BEAM_NARROR 0x00 // 8 +#define ANT_BEAM_SUBNARROR_0 0x10 // 25 +#define ANT_BEAM_SUBNARROR_1 0x20 // 60 +#define ANT_BEAM_WIDE 0x30 // 120 -#define ANT_MODE_HIGH_POWER 0x00 -#define ANT_MODE_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 @@ -49,21 +52,21 @@ #define CALIBRMODE_NORMAL 0x00 #define CALIBRMODE_SINGLE_TR_CAL 0x01 -#define MODECTRL_DEFAULT 0x00 +#define RF_CTRL_DEFAULT 0x00 // Pair by regex // Regex: (([0-9]+, ){8}) -uint16_t hopPattern_Config[L1_FRAME_MAX_HOPS] = +uint16_t hopPattern_Config[L1_FRAME_MAX_HOPS] = { 0 }; -uint16_t hopPattern_2KBPS_20MS[L1_FRAME_2KBPS_20MS_HOPS] = +uint16_t hopPattern_2KBPS_20MS[L1_FRAME_2KBPS_20MS_HOPS] = { 1500 }; -uint16_t hopPattern_2KBPS_100MS[L1_FRAME_2KBPS_100MS_HOPS] = +uint16_t hopPattern_2KBPS_100MS[L1_FRAME_2KBPS_100MS_HOPS] = { 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, @@ -78,104 +81,47 @@ uint16_t hopPattern_2KBPS_100MS[L1_FRAME_2KBPS_100MS_HOPS] = 2400 }; -uint16_t hopPattern_10KBPS_10MS[L1_FRAME_10KBPS_10MS_HOPS] = +uint16_t hopPattern_10KBPS_10MS[L1_FRAME_10KBPS_10MS_HOPS] = { 1500 }; -uint16_t hopPattern_10KBPS_20MS[L1_FRAME_10KBPS_20MS_HOPS] = -{ - 1500, 1600, 1700, 1800, 1900, 2000, 1500, 1600, - 1700, 1800, 1900 +uint16_t hopPattern_10KBPS_20MS[L1_FRAME_10KBPS_20MS_HOPS] = +{ + 1500, 1600, 1700, 1800, 1900, 2000, 1500, 1600, + 1700, 1800, 1900 }; -uint16_t hopPattern_40KBPS_10MS[L1_FRAME_40KBPS_10MS_HOPS] = +uint16_t hopPattern_40KBPS_10MS[L1_FRAME_40KBPS_10MS_HOPS] = { - 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, + 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400 }; -uint16_t hopPattern_40KBPS_20MS[L1_FRAME_40KBPS_20MS_HOPS] = +uint16_t hopPattern_40KBPS_20MS[L1_FRAME_40KBPS_20MS_HOPS] = { 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, - 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, + 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400 }; uint16_t hopPattern_200KBPS_5MS[L1_FRAME_200KBPS_5MS_HOPS] = -{ - 1500, 1600, 1700, 1800, 1900, 2000, 1500, 1600, - 1700, 1800, 1900, 2000, 1500, 1600, 1700, 1800, +{ + 1500, 1600, 1700, 1800, 1900, 2000, 1500, 1600, + 1700, 1800, 1900, 2000, 1500, 1600, 1700, 1800, 1900, 2000, 1500, 1500 }; -uint16_t hopPattern_1M2BPS_5MS[L1_FRAME_1M2BPS_5MS_HOPS] = +uint16_t hopPattern_1M2BPS_5MS[L1_FRAME_1M2BPS_5MS_HOPS] = { - 500 , 600 , 700 , 800 , 900 , 1000, 500 , 600 , - 700 , 800 , 900 , 1000, 500 , 600 , 700 , 800 , + 500 , 600 , 700 , 800 , 900 , 1000, 500 , 600 , + 700 , 800 , 900 , 1000, 500 , 600 , 700 , 800 , 900 , 1000, 500 , 500 }; // 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}, @@ -231,11 +177,11 @@ ANT_ANGLE antNrrwPattern[L1_NUM_ANT_NRRW_PATTERN] = { {.oaxis = 600, .raxis =2520} }; #else -PHY_ANT_ANGLE antSubnrrwPattern[L1_NUM_ANT_SUBNRRW_PATTERN] = +PHY_ANT_ANGLE antSubnrrwPattern[L1_NUM_ANT_SUBNRRW_PATTERN] = { 0 }; -PHY_ANT_ANGLE antNrrwPattern[L1_NUM_ANT_NRRW_PATTERN] = +PHY_ANT_ANGLE antNrrwPattern[L1_NUM_ANT_NRRW_PATTERN] = { 0 }; @@ -252,14 +198,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,7 +208,6 @@ 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); @@ -280,40 +219,33 @@ void Phy_AntConfigInit(PHY_ANT_CONFIG *antConfig) antConfig->antAtt = 20; // phase setting antConfig->phase = 0; + + antConfig->rxtxMode = RXTXMODE_DEFAULT; + antConfig->calibrMode = CALIBRMODE_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_CENTRTAL_FREQ); + antConfig->rfFreq[1] = (uint8_t)(DEFAULT_CENTRTAL_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->rcvMgc = 0; + antConfig->rfReserved0 = 0x00; + antConfig->rfReserved1 = 0x00; } -int32_t Phy_SetBeamNo(PHY_INST *instPtr, int32_t beamNo) +int32_t Phy_SetBeamNo(PHY_INST *instPtr, int32_t beamNo, PHY_ANT_BEAM_WIDTH beamWidth) { - if (instPtr->beamWd.next == PHY_ANT_BEAM_8) + if (beamWidth == PHY_ANT_BEAM_16) { if (beamNo >= L1_NUM_ANT_NRRW_PATTERN) { @@ -329,7 +261,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 +277,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,6 +289,10 @@ int32_t Phy_SetBeamNo(PHY_INST *instPtr, int32_t beamNo) DBG_WARNING("Using default beam number...\n"); return SUCCESS; } + else + { + return FAILURE; + } } int32_t Phy_SetBeamWidth(PHY_INST *instPtr, PHY_ANT_BEAM_WIDTH beamWidth) @@ -365,19 +301,19 @@ int32_t Phy_SetBeamWidth(PHY_INST *instPtr, PHY_ANT_BEAM_WIDTH beamWidth) switch (beamWidth) { case PHY_ANT_BEAM_120: - beamConfig |= ANT_MODE_WIDE_BEAM_3; + beamConfig |= ANT_BEAM_WIDE; break; case PHY_ANT_BEAM_60: - beamConfig |= ANT_MODE_WIDE_BEAM_2; + beamConfig |= ANT_BEAM_SUBNARROR_1; break; case PHY_ANT_BEAM_25: - beamConfig |= ANT_MODE_WIDE_BEAM_1; + beamConfig |= ANT_BEAM_SUBNARROR_0; break; - case PHY_ANT_BEAM_8: - beamConfig |= ANT_MODE_NARROR_BEAM; + 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; } diff --git a/datalink814_ge/src/phy_ctrl/phy_ctrl.c b/datalink814_ge/src/phy_ctrl/phy_ctrl.c index 204cca1..50ea6ba 100644 --- a/datalink814_ge/src/phy_ctrl/phy_ctrl.c +++ b/datalink814_ge/src/phy_ctrl/phy_ctrl.c @@ -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. @@ -590,7 +603,7 @@ int32_t Phy_SetupNextSlot(PHY_INST *instPtr, PHY_TOR_TYPE txrxMode, default: return EPARAM; } - + switch (frameType) { case L1_2KBPS_20MS_FRAME: @@ -647,20 +660,18 @@ 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); - memcpy((uint8_t *)(antConfigAddr + i * sizeof(PHY_ANT_CONFIG)), - dataSrcPtr, sizeof(PHY_ANT_CONFIG)); + 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 * ANT_CONFIG_LEN), + 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); + uint32_t antCtrl = (instPtr->antConfigOffset & ANT_CONFIG_OFFSET_MASK) + | ((hopNum << ANT_CONFIG_NUM_SHIFT) & ANT_CONFIG_NUM_MASK) + | ((ANT_CONFIG_LEN << 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) - | ((hopNum << ANT_CONFIG_NUM_SHIFT) & ANT_CONFIG_NUM_MASK) - | ((sizeof(uint16_t) << ANT_CONFIG_LEN_SHIFT) & ANT_CONFIG_LEN_MASK); - */ - PhyWrite(instPtr, ANT_CONFIG, antCtrl); if (txrxMode == PHY_TOR_TX) @@ -674,8 +685,8 @@ int32_t Phy_SetupNextSlot(PHY_INST *instPtr, PHY_TOR_TYPE txrxMode, } // Trigger physical configuration. - // Indicate physical layer that all the configurations were done. - PhyWrite(instPtr, SLOT_CMD, SLOT_CMD_KEY); + // Indicate physical layer that all the configurations were done. + PhyWrite(instPtr, SLOT_CMD, SLOT_CMD_KEY); Phy_RcdShift(&(instPtr->tor), txrxMode); Phy_RcdShift(&(instPtr->frameType), frameType); @@ -775,7 +786,7 @@ double Phy_GetFreqEst(PHY_INST *instPtr) L1_FRAME_TYPE frameType; double coarse, fine; - + frameType = Phy_GetLastRecvFrameType(instPtr); if (frameType > L1_1M2BPS_5MS_FRAME || frameType <= L1_NONE_FRAME) { @@ -804,9 +815,9 @@ double Phy_GetFreqEst(PHY_INST *instPtr) fine = 48e6/2048*((double)estAbs)/8192.0; } - fine = ((fineReg & FINE_FREQEST_SIGN_MASK) == FINE_FREQEST_SIGN_NEG) ? + fine = ((fineReg & FINE_FREQEST_SIGN_MASK) == FINE_FREQEST_SIGN_NEG) ? -fine : fine; - + return (coarse + fine); } @@ -884,7 +895,7 @@ double Phy_GetFineFreqEst(PHY_INST *instPtr) // 12M Rc freqEst = 48e6/2048*((double)estAbs)/8192.0; } - freqEst = ((regValue & FINE_FREQEST_SIGN_MASK) == FINE_FREQEST_SIGN_NEG) ? + freqEst = ((regValue & FINE_FREQEST_SIGN_MASK) == FINE_FREQEST_SIGN_NEG) ? -freqEst : freqEst; return freqEst; } diff --git a/datalink814_ge/src/phy_ctrl/phy_ctrl.h b/datalink814_ge/src/phy_ctrl/phy_ctrl.h index 1317f90..43b9138 100644 --- a/datalink814_ge/src/phy_ctrl/phy_ctrl.h +++ b/datalink814_ge/src/phy_ctrl/phy_ctrl.h @@ -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_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_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 #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 trSlect; ///< in single tr mode, 0~63 specified tr channel \n + /// in single subarray mode, 0~3 specified the subarray + /// ! Only in debug mode! + uint8_t antAtt; ///< Antenna attenuation 0~31, 0.5dB each LSB, Only in debug mode + uint8_t phase; ///< 0~63, 5.625 degree each LSB, Only in debug mode + uint8_t rxtxMode; ///< Only for debug \n + /// default 0x00 + uint8_t calibrMode; ///< 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 rcvMgc; ///< 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,21 +238,6 @@ 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); @@ -247,7 +266,7 @@ 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_SetBeamNo(PHY_INST *instPtr, int32_t beamNo, PHY_ANT_BEAM_WIDTH beamWidth); int32_t Phy_SetBeamAngle(PHY_INST *phyInstPtr, double offAx, double rndAx); int32_t Phy_SetTimeWord(PHY_INST *instPtr, const TIME_WORD *tmWord, PHY_TIME_WORD_TYPE tmType); diff --git a/datalink814_sp/src/inter_comm/inter_comm.c b/datalink814_sp/src/inter_comm/inter_comm.c index e4b918b..0254b14 100644 --- a/datalink814_sp/src/inter_comm/inter_comm.c +++ b/datalink814_sp/src/inter_comm/inter_comm.c @@ -1,18 +1,18 @@ /*****************************************************************************/ /** * Description: Inter-Communication protocol implementation. - * + * * Date: 2022-06-18 16:37 * LastEditTime: 2023-04-24 17:38 * Revisions: Rev 0.1 - * History: + * History: * [2022-06-18]: Initial version. * [2023-04-24]: Bug fix: * - Read frame type from PL status register. * * Copyright(c) 2022 Beijing Institute of Technology. * Lab of Communication and Networking - * + * ******************************************************************************/ /***************************** Include Files *********************************/ #include @@ -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