From 9518515748263c783284aaa390db70fe0f4bb2b5 Mon Sep 17 00:00:00 2001 From: Gatsby Van Date: Wed, 20 Dec 2023 19:39:49 +0800 Subject: [PATCH] add utility functions and update comment. --- datalink814_ge/src/linklayer/linklayer814.c | 91 ++++++++++++++++++++- 1 file changed, 89 insertions(+), 2 deletions(-) diff --git a/datalink814_ge/src/linklayer/linklayer814.c b/datalink814_ge/src/linklayer/linklayer814.c index f5be3e4..e34996f 100644 --- a/datalink814_ge/src/linklayer/linklayer814.c +++ b/datalink814_ge/src/linklayer/linklayer814.c @@ -87,7 +87,42 @@ static inline void L2_DataAvailUpdate(L2_INST* instPtr, bool status) { instPtr->dataAvail = status; } -L2_NODE_STATE L2_GetMainState(L2_INST* instPtr){ +/** + * @brief Get the current node ID. + */ +inline uint8_t L2_GetNodeId(L2_INST* instPtr){ + ASSERT(instPtr != NULL); + return instPtr->myInfo.nodeId; +} + +/** + * @brief Get the current cluster ID. + */ +inline uint8_t L2_GetClusterId(L2_INST* instPtr){ + ASSERT(instPtr != NULL); + return instPtr->myInfo.clustId; +} + +/** + * @brief Get the head node ID. + */ +uint8_t L2_GetHeadId(L2_INST* instPtr){ + ASSERT(instPtr != NULL); + return instPtr->myInfo.headId; +} + +/** + * @brief Get the current node type. + */ +inline L2_NODE_TYPE L2_GetNodeType(L2_INST* instPtr){ + ASSERT(instPtr != NULL); + return instPtr->myInfo.nodeType; +} + +/** + * @brief Get the current linklayer state. + */ +inline L2_NODE_STATE L2_GetMainState(L2_INST* instPtr){ ASSERT(instPtr != NULL); return instPtr->mainState; } @@ -124,6 +159,22 @@ inline uint32_t L2_GetLastSlotNum(L2_INST* instPtr) { return instPtr->slotNum.last; } +/** + * @brief Get the frame type of last slot. + */ +inline L2_FRAME_TYPE L2_GetLastFrameType(L2_INST* instPtr) { + ASSERT(instPtr != NULL); + return instPtr->frame.last; +} + +/** + * @brief Get the tx/rx state of last slot. + */ +inline L2_TOR_TYPE L2_GetLastTor(L2_INST* instPtr) { + ASSERT(instPtr != NULL); + return instPtr->tor.last; +} + /** * @brief Get current frame number. */ @@ -140,6 +191,22 @@ inline uint32_t L2_GetCurrentSlotNum(L2_INST* instPtr) { return instPtr->slotNum.curr; } +/** + * @brief Get the frame type of current slot. + */ +inline L2_FRAME_TYPE L2_GetCurrentFrameType(L2_INST* instPtr) { + ASSERT(instPtr != NULL); + return instPtr->frame.curr; +} + +/** + * @brief Get the tx/rx state of current slot. + */ +inline L2_TOR_TYPE L2_GetCurrentTor(L2_INST* instPtr) { + ASSERT(instPtr != NULL); + return instPtr->tor.curr; +} + /** * @brief Get next frame number. */ @@ -155,11 +222,31 @@ inline uint32_t L2_GetNextSlotNum(L2_INST* instPtr) { return instPtr->slotNum.next; } +/** + * @brief Get the frame type of next slot. + */ +inline L2_FRAME_TYPE L2_GetNextFrameType(L2_INST* instPtr) { + ASSERT(instPtr != NULL); + return instPtr->frame.next; +} + +/** + * @brief Get the tx/rx state of next slot. + */ +inline L2_TOR_TYPE L2_GetNextTor(L2_INST* instPtr) { + ASSERT(instPtr != NULL); + return instPtr->tor.next; +} + // TODO: Multi-node RTT -inline L2_RTT_FSM* L2_GetRttDesc(L2_INST* instPtr){ +/** + * @brief Get the RTT FSM. + */ +inline L2_RTT_FSM* L2_GetRttFsm(L2_INST* instPtr){ ASSERT(instPtr != NULL); return instPtr->rttFSM; } + /*****************************************************************************/ /** * @brief Creat a new schedule envent, register event in schedule event pool.