chore: merge GE program
* merge GE code * update fold structure * enable to build two types of projects separately
This commit is contained in:
@@ -27,10 +27,7 @@
|
||||
#include "common.h"
|
||||
#include "util.h"
|
||||
#include "circ_queue.h"
|
||||
#include "../time_ctrl/time_ctrl.h"
|
||||
#ifndef EMULATION
|
||||
#include "../config/app_config.h"
|
||||
#endif
|
||||
#include "time_ctrl/time_ctrl.h"
|
||||
/************************** Constant Definitions *****************************/
|
||||
#define NET_START_TIME_INFTY UINT32_MAX
|
||||
#define LINK_BROCK_THRESHOLD L2_SLOTS_PER_FRAME // 0.5 secods
|
||||
@@ -159,12 +156,18 @@ static void L2_FrameStateUpdate(L2_INST *instPtr)
|
||||
instPtr->log.cfmRecvCnt++;
|
||||
instPtr->log.cfmCorrectCnt = isValid ? instPtr->log.cfmCorrectCnt + 1 : instPtr->log.cfmCorrectCnt;
|
||||
break;
|
||||
case L2_SVC_FRAME:
|
||||
#ifndef DATALINK_ENABLE_BERTEST
|
||||
isValid = L2_CrcCheck(instPtr->recvPktData, L2_SVC_PACK_LEN, L2_CRC16_1021);
|
||||
#else
|
||||
isValid = true;
|
||||
#endif
|
||||
case L2_SVC_2K_FRAME:
|
||||
isValid = L2_CrcCheck(instPtr->recvPktData, L2_SVC_PACK_2K_LEN, L2_CRC16_1021);
|
||||
instPtr->log.svcRecvCnt++;
|
||||
instPtr->log.svcCorrectCnt = isValid ? instPtr->log.svcCorrectCnt + 1 : instPtr->log.svcCorrectCnt;
|
||||
break;
|
||||
case L2_SVC_128K_FRAME:
|
||||
isValid = L2_CrcCheck(instPtr->recvPktData, L2_SVC_PACK_128K_LEN, L2_CRC16_1021);
|
||||
instPtr->log.svcRecvCnt++;
|
||||
instPtr->log.svcCorrectCnt = isValid ? instPtr->log.svcCorrectCnt + 1 : instPtr->log.svcCorrectCnt;
|
||||
break;
|
||||
case L2_SVC_256K_FRAME:
|
||||
isValid = L2_CrcCheck(instPtr->recvPktData, L2_SVC_PACK_256K_LEN, L2_CRC16_1021);
|
||||
instPtr->log.svcRecvCnt++;
|
||||
instPtr->log.svcCorrectCnt = isValid ? instPtr->log.svcCorrectCnt + 1 : instPtr->log.svcCorrectCnt;
|
||||
break;
|
||||
@@ -333,6 +336,15 @@ inline L2_FRAME_TYPE L2_GetCurrentFrameType(L2_INST *instPtr)
|
||||
return instPtr->frame.curr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the current working speed mode.
|
||||
*/
|
||||
inline L2_SPEED_MODE L2_GetCurrentSpeedMode(L2_INST *instPtr)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
return instPtr->speedMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the tx/rx state of current slot.
|
||||
*/
|
||||
@@ -422,8 +434,12 @@ L1_FRAME_TYPE L2_L2frame2L1frame(L2_FRAME_TYPE l2Frame)
|
||||
case L2_ADV_FRAME:
|
||||
return L1_10KBPS_20MS_FRAME;
|
||||
case L2_CFM_FRAME:
|
||||
case L2_SVC_FRAME:
|
||||
case L2_SVC_2K_FRAME:
|
||||
return L1_40KBPS_20MS_FRAME;
|
||||
case L2_SVC_128K_FRAME:
|
||||
return L1_200KBPS_5MS_FRAME;
|
||||
case L2_SVC_256K_FRAME:
|
||||
return L1_1M2BPS_5MS_FRAME;
|
||||
default:
|
||||
return L1_NONE_FRAME;
|
||||
}
|
||||
@@ -471,6 +487,7 @@ int32_t Linklayer_Init(L2_INST **instPtr, const L2_CONFIG *config)
|
||||
|
||||
// Clear random content
|
||||
memset(*instPtr, 0x00, sizeof(L2_INST));
|
||||
(*instPtr)->speedMode = config->speedMode;
|
||||
(*instPtr)->sendPktData = NULL;
|
||||
(*instPtr)->recvPktData = NULL;
|
||||
(*instPtr)->schdEventPool = NULL;
|
||||
@@ -802,8 +819,25 @@ int32_t Linklayer_EventHandler(L2_INST *instPtr, const L2_EVENT *l2Event)
|
||||
else if (instPtr->nextState == L2_NORMAL_STATE)
|
||||
{
|
||||
UpdateMainSate(instPtr, L2_NORMAL_STATE);
|
||||
instPtr->rtneConfig.rtneTable = normalTable;
|
||||
instPtr->rtneConfig.rtnePrd = ARRAY_SIZE(normalTable);
|
||||
switch(L2_GetCurrentSpeedMode(instPtr)){
|
||||
case L2_SPEED_NONE :
|
||||
DBG_WARNING("Speed mode not configured, fallback to 2Kbps mode.\n");
|
||||
case L2_SPEED_2KBPS :
|
||||
instPtr->rtneConfig.rtneTable = normalTable2K;
|
||||
instPtr->rtneConfig.rtnePrd = ARRAY_SIZE(normalTable2K);
|
||||
break;
|
||||
case L2_SPEED_128KBPS :
|
||||
instPtr->rtneConfig.rtneTable = normalTable128K;
|
||||
instPtr->rtneConfig.rtnePrd = ARRAY_SIZE(normalTable128K);
|
||||
break;
|
||||
case L2_SPEED_256KBPS :
|
||||
instPtr->rtneConfig.rtneTable = normalTable256K;
|
||||
instPtr->rtneConfig.rtnePrd = ARRAY_SIZE(normalTable256K);
|
||||
break;
|
||||
default:
|
||||
DBG_ERROR("Unknown speed mode %d.\n", instPtr->speedMode);
|
||||
ASSERT(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -856,7 +890,9 @@ int32_t Linklayer_PktHandler(L2_INST *instPtr, L2_FRAME_TYPE frameType)
|
||||
case L2_CFM_FRAME:
|
||||
Status = L2_Scan_PktHandler(instPtr, instPtr->recvPktData);
|
||||
break;
|
||||
case L2_SVC_FRAME:
|
||||
case L2_SVC_2K_FRAME:
|
||||
case L2_SVC_128K_FRAME:
|
||||
case L2_SVC_256K_FRAME:
|
||||
Status = L2_Service_PktHandler(instPtr, instPtr->recvPktData);
|
||||
break;
|
||||
default:
|
||||
@@ -880,7 +916,6 @@ static int32_t IntcNodeTTL(NODE_ENTRY *node, const void *param)
|
||||
/**
|
||||
* @brief Utility function to check connection to node is still valid.
|
||||
*/
|
||||
#ifdef DATALINK_ENABLE_AUTORECONNECT
|
||||
static bool IsNodeConnected(NODE_ENTRY *node)
|
||||
{
|
||||
ASSERT(node != NULL);
|
||||
@@ -895,7 +930,6 @@ static bool IsNodeConnected(NODE_ENTRY *node)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
@@ -937,7 +971,9 @@ static int32_t Linklayer_Routine(L2_INST *instPtr)
|
||||
case L2_SLOT_CONFIRM:
|
||||
Status = L2_Scan_Routine(instPtr, &rtneEntry);
|
||||
break;
|
||||
case L2_SLOT_SERVICE:
|
||||
case L2_SLOT_SERVICE_2K:
|
||||
case L2_SLOT_SERVICE_128K:
|
||||
case L2_SLOT_SERVICE_256K:
|
||||
Status = L2_Service_Routine(instPtr, &rtneEntry);
|
||||
break;
|
||||
default:
|
||||
@@ -956,7 +992,7 @@ static int32_t Linklayer_Routine(L2_INST *instPtr)
|
||||
uint32_t increment = 1;
|
||||
L2_IterEditNode(instPtr->nodeList, &increment, IntcNodeTTL);
|
||||
|
||||
#ifdef DATALINK_ENABLE_AUTORECONNECT
|
||||
//#ifdef DATALINK_ENABLE_AUTORECONNECT
|
||||
if (L2_GetMainState(instPtr) != L2_INIT_STATE)
|
||||
{
|
||||
L2_IterDeleteNode(instPtr->nodeList, IsNodeConnected);
|
||||
@@ -970,7 +1006,7 @@ static int32_t Linklayer_Routine(L2_INST *instPtr)
|
||||
AssertL2Event(instPtr, &l2Event);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//#endif
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -1165,7 +1201,7 @@ int32_t L2_SetupNextSlot(L2_INST *instPtr, L2_TOR_TYPE txrxMode, L2_FRAME_TYPE f
|
||||
ASSERT(instPtr != NULL);
|
||||
PHY_INST *phyRef = instPtr->config.phyInstPtr;
|
||||
int32_t Status;
|
||||
if (frameType < L2_SCAN_FRAME || frameType > L2_SVC_FRAME)
|
||||
if (frameType < L2_SCAN_FRAME || frameType > L2_SVC_256K_FRAME)
|
||||
{
|
||||
return FAILURE;
|
||||
}
|
||||
@@ -1182,7 +1218,9 @@ int32_t L2_SetupNextSlot(L2_INST *instPtr, L2_TOR_TYPE txrxMode, L2_FRAME_TYPE f
|
||||
case L2_CFM_FRAME:
|
||||
instPtr->log.cfmTxCnt++;
|
||||
break;
|
||||
case L2_SVC_FRAME:
|
||||
case L2_SVC_2K_FRAME:
|
||||
case L2_SVC_128K_FRAME:
|
||||
case L2_SVC_256K_FRAME:
|
||||
instPtr->log.svcTxCnt++;
|
||||
break;
|
||||
default:
|
||||
@@ -1200,7 +1238,9 @@ int32_t L2_SetupNextSlot(L2_INST *instPtr, L2_TOR_TYPE txrxMode, L2_FRAME_TYPE f
|
||||
case L2_CFM_FRAME:
|
||||
instPtr->log.cfmRxCnt++;
|
||||
break;
|
||||
case L2_SVC_FRAME:
|
||||
case L2_SVC_2K_FRAME:
|
||||
case L2_SVC_128K_FRAME:
|
||||
case L2_SVC_256K_FRAME:
|
||||
instPtr->log.svcRxCnt++;
|
||||
break;
|
||||
default:
|
||||
@@ -1284,5 +1324,16 @@ int32_t L2_SetupNextSlot(L2_INST *instPtr, L2_TOR_TYPE txrxMode, L2_FRAME_TYPE f
|
||||
}
|
||||
return Status;
|
||||
}
|
||||
|
||||
int32_t Linklayer_UpdateSpeedMode(L2_INST *instPtr, L2_SPEED_MODE mode) {
|
||||
ASSERT(instPtr != NULL);
|
||||
if(mode < L2_SPEED_2KBPS || mode > L2_SPEED_256KBPS){
|
||||
DBG_ERROR("Unsurpport speed mode, %d.\n", mode);
|
||||
return EIGNORE;
|
||||
}
|
||||
instPtr->speedMode = mode;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/** @} LinkLayer_Main*/
|
||||
/** @} LinkLayer*/
|
||||
|
||||
Reference in New Issue
Block a user