From 65b3bf2f8ee33c650874a3bb0718c6bfb15c150f Mon Sep 17 00:00:00 2001 From: Josh Gao Date: Tue, 27 May 2025 10:41:44 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=B0=83=E6=95=B4=E8=8A=82=E7=82=B9ttl?= =?UTF-8?q?=E9=80=BB=E8=BE=91,=20=E5=90=AF=E7=94=A8=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E9=87=8D=E5=85=A5=E7=BD=91;=20=E6=A0=B9=E6=8D=AE=E7=89=A9?= =?UTF-8?q?=E7=90=86=E5=B1=82=E4=BF=AE=E6=94=B9=E6=97=B6=E9=97=B4=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/networking/link_layer/link_layer.c | 18 ++++++++---------- src/networking/link_layer/scan.c | 2 +- src/networking/phy_layer/phy_layer.c | 12 ++++++------ 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/networking/link_layer/link_layer.c b/src/networking/link_layer/link_layer.c index ef6bce1..de36915 100644 --- a/src/networking/link_layer/link_layer.c +++ b/src/networking/link_layer/link_layer.c @@ -1053,12 +1053,12 @@ static int32_t Linklayer_Routine(L2_INST *instPtr) if (L2_GetMainState(instPtr) != L2_INIT_STATE) { L2_IterDeleteNode(instPtr->nodeList, IsNodeConnected); - if (L2_GetNodeListLen(instPtr->nodeList) < instPtr->config.netScale - 1) + if (L2_GetNodeType(instPtr) == L2_NODE_MEMBER && (L2_GetNodeById(instPtr->nodeList, instPtr->myInfo.headId) == NULL)) { // reset scan process L2_EVENT l2Event; // Assert Net-Setup Done. - l2Event.event = (L2_GetNodeType(instPtr) == L2_NODE_HEAD) ? L2_EV_LOST_NODE : L2_EV_LOST_CXN; + l2Event.event = L2_EV_LOST_CXN; l2Event.msg = NULL; AssertL2Event(instPtr, &l2Event); } @@ -1323,15 +1323,13 @@ int32_t L2_SetupNextSlot(L2_INST *instPtr, L2_TOR_TYPE txrxMode, L2_FRAME_TYPE f DBG_ERROR("Physical set listening timeout failed, with error code: %" PRId32 "\n", Status); } } - else + + TIME_WORD pollTime = {0, 0}; + pollTime.int_part = TimeCtrl_GetIntCnt(instPtr->config.tmcInstPtr) + 1; + Status = Phy_SetTimeWord(phyRef, &pollTime, PHY_TIME_WORD_POLL); + if (Status != SUCCESS) { - TIME_WORD pollTime = {0, 0}; - pollTime.int_part = TimeCtrl_GetIntCnt(instPtr->config.tmcInstPtr) + 1; - Status = Phy_SetTimeWord(phyRef, &pollTime, PHY_TIME_WORD_POLL); - if (Status != SUCCESS) - { - DBG_ERROR("Physical set poll time failed, with error code: %" PRId32 "\n", Status); - } + DBG_ERROR("Physical set poll time failed, with error code: %" PRId32 "\n", Status); } PHY_TOR_TYPE tor; diff --git a/src/networking/link_layer/scan.c b/src/networking/link_layer/scan.c index 0704c41..b6e9a66 100644 --- a/src/networking/link_layer/scan.c +++ b/src/networking/link_layer/scan.c @@ -138,7 +138,7 @@ static int32_t ScanMsg_Packing(L2_INST *instPtr, L2_FRAME_TYPE type, uint8_t dst DBG_ERROR("Fail to generate CRC, error code: %" PRId32 ".\n", Status); return Status; } - message->crc = crcVal; + message->crc = (uint8_t)crcVal; // Logging... memcpy(instPtr->log.txLog.data, message, sizeof(L2_MSG_ADV)); diff --git a/src/networking/phy_layer/phy_layer.c b/src/networking/phy_layer/phy_layer.c index cdb7811..77c4f4e 100644 --- a/src/networking/phy_layer/phy_layer.c +++ b/src/networking/phy_layer/phy_layer.c @@ -42,11 +42,11 @@ #define L1_FRAME_512KBPS_4MS_LEN (2584 / 8) // byte #define L1_FRAME_2MBPS_4MS_LEN (10224 / 8) // byte -#define L1_FRAME_ADV_24MS_COMP 1841158 // FIXME: need update, *10ns(Timer_L) -#define L1_FRAME_ACK_8MS_COMP 1841158 // FIXME: need update, *10ns(Timer_L) -#define L1_FRAME_128KBPS_4MS_COMP 850950 // FIXME: need update, *10ns(Timer_L) -#define L1_FRAME_512KBPS_4MS_COMP 850950 // FIXME: need update, *10ns(Timer_L) -#define L1_FRAME_2MBPS_4MS_COMP 111485 // FIXME: need update, *10ns(Timer_L) +#define L1_FRAME_ADV_24MS_COMP 1399800 // *10ns(Timer_L) +#define L1_FRAME_ACK_8MS_COMP 598408 // *10ns(Timer_L) +#define L1_FRAME_128KBPS_4MS_COMP 9950 // *10ns(Timer_L) +#define L1_FRAME_512KBPS_4MS_COMP 9950 // *10ns(Timer_L) +#define L1_FRAME_2MBPS_4MS_COMP 9950 // *10ns(Timer_L) #define L1_ANTCONFIG_MAX_LEN 8192 #define L1_TXRXDATA_MAX_LEN 16384 @@ -747,7 +747,7 @@ int32_t Phy_SetupNextSlot(PHY_INST *instPtr, PHY_TOR_TYPE txrxMode, } // Set frame configs - PhyWrite(instPtr, PHY_MODE_CTRL, phyModeCtrl); + PhyWrite(instPtr, PHY_MODE_CTRL, phyModeCtrl | PHY_MODE_CTRL_CRC_EN); // TODO: Set antenna stand by, when suspend. const uint8_t *dataSrcPtr = (uint8_t *)(&(instPtr->antConfig));