?? zl5011xtif.c
字號:
/*******************************************************************************
*
* File name: zl5011xTif.c
*
* Version: 33
*
* Author: MRC
*
* Date created: 08/02/2002
*
* Copyright 2002, 2003, 2004, 2005, Zarlink Semiconductor Limited.
* All rights reserved.
*
* Module Description:
*
* This file contains all the functions that are used to control the TDM
* interface part of the device.
* Sets clock polarities and general operating mode.
*
* Revision History:
*
* Rev: Date: Author: Comments:
* 1 08/02/2002 MRC Creation
* 2 15/02/2002 MRC Pass device structure to read / write fns
* 3 28/02/2002 MRC Checked and quick test
* 4 08/03/2002 MRC Update
* 5 19/03/2002 MRC Update
* 6 27/03/2002 MRC Stores settings in the device structure
* 7 27/03/2002 MRC ReadModWrite parameter order changed.
* 8 28/03/2002 MRC Now use 8 bit rather than 32 bit locals for
* stream num etc.
* 9 09/04/2002 MRC Changes to TIF frame type block.
* 10 17/04/2002 MRC Changed the CHECK_.. macros to ZL5011X_CHECK_..
* 11 30/04/2002 MRC Made a fix to allow the init function to
* initialise all of the streams.
* 12 16/05/2002 MRC Added channel enable function
* 13 29/05/2002 MRC Added bit order control
* 14 31/05/2002 MRC Added tri-state control during device init
* 15 19/06/2002 MRC TIF now starts in DPLL slave mode (backplane)
* 16 20/06/2002 MRC Changed interface type enum names following review
* 17 09/07/2002 MRC Added LIU value to set interface fn and added BER
* functions.
* 18 26/07/2002 MRC Fixed bit stuffing function
* 19 14/08/2002 MRC Added control for sample point - 3/4 and x1 clock
* 20 03/10/2002 JFE Fixed ZL5011X_TRACE without : following function name.
* 21 30/10/2002 MRC Updated to allow variants
* 22 31/10/2002 MRC Added variants + minor fixes
* 23 05/11/2002 MRC Added check to ensure that streams are valid in
* zl5011xTifSetInterfaceType
* 24 06/11/2002 MRC Modified check in zl5011xTifSetInterfaceType,
* since TDM is not valid in one of the variants
* 25 29/07/2003 APL Renamed global wanLimits structure to devLimits
* 26 13/02/2004 APL Updated function header descriptions for BER receiver
* 27 23/07/2004 MRC Fixed some compiler warnings
* 28 29/07/2004 MRC Fixed some compiler warnings
* 29 19/08/2004 MRC Added user defined LIU frequency setting
* 30 16/11/2004 MRC Added individual stream frequency control
* 31 21/01/2005 MRC Updated for non CES operation
* 32 28/01/2005 MRC Updated stream enable for non CES stream
* 33 03/02/2005 APL Renamed device ID's to allow new family members
*
*******************************************************************************/
/***************** INCLUDE FILES *****************************/
#include "zl5011x.h"
#include "zl5011xTif.h"
#include "zl5011xTifMap.h"
#include "zl5011xUtilLib.h"
/***************** EXPORTED GLOBAL VARIABLES *****************************/
/***************** STATIC GLOBAL VARIABLES *****************************/
/***************** STATIC FUNCTION DECLARATIONS *****************************/
/******************************************************************************/
/*******************************************************************************
Function:
zl5011xTifInit
Description:
This function initialises the device, tri-stating the TDM outputs and
initialising the clock polarities.
Inputs:
zl5011xParams Pointer to the structure for this device instance
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xTifInit(zl5011xParamsS *zl5011xParams)
{
Uint8T loop;
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE(ZL5011X_TIF_FN_ID, "zl5011xTifInit:", 0, 0, 0, 0, 0, 0);
status = zl5011xTifControlOutputs(zl5011xParams, ZL5011X_WAN_OUTPUT_HIZ);
if (status == ZL5011X_OK)
{
/* temporarily set the number of streams to the maximum, to allow the
chip to be initialised */
zl5011xParams->wanIf.wanNumStreams = ZL5011X_MAX_NUMBER_STREAMS;
for (loop = 0; loop < ZL5011X_MAX_NUMBER_STREAMS; loop++)
{
status = zl5011xTifSetInputClockPolarity(zl5011xParams, loop, ZL5011X_NEGATIVE);
if (status != ZL5011X_OK)
break;
status = zl5011xTifSetOutputClockPolarity(zl5011xParams, loop, ZL5011X_POSITIVE);
if (status != ZL5011X_OK)
break;
}
}
if (status == ZL5011X_OK)
{
status = zl5011xTifBerDisableGenerator(zl5011xParams);
}
if (status == ZL5011X_OK)
{
status = zl5011xTifBerDisableReceiver(zl5011xParams);
}
/* reset the number of streams / channels that are available */
zl5011xParams->wanIf.wanNumStreams = 0;
zl5011xParams->wanIf.wanNumChannels = 0;
return(status);
}
/*******************************************************************************
Function:
zl5011xTifControlOutputs
Description:
Controls the tri-state for the TDM outputs.
Inputs:
zl5011xParams Pointer to the structure for this device instance
outputState Controls the tri-state for the TDM outputs
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xTifControlOutputs(zl5011xParamsS *zl5011xParams,
zl5011xWanIfOutputEnableE outputState)
{
Uint32T bit, bitMask;
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE(ZL5011X_TIF_FN_ID, "zl5011xTifControlOutputs: %d",
outputState, 0, 0, 0, 0, 0);
status = ZL5011X_CHECK_WAN_IF_OUTPUT_ENABLE(outputState);
if (status == ZL5011X_OK)
{
bit = (Uint32T)outputState << ZL5011X_TIF_OUTPUT_ENABLE_BIT;
bitMask = ZL5011X_1BIT_MASK << ZL5011X_TIF_OUTPUT_ENABLE_BIT;
status = zl5011xUpdateRegisters(zl5011xParams, ZL5011X_TIF_CTRL_REG,
&zl5011xParams->wanIf.wanIfControl, bit, bitMask);
zl5011xParams->wanIf.outputEnable = outputState;
}
return(status);
}
/*******************************************************************************
Function:
zl5011xTifSetFramePulseType
Description:
Sets the frame pulse type to use for framed TDM.
Inputs:
zl5011xParams Pointer to the structure for this device instance
pulseType Configures the frame pulse type for framed TDM.
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xTifSetFramePulseType(zl5011xParamsS *zl5011xParams,
zl5011xWanIfFramePulseTypeE pulseType)
{
Uint32T bit, bitMask;
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE(ZL5011X_TIF_FN_ID, "zl5011xTifSetFramePulseType: %d",
pulseType, 0, 0, 0, 0, 0);
status = ZL5011X_CHECK_WAN_IF_FRAME_PULSE_TYPE(pulseType);
if (status == ZL5011X_OK)
{
bit = (Uint32T)pulseType << ZL5011X_TIF_FRAME_PULSE_BITS;
bitMask = ZL5011X_TIF_FRAME_PULSE_MASK << ZL5011X_TIF_FRAME_PULSE_BITS;
zl5011xParams->wanIf.framePulseWidth = pulseType;
status = zl5011xUpdateRegisters(zl5011xParams, ZL5011X_TIF_CTRL_REG,
&zl5011xParams->wanIf.wanIfControl, bit, bitMask);
}
return(status);
}
/*******************************************************************************
Function:
zl5011xTifSetFramePolarity
Description:
Sets the polarity to be used for the frame pulse.
Inputs:
zl5011xParams Pointer to the structure for this device instance
polarity Configures the polarity of the frame pulse for framed TDM.
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xTifSetFramePolarity(zl5011xParamsS *zl5011xParams,
zl5011xPolarityE polarity)
{
Uint32T bit, bitMask;
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE(ZL5011X_TIF_FN_ID, "zl5011xTifSetFramePolarity: %d",
polarity, 0, 0, 0, 0, 0);
status = ZL5011X_CHECK_POLARITY(polarity);
if (status == ZL5011X_OK)
{
bit = (Uint32T)polarity << ZL5011X_TIF_FRAME_POL_BIT;
bitMask = ZL5011X_1BIT_MASK << ZL5011X_TIF_FRAME_POL_BIT;
zl5011xParams->wanIf.framePulsePolarity = polarity;
status = zl5011xUpdateRegisters(zl5011xParams, ZL5011X_TIF_CTRL_REG,
&zl5011xParams->wanIf.wanIfControl, bit, bitMask);
}
return(status);
}
/*******************************************************************************
Function:
zl5011xTifSetDataSampleMode
Description:
Sets the sample point for Rx TDM data.
Inputs:
zl5011xParams Pointer to the structure for this device instance
sampleMode Configures the sampling point for TDM input.
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xTifSetDataSampleMode(zl5011xParamsS *zl5011xParams,
zl5011xWanIfSamplePointE sampleMode)
{
Uint32T bits, bitMask;
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE(ZL5011X_TIF_FN_ID, "zl5011xTifSetDataSampleMode: %d",
sampleMode, 0, 0, 0, 0, 0);
status = ZL5011X_CHECK_WAN_IF_SAMPLE_POINT(sampleMode);
if (status == ZL5011X_OK)
{
bits = (Uint32T)sampleMode << ZL5011X_TIF_SAMPLING_BITS;
bitMask = (ZL5011X_TIF_SAMPLING_MASK << ZL5011X_TIF_SAMPLING_BITS) |
(ZL5011X_1BIT_MASK << ZL5011X_TIF_SAMPLE_CLOCK_BIT) |
(ZL5011X_1BIT_MASK << ZL5011X_TIF_SYSTEM_CLOCK_BIT);
/* if setting up a 3/4 sample point and using x1 clock, then must
set the async clocking mode */
if ((sampleMode == ZL5011X_WAN_SAMPLE_THREE_QUARTER_BIT) &&
(zl5011xParams->wanIf.wanClockMultiply == ZL5011X_WAN_CLK_DATA_RATE))
{
bits |= ZL5011X_1BIT_MASK << ZL5011X_TIF_SAMPLE_CLOCK_BIT;
/* since the system clock is used for this approximation, need to
set a bit to indicate the system clock frequency */
if (zl5011xParams->systemClockFreq > ZL5011X_TIF_HIGH_SYS_CLOCK_FREQ)
{
bits |= ZL5011X_1BIT_MASK << ZL5011X_TIF_SYSTEM_CLOCK_BIT;
}
}
status = zl5011xUpdateRegisters(zl5011xParams, ZL5011X_TIF_CTRL_REG,
&zl5011xParams->wanIf.wanIfControl, bits, bitMask);
}
zl5011xParams->wanIf.wanSampleMode = sampleMode;
return(status);
}
/*******************************************************************************
Function:
zl5011xTifSetClockRate
Description:
Sets the clock multiply bit - i.e. clock can be 1x or 2x data rate.
Inputs:
zl5011xParams Pointer to the structure for this device instance
clockRate selects the TDM clock multiply mode
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xTifSetClockRate(zl5011xParamsS *zl5011xParams,
zl5011xWanIfClockRateE clockRate)
{
Uint32T bit, bitMask;
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE(ZL5011X_TIF_FN_ID, "zl5011xTifSetClockRate: %d",
clockRate, 0, 0, 0, 0, 0);
status = ZL5011X_CHECK_WAN_IF_CLOCK_RATE(clockRate);
if (status == ZL5011X_OK)
{
bit = (Uint32T)clockRate << ZL5011X_TIF_CLK_MULTIPLY_BIT;
bitMask = ZL5011X_1BIT_MASK << ZL5011X_TIF_CLK_MULTIPLY_BIT;
status = zl5011xUpdateRegisters(zl5011xParams, ZL5011X_TIF_CTRL_REG,
&zl5011xParams->wanIf.wanIfControl, bit, bitMask);
zl5011xParams->wanIf.wanClockMultiply = clockRate;
}
return(status);
}
/*******************************************************************************
Function:
zl5011xTifSetDataRate
Description:
Sets the data rate for the TDM streams.
Inputs:
zl5011xParams Pointer to the structure for this device instance
dataRate selects the TDM data rate
Outputs:
None
Returns:
zlStatusE
Remarks:
None
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -