forked from 0xha0/df_datalink
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6d665eb853 | ||
|
|
b8e8c6272a |
@@ -510,7 +510,6 @@ int32_t Linklayer_Init(L2_INST **instPtr, const L2_CONFIG *config)
|
|||||||
(*instPtr)->recvPktData = NULL;
|
(*instPtr)->recvPktData = NULL;
|
||||||
(*instPtr)->schdEventPool = NULL;
|
(*instPtr)->schdEventPool = NULL;
|
||||||
(*instPtr)->nodeList = NULL;
|
(*instPtr)->nodeList = NULL;
|
||||||
(*instPtr)->scanFSM = NULL;
|
|
||||||
(*instPtr)->serviceFSM = NULL;
|
(*instPtr)->serviceFSM = NULL;
|
||||||
memcpy(&((*instPtr)->config), config, sizeof(L2_CONFIG));
|
memcpy(&((*instPtr)->config), config, sizeof(L2_CONFIG));
|
||||||
|
|
||||||
@@ -582,13 +581,6 @@ int32_t Linklayer_Init(L2_INST **instPtr, const L2_CONFIG *config)
|
|||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = L2_Scan_Init(&((*instPtr)->scanFSM));
|
|
||||||
if (Status != SUCCESS)
|
|
||||||
{
|
|
||||||
Linklayer_Destroy(*instPtr);
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = L2_Service_Init(&((*instPtr)->serviceFSM));
|
Status = L2_Service_Init(&((*instPtr)->serviceFSM));
|
||||||
if (Status != SUCCESS)
|
if (Status != SUCCESS)
|
||||||
{
|
{
|
||||||
@@ -664,7 +656,6 @@ int32_t Linklayer_Reconfig(L2_INST *instPtr, const L2_CONFIG *config)
|
|||||||
// Reset according instance
|
// Reset according instance
|
||||||
L2_ClearSchedEventPool(instPtr->schdEventPool);
|
L2_ClearSchedEventPool(instPtr->schdEventPool);
|
||||||
L2_NodeList_Clear(instPtr->nodeList);
|
L2_NodeList_Clear(instPtr->nodeList);
|
||||||
L2_Scan_Reset(instPtr->scanFSM);
|
|
||||||
L2_Service_Reset(instPtr->serviceFSM);
|
L2_Service_Reset(instPtr->serviceFSM);
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -689,7 +680,6 @@ void Linklayer_Destroy(L2_INST *instPtr)
|
|||||||
// Destroy FSMs and nodeList
|
// Destroy FSMs and nodeList
|
||||||
L2_DestroySchedEventPool(instPtr->schdEventPool);
|
L2_DestroySchedEventPool(instPtr->schdEventPool);
|
||||||
L2_NodeList_Destroy(instPtr->nodeList);
|
L2_NodeList_Destroy(instPtr->nodeList);
|
||||||
L2_Scan_Destroy(instPtr->scanFSM);
|
|
||||||
L2_Service_Destroy(instPtr->serviceFSM);
|
L2_Service_Destroy(instPtr->serviceFSM);
|
||||||
free(instPtr);
|
free(instPtr);
|
||||||
}
|
}
|
||||||
@@ -806,7 +796,6 @@ int32_t Linklayer_EventHandler(L2_INST *instPtr, const L2_EVENT *l2Event)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
DBG_WARNING("Lost connection with head node [%" PRId8 "].\n", L2_GetHeadId(instPtr));
|
DBG_WARNING("Lost connection with head node [%" PRId8 "].\n", L2_GetHeadId(instPtr));
|
||||||
L2_Scan_Reset(instPtr->scanFSM);
|
|
||||||
L2_Service_Reset(instPtr->serviceFSM);
|
L2_Service_Reset(instPtr->serviceFSM);
|
||||||
instPtr->cxn2Net = false;
|
instPtr->cxn2Net = false;
|
||||||
UpdateMainSate(instPtr, L2_INIT_STATE);
|
UpdateMainSate(instPtr, L2_INIT_STATE);
|
||||||
@@ -816,7 +805,6 @@ int32_t Linklayer_EventHandler(L2_INST *instPtr, const L2_EVENT *l2Event)
|
|||||||
case L2_EV_LOST_NODE:
|
case L2_EV_LOST_NODE:
|
||||||
{
|
{
|
||||||
DBG_INFO("Event L2_EV_LOST_NODE asserted....\n");
|
DBG_INFO("Event L2_EV_LOST_NODE asserted....\n");
|
||||||
L2_Scan_Reset(instPtr->scanFSM);
|
|
||||||
L2_Service_Reset(instPtr->serviceFSM);
|
L2_Service_Reset(instPtr->serviceFSM);
|
||||||
UpdateMainSate(instPtr, L2_INIT_STATE);
|
UpdateMainSate(instPtr, L2_INIT_STATE);
|
||||||
// Log reconnect
|
// Log reconnect
|
||||||
@@ -829,7 +817,6 @@ int32_t Linklayer_EventHandler(L2_INST *instPtr, const L2_EVENT *l2Event)
|
|||||||
if (instPtr->nextState == L2_INIT_STATE)
|
if (instPtr->nextState == L2_INIT_STATE)
|
||||||
{
|
{
|
||||||
// Reset scan net FMS for next scan process.
|
// Reset scan net FMS for next scan process.
|
||||||
L2_Scan_Reset(instPtr->scanFSM);
|
|
||||||
UpdateMainSate(instPtr, L2_INIT_STATE);
|
UpdateMainSate(instPtr, L2_INIT_STATE);
|
||||||
instPtr->rtneConfig.rtneTable = initTable;
|
instPtr->rtneConfig.rtneTable = initTable;
|
||||||
instPtr->rtneConfig.rtnePrd = ARRAY_SIZE(initTable);
|
instPtr->rtneConfig.rtnePrd = ARRAY_SIZE(initTable);
|
||||||
@@ -1084,7 +1071,6 @@ int32_t Linklayer_Proc(L2_INST *instPtr)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
Phy_SetMode(phyRef, PHY_MODE_LISTEN);
|
Phy_SetMode(phyRef, PHY_MODE_LISTEN);
|
||||||
Status = L2_Scan_Proc(instPtr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1105,7 +1091,6 @@ int32_t Linklayer_Proc(L2_INST *instPtr)
|
|||||||
instPtr->linkLog.cxnStatus = (L2_isCxn2Net(instPtr)) ? 0x11 : 0x00;
|
instPtr->linkLog.cxnStatus = (L2_isCxn2Net(instPtr)) ? 0x11 : 0x00;
|
||||||
instPtr->linkLog.linkStage = (instPtr->mainState == L2_INIT_STATE) ? 0x11 : 0x22;
|
instPtr->linkLog.linkStage = (instPtr->mainState == L2_INIT_STATE) ? 0x11 : 0x22;
|
||||||
instPtr->linkLog.recxnCnt = instPtr->log.reconnectCnt;
|
instPtr->linkLog.recxnCnt = instPtr->log.reconnectCnt;
|
||||||
instPtr->linkLog.antIndex = instPtr->scanFSM->antIndex;
|
|
||||||
instPtr->linkLog.advTxCnt = (uint16_t)instPtr->log.advTxCnt;
|
instPtr->linkLog.advTxCnt = (uint16_t)instPtr->log.advTxCnt;
|
||||||
instPtr->linkLog.advRecvCnt = (uint16_t)instPtr->log.advRecvCnt;
|
instPtr->linkLog.advRecvCnt = (uint16_t)instPtr->log.advRecvCnt;
|
||||||
instPtr->linkLog.advCorrectCnt = (uint16_t)instPtr->log.advCorrectCnt;
|
instPtr->linkLog.advCorrectCnt = (uint16_t)instPtr->log.advCorrectCnt;
|
||||||
|
|||||||
@@ -117,7 +117,6 @@ typedef struct
|
|||||||
L2_NODE_STATE mainState; ///< the main state of link layer state
|
L2_NODE_STATE mainState; ///< the main state of link layer state
|
||||||
L2_NODE_STATE nextState; ///< next state of link layer state, which will be applied to mainState every second.
|
L2_NODE_STATE nextState; ///< next state of link layer state, which will be applied to mainState every second.
|
||||||
L2_RTNE_CONFIG rtneConfig; ///< current routine table configuration and status.
|
L2_RTNE_CONFIG rtneConfig; ///< current routine table configuration and status.
|
||||||
L2_SCAN_FSM *scanFSM; ///< FSM of scan net (link set up)
|
|
||||||
L2_SVC_FSM *serviceFSM; ///< FSM of service net (data service)
|
L2_SVC_FSM *serviceFSM; ///< FSM of service net (data service)
|
||||||
uint8_t *sendPktData; ///< send data buffer
|
uint8_t *sendPktData; ///< send data buffer
|
||||||
uint8_t *recvPktData; ///< received data buffer
|
uint8_t *recvPktData; ///< received data buffer
|
||||||
@@ -153,6 +152,7 @@ int32_t L2_SetupNextSlot(L2_INST *instPtr, L2_TOR_TYPE txrxMode, L2_FRAME_TYPE f
|
|||||||
void L2_FrameInsertChunk(uint8_t *frame, size_t offset, size_t bytes, const void *chunk);
|
void L2_FrameInsertChunk(uint8_t *frame, size_t offset, size_t bytes, const void *chunk);
|
||||||
void L2_FrameGetChunk(uint8_t *frame, size_t offset, size_t bytes, void *chunk);
|
void L2_FrameGetChunk(uint8_t *frame, size_t offset, size_t bytes, void *chunk);
|
||||||
int32_t L2_CrcAppend(uint8_t *dataBuff, uint32_t dataLen, uint32_t crcPos, L2_CRC_TYPE crcType);
|
int32_t L2_CrcAppend(uint8_t *dataBuff, uint32_t dataLen, uint32_t crcPos, L2_CRC_TYPE crcType);
|
||||||
|
static int32_t L2_CrcGen(uint8_t *dataBuff, uint32_t dataLen, L2_CRC_TYPE crcType, uint32_t *crc);
|
||||||
bool L2_CrcCheck(uint8_t *dataBuff, uint32_t dataLen, L2_CRC_TYPE crcType);
|
bool L2_CrcCheck(uint8_t *dataBuff, uint32_t dataLen, L2_CRC_TYPE crcType);
|
||||||
/** @} LinkLayer_Framing*/
|
/** @} LinkLayer_Framing*/
|
||||||
|
|
||||||
@@ -171,11 +171,9 @@ int32_t L2_RescheduleEventAfter(L2_INST *instPtr, L2_SCHD_EVENT *schdEvent, uint
|
|||||||
* @defgroup LinkLayer_Scan
|
* @defgroup LinkLayer_Scan
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
int32_t L2_Scan_Init(L2_SCAN_FSM **scanFSMPtr);
|
|
||||||
void L2_Scan_RefreashScanTable(L2_INST *instPtr);
|
void L2_Scan_RefreashScanTable(L2_INST *instPtr);
|
||||||
void L2_Scan_Reset(L2_SCAN_FSM *scanFSMPtr);
|
void L2_Scan_Reset(L2_SCAN_FSM *scanFSMPtr);
|
||||||
void L2_Scan_Destroy(L2_SCAN_FSM *scanFSMPtr);
|
void L2_Scan_Destroy(L2_SCAN_FSM *scanFSMPtr);
|
||||||
int32_t L2_Scan_Proc(L2_INST *instPtr);
|
|
||||||
int32_t L2_Scan_PktHandler(L2_INST *instPtr, uint8_t *msg);
|
int32_t L2_Scan_PktHandler(L2_INST *instPtr, uint8_t *msg);
|
||||||
int32_t L2_Scan_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *schedEntry);
|
int32_t L2_Scan_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *schedEntry);
|
||||||
/** @} LinkLayer_Scan*/
|
/** @} LinkLayer_Scan*/
|
||||||
|
|||||||
@@ -215,17 +215,6 @@ typedef enum
|
|||||||
L2_SCAN_STAGE_ADV = 1
|
L2_SCAN_STAGE_ADV = 1
|
||||||
} SCAN_STAGE;
|
} SCAN_STAGE;
|
||||||
|
|
||||||
/**
|
|
||||||
* @struct L2_SCAN_FSM
|
|
||||||
* @brief Linklayer scan process FSM instance
|
|
||||||
*/
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
bool isAdvRecvd; ///< indicates if advertisement frame done(antenna locked).
|
|
||||||
uint8_t advCnt; ///< adv receive try count
|
|
||||||
uint8_t antIndex; ///< target antenna index
|
|
||||||
} L2_SCAN_FSM;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @struct L2_SVC_FSM
|
* @struct L2_SVC_FSM
|
||||||
* @brief Linklayer service process FSM
|
* @brief Linklayer service process FSM
|
||||||
|
|||||||
@@ -23,105 +23,154 @@
|
|||||||
#ifndef __L2_MSG_DEF_H_
|
#ifndef __L2_MSG_DEF_H_
|
||||||
#define __L2_MSG_DEF_H_
|
#define __L2_MSG_DEF_H_
|
||||||
|
|
||||||
#define L2_PACK_LEN_MAX 512 // bytes
|
#define L2_PACK_LEN_MAX 2048 // bytes
|
||||||
|
|
||||||
|
#define L2_PAYLOAD_LEN_ADV 17
|
||||||
|
#define L2_PAYLOAD_LEN_ACK 9
|
||||||
|
#define L2_PAYLOAD_LEN_SVC_128K 42
|
||||||
|
#define L2_PAYLOAD_LEN_SVC_512K 267
|
||||||
|
#define L2_PAYLOAD_LEN_SVC_2M 1222
|
||||||
|
#define L2_MSG_CRC_LEN 1
|
||||||
|
|
||||||
#define L2_ADV_PACK_LEN 28 // bytes
|
|
||||||
#define L2_CMF_PACK_LEN 268 // bytes
|
|
||||||
#define L2_SVC_PACK_LEN 268 // bytes
|
|
||||||
|
|
||||||
// Common structure:
|
|
||||||
// [bytes] [name]
|
// [bytes] [name]
|
||||||
// 4 fame number
|
// 1 udu number
|
||||||
|
// 10 crypto sync word
|
||||||
|
// 8 message authentication code
|
||||||
|
// 4 frame number
|
||||||
// 1 slot number
|
// 1 slot number
|
||||||
// 1 source id
|
// 1 source id
|
||||||
// 1 destination id
|
// 1 destination id
|
||||||
// 1 message type
|
// 1 message type
|
||||||
#define L2_MSG_FRAME_NUM 0
|
#define L2_MSG_UDU_NUM 0
|
||||||
|
#define L2_MSG_UDU_NUM_LEN 1
|
||||||
|
#define L2_MSG_SYNC_WORD 1
|
||||||
|
#define L2_MSG_SYNC_WORD_LEN 10
|
||||||
|
#define L2_MSG_AUTH_CODE 11
|
||||||
|
#define L2_MSG_AUTH_CODE_LEN 8
|
||||||
|
#define L2_MSG_FRAME_NUM 19
|
||||||
#define L2_MSG_FRAME_NUM_LEN 4
|
#define L2_MSG_FRAME_NUM_LEN 4
|
||||||
#define L2_MSG_SLOT_NUM 4
|
#define L2_MSG_SLOT_NUM 23
|
||||||
#define L2_MSG_SLOT_NUM_LEN 1
|
#define L2_MSG_SLOT_NUM_LEN 1
|
||||||
#define L2_MSG_SRC_ID 5
|
#define L2_MSG_SRC_ID 24
|
||||||
#define L2_MSG_SRC_ID_LEN 1
|
#define L2_MSG_SRC_ID_LEN 1
|
||||||
#define L2_MSG_DST_ID 6
|
#define L2_MSG_DST_ID 25
|
||||||
#define L2_MSG_DST_ID_LEN 1
|
#define L2_MSG_DST_ID_LEN 1
|
||||||
#define L2_MSG_TYPE 7
|
#define L2_MSG_TYPE 26
|
||||||
#define L2_MSG_TYPE_LEN 1
|
#define L2_MSG_TYPE_LEN 1
|
||||||
#define L2_MSG_PAYLOAD 8
|
#define L2_MSG_PAYLOAD 27
|
||||||
|
|
||||||
// advertisement payload structure:
|
#pragma pack(push, 1) // Force 1-byte alignment
|
||||||
// [bytes] [name]
|
|
||||||
// 4 position x
|
|
||||||
// 4 position y
|
|
||||||
// 4 position z
|
|
||||||
// 4 net start time
|
|
||||||
// 2 crc
|
|
||||||
#define L2_MSG_ADV_SRC_POSX 8
|
|
||||||
#define L2_MSG_ADV_SRC_POSX_LEN 4
|
|
||||||
#define L2_MSG_ADV_SRC_POSY 12
|
|
||||||
#define L2_MSG_ADV_SRC_POSY_LEN 4
|
|
||||||
#define L2_MSG_ADV_SRC_POSZ 16
|
|
||||||
#define L2_MSG_ADV_SRC_POSZ_LEN 4
|
|
||||||
#define L2_MSG_ADV_SRC_NETSTART_TIME 20
|
|
||||||
#define L2_MSG_ADV_SRC_NETSTART_TIME_LEN 4
|
|
||||||
#define L2_MSG_ADV_SVC_CRC 26
|
|
||||||
#define L2_MSG_ADV_SVC_CRC_LEN 2
|
|
||||||
|
|
||||||
// confirm payload structure:
|
/**
|
||||||
// [bytes] [name]
|
* @struct L2_MSG_COMMON
|
||||||
// 4 position x
|
* @brief Link layer common message header, 27 byte / 216 bit in total.
|
||||||
// 4 position y
|
*/
|
||||||
// 4 position z
|
typedef struct
|
||||||
// 4 speed x
|
{
|
||||||
// 4 speed y
|
uint8_t uduNum; ///< udu (user data unit) number per pdu (packet data unit)
|
||||||
// 4 speed z
|
struct
|
||||||
// 2 crc
|
{
|
||||||
#define L2_MSG_CFM_SRC_POSX 8
|
uint8_t cryptoSyncWord[10];
|
||||||
#define L2_MSG_CFM_SRC_POSX_LEN 4
|
uint8_t msgAuthCode[8];
|
||||||
#define L2_MSG_CFM_SRC_POSY 12
|
} MSG_KEY;
|
||||||
#define L2_MSG_CFM_SRC_POSY_LEN 4
|
|
||||||
#define L2_MSG_CFM_SRC_POSZ 16
|
|
||||||
#define L2_MSG_CFM_SRC_POSZ_LEN 4
|
|
||||||
#define L2_MSG_CFM_SRC_SPEEDX 20
|
|
||||||
#define L2_MSG_CFM_SRC_SPEEDX_LEN 4
|
|
||||||
#define L2_MSG_CFM_SRC_SPEEDY 24
|
|
||||||
#define L2_MSG_CFM_SRC_SPEEDY_LEN 4
|
|
||||||
#define L2_MSG_CFM_SRC_SPEEDZ 28
|
|
||||||
#define L2_MSG_CFM_SRC_SPEEDZ_LEN 4
|
|
||||||
#define L2_MSG_CFM_PAYLOAD_ID 32
|
|
||||||
#define L2_MSG_CFM_PAYLOAD_ID_LEN 4
|
|
||||||
#define L2_MSG_CFM_PAYLOAD 36
|
|
||||||
#define L2_MSG_CFM_PAYLOAD_LEN 230
|
|
||||||
#define L2_MSG_CFM_CRC 266
|
|
||||||
#define L2_MSG_CFM_CRC_LEN 2
|
|
||||||
|
|
||||||
// service payload structure:
|
uint32_t frameNum; ///< frame number
|
||||||
// [bytes] [name]
|
uint8_t slotNum; ///< slot number
|
||||||
// 4 position x
|
uint8_t src; ///< source id
|
||||||
// 4 position y
|
uint8_t dst; ///< destination id
|
||||||
// 4 position z
|
uint8_t msgType; ///< message type
|
||||||
// 4 speed x
|
} L2_MSG_COMMON;
|
||||||
// 4 speed y
|
|
||||||
// 4 speed z
|
/**
|
||||||
// 234 payload
|
* @struct L2_MSG_ADV
|
||||||
// 2 crc
|
* @brief Link layer advertise message definition, 65 byte / 520 bit in total.
|
||||||
#define L2_MSG_SVC_SRC_POSX 8
|
*/
|
||||||
#define L2_MSG_SVC_SRC_POSX_LEN 4
|
typedef struct
|
||||||
#define L2_MSG_SVC_SRC_POSY 12
|
{
|
||||||
#define L2_MSG_SVC_SRC_POSY_LEN 4
|
L2_MSG_COMMON *common; ///< common message header
|
||||||
#define L2_MSG_SVC_SRC_POSZ 16
|
double srcPosX; ///< position x
|
||||||
#define L2_MSG_SVC_SRC_POSZ_LEN 4
|
double srcPosY; ///< position y
|
||||||
#define L2_MSG_SVC_SRC_SPEEDX 20
|
double srcPosZ; ///< position z
|
||||||
#define L2_MSG_SVC_SRC_SPEEDX_LEN 4
|
uint32_t srcNetStatTime;///< net start time
|
||||||
#define L2_MSG_SVC_SRC_SPEEDY 24
|
uint32_t advDataId; ///< advertise payload id
|
||||||
#define L2_MSG_SVC_SRC_SPEEDY_LEN 4
|
uint8_t advData[17]; ///< advertise payload data
|
||||||
#define L2_MSG_SVC_SRC_SPEEDZ 28
|
uint8_t crc; ///< crc
|
||||||
#define L2_MSG_SVC_SRC_SPEEDZ_LEN 4
|
} L2_MSG_ADV;
|
||||||
#define L2_MSG_SVC_PAYLOAD_ID 32
|
|
||||||
#define L2_MSG_SVC_PAYLOAD_ID_LEN 4
|
/**
|
||||||
#define L2_MSG_SVC_PAYLOAD 36
|
* @struct L2_MSG_ACK
|
||||||
#define L2_MSG_SVC_PAYLOAD_LEN 230
|
* @brief Link layer acknowledge message definition, 65 byte / 520 bit in total.
|
||||||
#define L2_MSG_SVC_CRC 266
|
*/
|
||||||
#define L2_MSG_SVC_CRC_LEN 2
|
typedef struct
|
||||||
|
{
|
||||||
|
L2_MSG_COMMON *common; ///< common message header
|
||||||
|
double srcPosX; ///< position x
|
||||||
|
double srcPosY; ///< position y
|
||||||
|
double srcPosZ; ///< position z
|
||||||
|
double srcSpeedX; ///< speed x
|
||||||
|
double srcSpeedY; ///< speed y
|
||||||
|
double srcSpeedZ; ///< speed z
|
||||||
|
uint32_t ackDataId; ///< acknowledge payload id
|
||||||
|
uint8_t ackData[9]; ///< acknowledge payload data
|
||||||
|
uint8_t crc; ///< crc
|
||||||
|
} L2_MSG_ACK;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @struct L2_MSG_SVC_128K
|
||||||
|
* @brief Link layer 128 kbps service message definition, 98 byte / 784 bit in total.
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
L2_MSG_COMMON *common; ///< common message header
|
||||||
|
double srcPosX; ///< position x
|
||||||
|
double srcPosY; ///< position y
|
||||||
|
double srcPosZ; ///< position z
|
||||||
|
double srcSpeedX; ///< speed x
|
||||||
|
double srcSpeedY; ///< speed y
|
||||||
|
double srcSpeedZ; ///< speed z
|
||||||
|
uint32_t svcDataId; ///< service payload id
|
||||||
|
uint8_t svcData[42]; ///< service payload data
|
||||||
|
uint8_t crc; ///< crc
|
||||||
|
} L2_MSG_SVC_128K;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @struct L2_MSG_SVC_512K
|
||||||
|
* @brief Link layer 512 kbps service message definition, 323 byte / 2584 bit in total.
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
L2_MSG_COMMON *common; ///< common message header
|
||||||
|
double srcPosX; ///< position x
|
||||||
|
double srcPosY; ///< position y
|
||||||
|
double srcPosZ; ///< position z
|
||||||
|
double srcSpeedX; ///< speed x
|
||||||
|
double srcSpeedY; ///< speed y
|
||||||
|
double srcSpeedZ; ///< speed z
|
||||||
|
uint32_t svcDataId; ///< service payload id
|
||||||
|
uint8_t svcData[267]; ///< service payload data
|
||||||
|
uint8_t crc; ///< crc
|
||||||
|
} L2_MSG_SVC_512K;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @struct L2_MSG_SVC_2M
|
||||||
|
* @brief Link layer 2 Mbps service message definition, 1278 byte / 10224 bit in total.
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
L2_MSG_COMMON *common; ///< common message header
|
||||||
|
double srcPosX; ///< position x
|
||||||
|
double srcPosY; ///< position y
|
||||||
|
double srcPosZ; ///< position z
|
||||||
|
double srcSpeedX; ///< speed x
|
||||||
|
double srcSpeedY; ///< speed y
|
||||||
|
double srcSpeedZ; ///< speed z
|
||||||
|
uint32_t svcDataId; ///< service payload id
|
||||||
|
uint8_t svcData[1222]; ///< service payload data
|
||||||
|
uint8_t crc; ///< crc
|
||||||
|
} L2_MSG_SVC_2M;
|
||||||
|
|
||||||
|
#pragma pack(pop) // Restore original packing
|
||||||
|
|
||||||
#endif //__L2_MSG_DEF_H_
|
#endif //__L2_MSG_DEF_H_
|
||||||
|
|
||||||
|
|||||||
@@ -25,238 +25,289 @@
|
|||||||
#include "link_layer.h"
|
#include "link_layer.h"
|
||||||
#include "link_layer_types.h"
|
#include "link_layer_types.h"
|
||||||
|
|
||||||
L2_RTNE_TABLE_ENTRY intraScanSubT[L2_SLOTS_PER_FRAME] = {
|
L2_RTNE_TABLE_ENTRY innerScanSubT[L2_SLOTS_PER_FRAME] =
|
||||||
// SubFrame 0
|
{
|
||||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
// 36 slots: advertise of antenna-1 ~ antenna-3
|
||||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
// 12 slots: idle for no antenna-4
|
||||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
// 2 slots: service slot, set to idle
|
||||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
{L2_SLOT_ADVERTISE, 0x00, 0x01, L2_BROADCAST_ID1},
|
||||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
{L2_SLOT_ADVERTISE, 0x01, 0x01, L2_BROADCAST_ID1},
|
||||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
{L2_SLOT_ADVERTISE, 0x02, 0x01, L2_BROADCAST_ID1},
|
||||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
{L2_SLOT_ADVERTISE, 0x03, 0x01, L2_BROADCAST_ID1},
|
||||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
{L2_SLOT_ADVERTISE, 0x04, 0x01, L2_BROADCAST_ID1},
|
||||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
{L2_SLOT_ADVERTISE, 0x05, 0x01, L2_BROADCAST_ID1},
|
||||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
{L2_SLOT_ADVERTISE, 0x06, 0x01, L2_BROADCAST_ID1},
|
||||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
{L2_SLOT_ADVERTISE, 0x07, 0x01, L2_BROADCAST_ID1},
|
||||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
{L2_SLOT_ADVERTISE, 0x08, 0x01, L2_BROADCAST_ID1},
|
||||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
{L2_SLOT_ADVERTISE, 0x09, 0x01, L2_BROADCAST_ID1},
|
||||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
{L2_SLOT_ADVERTISE, 0x0A, 0x01, L2_BROADCAST_ID1},
|
||||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
{L2_SLOT_ADVERTISE, 0x0B, 0x01, L2_BROADCAST_ID1},
|
||||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
{L2_SLOT_ADVERTISE, 0x00, 0x01, L2_BROADCAST_ID2},
|
||||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
{L2_SLOT_ADVERTISE, 0x01, 0x01, L2_BROADCAST_ID2},
|
||||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
{L2_SLOT_ADVERTISE, 0x02, 0x01, L2_BROADCAST_ID2},
|
||||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
{L2_SLOT_ADVERTISE, 0x03, 0x01, L2_BROADCAST_ID2},
|
||||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
{L2_SLOT_ADVERTISE, 0x04, 0x01, L2_BROADCAST_ID2},
|
||||||
|
{L2_SLOT_ADVERTISE, 0x05, 0x01, L2_BROADCAST_ID2},
|
||||||
// SubFrame 1
|
{L2_SLOT_ADVERTISE, 0x06, 0x01, L2_BROADCAST_ID2},
|
||||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
{L2_SLOT_ADVERTISE, 0x07, 0x01, L2_BROADCAST_ID2},
|
||||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
{L2_SLOT_ADVERTISE, 0x08, 0x01, L2_BROADCAST_ID2},
|
||||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
{L2_SLOT_ADVERTISE, 0x09, 0x01, L2_BROADCAST_ID2},
|
||||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
{L2_SLOT_ADVERTISE, 0x0A, 0x01, L2_BROADCAST_ID2},
|
||||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
{L2_SLOT_ADVERTISE, 0x0B, 0x01, L2_BROADCAST_ID2},
|
||||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
{L2_SLOT_ADVERTISE, 0x00, 0x01, L2_BROADCAST_ID3},
|
||||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
{L2_SLOT_ADVERTISE, 0x01, 0x01, L2_BROADCAST_ID3},
|
||||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
{L2_SLOT_ADVERTISE, 0x02, 0x01, L2_BROADCAST_ID3},
|
||||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
{L2_SLOT_ADVERTISE, 0x03, 0x01, L2_BROADCAST_ID3},
|
||||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
{L2_SLOT_ADVERTISE, 0x04, 0x01, L2_BROADCAST_ID3},
|
||||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
{L2_SLOT_ADVERTISE, 0x05, 0x01, L2_BROADCAST_ID3},
|
||||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
{L2_SLOT_ADVERTISE, 0x06, 0x01, L2_BROADCAST_ID3},
|
||||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
{L2_SLOT_ADVERTISE, 0x07, 0x01, L2_BROADCAST_ID3},
|
||||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
{L2_SLOT_ADVERTISE, 0x08, 0x01, L2_BROADCAST_ID3},
|
||||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
{L2_SLOT_ADVERTISE, 0x09, 0x01, L2_BROADCAST_ID3},
|
||||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
{L2_SLOT_ADVERTISE, 0x0A, 0x01, L2_BROADCAST_ID3},
|
||||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
{L2_SLOT_ADVERTISE, 0x0B, 0x01, L2_BROADCAST_ID3},
|
||||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||||
|
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||||
// SubFrame 2
|
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||||
{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},
|
||||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||||
|
|
||||||
// SubFrame 4
|
// 36 slots: acknowledge of member nodes
|
||||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
// 14 slots: service
|
||||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
{L2_SLOT_ACKNOWLEDGE, 0x00, 0x02, 0x01},
|
||||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
{L2_SLOT_ACKNOWLEDGE, 0x01, 0x02, 0x01},
|
||||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
{L2_SLOT_ACKNOWLEDGE, 0x02, 0x02, 0x01},
|
||||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
{L2_SLOT_ACKNOWLEDGE, 0x03, 0x02, 0x01},
|
||||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
{L2_SLOT_ACKNOWLEDGE, 0x00, 0x03, 0x01},
|
||||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
{L2_SLOT_ACKNOWLEDGE, 0x01, 0x03, 0x01},
|
||||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
{L2_SLOT_ACKNOWLEDGE, 0x02, 0x03, 0x01},
|
||||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
{L2_SLOT_ACKNOWLEDGE, 0x03, 0x03, 0x01},
|
||||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
{L2_SLOT_ACKNOWLEDGE, 0x00, 0x04, 0x01},
|
||||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
{L2_SLOT_ACKNOWLEDGE, 0x01, 0x04, 0x01},
|
||||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
{L2_SLOT_ACKNOWLEDGE, 0x02, 0x04, 0x01},
|
||||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
{L2_SLOT_ACKNOWLEDGE, 0x03, 0x04, 0x01},
|
||||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
{L2_SLOT_ACKNOWLEDGE, 0x00, 0x05, 0x01},
|
||||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
{L2_SLOT_ACKNOWLEDGE, 0x01, 0x05, 0x01},
|
||||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
{L2_SLOT_ACKNOWLEDGE, 0x02, 0x05, 0x01},
|
||||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
{L2_SLOT_ACKNOWLEDGE, 0x03, 0x05, 0x01},
|
||||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
{L2_SLOT_ACKNOWLEDGE, 0x00, 0x06, 0x01},
|
||||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
{L2_SLOT_ACKNOWLEDGE, 0x01, 0x06, 0x01},
|
||||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
{L2_SLOT_ACKNOWLEDGE, 0x02, 0x06, 0x01},
|
||||||
};
|
{L2_SLOT_ACKNOWLEDGE, 0x03, 0x06, 0x01},
|
||||||
|
{L2_SLOT_ACKNOWLEDGE, 0x00, 0x07, 0x01},
|
||||||
|
{L2_SLOT_ACKNOWLEDGE, 0x01, 0x07, 0x01},
|
||||||
|
{L2_SLOT_ACKNOWLEDGE, 0x02, 0x07, 0x01},
|
||||||
|
{L2_SLOT_ACKNOWLEDGE, 0x03, 0x07, 0x01},
|
||||||
|
{L2_SLOT_ACKNOWLEDGE, 0x00, 0x08, 0x01},
|
||||||
|
{L2_SLOT_ACKNOWLEDGE, 0x01, 0x08, 0x01},
|
||||||
|
{L2_SLOT_ACKNOWLEDGE, 0x02, 0x08, 0x01},
|
||||||
|
{L2_SLOT_ACKNOWLEDGE, 0x03, 0x08, 0x01},
|
||||||
|
{L2_SLOT_ACKNOWLEDGE, 0x00, 0x09, 0x01},
|
||||||
|
{L2_SLOT_ACKNOWLEDGE, 0x01, 0x09, 0x01},
|
||||||
|
{L2_SLOT_ACKNOWLEDGE, 0x02, 0x09, 0x01},
|
||||||
|
{L2_SLOT_ACKNOWLEDGE, 0x03, 0x09, 0x01},
|
||||||
|
{L2_SLOT_ACKNOWLEDGE, 0x00, 0x0A, 0x01},
|
||||||
|
{L2_SLOT_ACKNOWLEDGE, 0x01, 0x0A, 0x01},
|
||||||
|
{L2_SLOT_ACKNOWLEDGE, 0x02, 0x0A, 0x01},
|
||||||
|
{L2_SLOT_ACKNOWLEDGE, 0x03, 0x0A, 0x01},
|
||||||
|
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||||
|
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||||
|
{L2_SLOT_SERVICE, 0x00, 0x01, 0x03},
|
||||||
|
{L2_SLOT_SERVICE, 0x01, 0x01, 0x03},
|
||||||
|
{L2_SLOT_SERVICE, 0x00, 0x01, 0x04},
|
||||||
|
{L2_SLOT_SERVICE, 0x01, 0x01, 0x04},
|
||||||
|
{L2_SLOT_SERVICE, 0x00, 0x01, 0x05},
|
||||||
|
{L2_SLOT_SERVICE, 0x01, 0x01, 0x05},
|
||||||
|
{L2_SLOT_SERVICE, 0x00, 0x01, 0x06},
|
||||||
|
{L2_SLOT_SERVICE, 0x01, 0x01, 0x06},
|
||||||
|
{L2_SLOT_SERVICE, 0x00, 0x01, 0x07},
|
||||||
|
{L2_SLOT_SERVICE, 0x01, 0x01, 0x07},
|
||||||
|
{L2_SLOT_SERVICE, 0x00, 0x01, 0x08},
|
||||||
|
{L2_SLOT_SERVICE, 0x01, 0x01, 0x08},
|
||||||
|
|
||||||
L2_RTNE_TABLE_ENTRY normalSub[L2_SLOTS_PER_FRAME] = {
|
// 12 slots: network management, head <--> node
|
||||||
// SubFrame 0
|
// 18 slots: message distribution, head ---> node
|
||||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
// 12 slots: rtt, head <--> node
|
||||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
// 8 slots: service
|
||||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
{L2_SLOT_MANAGE, 0x00, 0x01, 0x02},
|
||||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
{L2_SLOT_MANAGE, 0x01, 0x01, 0x02},
|
||||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
{L2_SLOT_MANAGE, 0x00, 0x01, 0x03},
|
||||||
|
{L2_SLOT_MANAGE, 0x01, 0x01, 0x03},
|
||||||
|
{L2_SLOT_MANAGE, 0x00, 0x01, 0x04},
|
||||||
|
{L2_SLOT_MANAGE, 0x01, 0x01, 0x04},
|
||||||
|
{L2_SLOT_MANAGE, 0x00, 0x02, 0x01},
|
||||||
|
{L2_SLOT_MANAGE, 0x01, 0x02, 0x01},
|
||||||
|
{L2_SLOT_MANAGE, 0x00, 0x03, 0x01},
|
||||||
|
{L2_SLOT_MANAGE, 0x01, 0x03, 0x01},
|
||||||
|
{L2_SLOT_MANAGE, 0x00, 0x04, 0x01},
|
||||||
|
{L2_SLOT_MANAGE, 0x01, 0x04, 0x01},
|
||||||
|
{L2_SLOT_DISTRIBUTE, 0x00, 0x01, 0x02},
|
||||||
|
{L2_SLOT_DISTRIBUTE, 0x01, 0x01, 0x02},
|
||||||
|
{L2_SLOT_DISTRIBUTE, 0x00, 0x01, 0x03},
|
||||||
|
{L2_SLOT_DISTRIBUTE, 0x01, 0x01, 0x03},
|
||||||
|
{L2_SLOT_DISTRIBUTE, 0x00, 0x01, 0x04},
|
||||||
|
{L2_SLOT_DISTRIBUTE, 0x01, 0x01, 0x04},
|
||||||
|
{L2_SLOT_DISTRIBUTE, 0x00, 0x01, 0x05},
|
||||||
|
{L2_SLOT_DISTRIBUTE, 0x01, 0x01, 0x05},
|
||||||
|
{L2_SLOT_DISTRIBUTE, 0x00, 0x01, 0x06},
|
||||||
|
{L2_SLOT_DISTRIBUTE, 0x01, 0x01, 0x06},
|
||||||
|
{L2_SLOT_DISTRIBUTE, 0x00, 0x01, 0x07},
|
||||||
|
{L2_SLOT_DISTRIBUTE, 0x01, 0x01, 0x07},
|
||||||
|
{L2_SLOT_DISTRIBUTE, 0x00, 0x01, 0x08},
|
||||||
|
{L2_SLOT_DISTRIBUTE, 0x01, 0x01, 0x08},
|
||||||
|
{L2_SLOT_DISTRIBUTE, 0x00, 0x01, 0x09},
|
||||||
|
{L2_SLOT_DISTRIBUTE, 0x01, 0x01, 0x09},
|
||||||
|
{L2_SLOT_DISTRIBUTE, 0x00, 0x01, 0x0A},
|
||||||
|
{L2_SLOT_DISTRIBUTE, 0x01, 0x01, 0x0A},
|
||||||
|
{L2_SLOT_RTT, 0x00, 0x01, 0x02},
|
||||||
|
{L2_SLOT_RTT, 0x01, 0x01, 0x02},
|
||||||
|
{L2_SLOT_RTT, 0x00, 0x01, 0x03},
|
||||||
|
{L2_SLOT_RTT, 0x01, 0x01, 0x03},
|
||||||
|
{L2_SLOT_RTT, 0x00, 0x01, 0x04},
|
||||||
|
{L2_SLOT_RTT, 0x01, 0x01, 0x04},
|
||||||
|
{L2_SLOT_RTT, 0x00, 0x02, 0x01},
|
||||||
|
{L2_SLOT_RTT, 0x01, 0x02, 0x01},
|
||||||
|
{L2_SLOT_RTT, 0x00, 0x03, 0x01},
|
||||||
|
{L2_SLOT_RTT, 0x01, 0x03, 0x01},
|
||||||
|
{L2_SLOT_RTT, 0x00, 0x04, 0x01},
|
||||||
|
{L2_SLOT_RTT, 0x01, 0x04, 0x01},
|
||||||
|
{L2_SLOT_SERVICE, 0x00, 0x01, 0x09},
|
||||||
|
{L2_SLOT_SERVICE, 0x01, 0x01, 0x09},
|
||||||
|
{L2_SLOT_SERVICE, 0x00, 0x01, 0x0A},
|
||||||
|
{L2_SLOT_SERVICE, 0x01, 0x01, 0x0A},
|
||||||
|
{L2_SLOT_SERVICE, 0x00, 0x01, 0x0B},
|
||||||
|
{L2_SLOT_SERVICE, 0x01, 0x01, 0x0B},
|
||||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||||
{L2_SLOT_SERVICE, 0x01, 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 1
|
// 12 slots: network management, head <--> node
|
||||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
// 18 slots: message distribution, head ---> node
|
||||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
// 12 slots: rtt, head <--> node
|
||||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
// 8 slots: service
|
||||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
{L2_SLOT_MANAGE, 0x00, 0x01, 0x05},
|
||||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
{L2_SLOT_MANAGE, 0x01, 0x01, 0x05},
|
||||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
{L2_SLOT_MANAGE, 0x00, 0x01, 0x06},
|
||||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
{L2_SLOT_MANAGE, 0x01, 0x01, 0x06},
|
||||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
{L2_SLOT_MANAGE, 0x00, 0x01, 0x07},
|
||||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
{L2_SLOT_MANAGE, 0x01, 0x01, 0x07},
|
||||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
{L2_SLOT_MANAGE, 0x00, 0x05, 0x01},
|
||||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
{L2_SLOT_MANAGE, 0x01, 0x05, 0x01},
|
||||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
{L2_SLOT_MANAGE, 0x00, 0x06, 0x01},
|
||||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
{L2_SLOT_MANAGE, 0x01, 0x06, 0x01},
|
||||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
{L2_SLOT_MANAGE, 0x00, 0x07, 0x01},
|
||||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
{L2_SLOT_MANAGE, 0x01, 0x07, 0x01},
|
||||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
{L2_SLOT_DISTRIBUTE, 0x00, 0x01, 0x02},
|
||||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
{L2_SLOT_DISTRIBUTE, 0x01, 0x01, 0x02},
|
||||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
{L2_SLOT_DISTRIBUTE, 0x00, 0x01, 0x03},
|
||||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
{L2_SLOT_DISTRIBUTE, 0x01, 0x01, 0x03},
|
||||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
{L2_SLOT_DISTRIBUTE, 0x00, 0x01, 0x04},
|
||||||
|
{L2_SLOT_DISTRIBUTE, 0x01, 0x01, 0x04},
|
||||||
|
{L2_SLOT_DISTRIBUTE, 0x00, 0x01, 0x05},
|
||||||
|
{L2_SLOT_DISTRIBUTE, 0x01, 0x01, 0x05},
|
||||||
|
{L2_SLOT_DISTRIBUTE, 0x00, 0x01, 0x06},
|
||||||
|
{L2_SLOT_DISTRIBUTE, 0x01, 0x01, 0x06},
|
||||||
|
{L2_SLOT_DISTRIBUTE, 0x00, 0x01, 0x07},
|
||||||
|
{L2_SLOT_DISTRIBUTE, 0x01, 0x01, 0x07},
|
||||||
|
{L2_SLOT_DISTRIBUTE, 0x00, 0x01, 0x08},
|
||||||
|
{L2_SLOT_DISTRIBUTE, 0x01, 0x01, 0x08},
|
||||||
|
{L2_SLOT_DISTRIBUTE, 0x00, 0x01, 0x09},
|
||||||
|
{L2_SLOT_DISTRIBUTE, 0x01, 0x01, 0x09},
|
||||||
|
{L2_SLOT_DISTRIBUTE, 0x00, 0x01, 0x0A},
|
||||||
|
{L2_SLOT_DISTRIBUTE, 0x01, 0x01, 0x0A},
|
||||||
|
{L2_SLOT_RTT, 0x00, 0x01, 0x05},
|
||||||
|
{L2_SLOT_RTT, 0x01, 0x01, 0x05},
|
||||||
|
{L2_SLOT_RTT, 0x00, 0x01, 0x06},
|
||||||
|
{L2_SLOT_RTT, 0x01, 0x01, 0x06},
|
||||||
|
{L2_SLOT_RTT, 0x00, 0x01, 0x07},
|
||||||
|
{L2_SLOT_RTT, 0x01, 0x01, 0x07},
|
||||||
|
{L2_SLOT_RTT, 0x00, 0x05, 0x01},
|
||||||
|
{L2_SLOT_RTT, 0x01, 0x05, 0x01},
|
||||||
|
{L2_SLOT_RTT, 0x00, 0x06, 0x01},
|
||||||
|
{L2_SLOT_RTT, 0x01, 0x06, 0x01},
|
||||||
|
{L2_SLOT_RTT, 0x00, 0x07, 0x01},
|
||||||
|
{L2_SLOT_RTT, 0x01, 0x07, 0x01},
|
||||||
|
{L2_SLOT_SERVICE, 0x00, 0x03, 0x01},
|
||||||
|
{L2_SLOT_SERVICE, 0x01, 0x03, 0x01},
|
||||||
|
{L2_SLOT_SERVICE, 0x00, 0x04, 0x01},
|
||||||
|
{L2_SLOT_SERVICE, 0x01, 0x04, 0x01},
|
||||||
|
{L2_SLOT_SERVICE, 0x00, 0x05, 0x01},
|
||||||
|
{L2_SLOT_SERVICE, 0x01, 0x05, 0x01},
|
||||||
|
{L2_SLOT_SERVICE, 0x00, 0x06, 0x01},
|
||||||
|
{L2_SLOT_SERVICE, 0x01, 0x06, 0x01},
|
||||||
|
|
||||||
// SubFrame 2
|
// 12 slots: network management, head <--> node
|
||||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
// 18 slots: message distribution, head ---> node
|
||||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
// 12 slots: rtt, head <--> node
|
||||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
// 8 slots: service, with one slot idle
|
||||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
{L2_SLOT_MANAGE, 0x00, 0x01, 0x08},
|
||||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
{L2_SLOT_MANAGE, 0x01, 0x01, 0x08},
|
||||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
{L2_SLOT_MANAGE, 0x00, 0x01, 0x09},
|
||||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
{L2_SLOT_MANAGE, 0x01, 0x01, 0x09},
|
||||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
{L2_SLOT_MANAGE, 0x00, 0x01, 0x0A},
|
||||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
{L2_SLOT_MANAGE, 0x01, 0x01, 0x0A},
|
||||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
{L2_SLOT_MANAGE, 0x00, 0x08, 0x01},
|
||||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
{L2_SLOT_MANAGE, 0x01, 0x08, 0x01},
|
||||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
{L2_SLOT_MANAGE, 0x00, 0x09, 0x01},
|
||||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
{L2_SLOT_MANAGE, 0x01, 0x09, 0x01},
|
||||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
{L2_SLOT_MANAGE, 0x00, 0x0A, 0x01},
|
||||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
{L2_SLOT_MANAGE, 0x01, 0x0A, 0x01},
|
||||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
{L2_SLOT_DISTRIBUTE, 0x00, 0x01, 0x02},
|
||||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
{L2_SLOT_DISTRIBUTE, 0x01, 0x01, 0x02},
|
||||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
{L2_SLOT_DISTRIBUTE, 0x00, 0x01, 0x03},
|
||||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
{L2_SLOT_DISTRIBUTE, 0x01, 0x01, 0x03},
|
||||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
{L2_SLOT_DISTRIBUTE, 0x00, 0x01, 0x04},
|
||||||
|
{L2_SLOT_DISTRIBUTE, 0x01, 0x01, 0x04},
|
||||||
// SubFrame 3
|
{L2_SLOT_DISTRIBUTE, 0x00, 0x01, 0x05},
|
||||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
{L2_SLOT_DISTRIBUTE, 0x01, 0x01, 0x05},
|
||||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
{L2_SLOT_DISTRIBUTE, 0x00, 0x01, 0x06},
|
||||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
{L2_SLOT_DISTRIBUTE, 0x01, 0x01, 0x06},
|
||||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
{L2_SLOT_DISTRIBUTE, 0x00, 0x01, 0x07},
|
||||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
{L2_SLOT_DISTRIBUTE, 0x01, 0x01, 0x07},
|
||||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
{L2_SLOT_DISTRIBUTE, 0x00, 0x01, 0x08},
|
||||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
{L2_SLOT_DISTRIBUTE, 0x01, 0x01, 0x08},
|
||||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
{L2_SLOT_DISTRIBUTE, 0x00, 0x01, 0x09},
|
||||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
{L2_SLOT_DISTRIBUTE, 0x01, 0x01, 0x09},
|
||||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
{L2_SLOT_DISTRIBUTE, 0x00, 0x01, 0x0A},
|
||||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
{L2_SLOT_DISTRIBUTE, 0x01, 0x01, 0x0A},
|
||||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
{L2_SLOT_RTT, 0x00, 0x01, 0x08},
|
||||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
{L2_SLOT_RTT, 0x01, 0x01, 0x08},
|
||||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
{L2_SLOT_RTT, 0x00, 0x01, 0x09},
|
||||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
{L2_SLOT_RTT, 0x01, 0x01, 0x09},
|
||||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
{L2_SLOT_RTT, 0x00, 0x01, 0x0A},
|
||||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
{L2_SLOT_RTT, 0x01, 0x01, 0x0A},
|
||||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
{L2_SLOT_RTT, 0x00, 0x08, 0x01},
|
||||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
{L2_SLOT_RTT, 0x01, 0x08, 0x01},
|
||||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
{L2_SLOT_RTT, 0x00, 0x09, 0x01},
|
||||||
|
{L2_SLOT_RTT, 0x01, 0x09, 0x01},
|
||||||
// SubFrame 4
|
{L2_SLOT_RTT, 0x00, 0x0A, 0x01},
|
||||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
{L2_SLOT_RTT, 0x01, 0x0A, 0x01},
|
||||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
{L2_SLOT_SERVICE, 0x00, 0x08, 0x01},
|
||||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
{L2_SLOT_SERVICE, 0x01, 0x08, 0x01},
|
||||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
{L2_SLOT_SERVICE, 0x00, 0x09, 0x01},
|
||||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
{L2_SLOT_SERVICE, 0x01, 0x09, 0x01},
|
||||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
{L2_SLOT_SERVICE, 0x00, 0x0A, 0x01},
|
||||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
{L2_SLOT_SERVICE, 0x01, 0x0A, 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},
|
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||||
|
{L2_SLOT_IDLE, 0x00, 0x00, 0x00}
|
||||||
};
|
};
|
||||||
|
|
||||||
L2_RTNE_TABLE_ENTRY *initTable[L2_INIT_RTNE_PERIOD] =
|
L2_RTNE_TABLE_ENTRY *initTable[L2_INIT_RTNE_PERIOD] =
|
||||||
{
|
{
|
||||||
intraScanSubT
|
innerScanSubT
|
||||||
};
|
};
|
||||||
|
|
||||||
L2_RTNE_TABLE_ENTRY *normalTable[L2_NORMAL_RTNE_PERIOD] =
|
L2_RTNE_TABLE_ENTRY *normalTable[L2_NORMAL_RTNE_PERIOD] =
|
||||||
{
|
{
|
||||||
normalSub
|
innerScanSubT
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @} RoutineTable*/
|
/** @} RoutineTable*/
|
||||||
|
|||||||
@@ -39,66 +39,8 @@
|
|||||||
/************************** Variable Definitions *****************************/
|
/************************** Variable Definitions *****************************/
|
||||||
|
|
||||||
/************************** Function Prototypes ******************************/
|
/************************** Function Prototypes ******************************/
|
||||||
static void AdvRecvStateUpdate(L2_SCAN_FSM *scanFsmPtr, bool state);
|
|
||||||
|
|
||||||
static int32_t Scan_AdvHandler(L2_INST *instPtr);
|
|
||||||
|
|
||||||
static int32_t ScanMsg_Packing(L2_INST *instPtr, L2_FRAME_TYPE type, uint8_t dstId);
|
static int32_t ScanMsg_Packing(L2_INST *instPtr, L2_FRAME_TYPE type, uint8_t dstId);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Update Base-info Advertisement state.
|
|
||||||
*/
|
|
||||||
static void AdvRecvStateUpdate(L2_SCAN_FSM *scanFsmPtr, bool state)
|
|
||||||
{
|
|
||||||
ASSERT(scanFsmPtr != NULL);
|
|
||||||
DBG_INFO("Update AdvRecvState from [%" PRId8 "] to [%" PRId8 "].\n",
|
|
||||||
scanFsmPtr->isAdvRecvd, state);
|
|
||||||
scanFsmPtr->isAdvRecvd = state;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/**
|
|
||||||
* @brief Member node scan net BmAdvt stage handler.
|
|
||||||
*
|
|
||||||
* @param scanFsmPtr A pointer to scan net fsm.
|
|
||||||
*
|
|
||||||
* @return used slot (2 ms slot).
|
|
||||||
*
|
|
||||||
******************************************************************************/
|
|
||||||
static int32_t Scan_AdvHandler(L2_INST *instPtr)
|
|
||||||
{
|
|
||||||
ASSERT(instPtr != NULL);
|
|
||||||
L2_SCAN_FSM *scanFsmPtr = instPtr->scanFSM;
|
|
||||||
PHY_INST *phyRef = instPtr->config.phyInstPtr;
|
|
||||||
TMC_INST *tmcRef = instPtr->config.tmcInstPtr;
|
|
||||||
DBG_INFO("** Net-Setup - Advertisement Procedure (Attempts: %" PRIu8 ") **\n", scanFsmPtr->advCnt);
|
|
||||||
|
|
||||||
// if received a valid bm frame.
|
|
||||||
if (scanFsmPtr->isAdvRecvd == true)
|
|
||||||
{
|
|
||||||
// antenna index from listening state
|
|
||||||
scanFsmPtr->antIndex = Phy_ListenAntIndex(phyRef);
|
|
||||||
|
|
||||||
// start a acknowledge frame reception if in the target slot
|
|
||||||
if ((TimeCtrl_GetIntCnt(tmcRef) + 1) % ACK_FRAME_SLOTS == 0) // FIXME: correct?
|
|
||||||
{
|
|
||||||
// using pull mode to transmit confirm frame
|
|
||||||
// since first time sync procedure is accomplished in ADV stage.
|
|
||||||
(void)Phy_SetAntIndex(phyRef, scanFsmPtr->antIndex);
|
|
||||||
(void)Phy_SetMode(phyRef, PHY_MODE_POLL);
|
|
||||||
(void)L2_SetupNextSlot(instPtr, L2_TOR_TX, L2_FRAME_ACK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// no valid bm frame was received.
|
|
||||||
else
|
|
||||||
{
|
|
||||||
(void)L2_SetupNextSlot(instPtr, L2_TOR_RX, L2_FRAME_ADV);
|
|
||||||
scanFsmPtr->advCnt++;
|
|
||||||
}
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/**
|
/**
|
||||||
* @brief Packing Scan message to a bit array.
|
* @brief Packing Scan message to a bit array.
|
||||||
@@ -115,89 +57,100 @@ static int32_t ScanMsg_Packing(L2_INST *instPtr, L2_FRAME_TYPE type, uint8_t dst
|
|||||||
ASSERT(instPtr != NULL);
|
ASSERT(instPtr != NULL);
|
||||||
int32_t Status;
|
int32_t Status;
|
||||||
uint32_t dataChunk;
|
uint32_t dataChunk;
|
||||||
uint8_t *buff = instPtr->sendPktData;
|
if ((type < L2_FRAME_ADV) || (type > L2_FRAME_ACK))
|
||||||
if ((type < L2_ADV_FRAME) || (type > L2_CFM_FRAME))
|
|
||||||
{
|
{
|
||||||
DBG_ERROR("Unexpected frame type: %" PRId8 ".\n", type);
|
DBG_ERROR("Unexpected frame type: %" PRId8 ".\n", type);
|
||||||
return EPARAM;
|
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);
|
|
||||||
L2_FrameInsertChunk(buff, L2_MSG_SLOT_NUM, L2_MSG_SLOT_NUM_LEN, &dataChunk);
|
|
||||||
dataChunk = L2_GetNodeId(instPtr);
|
|
||||||
L2_FrameInsertChunk(buff, L2_MSG_SRC_ID, L2_MSG_SRC_ID_LEN, &dataChunk);
|
|
||||||
dataChunk = dstId;
|
|
||||||
L2_FrameInsertChunk(buff, L2_MSG_DST_ID, L2_MSG_DST_ID_LEN, &dataChunk);
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case L2_FRAME_ADV:
|
case L2_FRAME_ADV:
|
||||||
{
|
{
|
||||||
dataChunk = L2_FRAME_ADV;
|
L2_MSG_ADV *message = calloc(sizeof(L2_MSG_ADV));
|
||||||
L2_FrameInsertChunk(buff, L2_MSG_TYPE, L2_MSG_TYPE_LEN, &dataChunk);
|
|
||||||
|
// Common section of link layer package
|
||||||
|
message->common->frameNum = L2_GetNextFrameNum(instPtr);
|
||||||
|
message->common->slotNum = L2_GetNextSlotNum(instPtr);
|
||||||
|
message->common->src = L2_GetNodeId(instPtr);
|
||||||
|
message->common->dst = dstId;
|
||||||
|
message->common->msgType = L2_FRAME_ADV;
|
||||||
|
|
||||||
SysMonitor_GetSysinfo(&(instPtr->sysInfo));
|
|
||||||
// insert position and speed info
|
// insert position and speed info
|
||||||
L2_FrameInsertChunk(buff, L2_MSG_ADV_SRC_POSX, L2_MSG_ADV_SRC_POSX_LEN, &(instPtr->sysInfo.posX));
|
SysMonitor_GetSysinfo(&(instPtr->sysInfo));
|
||||||
L2_FrameInsertChunk(buff, L2_MSG_ADV_SRC_POSY, L2_MSG_ADV_SRC_POSY_LEN, &(instPtr->sysInfo.posY));
|
message->srcPosX = &(instPtr->sysInfo.posX);
|
||||||
L2_FrameInsertChunk(buff, L2_MSG_ADV_SRC_POSZ, L2_MSG_ADV_SRC_POSZ_LEN, &(instPtr->sysInfo.posZ));
|
message->srcPosY = &(instPtr->sysInfo.posY);
|
||||||
|
message->srcPosZ = &(instPtr->sysInfo.posZ);
|
||||||
|
|
||||||
// Insert net start time
|
// Insert net start time
|
||||||
L2_FrameInsertChunk(buff, L2_MSG_ADV_SRC_NETSTART_TIME, L2_MSG_ADV_SRC_NETSTART_TIME_LEN, &(instPtr->netStartTime));
|
message->srcNetStatTime = &(instPtr->netStartTime);
|
||||||
|
|
||||||
|
// Packing extra payload
|
||||||
|
SysMonitor_GetSendPayload(message->advData, message->advDataId, L2_PAYLOAD_LEN_ADV);
|
||||||
|
if (message->ackDataId == DATA_ID_NONE)
|
||||||
|
{
|
||||||
|
memset(message->ackData, 0xAA, L2_PAYLOAD_LEN_ADV);
|
||||||
|
}
|
||||||
|
|
||||||
// Append CRC
|
// Append CRC
|
||||||
Status = L2_CrcAppend(buff, L2_ADV_PACK_LEN - L2_MSG_ADV_SVC_CRC_LEN, L2_MSG_ADV_SVC_CRC, L2_CRC16_1021);
|
uint32_t crcVal;
|
||||||
|
Status = L2_CrcGen(message, Phy_GetFrameLen(L2_L2frame2L1frame(L2_FRAME_ADV)) - L2_MSG_CRC_LEN, L2_CRC8_31, &crcVal);
|
||||||
if (Status != SUCCESS)
|
if (Status != SUCCESS)
|
||||||
{
|
{
|
||||||
DBG_ERROR("Fail to append CRC, error code: %" PRId32 ".\n", Status);
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
message->crc = crcVal;
|
||||||
|
|
||||||
|
instPtr->sendPktData = message;
|
||||||
|
|
||||||
|
// Logging...
|
||||||
|
memcpy(instPtr->log.txLog.data, message, Phy_GetFrameLen(L2_L2frame2L1frame(L2_FRAME_ADV)));
|
||||||
|
instPtr->log.txLog.dataId = message->ackDataId;
|
||||||
|
|
||||||
|
free(message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case L2_FRAME_ACK:
|
case L2_FRAME_ACK:
|
||||||
{
|
{
|
||||||
dataChunk = L2_FRAME_ACK;
|
L2_MSG_ACK *message = calloc(sizeof(L2_MSG_ACK));
|
||||||
L2_FrameInsertChunk(buff, L2_MSG_TYPE, L2_MSG_TYPE_LEN, &dataChunk);
|
|
||||||
|
// Common section of link layer package
|
||||||
|
message->common->frameNum = L2_GetNextFrameNum(instPtr);
|
||||||
|
message->common->slotNum = L2_GetNextSlotNum(instPtr);
|
||||||
|
message->common->src = L2_GetNodeId(instPtr);
|
||||||
|
message->common->dst = dstId;
|
||||||
|
message->common.msgType = L2_FRAME_ADV;
|
||||||
|
|
||||||
SysMonitor_GetSysinfo(&(instPtr->sysInfo));
|
|
||||||
// insert position and speed info
|
// insert position and speed info
|
||||||
L2_FrameInsertChunk(buff, L2_MSG_CFM_SRC_POSX, L2_MSG_CFM_SRC_POSX_LEN, &(instPtr->sysInfo.posX));
|
SysMonitor_GetSysinfo(&(instPtr->sysInfo));
|
||||||
L2_FrameInsertChunk(buff, L2_MSG_CFM_SRC_POSY, L2_MSG_CFM_SRC_POSY_LEN, &(instPtr->sysInfo.posY));
|
message->srcPosX = &(instPtr->sysInfo.posX);
|
||||||
L2_FrameInsertChunk(buff, L2_MSG_CFM_SRC_POSZ, L2_MSG_CFM_SRC_POSZ_LEN, &(instPtr->sysInfo.posZ));
|
message->srcPosY = &(instPtr->sysInfo.posY);
|
||||||
L2_FrameInsertChunk(buff, L2_MSG_CFM_SRC_SPEEDX, L2_MSG_CFM_SRC_SPEEDX_LEN, &(instPtr->sysInfo.vX));
|
message->srcPosZ = &(instPtr->sysInfo.posZ);
|
||||||
L2_FrameInsertChunk(buff, L2_MSG_CFM_SRC_SPEEDY, L2_MSG_CFM_SRC_SPEEDY_LEN, &(instPtr->sysInfo.vY));
|
message->srcSpeedX = &(instPtr->&(instPtr->sysInfo.vX));
|
||||||
L2_FrameInsertChunk(buff, L2_MSG_CFM_SRC_SPEEDZ, L2_MSG_CFM_SRC_SPEEDZ_LEN, &(instPtr->sysInfo.vZ));
|
message->srcSpeedY = &(instPtr->&(instPtr->sysInfo.vY));
|
||||||
|
message->srcSpeedZ = &(instPtr->&(instPtr->sysInfo.vZ));
|
||||||
|
|
||||||
// Packing extra payload
|
// Packing extra payload
|
||||||
uint32_t dataId;
|
SysMonitor_GetSendPayload(message->ackData, message->ackDataId, L2_PAYLOAD_LEN_ACK);
|
||||||
if (L2_GetNodeType(instPtr) == L2_NODE_HEAD)
|
if (message->ackDataId == DATA_ID_NONE)
|
||||||
{
|
{
|
||||||
SysMonitor_GetSendPayload(buff + L2_MSG_CFM_PAYLOAD, &dataId, PAYLOAD_LEN_FLJ_TX);
|
memset(message->ackData, 0xAA, L2_PAYLOAD_LEN_ACK);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SysMonitor_GetSendPayload(buff + L2_MSG_CFM_PAYLOAD, &dataId, PAYLOAD_LEN_LJ_TX);
|
|
||||||
}
|
|
||||||
|
|
||||||
L2_FrameInsertChunk(buff, L2_MSG_CFM_PAYLOAD_ID, L2_MSG_CFM_PAYLOAD_ID_LEN, &dataId);
|
|
||||||
if (dataId == DATA_ID_NONE)
|
|
||||||
{
|
|
||||||
memset(buff + L2_MSG_CFM_PAYLOAD, 0xAA, L2_MSG_CFM_PAYLOAD_LEN);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append CRC
|
// Append CRC
|
||||||
Status = L2_CrcAppend(buff, L2_CMF_PACK_LEN - L2_MSG_CFM_CRC_LEN, L2_MSG_CFM_CRC, L2_CRC16_1021);
|
uint32_t crcVal;
|
||||||
|
Status = L2_CrcGen(message, Phy_GetFrameLen(L2_L2frame2L1frame(L2_FRAME_ACK)) - L2_MSG_CRC_LEN, L2_CRC8_31, &crcVal);
|
||||||
if (Status != SUCCESS)
|
if (Status != SUCCESS)
|
||||||
{
|
{
|
||||||
DBG_ERROR("Fail to append CRC, error code: %" PRId32 ".\n", Status);
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
message->crc = crcVal;
|
||||||
|
|
||||||
// Logging...
|
// Logging...
|
||||||
memcpy(instPtr->log.txLog.data, buff, L2_CMF_PACK_LEN);
|
memcpy(instPtr->log.txLog.data, message, Phy_GetFrameLen(L2_L2frame2L1frame(L2_FRAME_ACK)));
|
||||||
instPtr->log.txLog.dataId = dataId;
|
instPtr->log.txLog.dataId = message->ackDataId;
|
||||||
|
|
||||||
|
free(message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@@ -224,7 +177,6 @@ int32_t L2_Scan_PktHandler(L2_INST *instPtr, uint8_t *msg)
|
|||||||
ASSERT(instPtr != NULL);
|
ASSERT(instPtr != NULL);
|
||||||
ASSERT(msg != NULL);
|
ASSERT(msg != NULL);
|
||||||
int32_t Status;
|
int32_t Status;
|
||||||
L2_SCAN_FSM *scanFsmPtr = instPtr->scanFSM;
|
|
||||||
L2_FRAME_TYPE frameType = L2_FRAME_NONE;
|
L2_FRAME_TYPE frameType = L2_FRAME_NONE;
|
||||||
L2_FrameGetChunk(msg, L2_MSG_TYPE, L2_MSG_TYPE_LEN, &frameType);
|
L2_FrameGetChunk(msg, L2_MSG_TYPE, L2_MSG_TYPE_LEN, &frameType);
|
||||||
|
|
||||||
@@ -292,17 +244,6 @@ int32_t L2_Scan_PktHandler(L2_INST *instPtr, uint8_t *msg)
|
|||||||
.msg = NULL
|
.msg = NULL
|
||||||
};
|
};
|
||||||
(void)AssertL2Event(instPtr, &l2Event);
|
(void)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);
|
|
||||||
(void)AssertL2Event(instPtr, &rtneUpEvent);
|
|
||||||
}
|
}
|
||||||
// Time sync.
|
// Time sync.
|
||||||
L2_TimeAdjust(instPtr, &(instPtr->log.timeDev));
|
L2_TimeAdjust(instPtr, &(instPtr->log.timeDev));
|
||||||
@@ -315,8 +256,6 @@ int32_t L2_Scan_PktHandler(L2_INST *instPtr, uint8_t *msg)
|
|||||||
memcpy(instPtr->log.rxLog.data, msg, Phy_GetFrameLen(L2_L2frame2L1frame(L2_FRAME_ADV, L2_SVC_NONE)));
|
memcpy(instPtr->log.rxLog.data, msg, Phy_GetFrameLen(L2_L2frame2L1frame(L2_FRAME_ADV, L2_SVC_NONE)));
|
||||||
instPtr->log.rxLog.dataId = dataId;
|
instPtr->log.rxLog.dataId = dataId;
|
||||||
|
|
||||||
// trigger flag
|
|
||||||
AdvRecvStateUpdate(scanFsmPtr, true);
|
|
||||||
Status = SUCCESS;
|
Status = SUCCESS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -352,6 +291,7 @@ int32_t L2_Scan_PktHandler(L2_INST *instPtr, uint8_t *msg)
|
|||||||
node->nodeInfo.speed.x = message->srcSpeedX;
|
node->nodeInfo.speed.x = message->srcSpeedX;
|
||||||
node->nodeInfo.speed.y = message->srcSpeedY;
|
node->nodeInfo.speed.y = message->srcSpeedY;
|
||||||
node->nodeInfo.speed.z = message->srcSpeedZ;
|
node->nodeInfo.speed.z = message->srcSpeedZ;
|
||||||
|
node->nodeInfo.antIndex = Phy_ListenAntIndex(instPtr->config.phyInstPtr);
|
||||||
|
|
||||||
// Reset node ttl
|
// Reset node ttl
|
||||||
node->ttlCnt = 0;
|
node->ttlCnt = 0;
|
||||||
@@ -395,29 +335,6 @@ int32_t L2_Scan_PktHandler(L2_INST *instPtr, uint8_t *msg)
|
|||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/**
|
|
||||||
* @brief Initialize scan FSM.
|
|
||||||
*
|
|
||||||
* @param instPtr
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*
|
|
||||||
******************************************************************************/
|
|
||||||
int32_t L2_Scan_Init(L2_SCAN_FSM **scanFSMPtr)
|
|
||||||
{
|
|
||||||
ASSERT(scanFSMPtr != NULL);
|
|
||||||
*scanFSMPtr = (L2_SCAN_FSM *)malloc(sizeof(L2_SCAN_FSM));
|
|
||||||
if (*scanFSMPtr == NULL)
|
|
||||||
{
|
|
||||||
DBG_ERROR("Failed to allocate memory for scanFsmPtr.\n");
|
|
||||||
return ENOMEM;
|
|
||||||
}
|
|
||||||
L2_Scan_Reset(*scanFSMPtr);
|
|
||||||
(*scanFSMPtr)->antIndex = 0;
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/**
|
/**
|
||||||
* @brief Reset ScanNet FSM
|
* @brief Reset ScanNet FSM
|
||||||
@@ -451,31 +368,6 @@ void L2_Scan_Destroy(L2_SCAN_FSM *scanFSMPtr)
|
|||||||
free(scanFSMPtr);
|
free(scanFSMPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/**
|
|
||||||
* @brief Execute a member node scan net procedure.
|
|
||||||
*
|
|
||||||
* @param instPtr a pointer to linklayer layer instance
|
|
||||||
*
|
|
||||||
* @return used slot (2 ms slot).
|
|
||||||
*
|
|
||||||
******************************************************************************/
|
|
||||||
int32_t L2_Scan_Proc(L2_INST *instPtr)
|
|
||||||
{
|
|
||||||
L2_SCAN_FSM *scanFSM = instPtr->scanFSM;
|
|
||||||
if (L2_GetNodeType(instPtr) == L2_NODE_HEAD)
|
|
||||||
{
|
|
||||||
DBG_ERROR("Only member node needs to execute L2_Scan_Proc. \n");
|
|
||||||
return FAILURE;
|
|
||||||
}
|
|
||||||
int32_t Status;
|
|
||||||
DBG_INFO("-------- ScanNet Process --------\n");
|
|
||||||
|
|
||||||
Status = Scan_AdvHandler(instPtr);
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -508,7 +400,6 @@ int32_t L2_Scan_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *rtneEntry)
|
|||||||
antIndex = L2_AntId2AntIndex(rtneEntry->dst); // antenna selection based on broadcast id in routing table
|
antIndex = L2_AntId2AntIndex(rtneEntry->dst); // antenna selection based on broadcast id in routing table
|
||||||
torState = L2_TOR_TX; // head node transmits messages in advertise slot
|
torState = L2_TOR_TX; // head node transmits messages in advertise slot
|
||||||
|
|
||||||
memset(instPtr->sendPktData, 0xAA, L2_PACK_LEN_MAX);
|
|
||||||
if (ScanMsg_Packing(instPtr, L2_FRAME_ADV, rtneEntry->dst) != SUCCESS)
|
if (ScanMsg_Packing(instPtr, L2_FRAME_ADV, rtneEntry->dst) != SUCCESS)
|
||||||
{
|
{
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
@@ -540,7 +431,6 @@ int32_t L2_Scan_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *rtneEntry)
|
|||||||
antIndex = commNode->nodeInfo.antIndex; // antenna selection based on node list
|
antIndex = commNode->nodeInfo.antIndex; // antenna selection based on node list
|
||||||
torState = L2_TOR_TX; // member node transmits message in acknowledge slot
|
torState = L2_TOR_TX; // member node transmits message in acknowledge slot
|
||||||
|
|
||||||
memset(instPtr->sendPktData, 0xAA, L2_PACK_LEN_MAX);
|
|
||||||
if (ScanMsg_Packing(instPtr, L2_FRAME_ACK, rtneEntry->dst) != SUCCESS)
|
if (ScanMsg_Packing(instPtr, L2_FRAME_ACK, rtneEntry->dst) != SUCCESS)
|
||||||
{
|
{
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
|
|||||||
@@ -333,6 +333,8 @@ void Phy_SetRxAntIndex(PHY_INST *instPtr, PHY_ANT_INDEX antRxIndex)
|
|||||||
{
|
{
|
||||||
ASSERT(instPtr != NULL);
|
ASSERT(instPtr != NULL);
|
||||||
|
|
||||||
|
if (instPtr->antConfig.antControl.antMode == ANT_MODE_RX_AJ)
|
||||||
|
{
|
||||||
switch (antRxIndex)
|
switch (antRxIndex)
|
||||||
{
|
{
|
||||||
case PHY_ANT_INDEX_1:
|
case PHY_ANT_INDEX_1:
|
||||||
@@ -357,6 +359,13 @@ void Phy_SetRxAntIndex(PHY_INST *instPtr, PHY_ANT_INDEX antRxIndex)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
instPtr->antConfig.antControl.antRx1En = ANT_DISABLE;
|
||||||
|
instPtr->antConfig.antControl.antRx2En = ANT_DISABLE;
|
||||||
|
instPtr->antConfig.antControl.antRx3En = ANT_DISABLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
#define PHY_TIME_WORD_H_MAX UINT32_MAX
|
#define PHY_TIME_WORD_H_MAX UINT32_MAX
|
||||||
#define PHY_TIME_WORD_L_MAX 0x0007A120 // 5ms/10ns
|
#define PHY_TIME_WORD_L_MAX 200000U // 2 ms/10 ns
|
||||||
|
|
||||||
#define L1_FRAME_LEN_MAX (16384 / 8) // byte
|
#define L1_FRAME_LEN_MAX (16384 / 8) // byte
|
||||||
#define L1_FRAME_ADV_24MS_LEN (520 / 8) // byte
|
#define L1_FRAME_ADV_24MS_LEN (520 / 8) // byte
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
#define L1_FRAME_128KBPS_4MS_HOPS 33U
|
#define L1_FRAME_128KBPS_4MS_HOPS 33U
|
||||||
#define L1_FRAME_512KBPS_4MS_HOPS 36U
|
#define L1_FRAME_512KBPS_4MS_HOPS 36U
|
||||||
#define L1_FRAME_2MBPS_4MS_HOPS 38U
|
#define L1_FRAME_2MBPS_4MS_HOPS 38U
|
||||||
#define PHY_LOG_EXPIRE 40U // 50*5ms
|
#define PHY_LOG_EXPIRE 50U // number of 2 ms slot
|
||||||
/** @} */
|
/** @} */
|
||||||
/***************** Macros (Inline Functions) Definitions *********************/
|
/***************** Macros (Inline Functions) Definitions *********************/
|
||||||
/**************************** Type Definitions *******************************/
|
/**************************** Type Definitions *******************************/
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ void TimeCtrl_ResetLow(TMC_INST *instPtr)
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/**
|
/**
|
||||||
* @brief Get current time integer value.
|
* @brief Get current time integer value (2 ms counter).
|
||||||
*
|
*
|
||||||
* @param instPtr a pointer to time controller instance
|
* @param instPtr a pointer to time controller instance
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
/***************************** Include Files *********************************/
|
/***************************** Include Files *********************************/
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
/************************** Constant Definitions *****************************/
|
/************************** Constant Definitions *****************************/
|
||||||
#define TIME_FRAC_MAX 500000 // how many 10ns in a 5ms
|
#define TIME_FRAC_MAX 200000 // how many 10ns in a 2 ms
|
||||||
/***************** Macros (Inline Functions) Definitions *********************/
|
/***************** Macros (Inline Functions) Definitions *********************/
|
||||||
/**************************** Type Definitions *******************************/
|
/**************************** Type Definitions *******************************/
|
||||||
/**
|
/**
|
||||||
@@ -44,7 +44,7 @@ typedef uint32_t TIME_INT;
|
|||||||
*/
|
*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
TIME_INT int_part; ///< 5ms each LSB
|
TIME_INT int_part; ///< 2 ms each LSB
|
||||||
TIME_FRAC frac_part; ///< 10 ns each LSB
|
TIME_FRAC frac_part; ///< 10 ns each LSB
|
||||||
} TIME_WORD;
|
} TIME_WORD;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user