rearrange and remove redundant code

This commit is contained in:
Gatsby Van
2024-01-25 12:13:02 +08:00
parent 966148ebef
commit 452df8ad81
3 changed files with 31 additions and 34 deletions
+22 -1
View File
@@ -32,6 +32,27 @@
#endif #endif
/************************** Constant Definitions *****************************/ /************************** Constant Definitions *****************************/
#define L1_FRAME_LEN_MAX (8192 / 8) // byte
#define L1_FRAME_2KBPS_20MS_LEN 0 // byte
#define L1_FRAME_2KBPS_100MS_LEN (312 / 8) // byte
#define L1_FRAME_10KBPS_10MS_LEN 0 // byte
#define L1_FRAME_10KBPS_20MS_LEN (232 / 8) // byte
#define L1_FRAME_40KBPS_20MS_LEN (2152 / 8) // byte
#define L1_FRAME_40KBPS_10MS_LEN (712 / 8) // byte
#define L1_FRAME_200KBPS_5MS_LEN (2040 / 8) // byte
#define L1_FRAME_1M2BPS_5MS_LEN (8176 / 8) // byte
#define L1_FRAME_2KBPS_20MS_COMP 1841158 // *10ns(Timer_L)
#define L1_FRAME_2KBPS_100MS_COMP 1841158 // *10ns(Timer_L)
#define L1_FRAME_10KBPS_10MS_COMP 850950 // *10ns(Timer_L)
#define L1_FRAME_10KBPS_20MS_COMP 850950 // *10ns(Timer_L)
#define L1_FRAME_40KBPS_20MS_COMP 110667 // *10ns(Timer_L)
#define L1_FRAME_40KBPS_10MS_COMP 110667 // *10ns(Timer_L)
#define L1_FRAME_200KBPS_5MS_COMP 22493 // *10ns(Timer_L)
#define L1_FRAME_1M2BPS_5MS_COMP 22493 // *10ns(Timer_L)
#define L1_ANTCONFIG_MAX_LEN 8192
/***************** Macros (Inline Functions) Definitions *********************/ /***************** Macros (Inline Functions) Definitions *********************/
/************************** Function Prototypes ******************************/ /************************** Function Prototypes ******************************/
static void Phy_RcdShift(PHY_RCD *rcd, int32_t netxVal); static void Phy_RcdShift(PHY_RCD *rcd, int32_t netxVal);
@@ -905,7 +926,7 @@ int32_t Phy_SetHopPattern(void *patternBuff, uint32_t patternLen)
int32_t Phy_SetTimeWord(PHY_INST *instPtr, const TIME_WORD *tmWord, PHY_TIME_WORD_TYPE tmType) int32_t Phy_SetTimeWord(PHY_INST *instPtr, const TIME_WORD *tmWord, PHY_TIME_WORD_TYPE tmType)
{ {
ASSERT(instPtr != NULL); ASSERT(instPtr != NULL);
if (tmWord->frac_part >= PHY_TIME_WORD_L_MAX) if (tmWord->frac_part >= TIME_FRAC_MAX)
{ {
return EPARAM; return EPARAM;
} }
+3 -27
View File
@@ -28,16 +28,16 @@
#include "../common.h" #include "../common.h"
#include "../time_ctrl/time_ctrl.h" #include "../time_ctrl/time_ctrl.h"
/************************** Constant Definitions *****************************/ /************************** Constant Definitions *****************************/
#define L1_TMWORD_FRAC_MAX 500000
#define L1_ANTCONFIG_MAX_LEN 8192
#define L1_TXRXDATA_MAX_LEN 2048
#define L1_NUM_ANT_SUBNRRW_PATTERN 37 #define L1_NUM_ANT_SUBNRRW_PATTERN 37
#define L1_NUM_ANT_NRRW_PATTERN 61 #define L1_NUM_ANT_NRRW_PATTERN 61
#define L1_INIT_BEAM_NO 0 #define L1_INIT_BEAM_NO 0
#define L1_INIT_ANT_WD PHY_ANT_BEAM_120 #define L1_INIT_ANT_WD PHY_ANT_BEAM_120
#define L1_INIT_ANT_NO 0 #define L1_INIT_ANT_NO 0
#define L1_FRAME_NONE_LEN UINT32_MAX // byte
#define L1_FRAME_NONE_COMP UINT32_MAX // *10ns(Timer_L)
#define L1_FRAME_NONE_HOPS UINT32_MAX #define L1_FRAME_NONE_HOPS UINT32_MAX
#define L1_TXRXDATA_MAX_LEN 2048
#define L1_FRAME_MAX_HOPS 81 #define L1_FRAME_MAX_HOPS 81
#define L1_FRAME_2KBPS_20MS_HOPS 1 #define L1_FRAME_2KBPS_20MS_HOPS 1
#define L1_FRAME_2KBPS_100MS_HOPS 81 #define L1_FRAME_2KBPS_100MS_HOPS 81
@@ -48,30 +48,6 @@
#define L1_FRAME_200KBPS_5MS_HOPS 20 #define L1_FRAME_200KBPS_5MS_HOPS 20
#define L1_FRAME_1M2BPS_5MS_HOPS 20 #define L1_FRAME_1M2BPS_5MS_HOPS 20
#define L1_FRAME_NONE_LEN UINT32_MAX // byte
#define L1_FRAME_LEN_MAX (8192 / 8) // byte
#define L1_FRAME_2KBPS_20MS_LEN 0 // byte
#define L1_FRAME_2KBPS_100MS_LEN 312 / 8 // byte
#define L1_FRAME_10KBPS_10MS_LEN 0 // byte
#define L1_FRAME_10KBPS_20MS_LEN (232 / 8) // byte
#define L1_FRAME_40KBPS_20MS_LEN (2152 / 8) // byte
#define L1_FRAME_40KBPS_10MS_LEN (712 / 8) // byte
#define L1_FRAME_200KBPS_5MS_LEN (2040 / 8) // byte
#define L1_FRAME_1M2BPS_5MS_LEN (8176 / 8) // byte
#define L1_FRAME_NONE_COMP UINT32_MAX // *10ns(Timer_L)
#define L1_FRAME_2KBPS_20MS_COMP 1841158 // *10ns(Timer_L)
#define L1_FRAME_2KBPS_100MS_COMP 1841158 // *10ns(Timer_L)
#define L1_FRAME_10KBPS_10MS_COMP 850950 // *10ns(Timer_L)
#define L1_FRAME_10KBPS_20MS_COMP 850950 // *10ns(Timer_L)
#define L1_FRAME_40KBPS_20MS_COMP 110667 // *10ns(Timer_L)
#define L1_FRAME_40KBPS_10MS_COMP 110667 // *10ns(Timer_L)
#define L1_FRAME_200KBPS_5MS_COMP 22493 // *10ns(Timer_L)
#define L1_FRAME_1M2BPS_5MS_COMP 22493 // *10ns(Timer_L)
#define PHY_TIME_WORD_H_MAX UINT32_MAX
#define PHY_TIME_WORD_L_MAX 0x0007A120 // 5ms/10ns
/***************** Macros (Inline Functions) Definitions *********************/ /***************** Macros (Inline Functions) Definitions *********************/
/**************************** Type Definitions *******************************/ /**************************** Type Definitions *******************************/
+6 -6
View File
@@ -524,8 +524,8 @@ int32_t InterComm_MsgHandler(INTER_COMM_INST* instPtr){
else{ else{
tmWord.frac_part += (uint32_t)(timeTemp); tmWord.frac_part += (uint32_t)(timeTemp);
tmWord.int_part += (uint32_t)(timeTemp>>32); tmWord.int_part += (uint32_t)(timeTemp>>32);
tmWord.int_part = (tmWord.frac_part >= L1_TMWORD_FRAC_MAX) ? tmWord.int_part + 1:tmWord.int_part; tmWord.int_part = (tmWord.frac_part >= TIME_FRAC_MAX) ? tmWord.int_part + 1:tmWord.int_part;
tmWord.frac_part %= L1_TMWORD_FRAC_MAX; tmWord.frac_part %= TIME_FRAC_MAX;
Status = Phy_SetTimeWord(instPtr->phyInstPtr, &tmWord, PHY_TIME_WORD_LISTEN_TIMEOUT); Status = Phy_SetTimeWord(instPtr->phyInstPtr, &tmWord, PHY_TIME_WORD_LISTEN_TIMEOUT);
if(Status != SUCCESS){ if(Status != SUCCESS){
return EPARAM; return EPARAM;
@@ -702,13 +702,13 @@ int32_t InterComm_PhyDataUpload(INTER_COMM_INST* instPtr){
instPtr->lastPhyTimeTag = fsTimeL; instPtr->lastPhyTimeTag = fsTimeL;
instPtr->lastPhyTimeTag |= ((uint64_t)fsTimeH)<<32; instPtr->lastPhyTimeTag |= ((uint64_t)fsTimeH)<<32;
uint32_t timeComp = Phy_GetTimeComp(lastFrameType); uint32_t timeComp = Phy_GetTimeComp(lastFrameType);
if(timeComp == L1_FRAME_NONE_COMP){ if(timeComp == TIME_FRAC_MAX){
return FAILURE; return FAILURE;
} }
fsTimeH -= timeComp/L1_TMWORD_FRAC_MAX; fsTimeH -= timeComp/TIME_FRAC_MAX;
timeComp %= L1_TMWORD_FRAC_MAX; timeComp %= TIME_FRAC_MAX;
fsTimeH = (fsTimeL < timeComp)?(fsTimeH - 1):fsTimeH; fsTimeH = (fsTimeL < timeComp)?(fsTimeH - 1):fsTimeH;
fsTimeL = (fsTimeL < timeComp)?(L1_TMWORD_FRAC_MAX + fsTimeL - timeComp) : (fsTimeL - timeComp); fsTimeL = (fsTimeL < timeComp)?(TIME_FRAC_MAX + fsTimeL - timeComp) : (fsTimeL - timeComp);
memcpy(txMsgBuff+DSEGRD_TIME_OFFSET, &fsTimeL, DSEGRD_TIME_LEN/2); memcpy(txMsgBuff+DSEGRD_TIME_OFFSET, &fsTimeL, DSEGRD_TIME_LEN/2);
memcpy(txMsgBuff+DSEGRD_TIME_OFFSET + DSEGRD_TIME_LEN/2, &fsTimeH, DSEGRD_TIME_LEN/2); memcpy(txMsgBuff+DSEGRD_TIME_OFFSET + DSEGRD_TIME_LEN/2, &fsTimeH, DSEGRD_TIME_LEN/2);