?? zl5011xtif.c
字號:
Inputs:
zl5011xParams Pointer to the structure for this device instance
reverse boolean to control byte construction order
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xTifReverseBitOrder(zl5011xParamsS *zl5011xParams, zl5011xBooleanE reverse)
{
zlStatusE status = ZL5011X_OK;
Uint32T bits, bitMask;
ZL5011X_TRACE(ZL5011X_TIF_FN_ID, "zl5011xTifReverseBitOrder: mode %d",
reverse, 0, 0, 0, 0, 0);
/* check parameter is in range */
status = ZL5011X_CHECK_BOOLEAN(reverse);
if (status == ZL5011X_OK)
{
bits = (Uint32T)reverse << ZL5011X_TIF_BIT_ORDER_BIT;
bitMask = ZL5011X_1BIT_MASK << ZL5011X_TIF_BIT_ORDER_BIT;
status = zl5011xUpdateRegisters(zl5011xParams, ZL5011X_TIF_CTRL_REG,
&zl5011xParams->wanIf.wanIfControl, bits, bitMask);
zl5011xParams->wanIf.reverseBitOrder = reverse;
}
return status;
}
/*******************************************************************************
Function:
zl5011xTifEnableBitStuffing
Description:
If the mode is unframed DS1 or J2 then bit stuffing can be enabled.
This is where the non-byte bits from each frame are added to the last byte of the
so-called frame.
i.e. for DS1, there is 1 frame bit and 24 timeslots. The TIF takes an arbitrary
alignment and counts 24 timeslots. If bit stuffing is enabled, then the next bit
(last in the frame) is tagged onto the 24th timeslot, giving the last byte equal to
9 bits!
The same happens in J2, except that there are 5 remainder bits in the frame after
98 timeslots.
Inputs:
zl5011xParams Pointer to the structure for this device instance
enable TRUE to enable bit stuffing, FALSE to disable
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xTifEnableBitStuffing(zl5011xParamsS *zl5011xParams,
zl5011xBooleanE enable)
{
Uint32T bit = 0, bitMask;
zlStatusE status = ZL5011X_OK;
status = ZL5011X_CHECK_BOOLEAN(enable);
if (status == ZL5011X_OK)
{
/* bit stuffing is only valid when the mode is unframed DS1 or J2 */
if ((enable == ZL5011X_TRUE) &&
((zl5011xParams->wanIf.wanMode == ZL5011X_WAN_UNFRAMED) &&
((zl5011xParams->wanIf.wanLiuFreq != ZL5011X_WAN_LIU_FREQ_1_544M) &&
(zl5011xParams->wanIf.wanLiuFreq != ZL5011X_WAN_LIU_FREQ_6_312M))))
{
status = ZL5011X_PARAMETER_INVALID;
}
}
if (status == ZL5011X_OK)
{
ZL5011X_TRACE(ZL5011X_TIF_FN_ID, "zl5011xTifEnableBitStuffing: %d", enable, 0, 0, 0, 0, 0);
if (enable == ZL5011X_FALSE)
{
bit = ZL5011X_1BIT_MASK << ZL5011X_TIF_STUFFING_BIT;
}
bitMask = ZL5011X_1BIT_MASK << ZL5011X_TIF_STUFFING_BIT;
status = zl5011xUpdateRegisters(zl5011xParams, ZL5011X_TIF_CTRL_REG,
&zl5011xParams->wanIf.wanIfControl, bit, bitMask);
zl5011xParams->wanIf.wanBitStuffingEnabled = enable;
}
return(status);
}
/*******************************************************************************
Function:
zl5011xTifBerConfigure
Description:
Used to setup the BER for both generate and receive directions.
Inputs:
zl5011xParams Pointer to the structure for this device instance
regAddress address of the register in the device
structAddress address to use for storing the settings
berDirection direction for the BER to connect to
berPattern which BER pattern to use
berStream which stream to use for the BER
berStartChannel which channel to start the BER in
berEndChannel which channel to end the BER in
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xTifBerConfigure(zl5011xParamsS *zl5011xParams,
Uint32T regAddress, zl5011xWanBerConfigS *structAddress,
zl5011xWanIfBerDirectionE berDirection, zl5011xWanIfBerPatternE berPattern,
Uint8T berStream, Uint8T berStartChannel, Uint8T berEndChannel)
{
Uint32T bits;
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE(ZL5011X_TIF_FN_ID,
"zl5011xTifBerConfigure: dir %d, patt %d, stream %d, start %d, end %d",
berDirection, berPattern, berStream, berStartChannel, berEndChannel, 0);
/* check the parameters */
status = ZL5011X_CHECK_WAN_IF_BER_DIRECTION(berDirection);
if (status == ZL5011X_OK)
{
status = ZL5011X_CHECK_WAN_IF_BER_PATTERN(berPattern);
}
/* if unstructured, then ignore the channel parameters passed in */
if (zl5011xParams->wanIf.wanConnectionMode == ZL5011X_WAN_CONNECTION_UNFRAMED)
{
berStartChannel = 0;
berEndChannel = 0;
}
else
{
if (status == ZL5011X_OK)
{
status = zl5011xCheckChannelRange(zl5011xParams, berStartChannel);
}
if (status == ZL5011X_OK)
{
status = zl5011xCheckChannelRange(zl5011xParams, berEndChannel);
}
if (status == ZL5011X_OK)
{
if (berEndChannel < berStartChannel)
{
status = ZL5011X_PARAMETER_INVALID;
}
}
}
if (status == ZL5011X_OK)
{
status = zl5011xCheckStreamRange(zl5011xParams, berStream);
}
/* assemble the register contents */
if (status == ZL5011X_OK)
{
bits = (berDirection << ZL5011X_TIF_BER_DIRECTION_BIT) |
(berPattern << ZL5011X_TIF_BER_PATTERN_BIT) |
(ZL5011X_1BIT_MASK << ZL5011X_TIF_BER_ENABLE_BIT) |
(berStartChannel << ZL5011X_TIF_BER_CHANNEL_START_BITS) |
((berEndChannel - berStartChannel) << ZL5011X_TIF_BER_CHANNEL_COUNT_BITS) |
(berStream << ZL5011X_TIF_BER_STREAM_BITS);
status = zl5011xWrite(zl5011xParams, regAddress, bits);
structAddress->berDirection = berDirection;
structAddress->berPattern = berPattern;
structAddress->berStream = berStream;
structAddress->berStartChannel = berStartChannel;
structAddress->berEndChannel = berEndChannel;
structAddress->berEnabled = ZL5011X_TRUE;
}
return(status);
}
/*******************************************************************************
Function:
zl5011xTifBerConfigureGenerator
Description:
Used to setup the BER for generator
Inputs:
zl5011xParams Pointer to the structure for this device instance
berDirection direction for the BER to connect to :
ZL5011X_WAN_BER_DIRECTION_TX for wan Tx (TDM o/p)
ZL5011X_WAN_BER_DIRECTION_RX for wan Rx (TDM i/p - pkt o/p)
berPattern which BER pattern to use
berStream which stream to use for the BER
berStartChannel which channel to start the BER in
berEndChannel which channel to end the BER in
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xTifBerConfigureGenerator(zl5011xParamsS *zl5011xParams,
zl5011xWanIfBerDirectionE berDirection, zl5011xWanIfBerPatternE berPattern,
Uint8T berStream, Uint8T berStartChannel, Uint8T berEndChannel)
{
zl5011xWanIfBerDirectionE dir;
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE(ZL5011X_TIF_FN_ID,
"zl5011xTifBerConfigureGenerator:",
0, 0, 0, 0, 0, 0);
status = ZL5011X_CHECK_WAN_IF_BER_PATTERN(berDirection);
if (status == ZL5011X_OK)
{
/* flip over the direction control to allow for terminology in the
TIF block */
if (berDirection == ZL5011X_WAN_BER_DIRECTION_RX)
{
dir = ZL5011X_WAN_BER_DIRECTION_TX;
}
else
{
dir = ZL5011X_WAN_BER_DIRECTION_RX;
}
status = zl5011xTifBerConfigure(zl5011xParams,
ZL5011X_TIF_BER_TX_REG, &(zl5011xParams->wanIf.wanBerGenerate),
dir , berPattern, berStream, berStartChannel, berEndChannel);
}
return(status);
}
/*******************************************************************************
Function:
zl5011xTifBerConfigureReceiver
Description:
Used to setup the BER receiver
Inputs:
zl5011xParams Pointer to the structure for this device instance
berDirection direction for the BER to connect to :
ZL5011X_WAN_BER_DIRECTION_RX for wan Rx (TDM i/p)
ZL5011X_WAN_BER_DIRECTION_TX for wan Tx (TDM o/p - pkt i/p)
berPattern which BER pattern to use
berStream which stream to use for the BER
berStartChannel which channel to start the BER in
berEndChannel which channel to end the BER in
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xTifBerConfigureReceiver(zl5011xParamsS *zl5011xParams,
zl5011xWanIfBerDirectionE berDirection, zl5011xWanIfBerPatternE berPattern,
Uint8T berStream, Uint8T berStartChannel, Uint8T berEndChannel)
{
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE(ZL5011X_TIF_FN_ID,
"zl5011xTifBerConfigureReceiver:",
0, 0, 0, 0, 0, 0);
status = zl5011xTifBerConfigure(zl5011xParams,
ZL5011X_TIF_BER_RX_REG, &(zl5011xParams->wanIf.wanBerReceive),
berDirection, berPattern, berStream, berStartChannel, berEndChannel);
if (status == ZL5011X_OK)
{
/* set the reset bit - this 0 to 1 transition will force a reset */
status = zl5011xReadModWrite(zl5011xParams, ZL5011X_TIF_BER_RX_REG,
ZL5011X_1BIT_MASK << ZL5011X_TIF_BER_RESET_BIT,
ZL5011X_1BIT_MASK << ZL5011X_TIF_BER_RESET_BIT);
}
return(status);
}
/*******************************************************************************
Function:
zl5011xTifBerDisableGenerator
Description:
Used to disable the BER generator
Inputs:
zl5011xParams Pointer to the structure for this device instance
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xTifBerDisableGenerator(zl5011xParamsS *zl5011xParams)
{
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE(ZL5011X_TIF_FN_ID,
"zl5011xTifBerDisableGenerator:",
0, 0, 0, 0, 0, 0);
/* set the enable bit to 0 to disable the transmitter */
status = zl5011xReadModWrite(zl5011xParams, ZL5011X_TIF_BER_TX_REG,
0,
ZL5011X_1BIT_MASK << ZL5011X_TIF_BER_ENABLE_BIT);
zl5011xParams->wanIf.wanBerGenerate.berEnabled = ZL5011X_FALSE;
return(status);
}
/*******************************************************************************
Function:
zl5011xTifBerDisableReceiver
Description:
Used to disable the BER receiver.
Inputs:
zl5011xParams Pointer to the structure for this device instance
Outputs:
None
Returns:
zlStatusE
Remarks:
Also clears the Lock status
*******************************************************************************/
zlStatusE zl5011xTifBerDisableReceiver(zl5011xParamsS *zl5011xParams)
{
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE(ZL5011X_TIF_FN_ID,
"zl5011xTifBerDisableReceiver:",
0, 0, 0, 0, 0, 0);
/* set the enable bit to 0 to disable the receiver */
status = zl5011xReadModWrite(zl5011xParams, ZL5011X_TIF_BER_RX_REG,
0,
ZL5011X_1BIT_MASK << ZL5011X_TIF_BER_ENABLE_BIT);
zl5011xParams->wanIf.wanBerReceive.berEnabled = ZL5011X_FALSE;
return(status);
}
/*******************************************************************************
Function:
zl5011xTifBerResetReceiver
Description:
Used to reset the BER receiver error counter, while the BER test is running.
Inputs:
zl5011xParams Pointer to the structure for this device instance
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -