Compare commits
18
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1fc4fad5ea | ||
|
|
957672a191 | ||
|
|
807b045b75 | ||
|
|
6f4774f6b8 | ||
|
|
de5759b392 | ||
|
|
2b18765563 | ||
|
|
03a6d86a3a | ||
|
|
729bbeb60e | ||
|
|
33545b63e1 | ||
|
|
6c64421336 | ||
|
|
dda9d09f2a | ||
|
|
14f2be3053 | ||
|
|
b7607a7a1b | ||
|
|
c07cd00f2f | ||
|
|
20da80f6c2 | ||
|
|
c7e3eb2800 | ||
|
|
9acdd0609a | ||
|
|
66529637a3 |
@@ -35,6 +35,8 @@
|
||||
// 2 - print warnings and errors
|
||||
// 1 - print only errors
|
||||
// other - print nothing
|
||||
|
||||
#define APP_EMULATE_DATA
|
||||
#define DATALINK_ENABLE_AUTORECONNECT
|
||||
#define DATALINK_ENABLE_AUTOTIMESYNC
|
||||
//#define DATALINK_ENABLE_BERTEST
|
||||
|
||||
@@ -132,6 +132,47 @@ static MPC_CONFIG mpcConfig = {
|
||||
.txQueueMax = 16,
|
||||
.rxQueueMax = 16
|
||||
};
|
||||
|
||||
#ifdef APP_EMULATE_DATA
|
||||
uint8_t testDataLj[] =
|
||||
{
|
||||
0xEA, 0xDF, 0x3F, 0x27, 0xCE, 0x9B, 0xE6, 0x3F,
|
||||
0xB5, 0xA3, 0x38, 0x47, 0x1D, 0x1D, 0xFA, 0x3F,
|
||||
0x39, 0xB4, 0xC8, 0x76, 0xBE, 0xAB, 0x8E, 0x40,
|
||||
0xC9, 0xE8, 0x80, 0x24, 0xEC, 0xCB, 0x13, 0x40,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4E, 0x0B,
|
||||
0x04, 0x00, 0xB8, 0xAA, 0x08, 0x47, 0x1E, 0xC6,
|
||||
0xB0, 0x47, 0x54, 0xFD, 0xEB, 0x45, 0xA1, 0x8A,
|
||||
0x86, 0x44, 0x43, 0xB6, 0xC8, 0x44, 0x4E, 0x19,
|
||||
0xA8, 0x42
|
||||
};
|
||||
|
||||
uint8_t testDataFlj[] =
|
||||
{
|
||||
0x1E, 0x8C, 0x16, 0x12, 0x0F, 0x03, 0xC1, 0x01,
|
||||
0x00, 0x00, 0x81, 0x97, 0x39, 0x3F, 0xF1, 0xF4,
|
||||
0xC0, 0x3F, 0x27, 0xF1, 0x65, 0x44, 0x53, 0x5C,
|
||||
0xD3, 0x3F, 0xEE, 0x8D, 0x17, 0x12, 0x0F, 0x03,
|
||||
0xE8, 0x02, 0x00, 0x00, 0xFC, 0xE0, 0x44, 0x47,
|
||||
0xB7, 0x83, 0x35, 0x47, 0xA4, 0xBF, 0xE5, 0xC4,
|
||||
0xE8, 0xDC, 0xD1, 0x44, 0x5D, 0x5D, 0xE7, 0x44,
|
||||
0x7D, 0x1B, 0xE8, 0xC1, 0x60, 0x97, 0x57, 0x42,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x7E, 0xF3, 0x17, 0x12, 0x0F, 0x03, 0x22, 0x00,
|
||||
0x00, 0x00, 0x97, 0x4E, 0xB5, 0x47, 0xC4, 0x2A,
|
||||
0xB0, 0x47, 0x2D, 0x00, 0x21, 0xC5, 0x8A, 0x85,
|
||||
0xD1, 0x44, 0x23, 0xFD, 0xC8, 0x44, 0xA1, 0xC4,
|
||||
0xEA, 0xC1, 0x91, 0x4E, 0x71, 0xC2, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8E, 0x1A,
|
||||
0x18, 0x12, 0x0F, 0x03, 0x22, 0x00, 0x00, 0x00,
|
||||
0xCD, 0x07, 0xD6, 0x47, 0x1D, 0xA4, 0xCE, 0x47,
|
||||
0x6E, 0x61, 0x33, 0xC5, 0x85, 0x55, 0xD1, 0x44,
|
||||
0x9C, 0x16, 0xBD, 0x44, 0x36, 0xC0, 0xEB, 0xC1,
|
||||
0xF0, 0xFF, 0x5B, 0x42, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xCB, 0x82, 0x02, 0x00
|
||||
};
|
||||
#endif
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
static struct irq_ctrl_desc *intcDescPtr; // General interrupt controller descriptor
|
||||
static struct timer_desc *logTmPtr;
|
||||
@@ -382,6 +423,16 @@ void ScuTimer_IntrHandler(void *context)
|
||||
{
|
||||
DBG_ERROR("Failed to apply remote test.\n");
|
||||
}
|
||||
#ifdef APP_EMULATE_DATA
|
||||
if (L2_GetNodeType(linkInstPtr) == L2_NODE_HEAD)
|
||||
{
|
||||
SysMonitor_UpdateSendPayload(testDataFlj, PAYLOAD_LEN_FLJ_TX);
|
||||
}
|
||||
else
|
||||
{
|
||||
SysMonitor_UpdateSendPayload(testDataLj, PAYLOAD_LEN_LJ_TX);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
XScuTimer_ClearInterruptStatus((XScuTimer *)xdesc->instance);
|
||||
|
||||
@@ -151,13 +151,14 @@ static int32_t Mpc_GenSelfTestRsp(MPC *instPtr)
|
||||
ASSERT(instPtr != NULL);
|
||||
MPC_HW_FRAME *mpcRsp;
|
||||
uint8_t *msg;
|
||||
if (instPtr->isEnable == false)
|
||||
if (Mpc_IsEnable(instPtr) == false)
|
||||
{
|
||||
DBG_ERROR("System is not enabled!\n");
|
||||
return EIGNORE;
|
||||
}
|
||||
mpcRsp = malloc(sizeof(MPC_HW_FRAME));
|
||||
if (mpcRsp == NULL) {
|
||||
if (mpcRsp == NULL)
|
||||
{
|
||||
DBG_ERROR("Failed to allocate memory for LJ REMOTE TEST Response!\n");
|
||||
return ENOMEM;
|
||||
}
|
||||
@@ -169,13 +170,13 @@ static int32_t Mpc_GenSelfTestRsp(MPC *instPtr)
|
||||
msg[WD_CMD] = CMD_SELF_TEST;
|
||||
msg[WD_PRD] = MY_PRD_ID;
|
||||
SysMonitor_GetHardwareStatus(hwStatsPtr);
|
||||
if (linkInstPtr->isEnable == false)
|
||||
if (Mpc_IsEnable(instPtr))
|
||||
{
|
||||
msg[WD_ST_RET] = (hwStatsPtr->isSpOk) ? ST_RET_OK : ST_RET_ERROR;
|
||||
msg[WD_ST_RET] = (hwStatsPtr->isSpOk && hwStatsPtr->isAntOk) ? ST_RET_OK : ST_RET_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
msg[WD_ST_RET] = (hwStatsPtr->isSpOk && hwStatsPtr->isAntOk) ? ST_RET_OK : ST_RET_ERROR;
|
||||
msg[WD_ST_RET] = (hwStatsPtr->isSpOk) ? ST_RET_OK : ST_RET_ERROR;
|
||||
}
|
||||
// apply status and omit 2 bytes of overhead.
|
||||
memcpy(msg + WD_SP_FPGA_VOLT, &(hwStatsPtr->spFpgaVolt), ST_RET_INFO_LEN);
|
||||
@@ -201,47 +202,49 @@ static int32_t Mpc_SystemConfig(MPC *instPtr, uint8_t *msg)
|
||||
if (msg[WD_MODE_CMD] == MODE_CMD_HEAD)
|
||||
{
|
||||
// omit unnecessary reconfiguration
|
||||
if (L2_GetNodeType(linkInstPtr) != L2_NODE_HEAD)
|
||||
{
|
||||
// head node config
|
||||
linkConfig.myType = L2_NODE_HEAD;
|
||||
linkConfig.myId = 1;
|
||||
reconfig = true;
|
||||
}
|
||||
reconfig = (L2_NODE_HEAD != L2_GetNodeType(linkInstPtr));
|
||||
linkConfig.myType = L2_NODE_HEAD;
|
||||
linkConfig.myId = 2;
|
||||
}
|
||||
|
||||
else if (msg[WD_MODE_CMD] == MODE_CMD_MEMBER )
|
||||
else if (msg[WD_MODE_CMD] == MODE_CMD_MEMBER)
|
||||
{
|
||||
// omit unnecessary reconfiguration
|
||||
if (L2_GetNodeType(linkInstPtr) != L2_NODE_MEMBER)
|
||||
{
|
||||
// member node config
|
||||
linkConfig.myType = L2_NODE_MEMBER;
|
||||
linkConfig.myId = 2;
|
||||
reconfig = true;
|
||||
}
|
||||
reconfig = (L2_NODE_MEMBER != L2_GetNodeType(linkInstPtr));
|
||||
linkConfig.myType = L2_NODE_MEMBER;
|
||||
linkConfig.myId = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Ignore current command
|
||||
DBG_ERROR("Unexpected config command 0x%02X:0x%02X",
|
||||
WD_MODE_CMD, msg[WD_MODE_CMD]);
|
||||
return EPARAM;
|
||||
WD_MODE_CMD, msg[WD_MODE_CMD]);
|
||||
return EIGNORE;
|
||||
}
|
||||
|
||||
if(msg[WD_EN_CMD] == EN_CMD_ON_HIGH_POWER)
|
||||
if (msg[WD_EN_CMD] == EN_CMD_ON_HIGH_POWER)
|
||||
{
|
||||
// high power config
|
||||
Phy_AntConfigMode(phyRef, PHY_ANT_MODE_POWER_FULL);
|
||||
if (reconfig == true || !Mpc_IsEnable(instPtr))
|
||||
{
|
||||
Linklayer_Reconfig(linkInstPtr, &linkConfig);
|
||||
}
|
||||
Linklayer_Start(linkInstPtr);
|
||||
instPtr->isEnable = true;
|
||||
}
|
||||
else if(msg[WD_EN_CMD] == EN_CMD_ON_LOW_POWER)
|
||||
else if (msg[WD_EN_CMD] == EN_CMD_ON_LOW_POWER)
|
||||
{
|
||||
// low power config
|
||||
Phy_AntConfigMode(phyRef, PHY_ANT_MODE_POWER_LOW);
|
||||
if (reconfig == true || !Mpc_IsEnable(instPtr))
|
||||
{
|
||||
Linklayer_Reconfig(linkInstPtr, &linkConfig);
|
||||
}
|
||||
Linklayer_Start(linkInstPtr);
|
||||
instPtr->isEnable = true;
|
||||
}
|
||||
else if(msg[WD_EN_CMD] == EN_CMD_SILENT)
|
||||
else if (msg[WD_EN_CMD] == EN_CMD_SILENT)
|
||||
{
|
||||
// silence config
|
||||
// TODO: better approach?
|
||||
@@ -256,20 +259,18 @@ static int32_t Mpc_SystemConfig(MPC *instPtr, uint8_t *msg)
|
||||
}
|
||||
Phy_SetupNextSlot(phyRef, PHY_TOR_RX, L1_10KBPS_10MS_FRAME, NULL);
|
||||
}
|
||||
if (reconfig == true)
|
||||
else
|
||||
{
|
||||
Linklayer_Reconfig(linkInstPtr, &linkConfig);
|
||||
}
|
||||
if (instPtr->isEnable == true)
|
||||
{
|
||||
Linklayer_Start(linkInstPtr);
|
||||
// Ignore current command
|
||||
DBG_ERROR("Unexpected config command 0x%02X:0x%02X",
|
||||
WD_EN_CMD, msg[WD_EN_CMD]);
|
||||
return EIGNORE;
|
||||
}
|
||||
instPtr->mpcLog.lastConfig[0] = msg[WD_MODE_CMD];
|
||||
instPtr->mpcLog.lastConfig[1] = msg[WD_EN_CMD];
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Initialize MPC instance.
|
||||
@@ -371,13 +372,14 @@ int32_t Mpc_PendRemoteTest(MPC *instPtr)
|
||||
{
|
||||
MPC_HW_FRAME *mpcRsp;
|
||||
uint8_t *msg;
|
||||
if (instPtr->isEnable == false)
|
||||
if (!Mpc_IsEnable(instPtr))
|
||||
{
|
||||
DBG_ERROR("System is not enabled!\n");
|
||||
return EIGNORE;
|
||||
}
|
||||
mpcRsp = malloc(sizeof(MPC_HW_FRAME));
|
||||
if (mpcRsp == NULL) {
|
||||
if (mpcRsp == NULL)
|
||||
{
|
||||
DBG_ERROR("Failed to allocate memory for LJ REMOTE TEST Response!\n");
|
||||
return ENOMEM;
|
||||
}
|
||||
@@ -407,7 +409,8 @@ int32_t Mpc_PendRemoteTest(MPC *instPtr)
|
||||
memcpy(msg + WD_PHY_LOG, &(instPtr->phyLog), WD_PHY_LOG_LEN);
|
||||
memcpy(msg + WD_HARDWARE_ST, &(instPtr->hwState.spFpgaVolt), WD_HARDWARE_ST_LEN);
|
||||
|
||||
if (CircQueuePush(instPtr->txQueue, (void *)mpcRsp) == false){
|
||||
if (CircQueuePush(instPtr->txQueue, (void *)mpcRsp) == false)
|
||||
{
|
||||
free(mpcRsp);
|
||||
DBG_WARNING("SystemBus::TX Queue overflowed!\n");
|
||||
return EQUEUE;
|
||||
|
||||
@@ -697,7 +697,6 @@ int32_t spi_engine_write_and_read(struct spi_desc *desc,
|
||||
uint8_t *data,
|
||||
uint16_t bytes_number)
|
||||
{
|
||||
uint8_t i;
|
||||
uint8_t word_len;
|
||||
uint8_t words_number;
|
||||
int32_t ret;
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#endif
|
||||
/************************** Constant Definitions *****************************/
|
||||
#define NET_START_TIME_INFTY UINT32_MAX
|
||||
#define LINK_BROCK_THRESHOLD (3 * 200) // 3 secods
|
||||
#define LINK_BROCK_THRESHOLD L2_SLOTS_PER_FRAME // 0.5 secods
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
@@ -147,6 +147,15 @@ inline L2_NODE_STATE L2_GetMainState(L2_INST *instPtr)
|
||||
return instPtr->mainState;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if there is a valid l2 frame.
|
||||
*/
|
||||
inline bool L2_isStarted(L2_INST *instPtr)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
return instPtr->isEnable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if there is a valid l2 frame.
|
||||
*/
|
||||
@@ -401,7 +410,6 @@ void L2_FrameStateUpdate(L2_INST *instPtr)
|
||||
int32_t L2_SteerBeam2Node(L2_INST *instPtr, uint8_t nodeId)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
ASSERT(instPtr->config.phyInstPtr != NULL);
|
||||
int32_t Status;
|
||||
|
||||
COORD myPos, dstPos, beamDir;
|
||||
@@ -948,7 +956,7 @@ int32_t Linklayer_EventHandler(L2_INST *instPtr, const L2_EVENT *l2Event)
|
||||
case L2_EV_LOST_CXN:
|
||||
{
|
||||
DBG_INFO("Event L2_EV_LOST_CXN asserted....\n");
|
||||
if (instPtr->config.myType == L2_NODE_HEAD)
|
||||
if (L2_GetNodeType(instPtr) == L2_NODE_HEAD)
|
||||
{
|
||||
DBG_ERROR("Illegal event, only None_Head node can assert L2_EV_LOST_CXN.\n");
|
||||
break;
|
||||
@@ -1171,6 +1179,8 @@ int32_t Linklayer_Proc(L2_INST *instPtr)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
int32_t Status;
|
||||
PHY_INST *phyRef = instPtr->config.phyInstPtr;
|
||||
TMC_INST *tmcRef = instPtr->config.tmcInstPtr;
|
||||
|
||||
if (instPtr->isEnable == false)
|
||||
{
|
||||
@@ -1179,7 +1189,7 @@ int32_t Linklayer_Proc(L2_INST *instPtr)
|
||||
}
|
||||
|
||||
// FIXME: Consider time wrapping.
|
||||
uint32_t nextTimeUnit = (TimeCtrl_GetIntCnt(instPtr->config.tmcInstPtr) + 1) / L2_SLOTS_PER_FRAME;
|
||||
uint32_t nextTimeUnit = (TimeCtrl_GetIntCnt(tmcRef) + 1) / L2_SLOTS_PER_FRAME;
|
||||
if (nextTimeUnit < instPtr->netStartTime)
|
||||
{
|
||||
DBG_WARNING("Linklayer not start yet, next time unit: %" PRIu32 ", start time unit: %" PRIu32 ".\n",
|
||||
@@ -1211,19 +1221,19 @@ int32_t Linklayer_Proc(L2_INST *instPtr)
|
||||
// Run Link layer routine, setup next slot procedure.
|
||||
if (L2_GetNodeType(instPtr) == L2_NODE_HEAD)
|
||||
{
|
||||
Phy_SetMode(instPtr->config.phyInstPtr, PHY_MODE_PULL);
|
||||
Phy_SetMode(phyRef, PHY_MODE_PULL);
|
||||
Status = Linklayer_Routine(instPtr);
|
||||
}
|
||||
else
|
||||
{ // L2_NODE_MEMBER
|
||||
if (L2_isCxn2Net(instPtr))
|
||||
{
|
||||
Phy_SetMode(instPtr->config.phyInstPtr, PHY_MODE_PULL);
|
||||
Phy_SetMode(phyRef, PHY_MODE_PULL);
|
||||
Status = Linklayer_Routine(instPtr);
|
||||
}
|
||||
else
|
||||
{
|
||||
Phy_SetMode(instPtr->config.phyInstPtr, PHY_MODE_LISTEN);
|
||||
Phy_SetMode(phyRef, PHY_MODE_LISTEN);
|
||||
Status = L2_Scan_Proc(instPtr);
|
||||
}
|
||||
}
|
||||
@@ -1241,14 +1251,14 @@ int32_t Linklayer_Proc(L2_INST *instPtr)
|
||||
instPtr->mainState = instPtr->nextState;
|
||||
instPtr->linkLog.tuNum = instPtr->frameNum.curr;
|
||||
instPtr->linkLog.slotNum = (uint8_t)instPtr->slotNum.curr;
|
||||
instPtr->linkLog.nodeType = (instPtr->config.myType == L2_NODE_HEAD) ? 0xAA : 0xCC;
|
||||
instPtr->linkLog.nodeType = (L2_GetNodeType(instPtr) == L2_NODE_HEAD) ? 0xAA : 0xCC;
|
||||
instPtr->linkLog.cxnStatus = (instPtr->cxn2Net) ? 0x11 : 0x00;
|
||||
instPtr->linkLog.linkStage = (instPtr->mainState == L2_INIT_STATE) ? 0x11 : 0x22;
|
||||
instPtr->linkLog.recxnCnt = instPtr->log.reconnectCnt;
|
||||
instPtr->linkLog.beamNo = instPtr->scanFSM->beamNo;
|
||||
instPtr->linkLog.beamWidth = instPtr->log.lastBeamWidth;
|
||||
instPtr->linkLog.beamAz = instPtr->config.phyInstPtr->antNrrwPattern[instPtr->scanFSM->beamNo].oaxis;
|
||||
instPtr->linkLog.beamEl = instPtr->config.phyInstPtr->antNrrwPattern[instPtr->scanFSM->beamNo].raxis;
|
||||
instPtr->linkLog.beamAz = phyRef->antNrrwPattern[instPtr->scanFSM->beamNo].oaxis;
|
||||
instPtr->linkLog.beamEl = phyRef->antNrrwPattern[instPtr->scanFSM->beamNo].raxis;
|
||||
instPtr->linkLog.advTxCnt = (uint16_t)instPtr->log.advTxCnt;
|
||||
instPtr->linkLog.advRecvCnt = (uint16_t)instPtr->log.advRecvCnt;
|
||||
instPtr->linkLog.advCorrectCnt = (uint16_t)instPtr->log.advCorrectCnt;
|
||||
@@ -1258,10 +1268,10 @@ int32_t Linklayer_Proc(L2_INST *instPtr)
|
||||
instPtr->linkLog.svcTxCnt = instPtr->log.svcTxCnt;
|
||||
instPtr->linkLog.svcRecvCnt = instPtr->log.svcRecvCnt;
|
||||
instPtr->linkLog.svcCorrectCnt = instPtr->log.svcCorrectCnt;
|
||||
instPtr->linkLog.timeDev = (instPtr->log.timeDev > INT32_MAX)
|
||||
instPtr->linkLog.timeDev = (instPtr->log.timeDev > INT32_MAX)
|
||||
? INT32_MAX : ((instPtr->log.timeDev < INT32_MIN) ? INT32_MIN : (int32_t)instPtr->log.timeDev);
|
||||
instPtr->linkLog.sendId = instPtr->serviceFSM->txLog.dataId;
|
||||
instPtr->linkLog.recvId = instPtr->serviceFSM->rxLog.dataId;
|
||||
instPtr->linkLog.sendId = instPtr->log.txLog.dataId;
|
||||
instPtr->linkLog.recvId = instPtr->log.rxLog.dataId;
|
||||
|
||||
SysMonitor_UpdateLinklayerLog(&(instPtr->linkLog));
|
||||
return SUCCESS;
|
||||
|
||||
@@ -68,6 +68,9 @@ typedef struct
|
||||
int64_t timeDev;
|
||||
uint8_t lastBeamWidth;
|
||||
uint32_t reconnectCnt;
|
||||
|
||||
PAYLOAD rxLog;
|
||||
PAYLOAD txLog;
|
||||
} L2_LOG;
|
||||
|
||||
typedef struct
|
||||
@@ -152,6 +155,7 @@ uint8_t L2_GetClusterId(L2_INST *instPtr);
|
||||
uint8_t L2_GetHeadId(L2_INST *instPtr);
|
||||
L2_NODE_TYPE L2_GetNodeType(L2_INST *instPtr);
|
||||
L2_NODE_STATE L2_GetMainState(L2_INST *instPtr);
|
||||
bool L2_isStarted(L2_INST *instPtr);
|
||||
bool L2_isDataAvail(L2_INST *instPtr);
|
||||
bool L2_isCxn2Net(L2_INST *instPtr);
|
||||
uint32_t L2_GetFrameLen(L2_FRAME_TYPE l2FrameType);
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#define L2_FRAMENO_NONE 0
|
||||
|
||||
// Common number of slots definition
|
||||
#define L2_SLOTS_PER_FRAME 200
|
||||
#define L2_SLOTS_PER_FRAME 100
|
||||
#define L2_SLOTS_PER_SUBFRAME 20
|
||||
|
||||
#define L2_NUM_SLOTS_NONE UINT32_MAX
|
||||
@@ -207,10 +207,9 @@ typedef struct
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
PAYLOAD rxLog;
|
||||
PAYLOAD txLog;
|
||||
uint32_t pktRecv;
|
||||
uint32_t pktCorrect;
|
||||
uint32_t txCnt;
|
||||
uint32_t rxCnt;
|
||||
uint32_t rxdCnt;
|
||||
#ifdef DATALINK_ENABLE_BERTEST
|
||||
uint32_t bitTotal;
|
||||
uint32_t bitError;
|
||||
|
||||
@@ -16,452 +16,6 @@
|
||||
#include "link_layer.h"
|
||||
#include "link_layer_types.h"
|
||||
|
||||
#define LINKLAYER_INSERT_EXTRGAP
|
||||
|
||||
#ifndef LINKLAYER_INSERT_EXTRGAP
|
||||
L2_RTNE_TABLE_ENTRY intraScanSubT[L2_SLOTS_PER_FRAME] = {
|
||||
// SubFrame 0
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
|
||||
// SubFrame 1
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
|
||||
// SubFrame 2
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
|
||||
// SubFrame 3
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_ADVERTISE, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_ADVERTISE, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_ADVERTISE, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_ADVERTISE, 0x03, 0x01, 0xFF},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
// SubFrame 4
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
|
||||
// SubFrame 5
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
|
||||
// SubFrame 6
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
|
||||
// SubFrame 7
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
|
||||
// SubFrame 8
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
|
||||
// SubFrame 9
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
};
|
||||
|
||||
L2_RTNE_TABLE_ENTRY normalSub[L2_SLOTS_PER_FRAME] = {
|
||||
// SubFrame 0
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
|
||||
// SubFrame 1
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
|
||||
// SubFrame 2
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
|
||||
// SubFrame 3
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
|
||||
// SubFrame 4
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
|
||||
// SubFrame 5
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
|
||||
// SubFrame 6
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
|
||||
// SubFrame 7
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
|
||||
// SubFrame 8
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
|
||||
// SubFrame 9
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
};
|
||||
#else
|
||||
L2_RTNE_TABLE_ENTRY intraScanSubT[L2_SLOTS_PER_FRAME] = {
|
||||
// SubFrame 0
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
@@ -572,116 +126,6 @@ L2_RTNE_TABLE_ENTRY intraScanSubT[L2_SLOTS_PER_FRAME] = {
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
|
||||
// SubFrame 5
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
|
||||
// SubFrame 6
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
|
||||
// SubFrame 7
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
|
||||
// SubFrame 8
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
|
||||
// SubFrame 9
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
};
|
||||
|
||||
L2_RTNE_TABLE_ENTRY normalSub[L2_SLOTS_PER_FRAME] = {
|
||||
@@ -794,118 +238,7 @@ L2_RTNE_TABLE_ENTRY normalSub[L2_SLOTS_PER_FRAME] = {
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
|
||||
// SubFrame 5
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
|
||||
// SubFrame 6
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
|
||||
// SubFrame 7
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
|
||||
// SubFrame 8
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
|
||||
// SubFrame 9
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
};
|
||||
#endif
|
||||
|
||||
L2_RTNE_TABLE_ENTRY *initTable[L2_INIT_RTNE_PERIOD] =
|
||||
{
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
#define ADV_LISTEN_TIMEOUT 40
|
||||
#define CFM_LISTEN_TIMEOUT 25
|
||||
#define CFM_LISTEN_TIMEOUT 5
|
||||
#define ADV_FRAME_SLOTS 4
|
||||
#define CFM_FRAME_SLOTS 5
|
||||
/***************** Macros (In-line Functions) Definitions *********************/
|
||||
@@ -36,7 +36,7 @@
|
||||
/************************** Variable Definitions *****************************/
|
||||
// Pair by regex
|
||||
// Regex: ((\{\.oaxis = [0-9]+[ ,]+\.raxis = [0-9]+[ ]*\}, ){2})
|
||||
PHY_ANT_ANGLE antNrrwPattern_0[L1_NUM_ANT_NRRW_PATTERN] =
|
||||
PHY_ANT_ANGLE antNrrwPattern_0[L1_NUM_ANT_NRRW_PATTERN] =
|
||||
{
|
||||
{.oaxis = 0 , .raxis = 0 },
|
||||
{.oaxis = 139, .raxis = 2225},
|
||||
@@ -77,7 +77,7 @@ PHY_ANT_ANGLE antNrrwPattern_0[L1_NUM_ANT_NRRW_PATTERN] =
|
||||
{.oaxis = 450, .raxis = 897 }
|
||||
};
|
||||
|
||||
PHY_ANT_ANGLE antNrrwPattern_1[L1_NUM_ANT_NRRW_PATTERN] =
|
||||
PHY_ANT_ANGLE antNrrwPattern_1[L1_NUM_ANT_NRRW_PATTERN] =
|
||||
{
|
||||
{.oaxis = 0 , .raxis = 0 },
|
||||
{.oaxis = 139, .raxis = 1155},
|
||||
@@ -198,30 +198,34 @@ static int32_t Scan_InitScanHandler(L2_INST *instPtr)
|
||||
L2_SCAN_FSM *scanFsmPtr = instPtr->scanFSM;
|
||||
DBG_INFO("** Net-Setup - InitScan Procedure (Attempts: %" PRIu8 ")**\n", scanFsmPtr->scanCnt);
|
||||
|
||||
if(scanFsmPtr->scanCnt == 0)
|
||||
if (scanFsmPtr->scanCnt == 0)
|
||||
{
|
||||
// Update scan beam table
|
||||
L2_Scan_RefreashScanTable(instPtr);
|
||||
}
|
||||
else if(Phy_IsFrameDetected(phyRef))
|
||||
else if (Phy_IsFrameDetected(phyRef))
|
||||
{
|
||||
// last scan beam number
|
||||
instPtr->scanFSM->beamNo = Phy_LastScanBeamNo(instPtr->config.phyInstPtr);
|
||||
scanFsmPtr->beamNo = Phy_LastScanBeamNo(phyRef);
|
||||
// Update scan beam table
|
||||
L2_Scan_RefreashScanTable(instPtr);
|
||||
}
|
||||
|
||||
if (scanFsmPtr->isLocked == true)
|
||||
{
|
||||
StageUpdate(scanFsmPtr, L2_SCAN_ADV_STAGE);
|
||||
/* Antenna setting (reserved.) */
|
||||
scanFsmPtr->beamNo = Phy_LastScanBeamNo(phyRef);
|
||||
Phy_SetBeamNo(phyRef, scanFsmPtr->beamNo, PHY_ANT_BEAM_16);
|
||||
L2_SetupNextSlot(instPtr, L2_TOR_RX, L2_ADV_FRAME);
|
||||
StageUpdate(scanFsmPtr, L2_SCAN_ADV_STAGE);
|
||||
instPtr->log.lastBeamWidth = PHY_ANT_BEAM_16;
|
||||
} /* Otherwise remain L2_SCAN_INIT_STAGE */
|
||||
else
|
||||
{
|
||||
/* Antenna setting (reserved.) */
|
||||
/* Antenna steering (reserved, automatically accomplished by physical layer) */
|
||||
Phy_SetBeamNo(phyRef, scanFsmPtr->beamNo, PHY_ANT_BEAM_16);
|
||||
L2_SetupNextSlot(instPtr, L2_TOR_RX, L2_SCAN_FRAME);
|
||||
scanFsmPtr->scanCnt++;
|
||||
instPtr->log.lastBeamWidth = PHY_ANT_BEAM_16;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
@@ -239,19 +243,22 @@ static int32_t Scan_InitScanHandler(L2_INST *instPtr)
|
||||
******************************************************************************/
|
||||
static int32_t Scan_AdvHandler(L2_INST *instPtr)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
L2_SCAN_FSM *scanFsmPtr = instPtr->scanFSM;
|
||||
PHY_INST *phyRef = instPtr->config.phyInstPtr;
|
||||
DBG_INFO("** Net-Setup - Advertisement Procedure (Timeout: %" PRIu8 ") **\n", scanFsmPtr->advTimeout);
|
||||
|
||||
// if received a valid bm frame.
|
||||
if (scanFsmPtr->isAdvRecvd == true)
|
||||
{
|
||||
// last scan beam number
|
||||
instPtr->scanFSM->beamNo = Phy_LastScanBeamNo(instPtr->config.phyInstPtr);
|
||||
scanFsmPtr->beamNo = Phy_LastScanBeamNo(phyRef);
|
||||
// reset listen counter.
|
||||
scanFsmPtr->advTimeout = 0;
|
||||
|
||||
scanFsmPtr->advTimeout = 0; /* reset listen counter. */
|
||||
DBG_INFO("Received Adv frame, skipping 10ms for turn around...\n");
|
||||
// TODO: check functionality.
|
||||
// Update scan stage
|
||||
StageUpdate(scanFsmPtr, L2_SCAN_CFM_STAGE);
|
||||
DBG_INFO("Received Adv frame, skipping 10ms for turn around...\n");
|
||||
return SUCCESS;
|
||||
}
|
||||
// no valid bm frame was received.
|
||||
@@ -260,16 +267,20 @@ static int32_t Scan_AdvHandler(L2_INST *instPtr)
|
||||
/* if time out reached, go back to init scan stage. */
|
||||
if (scanFsmPtr->advTimeout > ADV_LISTEN_TIMEOUT)
|
||||
{
|
||||
/* Antenna setting (reserved.) */
|
||||
/* Antenna steering (reserved, automatically accomplished by physical layer) */
|
||||
Phy_SetBeamNo(phyRef, scanFsmPtr->beamNo, PHY_ANT_BEAM_16);
|
||||
L2_SetupNextSlot(instPtr, L2_TOR_RX, L2_SCAN_FRAME);
|
||||
DBG_WARNING("Adv timeout, restart net scan from L2_SCAN_INIT_STAGE.\n");
|
||||
L2_Scan_Reset(scanFsmPtr);
|
||||
instPtr->log.lastBeamWidth = PHY_ANT_BEAM_16;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Antenna setting (reserved.) */
|
||||
/* Antenna steering (reserved, automatically accomplished by physical layer) */
|
||||
Phy_SetBeamNo(phyRef, scanFsmPtr->beamNo, PHY_ANT_BEAM_16);
|
||||
L2_SetupNextSlot(instPtr, L2_TOR_RX, L2_ADV_FRAME);
|
||||
scanFsmPtr->advTimeout++;
|
||||
instPtr->log.lastBeamWidth = PHY_ANT_BEAM_16;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
@@ -286,7 +297,9 @@ static int32_t Scan_AdvHandler(L2_INST *instPtr)
|
||||
******************************************************************************/
|
||||
static int32_t Scan_CfmHandler(L2_INST *instPtr)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
L2_SCAN_FSM *scanFsmPtr = instPtr->scanFSM;
|
||||
PHY_INST *phyRef = instPtr->config.phyInstPtr;
|
||||
DBG_INFO("** Net-Setup - Confirm Procedure (Timeout: %" PRIu8 ") **\n", scanFsmPtr->cfmTimeout);
|
||||
|
||||
// 2 way acq failed, back to init stage.
|
||||
@@ -300,9 +313,9 @@ static int32_t Scan_CfmHandler(L2_INST *instPtr)
|
||||
{
|
||||
// using pull mode to receive confirm frame
|
||||
// since first time sync procedure is accomplished in ADV stage.
|
||||
Phy_SetBeamWidth(instPtr->config.phyInstPtr, PHY_ANT_BEAM_16);
|
||||
Phy_SetBeamNo(instPtr->config.phyInstPtr, scanFsmPtr->beamNo, PHY_ANT_BEAM_16);
|
||||
Phy_SetMode(instPtr->config.phyInstPtr, PHY_MODE_PULL);
|
||||
Phy_SetBeamWidth(phyRef, PHY_ANT_BEAM_16);
|
||||
Phy_SetBeamNo(phyRef, scanFsmPtr->beamNo, PHY_ANT_BEAM_16);
|
||||
Phy_SetMode(phyRef, PHY_MODE_PULL);
|
||||
L2_SetupNextSlot(instPtr, L2_TOR_RX, L2_CFM_FRAME);
|
||||
scanFsmPtr->cfmTimeout++; // increase counter.
|
||||
instPtr->log.lastBeamWidth = PHY_ANT_BEAM_16;
|
||||
@@ -327,12 +340,13 @@ static int32_t ScanMsg_Packing(L2_INST *instPtr, L2_FRAME_TYPE type, uint8_t dst
|
||||
int32_t Status;
|
||||
uint32_t dataChunk;
|
||||
uint8_t *buff = instPtr->sendPktData;
|
||||
if(type < L2_ADV_FRAME || type > L2_CFM_FRAME)
|
||||
if (type < L2_ADV_FRAME || type > L2_CFM_FRAME)
|
||||
{
|
||||
DBG_ERROR("Unexpected frame type: %" PRId8 ".\n", type);
|
||||
return EPARAM;
|
||||
}
|
||||
|
||||
// Common section of link layer package
|
||||
dataChunk = L2_GetNextFrameNum(instPtr);
|
||||
L2_FrameInsertChunk(buff, L2_MSG_FRAME_NUM, L2_MSG_FRAME_NUM_LEN, &dataChunk);
|
||||
dataChunk = L2_GetNextSlotNum(instPtr);
|
||||
@@ -382,7 +396,7 @@ static int32_t ScanMsg_Packing(L2_INST *instPtr, L2_FRAME_TYPE type, uint8_t dst
|
||||
|
||||
// Packing extra payload
|
||||
uint32_t dataId;
|
||||
if(L2_GetNodeType(instPtr) == L2_NODE_HEAD)
|
||||
if (L2_GetNodeType(instPtr) == L2_NODE_HEAD)
|
||||
{
|
||||
SysMonitor_GetSendPayload(buff + L2_MSG_CFM_PAYLOAD, &dataId, PAYLOAD_LEN_FLJ_TX);
|
||||
}
|
||||
@@ -404,6 +418,10 @@ static int32_t ScanMsg_Packing(L2_INST *instPtr, L2_FRAME_TYPE type, uint8_t dst
|
||||
DBG_ERROR("Fail to append CRC, error code: %" PRId32 ".\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
// Logging...
|
||||
memcpy(instPtr->log.txLog.data, buff, L2_CMF_PACK_LEN);
|
||||
instPtr->log.txLog.dataId = dataId;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -415,6 +433,208 @@ static int32_t ScanMsg_Packing(L2_INST *instPtr, L2_FRAME_TYPE type, uint8_t dst
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Scan net packet handler.
|
||||
*
|
||||
* @param instPtr a pointer to linklayer layer instance
|
||||
* @param msg A pointer to frame data buffer.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
******************************************************************************/
|
||||
int32_t L2_Scan_PktHandler(L2_INST *instPtr, uint8_t *msg)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
ASSERT(msg != NULL);
|
||||
int32_t Status;
|
||||
L2_SCAN_FSM *scanFsmPtr = instPtr->scanFSM;
|
||||
L2_FRAME_TYPE frameType = L2_NONE_FRAME;
|
||||
L2_FrameGetChunk(msg, L2_MSG_TYPE, L2_MSG_TYPE_LEN, &frameType);
|
||||
switch (frameType)
|
||||
{
|
||||
case L2_SCAN_FRAME:
|
||||
case L2_ADV_FRAME:
|
||||
{
|
||||
if (L2_GetLastOptFrameType(instPtr) == L2_SCAN_FRAME)
|
||||
{
|
||||
LockStateUpdate(scanFsmPtr, true);
|
||||
StageUpdate(scanFsmPtr, L2_SCAN_ADV_STAGE);
|
||||
}
|
||||
if (L2_GetNodeType(instPtr) == L2_NODE_HEAD)
|
||||
{
|
||||
DBG_ERROR("Unexpected call from head node, only member Node can handle L2_SCAN_FRAME and L2_ADV_FRAME.\n");
|
||||
Status = EUNEXP;
|
||||
break;
|
||||
}
|
||||
uint8_t nodeId;
|
||||
L2_FrameGetChunk(msg, L2_MSG_SRC_ID, L2_MSG_SRC_ID_LEN, &nodeId);
|
||||
NODE_ENTRY *node;
|
||||
node = L2_GetNodeById(instPtr->nodeList, nodeId);
|
||||
if (node == NULL)
|
||||
{
|
||||
node = L2_AppendNode(instPtr->nodeList, nodeId, L2_NODE_MEMBER);
|
||||
if (node == NULL)
|
||||
{
|
||||
DBG_ERROR("Failed to append new node [id: %" PRId8 "]", nodeId);
|
||||
Status = ENOMEM;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Update node info.
|
||||
float nodePos;
|
||||
L2_FrameGetChunk(msg, L2_MSG_ADV_SRC_POSX, L2_MSG_ADV_SRC_POSX_LEN, &nodePos);
|
||||
node->nodeInfo.pos.x = (double)nodePos;
|
||||
L2_FrameGetChunk(msg, L2_MSG_ADV_SRC_POSY, L2_MSG_ADV_SRC_POSY_LEN, &nodePos);
|
||||
node->nodeInfo.pos.y = (double)nodePos;
|
||||
L2_FrameGetChunk(msg, L2_MSG_ADV_SRC_POSZ, L2_MSG_ADV_SRC_POSZ_LEN, &nodePos);
|
||||
node->nodeInfo.pos.z = (double)nodePos;
|
||||
node->nodeInfo.beamNo = Phy_LastScanBeamNo(instPtr->config.phyInstPtr);
|
||||
|
||||
// Reset node ttl
|
||||
node->ttlCnt = 0;
|
||||
|
||||
uint32_t netstartTime;
|
||||
// Update net start time.
|
||||
L2_FrameGetChunk(msg, L2_MSG_ADV_SRC_NETSTART_TIME, L2_MSG_ADV_SRC_NETSTART_TIME_LEN, &netstartTime);
|
||||
L2_EVENT netSetupDoneEvent = {
|
||||
.event = L2_EV_NET_ADV_UPDATE,
|
||||
.msg = &netstartTime};
|
||||
AssertL2Event(instPtr, &netSetupDoneEvent);
|
||||
|
||||
// Calculate time deviation
|
||||
uint32_t frameNum, slotNum = 0;
|
||||
L2_FrameGetChunk(msg, L2_MSG_FRAME_NUM, L2_MSG_FRAME_NUM_LEN, &frameNum);
|
||||
L2_FrameGetChunk(msg, L2_MSG_SLOT_NUM, L2_MSG_SLOT_NUM_LEN, &slotNum);
|
||||
Status = L2_GetTimeDeviation(instPtr, frameNum, slotNum, true, &(instPtr->log.timeDev));
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("Failed to compute time deviation.\n")
|
||||
break;
|
||||
}
|
||||
|
||||
// Time sync.
|
||||
L2_TimeAdjust(instPtr, &(instPtr->log.timeDev));
|
||||
|
||||
// trigger flag
|
||||
AdvRecvStateUpdate(scanFsmPtr, true);
|
||||
Status = SUCCESS;
|
||||
break;
|
||||
}
|
||||
case L2_CFM_FRAME:
|
||||
{
|
||||
uint8_t nodeId;
|
||||
L2_FrameGetChunk(msg, L2_MSG_SRC_ID, L2_MSG_SRC_ID_LEN, &nodeId);
|
||||
NODE_ENTRY *node;
|
||||
node = L2_GetNodeById(instPtr->nodeList, nodeId);
|
||||
if (node == NULL)
|
||||
{
|
||||
node = L2_AppendNode(instPtr->nodeList, nodeId, L2_NODE_MEMBER);
|
||||
if (node == NULL)
|
||||
{
|
||||
DBG_ERROR("Failed to append new node [id: %" PRId8 "]", nodeId);
|
||||
Status = ENOMEM;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Update node info.
|
||||
float nodePos;
|
||||
L2_FrameGetChunk(msg, L2_MSG_CFM_SRC_POSX, L2_MSG_CFM_SRC_POSX_LEN, &nodePos);
|
||||
node->nodeInfo.pos.x = (double)nodePos;
|
||||
L2_FrameGetChunk(msg, L2_MSG_CFM_SRC_POSY, L2_MSG_CFM_SRC_POSY_LEN, &nodePos);
|
||||
node->nodeInfo.pos.y = (double)nodePos;
|
||||
L2_FrameGetChunk(msg, L2_MSG_CFM_SRC_POSZ, L2_MSG_CFM_SRC_POSZ_LEN, &nodePos);
|
||||
node->nodeInfo.pos.z = (double)nodePos;
|
||||
float nodeSpeed;
|
||||
L2_FrameGetChunk(msg, L2_MSG_CFM_SRC_SPEEDX, L2_MSG_CFM_SRC_SPEEDX_LEN, &nodeSpeed);
|
||||
node->nodeInfo.speed.x = (double)nodePos;
|
||||
L2_FrameGetChunk(msg, L2_MSG_CFM_SRC_SPEEDY, L2_MSG_CFM_SRC_SPEEDY_LEN, &nodeSpeed);
|
||||
node->nodeInfo.speed.y = (double)nodePos;
|
||||
L2_FrameGetChunk(msg, L2_MSG_CFM_SRC_SPEEDZ, L2_MSG_CFM_SRC_SPEEDZ_LEN, &nodeSpeed);
|
||||
node->nodeInfo.speed.z = (double)nodePos;
|
||||
|
||||
// Reset node ttl
|
||||
node->ttlCnt = 0;
|
||||
|
||||
// Calculate time deviation
|
||||
uint32_t frameNum, slotNum = 0;
|
||||
L2_FrameGetChunk(msg, L2_MSG_FRAME_NUM, L2_MSG_FRAME_NUM_LEN, &frameNum);
|
||||
L2_FrameGetChunk(msg, L2_MSG_SLOT_NUM, L2_MSG_SLOT_NUM_LEN, &slotNum);
|
||||
Status = L2_GetTimeDeviation(instPtr, frameNum, slotNum, true, &(instPtr->log.timeDev));
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("Failed to compute time deviation.\n")
|
||||
break;
|
||||
}
|
||||
|
||||
if (L2_GetNodeType(instPtr) != L2_NODE_HEAD)
|
||||
{
|
||||
// check if net setup finished.
|
||||
if (L2_isCxn2Net(instPtr) == false)
|
||||
{
|
||||
// Assert Net-Setup Done.
|
||||
L2_EVENT l2Event;
|
||||
l2Event.event = L2_EV_NET_SETUP_DONE;
|
||||
l2Event.msg = NULL;
|
||||
AssertL2Event(instPtr, &l2Event);
|
||||
|
||||
// Assert update routine event...
|
||||
L2_RTNE_CONFIG newRtneConfig = {0};
|
||||
L2_EVENT rtneUpEvent =
|
||||
{
|
||||
.event = L2_ROUTINE_UPDATE,
|
||||
.msg = &newRtneConfig
|
||||
};
|
||||
newRtneConfig.rtneTable = initTable;
|
||||
newRtneConfig.rtnePrd = ARRAY_SIZE(initTable);
|
||||
AssertL2Event(instPtr, &rtneUpEvent);
|
||||
}
|
||||
PendCfmAck(instPtr->scanFSM);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (L2_GetMainState(instPtr) == L2_INIT_STATE
|
||||
&& L2_GetNodeListLen(instPtr->nodeList) >= instPtr->config.netScale - 1)
|
||||
{
|
||||
// Assert Net-Setup Done.
|
||||
L2_EVENT l2Event;
|
||||
L2_NODE_STATE newState = L2_NORMAL_STATE;
|
||||
l2Event.event = L2_EV_MAIN_STATE_UPDATE;
|
||||
l2Event.msg = &newState;
|
||||
AssertL2Event(instPtr, &l2Event);
|
||||
}
|
||||
// Time sync.
|
||||
L2_TimeAdjust(instPtr, &(instPtr->log.timeDev));
|
||||
}
|
||||
|
||||
// Get data payload
|
||||
uint32_t dataId;
|
||||
L2_FrameGetChunk(msg, L2_MSG_CFM_PAYLOAD_ID, L2_MSG_CFM_PAYLOAD_ID_LEN, &dataId);
|
||||
|
||||
if (L2_GetNodeType(instPtr) == L2_NODE_HEAD)
|
||||
{
|
||||
SysMonitor_UpdateRecvPayload(msg + L2_MSG_CFM_PAYLOAD, dataId, PAYLOAD_LEN_FLJ_RX);
|
||||
}
|
||||
else
|
||||
{
|
||||
SysMonitor_UpdateRecvPayload(msg + L2_MSG_CFM_PAYLOAD, dataId, PAYLOAD_LEN_LJ_RX);
|
||||
}
|
||||
|
||||
// Logging...
|
||||
memcpy(instPtr->log.rxLog.data, msg, L2_CMF_PACK_LEN);
|
||||
instPtr->log.rxLog.dataId = dataId;
|
||||
|
||||
Status = SUCCESS;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
DBG_ERROR("Unsupported frame type: %" PRId8 ".\n", frameType);
|
||||
Status = EUNEXP;
|
||||
break;
|
||||
}
|
||||
return Status;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Initialize scan FSM.
|
||||
@@ -500,204 +720,6 @@ void L2_Scan_RefreashScanTable(L2_INST *instPtr)
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Scan net packet handler.
|
||||
*
|
||||
* @param instPtr a pointer to linklayer layer instance
|
||||
* @param msg A pointer to frame data buffer.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
******************************************************************************/
|
||||
int32_t L2_Scan_PktHandler(L2_INST *instPtr, uint8_t *msg)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
ASSERT(msg != NULL);
|
||||
int32_t Status;
|
||||
L2_SCAN_FSM *scanFsmPtr = instPtr->scanFSM;
|
||||
L2_FRAME_TYPE frameType = L2_GetLastOptFrameType(instPtr);
|
||||
switch (frameType)
|
||||
{
|
||||
case L2_SCAN_FRAME:
|
||||
LockStateUpdate(scanFsmPtr, true);
|
||||
StageUpdate(scanFsmPtr, L2_SCAN_ADV_STAGE);
|
||||
case L2_ADV_FRAME:
|
||||
{
|
||||
if (instPtr->config.myType == L2_NODE_HEAD)
|
||||
{
|
||||
DBG_ERROR("Unexpected call from head node, only member Node can handle L2_SCAN_FRAME and L2_ADV_FRAME.\n");
|
||||
Status = EUNEXP;
|
||||
break;
|
||||
}
|
||||
uint8_t nodeId;
|
||||
L2_FrameGetChunk(msg, L2_MSG_SRC_ID, L2_MSG_SRC_ID_LEN, &nodeId);
|
||||
NODE_ENTRY *node;
|
||||
node = L2_GetNodeById(instPtr->nodeList, nodeId);
|
||||
if (node == NULL)
|
||||
{
|
||||
node = L2_AppendNode(instPtr->nodeList, nodeId, L2_NODE_MEMBER);
|
||||
if(node == NULL)
|
||||
{
|
||||
DBG_ERROR("Failed to append new node [id: %" PRId8 "]", nodeId);
|
||||
Status = ENOMEM;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Update node info.
|
||||
float nodePos;
|
||||
L2_FrameGetChunk(msg, L2_MSG_ADV_SRC_POSX, L2_MSG_ADV_SRC_POSX_LEN, &nodePos);
|
||||
node->nodeInfo.pos.x = (double) nodePos;
|
||||
L2_FrameGetChunk(msg, L2_MSG_ADV_SRC_POSY, L2_MSG_ADV_SRC_POSY_LEN, &nodePos);
|
||||
node->nodeInfo.pos.y = (double) nodePos;
|
||||
L2_FrameGetChunk(msg, L2_MSG_ADV_SRC_POSZ, L2_MSG_ADV_SRC_POSZ_LEN, &nodePos);
|
||||
node->nodeInfo.pos.z = (double) nodePos;
|
||||
node->nodeInfo.beamNo = Phy_LastScanBeamNo(instPtr->config.phyInstPtr);
|
||||
|
||||
// Reset node ttl
|
||||
node->ttlCnt = 0;
|
||||
|
||||
uint32_t netstartTime;
|
||||
// Update net start time.
|
||||
L2_FrameGetChunk(msg, L2_MSG_ADV_SRC_NETSTART_TIME, L2_MSG_ADV_SRC_NETSTART_TIME_LEN, &netstartTime);
|
||||
L2_EVENT netSetupDoneEvent = {
|
||||
.event = L2_EV_NET_ADV_UPDATE,
|
||||
.msg = &netstartTime};
|
||||
AssertL2Event(instPtr, &netSetupDoneEvent);
|
||||
|
||||
// Calculate time deviation
|
||||
uint32_t frameNum, slotNum = 0;
|
||||
L2_FrameGetChunk(msg, L2_MSG_FRAME_NUM, L2_MSG_FRAME_NUM_LEN, &frameNum);
|
||||
L2_FrameGetChunk(msg, L2_MSG_SLOT_NUM, L2_MSG_SLOT_NUM_LEN, &slotNum);
|
||||
Status = L2_GetTimeDeviation(instPtr, frameNum, slotNum, true, &(instPtr->log.timeDev));
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("Failed to compute time deviation.\n")
|
||||
break;
|
||||
}
|
||||
|
||||
// Time sync.
|
||||
L2_TimeAdjust(instPtr, &(instPtr->log.timeDev));
|
||||
|
||||
// trigger flag
|
||||
AdvRecvStateUpdate(scanFsmPtr, true);
|
||||
Status = SUCCESS;
|
||||
break;
|
||||
}
|
||||
case L2_CFM_FRAME:
|
||||
{
|
||||
uint8_t nodeId;
|
||||
L2_FrameGetChunk(msg, L2_MSG_SRC_ID, L2_MSG_SRC_ID_LEN, &nodeId);
|
||||
NODE_ENTRY *node;
|
||||
node = L2_GetNodeById(instPtr->nodeList, nodeId);
|
||||
if (node == NULL)
|
||||
{
|
||||
node = L2_AppendNode(instPtr->nodeList, nodeId, L2_NODE_MEMBER);
|
||||
if(node == NULL)
|
||||
{
|
||||
DBG_ERROR("Failed to append new node [id: %" PRId8 "]", nodeId);
|
||||
Status = ENOMEM;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Update node info.
|
||||
float nodePos;
|
||||
L2_FrameGetChunk(msg, L2_MSG_CFM_SRC_POSX, L2_MSG_CFM_SRC_POSX_LEN, &nodePos);
|
||||
node->nodeInfo.pos.x = (double) nodePos;
|
||||
L2_FrameGetChunk(msg, L2_MSG_CFM_SRC_POSY, L2_MSG_CFM_SRC_POSY_LEN, &nodePos);
|
||||
node->nodeInfo.pos.y = (double) nodePos;
|
||||
L2_FrameGetChunk(msg, L2_MSG_CFM_SRC_POSZ, L2_MSG_CFM_SRC_POSZ_LEN, &nodePos);
|
||||
node->nodeInfo.pos.z = (double) nodePos;
|
||||
float nodeSpeed;
|
||||
L2_FrameGetChunk(msg, L2_MSG_CFM_SRC_SPEEDX, L2_MSG_CFM_SRC_SPEEDX_LEN, &nodeSpeed);
|
||||
node->nodeInfo.speed.x = (double) nodePos;
|
||||
L2_FrameGetChunk(msg, L2_MSG_CFM_SRC_SPEEDY, L2_MSG_CFM_SRC_SPEEDY_LEN, &nodeSpeed);
|
||||
node->nodeInfo.speed.y = (double) nodePos;
|
||||
L2_FrameGetChunk(msg, L2_MSG_CFM_SRC_SPEEDZ, L2_MSG_CFM_SRC_SPEEDZ_LEN, &nodeSpeed);
|
||||
node->nodeInfo.speed.z = (double) nodePos;
|
||||
|
||||
// Reset node ttl
|
||||
node->ttlCnt = 0;
|
||||
|
||||
// Calculate time deviation
|
||||
uint32_t frameNum, slotNum = 0;
|
||||
L2_FrameGetChunk(msg, L2_MSG_FRAME_NUM, L2_MSG_FRAME_NUM_LEN, &frameNum);
|
||||
L2_FrameGetChunk(msg, L2_MSG_SLOT_NUM, L2_MSG_SLOT_NUM_LEN, &slotNum);
|
||||
Status = L2_GetTimeDeviation(instPtr, frameNum, slotNum, true, &(instPtr->log.timeDev));
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("Failed to compute time deviation.\n")
|
||||
break;
|
||||
}
|
||||
|
||||
if (L2_GetNodeType(instPtr) != L2_NODE_HEAD)
|
||||
{
|
||||
// check if net setup finished.
|
||||
if (L2_isCxn2Net(instPtr) == false)
|
||||
{
|
||||
// Assert Net-Setup Done.
|
||||
L2_EVENT l2Event;
|
||||
l2Event.event = L2_EV_NET_SETUP_DONE;
|
||||
l2Event.msg = NULL;
|
||||
AssertL2Event(instPtr, &l2Event);
|
||||
|
||||
// Assert update routine event...
|
||||
L2_RTNE_CONFIG newRtneConfig = {0};
|
||||
L2_EVENT rtneUpEvent =
|
||||
{
|
||||
.event = L2_ROUTINE_UPDATE,
|
||||
.msg = &newRtneConfig
|
||||
};
|
||||
newRtneConfig.rtneTable = initTable;
|
||||
newRtneConfig.rtnePrd = ARRAY_SIZE(initTable);
|
||||
AssertL2Event(instPtr, &rtneUpEvent);
|
||||
}
|
||||
PendCfmAck(instPtr->scanFSM);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (L2_GetMainState(instPtr) == L2_INIT_STATE
|
||||
&& L2_GetNodeListLen(instPtr->nodeList) >= instPtr->config.netScale - 1)
|
||||
{
|
||||
// Assert Net-Setup Done.
|
||||
L2_EVENT l2Event;
|
||||
L2_NODE_STATE newState = L2_NORMAL_STATE;
|
||||
l2Event.event = L2_EV_MAIN_STATE_UPDATE;
|
||||
l2Event.msg = &newState;
|
||||
AssertL2Event(instPtr, &l2Event);
|
||||
}
|
||||
// Time sync.
|
||||
L2_TimeAdjust(instPtr, &(instPtr->log.timeDev));
|
||||
}
|
||||
|
||||
// Get data payload
|
||||
uint32_t dataId;
|
||||
L2_FrameGetChunk(msg, L2_MSG_CFM_PAYLOAD_ID, L2_MSG_CFM_PAYLOAD_ID_LEN, &dataId);
|
||||
|
||||
if(dataId != DATA_ID_NONE)
|
||||
{
|
||||
if(L2_GetNodeType(instPtr) == L2_NODE_HEAD)
|
||||
{
|
||||
SysMonitor_UpdateRecvPayload(msg+L2_MSG_CFM_PAYLOAD, PAYLOAD_LEN_FLJ_RX);
|
||||
}
|
||||
else
|
||||
{
|
||||
SysMonitor_UpdateRecvPayload(msg+L2_MSG_CFM_PAYLOAD, PAYLOAD_LEN_LJ_RX);
|
||||
}
|
||||
}
|
||||
|
||||
Status = SUCCESS;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
DBG_ERROR("Unsupported frame type: %" PRId8 ".\n", frameType);
|
||||
Status = EUNEXP;
|
||||
break;
|
||||
}
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Execute a member node scan net procedure.
|
||||
@@ -756,7 +778,8 @@ int32_t L2_Scan_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *rtneEntry)
|
||||
ASSERT(instPtr != NULL);
|
||||
L2_TOR_TYPE torState;
|
||||
int32_t Status;
|
||||
const NODE_ENTRY* commNode;
|
||||
const NODE_ENTRY *commNode;
|
||||
PHY_INST *phyRef = instPtr->config.phyInstPtr;
|
||||
DBG_INFO("-------- Scan Routine --------\n");
|
||||
|
||||
if (rtneEntry->slotSeq != 0)
|
||||
@@ -782,11 +805,11 @@ int32_t L2_Scan_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *rtneEntry)
|
||||
}
|
||||
|
||||
// Setup antenna beam
|
||||
Phy_SetBeamWidth(instPtr->config.phyInstPtr, PHY_ANT_BEAM_16);
|
||||
Phy_SetBeamWidth(phyRef, PHY_ANT_BEAM_16);
|
||||
instPtr->log.lastBeamWidth = PHY_ANT_BEAM_16;
|
||||
if (commNode != NULL)
|
||||
{
|
||||
Phy_SetBeamNo(instPtr->config.phyInstPtr, commNode->nodeInfo.beamNo, PHY_ANT_BEAM_16);
|
||||
Phy_SetBeamNo(phyRef, commNode->nodeInfo.beamNo, PHY_ANT_BEAM_16);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -804,7 +827,7 @@ int32_t L2_Scan_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *rtneEntry)
|
||||
torState = L2_TOR_SUSPEND;
|
||||
}
|
||||
// Setup antenna beam
|
||||
Phy_SetBeamWidth(instPtr->config.phyInstPtr, PHY_ANT_BEAM_120);
|
||||
Phy_SetBeamWidth(phyRef, PHY_ANT_BEAM_120);
|
||||
instPtr->log.lastBeamWidth = PHY_ANT_BEAM_120;
|
||||
}
|
||||
|
||||
|
||||
@@ -88,6 +88,7 @@ static int32_t Service_Packing(L2_INST *instPtr, L2_FRAME_TYPE type, uint8_t dst
|
||||
uint32_t dataChunk;
|
||||
uint8_t *buff = instPtr->sendPktData;
|
||||
|
||||
// Common section of link layer package
|
||||
dataChunk = L2_GetNextFrameNum(instPtr);
|
||||
L2_FrameInsertChunk(buff, L2_MSG_FRAME_NUM, L2_MSG_FRAME_NUM_LEN, &dataChunk);
|
||||
dataChunk = L2_GetNextSlotNum(instPtr);
|
||||
@@ -113,7 +114,7 @@ static int32_t Service_Packing(L2_INST *instPtr, L2_FRAME_TYPE type, uint8_t dst
|
||||
L2_FrameInsertChunk(buff, L2_MSG_SVC_SRC_SPEEDZ, L2_MSG_SVC_SRC_SPEEDZ_LEN, &(instPtr->sysInfo.vZ));
|
||||
|
||||
uint32_t dataId;
|
||||
if(L2_GetNodeType(instPtr) == L2_NODE_HEAD)
|
||||
if (L2_GetNodeType(instPtr) == L2_NODE_HEAD)
|
||||
{
|
||||
SysMonitor_GetSendPayload(buff + L2_MSG_SVC_PAYLOAD, &dataId, PAYLOAD_LEN_FLJ_TX);
|
||||
}
|
||||
@@ -128,12 +129,6 @@ static int32_t Service_Packing(L2_INST *instPtr, L2_FRAME_TYPE type, uint8_t dst
|
||||
L2_FrameInsertChunk(buff, L2_MSG_SVC_PAYLOAD, L2_MSG_SVC_PAYLOAD_LEN, testData);
|
||||
}
|
||||
|
||||
// // packing payload
|
||||
// uint32_t dataId;
|
||||
// dataId = DATA_ID_TEST;
|
||||
// L2_FrameInsertChunk(buff, L2_MSG_SVC_PAYLOAD_ID, L2_MSG_SVC_PAYLOAD_ID_LEN, &dataId);
|
||||
// L2_FrameInsertChunk(buff, L2_MSG_SVC_PAYLOAD, L2_MSG_SVC_PAYLOAD_LEN, testData);
|
||||
|
||||
Status = L2_CrcAppend(buff, L2_SVC_PACK_LEN - L2_MSG_SVC_CRC_LEN, L2_MSG_SVC_CRC, L2_CRC16_1021);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
@@ -141,8 +136,8 @@ static int32_t Service_Packing(L2_INST *instPtr, L2_FRAME_TYPE type, uint8_t dst
|
||||
return Status;
|
||||
}
|
||||
|
||||
memcpy(instPtr->serviceFSM->txLog.data, buff, L2_SVC_PACK_LEN);
|
||||
instPtr->serviceFSM->txLog.dataId = dataId;
|
||||
memcpy(instPtr->log.txLog.data, buff, L2_SVC_PACK_LEN);
|
||||
instPtr->log.txLog.dataId = dataId;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -159,62 +154,6 @@ static int32_t Service_Packing(L2_INST *instPtr, L2_FRAME_TYPE type, uint8_t dst
|
||||
#endif
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Initialize service net FSM
|
||||
*
|
||||
* @param serviceFSM A pointer to service FSM instance.
|
||||
*
|
||||
* @return SUCCESS Initialize successfully.
|
||||
* Other Initialize failed.
|
||||
*
|
||||
******************************************************************************/
|
||||
int32_t L2_Service_Init(L2_SVC_FSM **svcFSMPtr)
|
||||
{
|
||||
ASSERT(svcFSMPtr != NULL);
|
||||
*svcFSMPtr = (L2_SVC_FSM *)malloc(sizeof(L2_SVC_FSM));
|
||||
if (*svcFSMPtr == NULL)
|
||||
{
|
||||
return ENOMEM;
|
||||
}
|
||||
L2_Service_Reset(*svcFSMPtr);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Reset ServiceNet FSM
|
||||
*
|
||||
* @param scanFsmPtr a pointer to service net finite state machine
|
||||
*
|
||||
* @return NONE
|
||||
*
|
||||
******************************************************************************/
|
||||
void L2_Service_Reset(L2_SVC_FSM *svcFSMPtr)
|
||||
{
|
||||
ASSERT(svcFSMPtr != NULL);
|
||||
memset((&svcFSMPtr->rxLog), 0x00, sizeof(PAYLOAD));
|
||||
memset((&svcFSMPtr->txLog), 0x00, sizeof(PAYLOAD));
|
||||
#ifdef DATALINK_ENABLE_BERTEST
|
||||
svcFSMPtr->bitTotal = 0;
|
||||
svcFSMPtr->bitError = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Destroy ServiceNet FSM, free memory
|
||||
*
|
||||
* @param scanFsmPtr a pointer to service net finite state machine
|
||||
*
|
||||
* @return NONE
|
||||
*
|
||||
******************************************************************************/
|
||||
void L2_Service_Destroy(L2_SVC_FSM *serviceFSM)
|
||||
{
|
||||
free(serviceFSM);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Handle service received packet. Send data up to MPC
|
||||
@@ -231,7 +170,7 @@ int32_t L2_Service_PktHandler(L2_INST *instPtr, uint8_t *msg)
|
||||
ASSERT(msg != NULL);
|
||||
int32_t Status;
|
||||
#ifndef DATALINK_ENABLE_BERTEST
|
||||
uint8_t frameType;
|
||||
L2_FRAME_TYPE frameType = L2_NONE_FRAME;
|
||||
L2_FrameGetChunk(msg, L2_MSG_TYPE, L2_MSG_TYPE_LEN, &frameType);
|
||||
switch (frameType)
|
||||
{
|
||||
@@ -244,7 +183,7 @@ int32_t L2_Service_PktHandler(L2_INST *instPtr, uint8_t *msg)
|
||||
if (node == NULL)
|
||||
{
|
||||
node = L2_AppendNode(instPtr->nodeList, nodeId, L2_NODE_MEMBER);
|
||||
if(node == NULL)
|
||||
if (node == NULL)
|
||||
{
|
||||
DBG_ERROR("Failed to append new node [id: %" PRIu8 "]", nodeId);
|
||||
Status = ENOMEM;
|
||||
@@ -255,18 +194,18 @@ int32_t L2_Service_PktHandler(L2_INST *instPtr, uint8_t *msg)
|
||||
// Update node info.
|
||||
float nodePos;
|
||||
L2_FrameGetChunk(msg, L2_MSG_SVC_SRC_POSX, L2_MSG_SVC_SRC_POSX_LEN, &nodePos);
|
||||
node->nodeInfo.pos.x = (double) nodePos;
|
||||
node->nodeInfo.pos.x = (double)nodePos;
|
||||
L2_FrameGetChunk(msg, L2_MSG_SVC_SRC_POSY, L2_MSG_SVC_SRC_POSY_LEN, &nodePos);
|
||||
node->nodeInfo.pos.y = (double) nodePos;
|
||||
node->nodeInfo.pos.y = (double)nodePos;
|
||||
L2_FrameGetChunk(msg, L2_MSG_SVC_SRC_POSZ, L2_MSG_SVC_SRC_POSZ_LEN, &nodePos);
|
||||
node->nodeInfo.pos.z = (double) nodePos;
|
||||
node->nodeInfo.pos.z = (double)nodePos;
|
||||
float nodeSpeed;
|
||||
L2_FrameGetChunk(msg, L2_MSG_SVC_SRC_SPEEDX, L2_MSG_SVC_SRC_SPEEDX_LEN, &nodeSpeed);
|
||||
node->nodeInfo.speed.x = (double) nodePos;
|
||||
node->nodeInfo.speed.x = (double)nodePos;
|
||||
L2_FrameGetChunk(msg, L2_MSG_SVC_SRC_SPEEDY, L2_MSG_SVC_SRC_SPEEDY_LEN, &nodeSpeed);
|
||||
node->nodeInfo.speed.y = (double) nodePos;
|
||||
node->nodeInfo.speed.y = (double)nodePos;
|
||||
L2_FrameGetChunk(msg, L2_MSG_SVC_SRC_SPEEDZ, L2_MSG_SVC_SRC_SPEEDZ_LEN, &nodeSpeed);
|
||||
node->nodeInfo.speed.z = (double) nodePos;
|
||||
node->nodeInfo.speed.z = (double)nodePos;
|
||||
|
||||
// Reset node ttl
|
||||
node->ttlCnt = 0;
|
||||
@@ -285,21 +224,19 @@ int32_t L2_Service_PktHandler(L2_INST *instPtr, uint8_t *msg)
|
||||
uint32_t dataId;
|
||||
L2_FrameGetChunk(msg, L2_MSG_SVC_PAYLOAD_ID, L2_MSG_SVC_PAYLOAD_ID_LEN, &dataId);
|
||||
|
||||
if(dataId != DATA_ID_NONE)
|
||||
if (L2_GetNodeType(instPtr) == L2_NODE_HEAD)
|
||||
{
|
||||
if(L2_GetNodeType(instPtr) == L2_NODE_HEAD)
|
||||
{
|
||||
SysMonitor_UpdateRecvPayload(msg+L2_MSG_SVC_PAYLOAD, PAYLOAD_LEN_FLJ_RX);
|
||||
}
|
||||
else
|
||||
{
|
||||
SysMonitor_UpdateRecvPayload(msg+L2_MSG_SVC_PAYLOAD, PAYLOAD_LEN_LJ_RX);
|
||||
}
|
||||
SysMonitor_UpdateRecvPayload(msg + L2_MSG_SVC_PAYLOAD, dataId, PAYLOAD_LEN_FLJ_RX);
|
||||
}
|
||||
else
|
||||
{
|
||||
SysMonitor_UpdateRecvPayload(msg + L2_MSG_SVC_PAYLOAD, dataId, PAYLOAD_LEN_LJ_RX);
|
||||
}
|
||||
|
||||
// Logging
|
||||
memcpy(instPtr->serviceFSM->rxLog.data, msg, L2_SVC_PACK_LEN);
|
||||
instPtr->serviceFSM->rxLog.dataId = dataId;
|
||||
memcpy(instPtr->log.rxLog.data, msg, L2_SVC_PACK_LEN);
|
||||
instPtr->log.rxLog.dataId = dataId;
|
||||
instPtr->serviceFSM->rxdCnt++;
|
||||
|
||||
#ifdef DATALINK_ENABLE_AUTOTIMESYNC
|
||||
// Implement a auto time sync.
|
||||
@@ -346,6 +283,65 @@ int32_t L2_Service_PktHandler(L2_INST *instPtr, uint8_t *msg)
|
||||
#endif
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Initialize service net FSM
|
||||
*
|
||||
* @param serviceFSM A pointer to service FSM instance.
|
||||
*
|
||||
* @return SUCCESS Initialize successfully.
|
||||
* Other Initialize failed.
|
||||
*
|
||||
******************************************************************************/
|
||||
int32_t L2_Service_Init(L2_SVC_FSM **svcFSMPtr)
|
||||
{
|
||||
ASSERT(svcFSMPtr != NULL);
|
||||
*svcFSMPtr = (L2_SVC_FSM *)malloc(sizeof(L2_SVC_FSM));
|
||||
if (*svcFSMPtr == NULL)
|
||||
{
|
||||
return ENOMEM;
|
||||
}
|
||||
L2_Service_Reset(*svcFSMPtr);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Reset ServiceNet FSM
|
||||
*
|
||||
* @param scanFsmPtr a pointer to service net finite state machine
|
||||
*
|
||||
* @return NONE
|
||||
*
|
||||
******************************************************************************/
|
||||
void L2_Service_Reset(L2_SVC_FSM *svcFSMPtr)
|
||||
{
|
||||
ASSERT(svcFSMPtr != NULL);
|
||||
svcFSMPtr->txCnt = 0;
|
||||
svcFSMPtr->rxCnt = 0;
|
||||
svcFSMPtr->rxdCnt = 0;
|
||||
#ifdef DATALINK_ENABLE_BERTEST
|
||||
svcFSMPtr->bitTotal = 0;
|
||||
svcFSMPtr->bitError = 0;
|
||||
svcFSMPtr->lossRate = 0;
|
||||
svcFSMPtr->errorRate = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Destroy ServiceNet FSM, free memory
|
||||
*
|
||||
* @param scanFsmPtr a pointer to service net finite state machine
|
||||
*
|
||||
* @return NONE
|
||||
*
|
||||
******************************************************************************/
|
||||
void L2_Service_Destroy(L2_SVC_FSM *serviceFSM)
|
||||
{
|
||||
free(serviceFSM);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Service FSM Routine.
|
||||
@@ -366,9 +362,10 @@ int32_t L2_Service_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *rtneEntr
|
||||
return SUCCESS; // skip
|
||||
}
|
||||
|
||||
PHY_INST* phyRef = instPtr->config.phyInstPtr;
|
||||
PHY_INST *phyRef = instPtr->config.phyInstPtr;
|
||||
L2_SVC_FSM *svcFSMPtr = instPtr->serviceFSM;
|
||||
L2_TOR_TYPE torState;
|
||||
const NODE_ENTRY* commNode;
|
||||
const NODE_ENTRY *commNode;
|
||||
if (rtneEntry->src == L2_GetNodeId(instPtr))
|
||||
{
|
||||
torState = L2_TOR_TX;
|
||||
@@ -402,6 +399,7 @@ int32_t L2_Service_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *rtneEntr
|
||||
case L2_SLOT_SERVICE:
|
||||
if (torState == L2_TOR_TX)
|
||||
{
|
||||
svcFSMPtr->txCnt++;
|
||||
#ifndef DATALINK_ENABLE_BERTEST
|
||||
// Packing service data
|
||||
Service_Packing(instPtr, L2_SVC_FRAME, rtneEntry->dst);
|
||||
@@ -409,6 +407,10 @@ int32_t L2_Service_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *rtneEntr
|
||||
memcpy(instPtr->sendPktData, testData, L2_SVC_PACK_LEN);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
svcFSMPtr->rxCnt++;
|
||||
}
|
||||
L2_SetupNextSlot(instPtr, torState, L2_SVC_FRAME);
|
||||
break;
|
||||
default:
|
||||
@@ -417,11 +419,11 @@ int32_t L2_Service_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *rtneEntr
|
||||
}
|
||||
#ifdef DATALINK_ENABLE_BERTEST
|
||||
uint32_t pktLoss;
|
||||
pktLoss = instPtr->log.svcRecvCnt - instPtr->log.svcCorrectCnt;
|
||||
instPtr->serviceFSM->lossRate = (instPtr->log.svcRecvCnt == 0) ? 0 : (double)pktLoss / (double)instPtr->serviceFSM->pktRecv;
|
||||
instPtr->serviceFSM->errorRate = (instPtr->serviceFSM->bitTotal == 0) ? 0 : (double)instPtr->serviceFSM->bitError / (double)instPtr->serviceFSM->bitTotal;
|
||||
DBG_PRINT("Packet Loss Rate -- Total: %lu, Loss: %lu.\n", instPtr->serviceFSM->pktRecv, pktLoss);
|
||||
DBG_PRINT("Bit Error Rate -- Total:%lu, Error:%lu.\n", instPtr->serviceFSM->bitTotal, instPtr->serviceFSM->bitError);
|
||||
pktLoss = svcFSMPtr->rxCnt - svcFSMPtr->rxdCnt;
|
||||
svcFSMPtr->lossRate = (svcFSMPtr->rxCnt == 0) ? 0 : (double)pktLoss / (double)svcFSMPtr->rxCnt;
|
||||
svcFSMPtr->errorRate = (svcFSMPtr->bitTotal == 0) ? 0 : (double)svcFSMPtr->bitError / (double)svcFSMPtr->bitTotal;
|
||||
DBG_PRINT("Packet Loss Rate -- Total: %lu, Loss: %lu.\n", instPtr->log.svcRxCnt, pktLoss);
|
||||
DBG_PRINT("Bit Error Rate -- Total:%lu, Error:%lu.\n", svcFSMPtr->bitTotal, svcFSMPtr->bitError);
|
||||
#endif
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,8 @@ int32_t L2_GetTimeDeviation(L2_INST *instPtr, uint32_t frameNum, uint32_t slotNu
|
||||
ASSERT(instPtr != NULL);
|
||||
ASSERT(timeDev != NULL);
|
||||
L1_FRAME_TYPE lastRecvdFrame;
|
||||
lastRecvdFrame = Phy_GetLastRecvFrameType(instPtr->config.phyInstPtr);
|
||||
PHY_INST *phyRef = instPtr->config.phyInstPtr;
|
||||
lastRecvdFrame = Phy_GetLastRecvFrameType(phyRef);
|
||||
if (lastRecvdFrame == L1_NONE_FRAME)
|
||||
{
|
||||
DBG_ERROR("Invalid TimeAlign operation, no frame was received.");
|
||||
@@ -68,7 +69,7 @@ int32_t L2_GetTimeDeviation(L2_INST *instPtr, uint32_t frameNum, uint32_t slotNu
|
||||
expectTime += (uint64_t)instPtr->netStartTime * L2_SLOTS_PER_FRAME * TIME_FRAC_MAX;
|
||||
}
|
||||
|
||||
Phy_GetLastReceivedFrameSyncTimeStamp(instPtr->config.phyInstPtr, &timeStamp);
|
||||
Phy_GetLastReceivedFrameSyncTimeStamp(phyRef, &timeStamp);
|
||||
currTime = (uint64_t)timeStamp.frac_part;
|
||||
currTime += ((uint64_t)timeStamp.int_part) * TIME_FRAC_MAX;
|
||||
|
||||
@@ -76,7 +77,6 @@ int32_t L2_GetTimeDeviation(L2_INST *instPtr, uint32_t frameNum, uint32_t slotNu
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Implement time adjustment by applying time deviation.
|
||||
|
||||
@@ -224,6 +224,8 @@ void Phy_AntConfigMode(PHY_INST *instPtr, PHY_ANT_MODE mode)
|
||||
}
|
||||
instPtr->phyLog.antMode = mode;
|
||||
instPtr->antConfig.antMode = config;
|
||||
// Sync logs to system monitor
|
||||
SysMonitor_UpdatePhysicalLayerLog(&(instPtr->phyLog));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
@@ -59,6 +59,16 @@
|
||||
|
||||
#define ANT_COINFO_LEN 32 // bytes
|
||||
|
||||
#define ATTN_DEFAULT 0
|
||||
#define ATTN_2KBPS_100MS ATTN_DEFAULT
|
||||
#define ATTN_2KBPS_20MS ATTN_DEFAULT
|
||||
#define ATTN_10KBPS_10MS 31
|
||||
#define ATTN_10KBPS_20MS 31
|
||||
#define ATTN_40KBPS_10MS 21
|
||||
#define ATTN_40KBPS_20MS 21
|
||||
#define ATTN_200KBPS_5MS ATTN_DEFAULT
|
||||
#define ATTN_1M2BPS_5MS ATTN_DEFAULT
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
/************************** Function Prototypes ******************************/
|
||||
static void Phy_RcdShift(PHY_RCD *rcd, int32_t netxVal);
|
||||
@@ -493,7 +503,7 @@ int32_t Phy_InstInit(PHY_INST **instPtr, PHY_CONFIG *phyConfig)
|
||||
}
|
||||
else
|
||||
{
|
||||
(*instPtr)->antInfoAddr = NULL;
|
||||
(*instPtr)->antInfoAddr = (uintptr_t)NULL;
|
||||
}
|
||||
|
||||
/* Initialize the XAdc driver. */
|
||||
@@ -696,41 +706,49 @@ int32_t Phy_SetupNextSlot(PHY_INST *instPtr, PHY_TOR_TYPE txrxMode,
|
||||
phyModeCtrl |= PHY_MODE_CTRL_FRAME_2KBPS_20MS;
|
||||
hopNum = L1_FRAME_2KBPS_20MS_HOPS;
|
||||
hopPattern = hopPattern_2KBPS_20MS;
|
||||
instPtr->antConfig.rfTxMgc = ATTN_2KBPS_20MS;
|
||||
break;
|
||||
case L1_2KBPS_100MS_FRAME:
|
||||
phyModeCtrl |= PHY_MODE_CTRL_FRAME_2KBPS_100MS;
|
||||
hopNum = L1_FRAME_2KBPS_100MS_HOPS;
|
||||
hopPattern = hopPattern_2KBPS_100MS;
|
||||
instPtr->antConfig.rfTxMgc = ATTN_2KBPS_100MS;
|
||||
break;
|
||||
case L1_10KBPS_10MS_FRAME:
|
||||
phyModeCtrl |= PHY_MODE_CTRL_FRAME_10KBPS_10MS;
|
||||
hopNum = L1_FRAME_10KBPS_20MS_HOPS;
|
||||
hopPattern = hopPattern_10KBPS_20MS;
|
||||
instPtr->antConfig.rfTxMgc = ATTN_10KBPS_10MS;
|
||||
break;
|
||||
case L1_10KBPS_20MS_FRAME:
|
||||
phyModeCtrl |= PHY_MODE_CTRL_FRAME_10KBPS_20MS;
|
||||
hopNum = L1_FRAME_10KBPS_20MS_HOPS;
|
||||
hopPattern = hopPattern_10KBPS_20MS;
|
||||
instPtr->antConfig.rfTxMgc = ATTN_10KBPS_20MS;
|
||||
break;
|
||||
case L1_40KBPS_20MS_FRAME:
|
||||
phyModeCtrl |= PHY_MODE_CTRL_FRAME_40KBPS_20MS;
|
||||
hopNum = L1_FRAME_40KBPS_20MS_HOPS;
|
||||
hopPattern = hopPattern_40KBPS_20MS;
|
||||
instPtr->antConfig.rfTxMgc = ATTN_40KBPS_20MS;
|
||||
break;
|
||||
case L1_40KBPS_10MS_FRAME:
|
||||
phyModeCtrl |= PHY_MODE_CTRL_FRAME_40KBPS_10MS;
|
||||
hopNum = L1_FRAME_40KBPS_10MS_HOPS;
|
||||
hopPattern = hopPattern_40KBPS_10MS;
|
||||
instPtr->antConfig.rfTxMgc = ATTN_40KBPS_10MS;
|
||||
break;
|
||||
case L1_200KBPS_5MS_FRAME:
|
||||
phyModeCtrl |= PHY_MODE_CTRL_FRAME_200KBPS_5MS;
|
||||
hopNum = L1_FRAME_200KBPS_5MS_HOPS;
|
||||
hopPattern = hopPattern_200KBPS_5MS;
|
||||
instPtr->antConfig.rfTxMgc = ATTN_200KBPS_5MS;
|
||||
break;
|
||||
case L1_1M2BPS_5MS_FRAME:
|
||||
phyModeCtrl |= PHY_MODE_CTRL_FRAME_1M2BPS_5MS;
|
||||
hopNum = L1_FRAME_1M2BPS_5MS_HOPS;
|
||||
hopPattern = hopPattern_1M2BPS_5MS;
|
||||
instPtr->antConfig.rfTxMgc = ATTN_1M2BPS_5MS;
|
||||
break;
|
||||
default:
|
||||
return EPARAM;
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
/***************************** Include Files *********************************/
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "common.h"
|
||||
#include "system_monitor.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
#define BUFF_A 0x00
|
||||
#define BUFF_B 0x01
|
||||
#define BUFF_NONE 0xFF
|
||||
@@ -14,6 +15,7 @@
|
||||
#define PRTCLLOG_PACK_ELN 24 // bytes
|
||||
#define HWSTATE_PACK_ELN 12 // bytes
|
||||
|
||||
/************************** Data Type Definitions ****************************/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t latest;
|
||||
@@ -37,12 +39,14 @@ typedef struct
|
||||
HWSTATE hwState[2];
|
||||
} SYSMONITOR;
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
static uint8_t GetWritable(PINGPONG ctrllor);
|
||||
static uint8_t GetReadable(PINGPONG ctrllor);
|
||||
/************************** Variable Definitions *****************************/
|
||||
static SYSMONITOR *sysMonitorInst;
|
||||
|
||||
uint8_t GetWritable(PINGPONG ctrllor);
|
||||
uint8_t GetReadable(PINGPONG ctrllor);
|
||||
|
||||
inline uint8_t GetWritable(PINGPONG ctrllor)
|
||||
/*********************** Function Implementations ***************************/
|
||||
inline static uint8_t GetWritable(PINGPONG ctrllor)
|
||||
{
|
||||
// Allow only one write.
|
||||
ASSERT(ctrllor.wBusy == BUFF_NONE);
|
||||
@@ -52,7 +56,7 @@ inline uint8_t GetWritable(PINGPONG ctrllor)
|
||||
return ((ctrllor.rBusy == BUFF_B) ? BUFF_A : BUFF_B);
|
||||
}
|
||||
|
||||
inline uint8_t GetReadable(PINGPONG ctrllor)
|
||||
inline static uint8_t GetReadable(PINGPONG ctrllor)
|
||||
{
|
||||
if (ctrllor.wBusy == BUFF_NONE || ctrllor.wBusy != ctrllor.latest)
|
||||
return ((ctrllor.latest == BUFF_NONE) ? BUFF_A : BUFF_B);
|
||||
@@ -126,6 +130,10 @@ void SysMonitor_GetSysinfo(SYSINFO *info)
|
||||
void SysMonitor_UpdateSendPayload(const uint8_t *buff, size_t len)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
if (len > PAYLOAD_LEN_MAX)
|
||||
{
|
||||
return;
|
||||
}
|
||||
uint8_t buffIndx;
|
||||
buffIndx = GetWritable(sysMonitorInst->sendCtrl);
|
||||
sysMonitorInst->sendCtrl.wBusy = buffIndx;
|
||||
@@ -141,6 +149,12 @@ void SysMonitor_UpdateSendPayload(const uint8_t *buff, size_t len)
|
||||
void SysMonitor_GetSendPayload(uint8_t *buff, uint32_t *id, size_t len)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
ASSERT(buff != NULL);
|
||||
ASSERT(id != NULL);
|
||||
if (len > PAYLOAD_LEN_MAX)
|
||||
{
|
||||
return;
|
||||
}
|
||||
uint8_t buffIndx, buffIndex_old;
|
||||
buffIndex_old = sysMonitorInst->sendCtrl.rBusy;
|
||||
if (buffIndex_old != BUFF_NONE)
|
||||
@@ -160,14 +174,19 @@ void SysMonitor_GetSendPayload(uint8_t *buff, uint32_t *id, size_t len)
|
||||
/**
|
||||
* Update receive payload.
|
||||
*/
|
||||
void SysMonitor_UpdateRecvPayload(const uint8_t *buff, size_t len)
|
||||
void SysMonitor_UpdateRecvPayload(const uint8_t *buff, uint32_t id, size_t len)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
ASSERT(buff != NULL);
|
||||
if (id == DATA_ID_NONE || len > PAYLOAD_LEN_MAX)
|
||||
{
|
||||
return;
|
||||
}
|
||||
uint8_t buffIndx;
|
||||
buffIndx = GetWritable(sysMonitorInst->recvCtrl);
|
||||
sysMonitorInst->recvCtrl.wBusy = buffIndx;
|
||||
memcpy(sysMonitorInst->recv[buffIndx].data, buff, len);
|
||||
sysMonitorInst->recv[buffIndx].dataId++;
|
||||
sysMonitorInst->recv[buffIndx].dataId = id;
|
||||
sysMonitorInst->recvCtrl.latest = buffIndx;
|
||||
sysMonitorInst->recvCtrl.wBusy = BUFF_NONE;
|
||||
}
|
||||
@@ -178,6 +197,12 @@ void SysMonitor_UpdateRecvPayload(const uint8_t *buff, size_t len)
|
||||
void SysMonitor_GetRecvPayload(uint8_t *buff, uint32_t *id, size_t len)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
ASSERT(buff != NULL);
|
||||
ASSERT(id != NULL);
|
||||
if(len > PAYLOAD_LEN_MAX)
|
||||
{
|
||||
return;
|
||||
}
|
||||
uint8_t buffIndx, buffIndex_old;
|
||||
buffIndex_old = sysMonitorInst->recvCtrl.rBusy;
|
||||
if (buffIndex_old != BUFF_NONE)
|
||||
@@ -200,6 +225,7 @@ void SysMonitor_GetRecvPayload(uint8_t *buff, uint32_t *id, size_t len)
|
||||
void SysMonitor_UpdateLinklayerLog(const LINKLOG *log)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
ASSERT(log != NULL);
|
||||
uint8_t buffIndx;
|
||||
buffIndx = GetWritable(sysMonitorInst->linkLogCtrl);
|
||||
sysMonitorInst->linkLogCtrl.wBusy = buffIndx;
|
||||
@@ -214,6 +240,7 @@ void SysMonitor_UpdateLinklayerLog(const LINKLOG *log)
|
||||
void SysMonitor_GetLinklayerLog(LINKLOG *log)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
ASSERT(log != NULL);
|
||||
uint8_t buffIndx, buffIndex_old;
|
||||
buffIndex_old = sysMonitorInst->linkLogCtrl.rBusy;
|
||||
if (buffIndex_old != BUFF_NONE)
|
||||
@@ -232,6 +259,7 @@ void SysMonitor_GetLinklayerLog(LINKLOG *log)
|
||||
void SysMonitor_UpdatePhysicalLayerLog(const PHYLOG *log)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
ASSERT(log != NULL);
|
||||
uint8_t buffIndx;
|
||||
buffIndx = GetWritable(sysMonitorInst->phyLogCtrl);
|
||||
sysMonitorInst->phyLogCtrl.wBusy = buffIndx;
|
||||
@@ -246,6 +274,7 @@ void SysMonitor_UpdatePhysicalLayerLog(const PHYLOG *log)
|
||||
void SysMonitor_GetPhysicalLayerLog(PHYLOG *log)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
ASSERT(log != NULL);
|
||||
uint8_t buffIndx, buffIndex_old;
|
||||
buffIndex_old = sysMonitorInst->phyLogCtrl.rBusy;
|
||||
if (buffIndex_old != BUFF_NONE)
|
||||
@@ -257,7 +286,6 @@ void SysMonitor_GetPhysicalLayerLog(PHYLOG *log)
|
||||
sysMonitorInst->phyLogCtrl.rBusy = buffIndex_old;
|
||||
}
|
||||
|
||||
|
||||
// @Hardware state
|
||||
/**
|
||||
* Log hardware running status.
|
||||
@@ -265,6 +293,7 @@ void SysMonitor_GetPhysicalLayerLog(PHYLOG *log)
|
||||
void SysMonitor_UpdateHardwareStatus(const HWSTATE *state)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
ASSERT(state != NULL);
|
||||
uint8_t buffIndx;
|
||||
buffIndx = GetWritable(sysMonitorInst->hwStateCtrl);
|
||||
sysMonitorInst->hwStateCtrl.wBusy = buffIndx;
|
||||
@@ -279,6 +308,7 @@ void SysMonitor_UpdateHardwareStatus(const HWSTATE *state)
|
||||
void SysMonitor_GetHardwareStatus(HWSTATE *state)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
ASSERT(state != NULL);
|
||||
uint8_t buffIndx, buffIndex_old;
|
||||
buffIndex_old = sysMonitorInst->hwStateCtrl.rBusy;
|
||||
if (buffIndex_old != BUFF_NONE)
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
#ifndef __SYSTEM_MONITOR_H_
|
||||
#define __SYSTEM_MONITOR_H_
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "util.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
#define PAYLOAD_LEN_MAX 256
|
||||
#define PAYLOAD_LEN_FLJ_RX 168
|
||||
#define PAYLOAD_LEN_FLJ_TX 66
|
||||
@@ -36,12 +38,19 @@
|
||||
#define VOLT_ANT_NIL_OK BIT(4)
|
||||
#define ANT_STATE_OK BIT(6)
|
||||
|
||||
// Xilinx Recommended
|
||||
// #define IS_PS_VALID(x) (x <= 1.05 && x >= 0.95)
|
||||
// #define IS_PSAUX_VALID(x) (x <= 1.89 && x >= 1.71)
|
||||
// #define IS_DDR_VALID(x) (x <= 1.89 && x >= 1.14)
|
||||
// #define IS_PL_VALID(x) (x <= 1.03 && x >= 0.97)
|
||||
// #define IS_PLAUX_VALID(x) (x <= 1.89 && x >= 1.71)
|
||||
// #define IS_BRAM_VALID(x) (x <= 1.03 && x >= 0.97)
|
||||
#define IS_PS_VALID(x) (x <= 1.05 && x >= 0.95)
|
||||
#define IS_PSAUX_VALID(x) (x <= 1.89 && x >= 1.71)
|
||||
#define IS_DDR_VALID(x) (x <= 1.89 && x >= 1.14)
|
||||
#define IS_PL_VALID(x) (x <= 1.03 && x >= 0.97)
|
||||
#define IS_PL_VALID(x) (x <= 1.03 && x >= 0.96)
|
||||
#define IS_PLAUX_VALID(x) (x <= 1.89 && x >= 1.71)
|
||||
#define IS_BRAM_VALID(x) (x <= 1.03 && x >= 0.97)
|
||||
#define IS_BRAM_VALID(x) (x <= 1.03 && x >= 0.96)
|
||||
|
||||
#define CLK_SP_PLL0_LOCK BIT(0)
|
||||
#define CLK_SP_PLL1_LOCK BIT(2)
|
||||
@@ -59,6 +68,9 @@
|
||||
#define TEMPERATURE_MAX 127.0 // Celsius degree
|
||||
#define TEMPERATURE_MIN -128.0 // Celsius degree
|
||||
|
||||
/************************** Data Type Definitions ****************************/
|
||||
/** @name System Info
|
||||
*/
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
// -- unit: ms, 0~604799999
|
||||
@@ -98,6 +110,8 @@ typedef struct __attribute__((packed))
|
||||
float roll;
|
||||
} SYSINFO;
|
||||
|
||||
/** @name System Bus Log
|
||||
*/
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
// SystemBus log
|
||||
@@ -110,6 +124,8 @@ typedef struct __attribute__((packed))
|
||||
uint32_t remoteCnt;
|
||||
} SYSBUSLOG;
|
||||
|
||||
/** @name Linklayer Log
|
||||
*/
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
// Network log
|
||||
@@ -138,6 +154,8 @@ typedef struct __attribute__((packed))
|
||||
uint8_t reserve[4];
|
||||
} LINKLOG;
|
||||
|
||||
/** @name Physical layer Log
|
||||
*/
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
uint32_t acqCnt;
|
||||
@@ -156,6 +174,8 @@ typedef struct __attribute__((packed))
|
||||
uint8_t reserve[3];
|
||||
} PHYLOG;
|
||||
|
||||
/** @name Hardware Status Log
|
||||
*/
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
// Hardware status
|
||||
@@ -177,12 +197,15 @@ typedef struct __attribute__((packed))
|
||||
uint8_t reserve[2];
|
||||
} HWSTATE;
|
||||
|
||||
/** @name Payload
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t dataId;
|
||||
uint8_t data[PAYLOAD_LEN_MAX];
|
||||
} PAYLOAD;
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
int32_t SysMonitor_Init(void);
|
||||
void SysMonitor_Destroy(void);
|
||||
|
||||
@@ -190,7 +213,7 @@ void SysMonitor_UpdateSysinfo(const SYSINFO *info);
|
||||
void SysMonitor_GetSysinfo(SYSINFO *info);
|
||||
|
||||
void SysMonitor_UpdateSendPayload(const uint8_t *buff, size_t len);
|
||||
void SysMonitor_UpdateRecvPayload(const uint8_t *buff, size_t len);
|
||||
void SysMonitor_UpdateRecvPayload(const uint8_t *buff, uint32_t id, size_t len);
|
||||
void SysMonitor_GetSendPayload(uint8_t *buff, uint32_t *id, size_t len);
|
||||
void SysMonitor_GetRecvPayload(uint8_t *buff, uint32_t *id, size_t len);
|
||||
|
||||
|
||||
@@ -190,7 +190,6 @@
|
||||
|
||||
#define LJ_RM_TEST_RESP_LEN 158
|
||||
|
||||
|
||||
// My Production Type
|
||||
#define MY_PRD_ID PRD_DL_K
|
||||
|
||||
@@ -238,7 +237,8 @@ static int32_t SystemBus_GenSelfTestRsp(SYSBUS *instPtr)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
SYSBUS_UART_FRAME *sysbusRsp = malloc(sizeof(SYSBUS_UART_FRAME));
|
||||
if (sysbusRsp == NULL) {
|
||||
if (sysbusRsp == NULL)
|
||||
{
|
||||
DBG_ERROR("Failed to allocate memory for SELF TEST Response!\n");
|
||||
return ENOMEM;
|
||||
}
|
||||
@@ -248,13 +248,13 @@ static int32_t SystemBus_GenSelfTestRsp(SYSBUS *instPtr)
|
||||
sysbusRsp->data[WD_CMD] = CMD_SELF_TEST;
|
||||
sysbusRsp->data[WD_PRD] = MY_PRD_ID;
|
||||
SysMonitor_GetHardwareStatus(hwStatsPtr);
|
||||
if (linkInstPtr->isEnable == false)
|
||||
if (L2_isStarted(linkInstPtr))
|
||||
{
|
||||
sysbusRsp->data[WD_ST_RET] = (hwStatsPtr->isSpOk) ? ST_RET_OK : ST_RET_ERROR;
|
||||
sysbusRsp->data[WD_ST_RET] = (hwStatsPtr->isSpOk && hwStatsPtr->isAntOk) ? ST_RET_OK : ST_RET_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
sysbusRsp->data[WD_ST_RET] = (hwStatsPtr->isSpOk && hwStatsPtr->isAntOk) ? ST_RET_OK : ST_RET_ERROR;
|
||||
sysbusRsp->data[WD_ST_RET] = (hwStatsPtr->isSpOk) ? ST_RET_OK : ST_RET_ERROR;
|
||||
}
|
||||
// apply status and omit 2 bytes of overhead.
|
||||
memcpy(sysbusRsp->data + WD_SP_FPGA_VOLT, &(hwStatsPtr->spFpgaVolt), ST_RET_INFO_LEN);
|
||||
@@ -278,56 +278,54 @@ static int32_t SystemBus_SystemConfig(SYSBUS *instPtr, uint8_t *msg)
|
||||
PHY_INST *phyRef = linkInstPtr->config.phyInstPtr;
|
||||
TMC_INST *tmcRef = linkInstPtr->config.tmcInstPtr;
|
||||
bool reconfig = false;
|
||||
bool start = false;
|
||||
|
||||
if (msg[WD_MODE_CMD] == MODE_CMD_HEAD)
|
||||
{
|
||||
// omit unnecessary reconfiguration
|
||||
if (L2_GetNodeType(linkInstPtr) != L2_NODE_HEAD)
|
||||
{
|
||||
// head node config
|
||||
linkConfig.myType = L2_NODE_HEAD;
|
||||
linkConfig.myId = 1;
|
||||
reconfig = true;
|
||||
}
|
||||
// head node config
|
||||
reconfig = (L2_NODE_HEAD != L2_GetNodeType(linkInstPtr));
|
||||
linkConfig.myType = L2_NODE_HEAD;
|
||||
linkConfig.myId = 1;
|
||||
}
|
||||
|
||||
else if (msg[WD_MODE_CMD] == MODE_CMD_MEMBER )
|
||||
else if (msg[WD_MODE_CMD] == MODE_CMD_MEMBER)
|
||||
{
|
||||
// omit unnecessary reconfiguration
|
||||
if (L2_GetNodeType(linkInstPtr) != L2_NODE_MEMBER)
|
||||
{
|
||||
// member node config
|
||||
linkConfig.myType = L2_NODE_MEMBER;
|
||||
linkConfig.myId = 2;
|
||||
reconfig = true;
|
||||
}
|
||||
// member node config
|
||||
reconfig = (L2_NODE_MEMBER != L2_GetNodeType(linkInstPtr));
|
||||
linkConfig.myType = L2_NODE_MEMBER;
|
||||
linkConfig.myId = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Ignore current command
|
||||
DBG_ERROR("Unexpected config command 0x%02X:0x%02X",
|
||||
WD_MODE_CMD, msg[WD_MODE_CMD]);
|
||||
WD_MODE_CMD, msg[WD_MODE_CMD]);
|
||||
return EPARAM;
|
||||
}
|
||||
|
||||
if(msg[WD_EN_CMD] == EN_CMD_ON_HIGH_POWER)
|
||||
if (msg[WD_EN_CMD] == EN_CMD_ON_HIGH_POWER)
|
||||
{
|
||||
// high power config
|
||||
// full power config
|
||||
Phy_AntConfigMode(phyRef, PHY_ANT_MODE_POWER_FULL);
|
||||
start = true;
|
||||
if (reconfig || !L2_isStarted(linkInstPtr))
|
||||
{
|
||||
Linklayer_Reconfig(linkInstPtr, &linkConfig);
|
||||
}
|
||||
Linklayer_Start(linkInstPtr);
|
||||
}
|
||||
else if(msg[WD_EN_CMD] == EN_CMD_ON_LOW_POWER)
|
||||
else if (msg[WD_EN_CMD] == EN_CMD_ON_LOW_POWER)
|
||||
{
|
||||
// low power config
|
||||
Phy_AntConfigMode(phyRef, PHY_ANT_MODE_POWER_LOW);
|
||||
start = true;
|
||||
if (reconfig || !L2_isStarted(linkInstPtr))
|
||||
{
|
||||
Linklayer_Reconfig(linkInstPtr, &linkConfig);
|
||||
}
|
||||
Linklayer_Start(linkInstPtr);
|
||||
}
|
||||
else if(msg[WD_EN_CMD] == EN_CMD_SILENT)
|
||||
else if (msg[WD_EN_CMD] == EN_CMD_SILENT)
|
||||
{
|
||||
// silence config
|
||||
// TODO: better approach?
|
||||
start = false;
|
||||
Linklayer_Halt(linkInstPtr);
|
||||
Phy_AntConfigMode(phyRef, PHY_ANT_MODE_STANDBY);
|
||||
TIME_WORD pullTime = {0, 0};
|
||||
@@ -338,13 +336,12 @@ static int32_t SystemBus_SystemConfig(SYSBUS *instPtr, uint8_t *msg)
|
||||
}
|
||||
Phy_SetupNextSlot(phyRef, PHY_TOR_RX, L1_10KBPS_10MS_FRAME, NULL);
|
||||
}
|
||||
if (reconfig == true)
|
||||
else
|
||||
{
|
||||
Linklayer_Reconfig(linkInstPtr, &linkConfig);
|
||||
}
|
||||
if (start == true)
|
||||
{
|
||||
Linklayer_Start(linkInstPtr);
|
||||
// Ignore current command
|
||||
DBG_ERROR("Unexpected config command 0x%02X:0x%02X",
|
||||
WD_EN_CMD, msg[WD_EN_CMD]);
|
||||
return EIGNORE;
|
||||
}
|
||||
instPtr->sysbusLog.lastConfig[0] = msg[WD_MODE_CMD];
|
||||
instPtr->sysbusLog.lastConfig[1] = msg[WD_EN_CMD];
|
||||
@@ -359,7 +356,8 @@ static int32_t SystemBus_Echo(SYSBUS *instPtr, SYSBUS_UART_FRAME *frame)
|
||||
ASSERT(instPtr != NULL);
|
||||
ASSERT(frame != NULL);
|
||||
SYSBUS_UART_FRAME *sysbusRsp = malloc(sizeof(SYSBUS_UART_FRAME));
|
||||
if (sysbusRsp == NULL) {
|
||||
if (sysbusRsp == NULL)
|
||||
{
|
||||
DBG_ERROR("Failed to allocate memory for DATA TEST A Response!\n");
|
||||
return ENOMEM;
|
||||
}
|
||||
@@ -384,12 +382,13 @@ static int32_t SystemBus_GenPollRsp(SYSBUS *instPtr, uint8_t *msg)
|
||||
size_t dataLen;
|
||||
uint8_t *payload;
|
||||
SYSBUS_UART_FRAME *sysbusRsp = malloc(sizeof(SYSBUS_UART_FRAME));
|
||||
if (sysbusRsp == NULL) {
|
||||
if (sysbusRsp == NULL)
|
||||
{
|
||||
DBG_ERROR("Failed to allocate memory for FLJ POLL Response!\n");
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
if(msg[WD_CMD] == CMD_FLJ_POLL)
|
||||
if (msg[WD_CMD] == CMD_FLJ_POLL)
|
||||
{
|
||||
sysbusRsp->len = FLJ_POLL_RESP_LEN;
|
||||
sysbusRsp->data[WD_CMD] = CMD_FLJ_POLL;
|
||||
@@ -397,7 +396,7 @@ static int32_t SystemBus_GenPollRsp(SYSBUS *instPtr, uint8_t *msg)
|
||||
dataLen = PAYLOAD_LEN_FLJ_RX;
|
||||
payload = sysbusRsp->data + FLJ_DATA_OFFSET;
|
||||
}
|
||||
else if(msg[WD_CMD] == CMD_LJ_POLL)
|
||||
else if (msg[WD_CMD] == CMD_LJ_POLL)
|
||||
{
|
||||
sysbusRsp->len = LJ_POLL_RESP_LEN;
|
||||
sysbusRsp->data[WD_CMD] = CMD_LJ_POLL;
|
||||
@@ -437,7 +436,8 @@ static int32_t SystemBus_GenRemoteTestRsp(SYSBUS *instPtr, uint8_t *msg)
|
||||
ASSERT(instPtr != NULL);
|
||||
ASSERT(msg != NULL);
|
||||
SYSBUS_UART_FRAME *sysbusRsp = malloc(sizeof(SYSBUS_UART_FRAME));
|
||||
if (sysbusRsp == NULL) {
|
||||
if (sysbusRsp == NULL)
|
||||
{
|
||||
DBG_ERROR("Failed to allocate memory for LJ REMOTE TEST Response!\n");
|
||||
return ENOMEM;
|
||||
}
|
||||
@@ -447,7 +447,7 @@ static int32_t SystemBus_GenRemoteTestRsp(SYSBUS *instPtr, uint8_t *msg)
|
||||
TimeCtrl_GetCurrentTime(linkInstPtr->config.tmcInstPtr, &tmWord);
|
||||
time = (uint64_t)tmWord.int_part * TIME_FRAC_MAX + tmWord.frac_part;
|
||||
|
||||
if(msg[WD_CMD] == CMD_FLJ_RM_TEST)
|
||||
if (msg[WD_CMD] == CMD_FLJ_RM_TEST)
|
||||
{
|
||||
sysbusRsp->len = FLJ_RM_TEST_RESP_LEN;
|
||||
memset(sysbusRsp->data, 0x00, FLJ_RM_TEST_RESP_LEN);
|
||||
@@ -485,7 +485,8 @@ static int32_t SystemBus_GenRemoteTestRsp(SYSBUS *instPtr, uint8_t *msg)
|
||||
return EUNEXP;
|
||||
}
|
||||
|
||||
if (CircQueuePush(instPtr->txQueue, (void *)sysbusRsp) == false){
|
||||
if (CircQueuePush(instPtr->txQueue, (void *)sysbusRsp) == false)
|
||||
{
|
||||
free(sysbusRsp);
|
||||
DBG_WARNING("SystemBus::TX Queue overflowed!\n");
|
||||
return EQUEUE;
|
||||
|
||||
Reference in New Issue
Block a user