add utility functions and update comment.

This commit is contained in:
Gatsby Van
2023-12-20 19:39:49 +08:00
parent fe89eb3b90
commit 9518515748
+89 -2
View File
@@ -87,7 +87,42 @@ static inline void L2_DataAvailUpdate(L2_INST* instPtr, bool status) {
instPtr->dataAvail = 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); ASSERT(instPtr != NULL);
return instPtr->mainState; return instPtr->mainState;
} }
@@ -124,6 +159,22 @@ inline uint32_t L2_GetLastSlotNum(L2_INST* instPtr) {
return instPtr->slotNum.last; 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. * @brief Get current frame number.
*/ */
@@ -140,6 +191,22 @@ inline uint32_t L2_GetCurrentSlotNum(L2_INST* instPtr) {
return instPtr->slotNum.curr; 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. * @brief Get next frame number.
*/ */
@@ -155,11 +222,31 @@ inline uint32_t L2_GetNextSlotNum(L2_INST* instPtr) {
return instPtr->slotNum.next; 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 // 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); ASSERT(instPtr != NULL);
return instPtr->rttFSM; return instPtr->rttFSM;
} }
/*****************************************************************************/ /*****************************************************************************/
/** /**
* @brief Creat a new schedule envent, register event in schedule event pool. * @brief Creat a new schedule envent, register event in schedule event pool.