📄 ixtimesyncacc.c
字号:
} /* end of if (TRUE == masterMode) */ } /* if (FALSE == allMsgMode) */ else { /* * When Any mode is on (the ta bit is set) we do not care * for Master/Slave mode (the mm bit status) since all the * packets gets time stamped anyways. */ ptpPortMode = IX_TIMESYNCACC_1588PTP_PORT_ANYMODE; } /* end of if (FALSE == allMsgMode) */ return ptpPortMode;} /* end of ixTimeSyncAccPTPPortModeGet() function *//* * TimeSync Interrupt Service Routine definition */voidixTimeSyncAccIsr(void){ /* Local variables */ IxTimeSyncAccTimeValue targetTime = {0, 0}; IxTimeSyncAccTimeValue auxTime = {0, 0}; /* * Handle the Interrupts in the following order * * 1 - Target Time Reached/Hit Condition * 2 - Auxiliary Master Timestamp * 3 - Auxiliary Slave Timestamp * * Also verify that valid callbacks are available for each of the following * since the client application may choose to use one or more of the following * in interrupt mode while others in non-interrupt mode i.e., makes use of poll * or get methods in which case there is no valid callback registered. */ /* Handle Target Time Reached or Exceeded Interrupt */ if ((NULL != ixTsTargetTimeCallback) && (TRUE == ixTimeSyncAccEventTtmFlagGet())) { /* Target Time registers contents */ ixTimeSyncAccTargetTimeSnapshotGet(&targetTime.timeValueLowWord, &targetTime.timeValueHighWord); /* Invoke client callback */ (*ixTsTargetTimeCallback)(targetTime); /* Clear the target time reached condition (ttipend bit) */ ixTimeSyncAccEventTtmFlagClear(); return; } /* end of if ((NULL != ixTsTargetTimeCallback) && (TRUE == ixTimeSyncAccEventTtmFlagGet())) */ /* Handle Auxiliary Master Mode Snapshot Interrupt */ if ((NULL != ixTsAuxMasterTimeCallback) && (TRUE == ixTimeSyncAccEventAmmsFlagGet())) { /* Fetch Auxiliary Master Mode Snapshot */ ixTimeSyncAccAuxMasterModeSnapshotGet(&auxTime.timeValueLowWord, &auxTime.timeValueHighWord); /* Return Auxiliary Master Mode Snapshot */ (*ixTsAuxMasterTimeCallback)(IX_TIMESYNCACC_AUXMODE_MASTER,auxTime); /* Clear the snapshot availability condition */ ixTimeSyncAccEventAmmsFlagClear(); return; } /* end of if ((NULL != ixTsAuxMasterTimeCallback) && (TRUE == ixTimeSyncAccEventAmmsFlagGet())) */ /* Handle Auxiliary Slave Mode Snapshot Interrupt */ if ((NULL != ixTsAuxSlaveTimeCallback) && (TRUE == ixTimeSyncAccEventAsmsFlagGet())) { /* Fetch Auxiliary Slave Mode Snapshot */ ixTimeSyncAccAuxSlaveModeSnapshotGet(&auxTime.timeValueLowWord, &auxTime.timeValueHighWord); /* Return Auxiliary Slave Mode Snapshot */ (*ixTsAuxSlaveTimeCallback)(IX_TIMESYNCACC_AUXMODE_SLAVE,auxTime); /* Clear the snapshot availability condition */ ixTimeSyncAccEventAsmsFlagClear(); return; } /* end of if ((NULL != ixTsAuxSlaveTimeCallback) && (TRUE == ixTimeSyncAccEventAsmsFlagGet())) */ /* This part of code should never be reached */#ifndef NDEBUG ixOsalLog (IX_OSAL_LOG_LVL_ERROR, IX_OSAL_LOG_DEV_STDERR, "ixTimeSyncAccIsr(): Invalid Interrupt!!!\n", 0,0,0,0,0,0);#endif /* end of #ifndef NDEBUG */ return;} /* end of ixTimeSyncAccIsr() function *//* * ------------------------------------------------------------------ * * Public API definitions * ------------------------------------------------------------------ * *//* Configure IEEE 1588 message detection on a particular PTP port */PUBLIC IxTimeSyncAccStatusixTimeSyncAccPTPPortConfigSet( IxTimeSyncAcc1588PTPPort ptpPort, IxTimeSyncAcc1588PTPPortMode ptpPortMode){ /* Verify the parameters for proper values */ if ((IX_TIMESYNCACC_NPE_1588PORT_INVALID <= ptpPort) || (IX_TIMESYNCACC_1588PTP_PORT_MODE_INVALID <= ptpPortMode)) { return IX_TIMESYNCACC_INVALIDPARAM; } /* end of if ((IX_TIMESYNCACC_NPE_1588PORT_INVALID <= ptpPort) || (IX_TIMESYNCACC_1588PTP_PORT_MODE_INVALID <= ptpPortMode)) */ /* Initialised before? */ IXP400_TIMESYNCACC_INIT_CHECK(); /* Check NPE fused-out status */ IXP400_TIMESYNCACC_NPE_FUSED_STATUS_CHECK(ptpPort); /* Set the Mode of the PTP Port */ switch (ptpPortMode) { case IX_TIMESYNCACC_1588PTP_PORT_MASTER: { ixTimeSyncAccControlPTPPortMasterModeSet(ptpPort, TRUE); ixTimeSyncAccControlPTPPortPTPMsgTimestampSet(ptpPort, FALSE); break; } /* end of case IX_TIMESYNCACC_1588PTP_PORT_MASTER */ case IX_TIMESYNCACC_1588PTP_PORT_SLAVE: { ixTimeSyncAccControlPTPPortMasterModeSet(ptpPort, FALSE); ixTimeSyncAccControlPTPPortPTPMsgTimestampSet(ptpPort, FALSE); break; } /* end of case IX_TIMESYNCACC_1588PTP_PORT_SLAVE */ case IX_TIMESYNCACC_1588PTP_PORT_ANYMODE: { ixTimeSyncAccControlPTPPortMasterModeSet(ptpPort, FALSE); ixTimeSyncAccControlPTPPortPTPMsgTimestampSet(ptpPort, TRUE); break; } /* end of case IX_TIMESYNCACC_1588PTP_PORT_ANYMODE */ default: { /* This part of the code should not be reached */#ifndef NDEBUG ixOsalLog (IX_OSAL_LOG_LVL_ERROR, IX_OSAL_LOG_DEV_STDERR, "ixTimeSyncAccPTPPortConfigSet(): " "Invalid Port Mode\n", 0,0,0,0,0,0);#endif /* end of #ifndef NDEBUG */ return IX_TIMESYNCACC_FAILED; } /* end of case default */ } /* end of switch (ptpPortMode) */ return IX_TIMESYNCACC_SUCCESS;} /* end of ixTimeSyncAccPTPPortConfigSet() function *//* Retrieve IEEE 1588 PTP operation mode on particular PTP port */PUBLIC IxTimeSyncAccStatusixTimeSyncAccPTPPortConfigGet( IxTimeSyncAcc1588PTPPort ptpPort, IxTimeSyncAcc1588PTPPortMode *ptpPortMode){ /* Verify the parameters for proper values */ if ((IX_TIMESYNCACC_NPE_1588PORT_INVALID <= ptpPort) || ((IxTimeSyncAcc1588PTPPortMode *)NULL == ptpPortMode)) { return IX_TIMESYNCACC_INVALIDPARAM; } /* end of if ((IX_TIMESYNCACC_NPE_1588PORT_INVALID <= ptpPort) || ((IxTimeSyncAcc1588PTPPortMode *)NULL == ptpPortMode)) */ /* Initialised before? */ IXP400_TIMESYNCACC_INIT_CHECK(); /* Check NPE fused-out status */ IXP400_TIMESYNCACC_NPE_FUSED_STATUS_CHECK(ptpPort); /* Get the Mode of the PTP Port */ *ptpPortMode = ixTimeSyncAccPTPPortModeGet(ptpPort); return IX_TIMESYNCACC_SUCCESS;} /* end of ixTimeSyncAccPTPPortConfigGet() function *//* * Poll the IEEE 1588 message/time stamp detect status on a particular * PTP Port on the Receive side */PUBLIC IxTimeSyncAccStatusixTimeSyncAccPTPRxPoll( IxTimeSyncAcc1588PTPPort ptpPort, IxTimeSyncAccPtpMsgData *ptpMsgData){ /* Local variables */ BOOL rxsFlag = FALSE; IxTimeSyncAcc1588PTPPortMode ptpPortMode = IX_TIMESYNCACC_1588PTP_PORT_SLAVE; /* Verify the parameters for proper values */ if ((IX_TIMESYNCACC_NPE_1588PORT_INVALID <= ptpPort) || ((IxTimeSyncAccPtpMsgData *)NULL == ptpMsgData)) { return IX_TIMESYNCACC_INVALIDPARAM; } /* end of if ((IX_TIMESYNCACC_NPE_1588PORT_INVALID <= ptpPort) || ((IxTimeSyncAccPtpMsgData *)NULL == ptpMsgData)) */ /* Initialised before? */ IXP400_TIMESYNCACC_INIT_CHECK(); /* Check NPE fused-out status */ IXP400_TIMESYNCACC_NPE_FUSED_STATUS_CHECK(ptpPort); /* Get the Mode of the PTP Port */ ptpPortMode = ixTimeSyncAccPTPPortModeGet(ptpPort); /* Is the Port Mode is ANY mode OR the receive timestamp available? */ rxsFlag = ixTimeSyncAccControlPTPPortRxsFlagGet(ptpPort); /* Neither the port is configured for 'Any Mode' nor there is a timestamp */ if ((IX_TIMESYNCACC_1588PTP_PORT_ANYMODE != ptpPortMode) && (TRUE != rxsFlag)) { return IX_TIMESYNCACC_NOTIMESTAMP; } /* end of if ((IX_TIMESYNCACC_1588PTP_PORT_ANYMODE != ptpPortMode) && (TRUE != rxsFlag)) */ /* Fetch the receive timestamp */ ixTimeSyncAccPTPPortReceiveSnapshotGet(ptpPort, &ptpMsgData->ptpTimeStamp.timeValueLowWord, &ptpMsgData->ptpTimeStamp.timeValueHighWord); /* Fetch the UUID & Seq# of PTP messages in 'Master/Slave Mode' only */ if (TRUE == rxsFlag) { ixTimeSyncAccPTPMsgUuidSeqIdGet(ptpPort, &ptpMsgData->ptpUuid.uuidValueLowWord, &ptpMsgData->ptpUuid.uuidValueHighHalfword, &ptpMsgData->ptpSequenceNumber); } /* Clear-off the UUID & Seq# of all the messages in 'Any Mode' */ else { ptpMsgData->ptpUuid.uuidValueLowWord = 0; ptpMsgData->ptpUuid.uuidValueHighHalfword = 0; ptpMsgData->ptpSequenceNumber = 0; } /* end of if (TRUE == rxsFlag) */ /* Fill-in the PTP message type */ switch (ptpPortMode) { case IX_TIMESYNCACC_1588PTP_PORT_MASTER: { ptpMsgData->ptpMsgType = IX_TIMESYNCACC_1588PTP_MSGTYPE_DELAYREQ; break; } /* end of case IX_TIMESYNCACC_1588PTP_PORT_MASTER */ case IX_TIMESYNCACC_1588PTP_PORT_SLAVE: { ptpMsgData->ptpMsgType = IX_TIMESYNCACC_1588PTP_MSGTYPE_SYNC; break; } /* end of case IX_TIMESYNCACC_1588PTP_PORT_SLAVE */ case IX_TIMESYNCACC_1588PTP_PORT_ANYMODE: { ptpMsgData->ptpMsgType = IX_TIMESYNCACC_1588PTP_MSGTYPE_UNKNOWN; break; } /* end of case IX_TIMESYNCACC_1588PTP_PORT_ANYMODE */ default: { /* This part of the code should never be reached */#ifndef NDEBUG ixOsalLog (IX_OSAL_LOG_LVL_ERROR, IX_OSAL_LOG_DEV_STDERR, "ixTimeSyncAccPTPRxPoll(): Invalid Port Mode\n", 0,0,0,0,0,0);#endif /* end of #ifndef NDEBUG */ return IX_TIMESYNCACC_FAILED; } /* end of case default */ } /* end of switch (ptpPortMode) */ /* Increment receive timestamp counter */ ixTsStats.rxMsgs++; /* Allow next timestamp to be captured */ ixTimeSyncAccControlPTPPortRxsFlagClear(ptpPort); return IX_TIMESYNCACC_SUCCESS;} /* end of ixTimeSyncAccPTPRxPoll() function *//* * Poll for the IEEE 1588 message/time stamp detect status on a particular * PTP Port on the Transmit side. */PUBLIC IxTimeSyncAccStatusixTimeSyncAccPTPTxPoll( IxTimeSyncAcc1588PTPPort ptpPort, IxTimeSyncAccPtpMsgData *ptpMsgData){ /* Local variables */ BOOL txsFlag = FALSE; IxTimeSyncAcc1588PTPPortMode ptpPortMode = IX_TIMESYNCACC_1588PTP_PORT_SLAVE; /* Verify the parameters for proper values */ if ((IX_TIMESYNCACC_NPE_1588PORT_INVALID <= ptpPort) || ((IxTimeSyncAccPtpMsgData *)NULL == ptpMsgData)) { return IX_TIMESYNCACC_INVALIDPARAM; } /* end of if ((IX_TIMESYNCACC_NPE_1588PORT_INVALID <= ptpPort) || ((IxTimeSyncAccPtpMsgData *)NULL == ptpMsgData)) */ /* Initialised before? */ IXP400_TIMESYNCACC_INIT_CHECK(); /* Check NPE fused-out status */ IXP400_TIMESYNCACC_NPE_FUSED_STATUS_CHECK(ptpPort); /* Get the Mode of the PTP Port */ ptpPortMode = ixTimeSyncAccPTPPortModeGet(ptpPort); /* Is the Port Mode is ANY mode OR the transmit timestamp available? */ txsFlag = ixTimeSyncAccControlPTPPortTxsFlagGet(ptpPort); if ((IX_TIMESYNCACC_1588PTP_PORT_ANYMODE == ptpPortMode) || (TRUE == txsFlag)) { /* Fetch the transmit timestamp */ ixTimeSyncAccPTPPortTransmitSnapshotGet(ptpPort, &ptpMsgData->ptpTimeStamp.timeValueLowWord, &ptpMsgData->ptpTimeStamp.timeValueHighWord); /* * Fill the UUID and Seq# with invalid values (zeros) * since they are not relevant for transmit timestamp */ ptpMsgData->ptpUuid.uuidValueLowWord = 0; ptpMsgData->ptpUuid.uuidValueHighHalfword = 0; ptpMsgData->ptpSequenceNumber = 0; } /* else of if ((IX_TIMESYNCACC_1588PTP_PORT_ANYMODE == ptpPortMode) || * (TRUE == txsFlag)) */ else { return IX_TIMESYNCACC_NOTIMESTAMP;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -