update physical layer logging scheme

This commit is contained in:
Gatsby Van
2024-03-24 22:13:22 +08:00
parent ad3bc29cfa
commit 3edfce69f2
4 changed files with 36 additions and 7 deletions
+6 -1
View File
@@ -360,6 +360,11 @@ void ScuTimer_IntrHandler(void *context)
{
// Refresh log
Phy_RefreshHwSate(phyInstPtr);
if (TimeCtrl_GetIntCnt(tmcInstPtr) - phyInstPtr->lastLogTime >= PHY_LOG_EXPIRE)
{
Phy_UpdateLogging(phyInstPtr);
}
XScuTimer_ClearInterruptStatus((XScuTimer *)xdesc->instance);
}
else
@@ -420,7 +425,7 @@ int main(void)
}
/* Physical Layer Initialize */
Status = Phy_InstInit(&phyInstPtr, &phyConfig);
Status = Phy_Init(&phyInstPtr, &phyConfig);
if (Status == SUCCESS)
{
DBG_PRINT("Physical layer Init SUCCESS! \n");
@@ -35,6 +35,9 @@
#endif
/************************** Constant Definitions *****************************/
#define PHY_TIME_WORD_H_MAX UINT32_MAX
#define PHY_TIME_WORD_L_MAX 0x0007A120 // 5ms/10ns
#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
@@ -318,7 +321,22 @@ void Phy_UpdateState(PHY_INST *instPtr)
{
instPtr->isValid = false;
}
Phy_UpdateLogging(instPtr);
}
/*****************************************************************************/
/**
* @brief Update physical layer logging.
*
* @param instPtr A pointer to physical layer control instance.
*
* @return NONE.
*
******************************************************************************/
void Phy_UpdateLogging(PHY_INST *instPtr)
{
ASSERT(instPtr != NULL);
uint64_t peak, avg;
// Logging
instPtr->recvSlotTime.int_part = PhyRead(instPtr, TM_TARGET_H);
instPtr->recvSlotTime.frac_part = PhyRead(instPtr, TM_TARGET_L);
@@ -330,7 +348,6 @@ void Phy_UpdateState(PHY_INST *instPtr)
instPtr->phyLog.crcCnt = PhyRead(instPtr, PHY_CRC_OK_CNT);
instPtr->phyLog.doppler = Phy_GetFreqEst(instPtr);
instPtr->phyLog.recvStamp = (uint64_t)instPtr->recvFsTime.int_part * TIME_FRAC_MAX + instPtr->recvFsTime.frac_part;
uint64_t peak, avg;
peak = PhyRead(instPtr, PHY_ACQ_PEAK_L);
peak |= ((uint64_t)PhyRead(instPtr, PHY_ACQ_PEAK_H)) << 32;
avg = PhyRead(instPtr, PHY_ACQ_MEAN_L);
@@ -348,6 +365,7 @@ void Phy_UpdateState(PHY_INST *instPtr)
memset(instPtr->phyLog.reserve, 0x00, sizeof(instPtr->phyLog.reserve));
// Sync logs to system monitor
SysMonitor_UpdatePhysicalLayerLog(&(instPtr->phyLog));
instPtr->lastLogTime = PhyRead(instPtr, TM_TARGET_H);
}
/*****************************************************************************/
@@ -361,7 +379,7 @@ void Phy_UpdateState(PHY_INST *instPtr)
* @return SUCCESS
*
******************************************************************************/
int32_t Phy_InstInit(PHY_INST **instPtr, PHY_CONFIG *phyConfig)
int32_t Phy_Init(PHY_INST **instPtr, PHY_CONFIG *phyConfig)
{
ASSERT(instPtr != NULL);
ASSERT(phyConfig != NULL);
@@ -387,6 +405,7 @@ int32_t Phy_InstInit(PHY_INST **instPtr, PHY_CONFIG *phyConfig)
(*instPtr)->recvSlotTime.frac_part = UINT32_MAX;
(*instPtr)->antConfigOffset = 0;
(*instPtr)->sendDataOffset = 0;
(*instPtr)->lastLogTime = 0;
Phy_AntConfigInit(&((*instPtr)->antConfig));
memset(&((*instPtr))->tor, PHY_TOR_SUSPEND, sizeof(PHY_RCD));
@@ -53,8 +53,7 @@
#define L1_FRAME_200KBPS_5MS_HOPS 20
#define L1_FRAME_1M2BPS_5MS_HOPS 20
#define PHY_TIME_WORD_H_MAX UINT32_MAX
#define PHY_TIME_WORD_L_MAX 0x0007A120 // 5ms/10ns
#define PHY_LOG_EXPIRE 40 // 50*5ms
/***************** Macros (Inline Functions) Definitions *********************/
/**************************** Type Definitions *******************************/
typedef enum
@@ -227,6 +226,7 @@ typedef struct
PHY_ANT_ANGLE antNrrwPattern[L1_NUM_ANT_NRRW_PATTERN];
HWSTATE hwSate;
PHYLOG phyLog;
uint32_t lastLogTime;
} PHY_INST;
/************************** Variable Definitions *****************************/
@@ -242,10 +242,11 @@ extern uint16_t hopPattern_200KBPS_5MS[L1_FRAME_200KBPS_5MS_HOPS];
extern uint16_t hopPattern_1M2BPS_5MS[L1_FRAME_1M2BPS_5MS_HOPS];
/************************** Function Prototypes ******************************/
int32_t Phy_InstInit(PHY_INST **instPtr, PHY_CONFIG *phyConfig);
int32_t Phy_Init(PHY_INST **instPtr, PHY_CONFIG *phyConfig);
void Phy_Destroy(PHY_INST *instPtr);
void Phy_UpdateState(PHY_INST *instPtr);
void Phy_UpdateLogging(PHY_INST *instPtr);
void Phy_RefreshHwSate(PHY_INST *instPtr);
void Phy_Start(PHY_INST *instPtr);