?? zl5011xrtp.c
字號:
zl5011xParams Pointer to the structure for this device instance
rtpInterval Interrupt interval in ms
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
extern zlStatusE zl5011xRtpSetInterruptPeriod(zl5011xParamsS *zl5011xParams,
Uint32T rtpInterval)
{
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE(ZL5011X_RTP_FN_ID,
"zl5011xRtpSetInterruptPeriod: %d",
rtpInterval, 0, 0, 0, 0, 0);
if ((rtpInterval & ~ZL5011X_RTP_INTERVAL_MASK) != 0)
{
status = ZL5011X_PARAMETER_INVALID;
}
else
{
/* Set interval field as required and upper bits bits to ZERO setting
randomising feature OFF */
status = zl5011xWrite(zl5011xParams,
ZL5011X_RTP_CONFIG2,
rtpInterval << ZL5011X_RTP_INTERVAL_BITS);
/* update structure */
zl5011xParams->rtp.rtpInterval = rtpInterval;
}
if (status == ZL5011X_OK)
{
/* enable the interrupt statistics */
status = zl5011xReadModWrite(zl5011xParams, ZL5011X_RTP_CONFIG0,
ZL5011X_1BIT_MASK << ZL5011X_RTP_CPU_SETUP_DONE,
ZL5011X_1BIT_MASK << ZL5011X_RTP_CPU_SETUP_DONE);
}
return(status);
}
/*******************************************************************************
Function:
zl5011xRtpEnableReporting
Description:
Enables reporting and enables the interrupt
Inputs:
zl5011xParams Pointer to the structure for this device instance
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
extern zlStatusE zl5011xRtpEnableReporting(zl5011xParamsS *zl5011xParams)
{
zlStatusE status = ZL5011X_OK;
Uint32T rtpMask;
ZL5011X_TRACE(ZL5011X_RTP_FN_ID, "zl5011xRtpEnableReporting:", 0, 0, 0, 0, 0, 0);
/* Enable the interrupt & set mode.*/
rtpMask = (ZL5011X_1BIT_MASK << ZL5011X_RTPS_INT_MASK_BIT) |
(ZL5011X_1BIT_MASK << ZL5011X_RTP_FORMAT);
status = zl5011xReadModWrite(zl5011xParams, ZL5011X_RTP_CONFIG0, 0, rtpMask);
zl5011xParams->interruptMasks.rtpInterruptEnabled = ZL5011X_TRUE;
return(status);
}
/*******************************************************************************
Function:
zl5011xRtpDisableReporting
Description:
Disables the interrupt.
Inputs:
zl5011xParams Pointer to the structure for this device instance
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
extern zlStatusE zl5011xRtpDisableReporting(zl5011xParamsS *zl5011xParams)
{
zlStatusE status = ZL5011X_OK;
Uint32T rtpAddress=ZL5011X_RTP_CONFIG0;
ZL5011X_TRACE(ZL5011X_RTP_FN_ID, "zl5011xRtpDisableReporting:", 0, 0, 0, 0, 0, 0);
/* Disable the interrupt.*/
status = zl5011xReadModWrite(zl5011xParams, rtpAddress,
ZL5011X_1BIT_MASK <<ZL5011X_RTPS_INT_MASK_BIT,
ZL5011X_1BIT_MASK <<ZL5011X_RTPS_INT_MASK_BIT);
zl5011xParams->interruptMasks.rtpInterruptEnabled = ZL5011X_FALSE;
return(status);
}
/*******************************************************************************
Function:
zl5011xRtpSetHeader
Description:
If a context is active, then only the shadow header should be modified.
The structure contains the enable / disable state and the position of the
fields that can be added by the Rtp.
i.e.
Timestamp size and position - RTP
Timestamp increment - RTP
sequence number position - RTP
length position - UDP
checksum position - UDP
The RtpHeaderFieldsS and the header info are stored in the device structure.
For device variants with a TDM interface this always modifies the header
that is not currently in use. Other devices modify the active one.
Inputs:
zl5011xParams Pointer to the structure for this device instance
context Selected context
RtpHeaderFieldsS - header data and position of dynamic fields
Outputs:
None
Returns:
zlStatusE
Remarks:
The shadow header must be set before calling this function
*******************************************************************************/
extern zlStatusE zl5011xRtpSetHeader(zl5011xParamsS *zl5011xParams,
Uint32T context,
zl5011xPacketTxHighHeaderS *pFieldPositions)
{
zlStatusE status = ZL5011X_OK;
zl5011xContextHeaderSwitchE primaryOrSecondary;
Uint32T headerAddress;
Uint32T rtpData= 0, byteAsWord=0 ;
Uint8T byteCount= 0;
ZL5011X_TRACE_CONTEXT(ZL5011X_RTP_FN_ID, context, "zl5011xRtpSetHeader: ctxt %3d",
context, 0, 0, 0, 0, 0);
/* New header will be written into shadow header so find out which one this is */
primaryOrSecondary= zl5011xParams->packetIf.packetTx.txHeader[context].shadowHeader;
status = zl5011xRtpGetHeaderAddress(zl5011xParams, context, primaryOrSecondary,
&headerAddress);
if (status == ZL5011X_OK)
{
/* check the packet length is valid */
if ((pFieldPositions->txHighLength & ~(ZL5011X_4BIT_MASK << ZL5011X_1BIT_MASK)) != 0)
{
status = ZL5011X_PKT_HEADER_SIZE_ERROR;
}
}
if (status == ZL5011X_OK)
{
if (pFieldPositions == NULL)
{
status = ZL5011X_PARAMETER_INVALID;
}
}
/* write 24byte block to header */
for( byteCount= 0; byteCount < ZL5011X_RTP_HIGH_HEADER_MAX_LEN; byteCount++)
{
if (status != ZL5011X_OK)
break;
byteAsWord= pFieldPositions->txHighData[byteCount] << (8 * (byteCount % ZL5011X_NUM_BYTES_IN_WORD));
rtpData= rtpData | byteAsWord;
if ( (byteCount % ZL5011X_NUM_BYTES_IN_WORD)==
(ZL5011X_NUM_BYTES_IN_WORD- sizeof(Uint8T)))
{
status = zl5011xWrite(zl5011xParams, headerAddress, rtpData);
headerAddress+= sizeof( Uint32T);
rtpData= 0;
}
}
/* write field positions to header - lower word first */
if (status == ZL5011X_OK)
{
if (pFieldPositions->layer5Timestamp32bit == ZL5011X_TRUE)
{
rtpData = ZL5011X_1BIT_MASK << ZL5011X_RTP_TS;
}
if (pFieldPositions->layer5SequenceNum16bit == ZL5011X_TRUE)
{
rtpData |= ZL5011X_1BIT_MASK << ZL5011X_RTP_SS;
}
if (pFieldPositions->firstHighHeader == ZL5011X_FALSE)
{
rtpData |= ZL5011X_1BIT_MASK << ZL5011X_RTP_CSW;
}
/* packet length was checked on entry, so just use it now */
rtpData |= (pFieldPositions->txHighLength / 2) << ZL5011X_RTP_HDR_LEN;
}
if (status == ZL5011X_OK)
{
if (pFieldPositions->highSilenceCtrl > ZL5011X_2BIT_MASK)
{
status= ZL5011X_PARAMETER_INVALID;
}
else
{
rtpData |= pFieldPositions->highSilenceCtrl << ZL5011X_RTP_CTRL;
}
}
if (status == ZL5011X_OK)
{
if ( pFieldPositions->highContextOut > ZL5011X_13BIT_MASK)
{
status= ZL5011X_PARAMETER_INVALID;
}
else
{
rtpData |= pFieldPositions->highContextOut << ZL5011X_RTP_CTXT_OUT;
}
}
if (status == ZL5011X_OK)
{
/* write lower word and increment to next word of field positions */
status = zl5011xWrite(zl5011xParams, headerAddress, rtpData);
headerAddress+= sizeof(Uint32T);
rtpData= 0;
}
if (status == ZL5011X_OK)
{
if ( pFieldPositions->layer5TimestampIncrement > ZL5011X_13BIT_MASK)
{
if (pFieldPositions->layer5TimestampFromWan != ZL5011X_TRUE)
{
status = ZL5011X_PARAMETER_INVALID;
}
}
else
{
rtpData |= pFieldPositions->layer5TimestampIncrement << ZL5011X_RTP_TS_INC;
}
}
if (status == ZL5011X_OK)
{
if (pFieldPositions->layer5TimestampEnable == ZL5011X_TRUE)
{
if ((pFieldPositions->layer5TimestampPos & ~(ZL5011X_4BIT_MASK << ZL5011X_1BIT_MASK)) != 0)
{
status = ZL5011X_PARAMETER_INVALID;
}
else
{
/* check that the timestamp is in a valid position and aligned to a 16 / 32
bit boundary for 16 / 32 bit size respectively */
if (((pFieldPositions->layer5Timestamp32bit == ZL5011X_TRUE) &&
((pFieldPositions->layer5TimestampPos > (ZL5011X_RTP_HIGH_HEADER_MAX_LEN - sizeof(Uint32T))) ||
((pFieldPositions->layer5TimestampPos & ZL5011X_2BIT_MASK) != 0))) ||
((pFieldPositions->layer5Timestamp32bit == ZL5011X_FALSE) &&
((pFieldPositions->layer5TimestampPos > (ZL5011X_RTP_HIGH_HEADER_MAX_LEN - sizeof(Uint16T))) &&
((pFieldPositions->layer5TimestampPos & ZL5011X_1BIT_MASK) != 0))))
{
status = ZL5011X_PARAMETER_INVALID;
}
else
{
rtpData |= (pFieldPositions->layer5TimestampPos / 2) << ZL5011X_RTP_TS_LOC;
/* Enable the control for obtaining timestamp from the Wan interface */
if (pFieldPositions->layer5TimestampFromWan == ZL5011X_TRUE)
{
rtpData |= ZL5011X_1BIT_MASK << ZL5011X_RTP_CES_LOC;
}
}
}
}
else /* indicate 'disabled' */
{
rtpData |= ZL5011X_4BIT_MASK << ZL5011X_RTP_TS_LOC;
}
}
if (status == ZL5011X_OK)
{
if ( pFieldPositions->layer4LengthEnable== ZL5011X_TRUE)
{
if ((pFieldPositions->layer4LengthPos & ~(ZL5011X_4BIT_MASK << ZL5011X_1BIT_MASK)) != 0)
{
status= ZL5011X_PARAMETER_INVALID;
}
else
{
if (pFieldPositions->layer4LengthPos > (ZL5011X_RTP_HIGH_HEADER_MAX_LEN - sizeof(Uint16T)))
{
status = ZL5011X_PARAMETER_INVALID;
}
else
{
rtpData |= (pFieldPositions->layer4LengthPos / 2) << ZL5011X_RTP_LEN_LOC;
}
}
}
else /* indicate 'disabled' */
{
rtpData |= ZL5011X_4BIT_MASK << ZL5011X_RTP_LEN_LOC;
}
}
if (status == ZL5011X_OK)
{
if ( pFieldPositions->layer4ChecksumEnable== ZL5011X_TRUE)
{
if ((pFieldPositions->layer4ChecksumPos & ~(ZL5011X_4BIT_MASK << ZL5011X_1BIT_MASK)) != 0)
{
status= ZL5011X_PARAMETER_INVALID;
}
else
{
if (pFieldPositions->layer4ChecksumPos > (ZL5011X_RTP_HIGH_HEADER_MAX_LEN - sizeof(Uint16T)))
{
status = ZL5011X_PARAMETER_INVALID;
}
else
{
rtpData |= (pFieldPositions->layer4ChecksumPos / 2) << ZL5011X_RTP_CHK_LOC;
}
}
}
else /* indicate 'disabled' */
{
rtpData |= ZL5011X_4BIT_MASK << ZL5011X_RTP_CHK_LOC;
}
}
if (status == ZL5011X_OK)
{
if (pFieldPositions->layer5SequenceNumEnable == ZL5011X_TRUE)
{
if (pFieldPositions->layer5SequenceNumPos > ZL5011X_5BIT_MASK)
{
status= ZL5011X_PARAMETER_INVALID;
}
else
{
if (((pFieldPositions->layer5SequenceNum16bit == ZL5011X_TRUE) &&
(pFieldPositions->layer5SequenceNumPos > (ZL5011X_RTP_HIGH_HEADER_MAX_LEN - sizeof(Uint16T)))) ||
((pFieldPositions->layer5SequenceNum16bit == ZL5011X_FALSE) &&
(pFieldPositions->layer5SequenceNumPos > (ZL5011X_RTP_HIGH_HEADER_MAX_LEN - sizeof(Uint8T)))))
{
status = ZL5011X_PARAMETER_INVALID;
}
else
{
rtpData |= pFieldPositions->layer5SequenceNumPos << ZL5011X_RTP_SN_LOC;
}
}
}
else /* indicate 'disabled' */
{
rtpData |= ZL5011X_5BIT_MASK << ZL5011X_RTP_SN_LOC;
}
}
if (status == ZL5011X_OK)
{
/* write upper word of field positions */
status = zl5011xWrite(zl5011xParams, headerAddress, rtpData);
}
if (status == ZL5011X_OK)
{
/* Keep a copy of the data written */
(void*)memcpy(&(zl5011xParams->packetIf.packetTx.txHeader[context].highHeader[primaryOrSecondary]),
pFieldPositions, sizeof(zl5011xPacketTxHighHeaderS));
}
return status;
}
/*******************************************************************************
Function:
zl5011xRtpSeedTimestamp
Description:
This is used to set the RTP timestamp initial value.
The value can be set using the set header function, but for tight control,
this function allows the field to be set independently. This will probably
only be necessary when in async mode and using RTP based differential
clocking, where the PAC Rx count is used to generate the RTP Tx timestamp.
So, in this case, the timestamp would be seeded immediately before enabling
the context.
Inputs:
zl5011xParams Pointer to the structure for this device instance
context Selected context
timestamp Initial timestamp value
Outputs:
None
Returns:
zlStatusE
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -