20240429: physical layer update.

This commit is contained in:
Gatsby Van
2024-04-29 14:20:12 +08:00
parent 247700fee2
commit ad0d589141
5 changed files with 222 additions and 256 deletions
+20 -20
View File
@@ -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 <stdint.h>
@@ -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
@@ -787,13 +787,13 @@ int32_t InterComm_PhyDataUpload(INTER_COMM_INST* instPtr){
/*****************************************************************************/
/**
* @brief Append frame CRC-16 result to frame data buffer.
*
*
* @param buffPtr
* @param dataLen
*
*
* @return SUCCESS append successfully
* Other frame cannot be recognized.
*
*
******************************************************************************/
int AppendCrc(uint8_t* buffPtr, uint32_t dataLen) {
ASSERT(buffPtr != NULL);
@@ -822,13 +822,13 @@ int AppendCrc(uint8_t* buffPtr, uint32_t dataLen) {
/**
* @brief Check the frame CRC-16, witch can infer the frame should be dump
* or not.
*
*
* @param frameBuffPtr
* @param frameType
*
*
* @return true CRC check passed, good frame.
* false CRC check failed, bad frame.
*
*
******************************************************************************/
bool CrcCheck(uint8_t* buffPtr, uint32_t dataLen){
if (dataLen == 0) {
+2 -2
View File
@@ -429,7 +429,7 @@ int32_t Intercom_C2cRecvData(void* buffPtr, int32_t buffSize){
return FAILURE;
}
}
uint32_t recvLen = IO_In32((uintptr_t)(c2cRecvDataPtr + C2C_DLEN_OFFSET)) - C2C_HEADER_LEN;
memcpy(buffPtr, c2cRecvDataPtr + C2C_PLOAD_OFFSET, recvLen);
@@ -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;
}
}