⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 txc_envoy_spi3_valid.c

📁 TranSwitch Envoy CE2 & Envoy CE4 设备驱动及编程指南
💻 C
📖 第 1 页 / 共 3 页
字号:
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
/************************************************************************************

   FUNCTION:  ENVOY_SetSpi3OutputIfaceValid

   DESCRIPTION: This function validates the TXC_IfSPI3_OutputIfaceSet

   INPUTS:  Same as TXC_IfSPI3_OutputIfaceSet

   RETURNS:  TXC_NO_ERR or an appropriate specific error code listed in
   appendix.

   CAVEATS: None.

   REVISION HISTORY:

    Rev       Date          Author               Description
   -----    -------      ------------         -----------------
   0.0.5    5/17/04      F. Giannella            initial code 
 *--------------------------------------------------------------------------*/

TXC_U16BIT ENVOY_SetSpi3OutputIfaceValid (TXC_U16BIT handle, TXC_U8BIT interfaceId,
                                      TXC_IfSPI3_OUTPUT_STRUCT *spi3OutputIfaceDataPtr)
{
    TXC_U16BIT error;
    ENVOY_DEV_EXT_PIN_STRUCT pinData;

    /* fill the structure with 0 */
    memset ((void *) &pinData, 0, sizeof (pinData));

    /* first heck the handle and the interfaceId */
    error = ENVOY_VerifySpi3HandleAndIfaceId (handle, interfaceId);

    /* now range check the data */
    if (error == TXC_NO_ERR)
    {
        if (spi3OutputIfaceDataPtr->outputMode >= TXC_IfSPI3_END_OF_MODE_ENUM)
        {
            spi3OutputIfaceDataPtr->outputMode = TXC_IfSPI3_MODE_ENUM_ERR;
            error = TXC_INVALID_PARM_ERR;
        }
        else
        {
            /* checking of the outputMode */
            error = TXC_ENVOY_DeviceExPinRtrv (handle, &pinData);
            if (error != TXC_NO_ERR)
            {
                return error;
            }
            else
            {
                switch (spi3OutputIfaceDataPtr->outputMode)
                {
                    case TXC_IfSPI3_PHY_LAYER_SINGLE_PHY:
                        /* check if in PHY mode, otherwise return an error */
                        if (pinData.spi3OutputMode == ENVOY_DEV_PIN_SPI3_LINK_MODE)
                        {
                            spi3OutputIfaceDataPtr->outputMode = TXC_IfSPI3_MODE_ENUM_ERR;
                            error = TXC_INVALID_PARM_ERR; /* the CLI will take place */
                        }
                        break;

                    case TXC_IfSPI3_PHY_LAYER_MULTI_PHY:
                        /* check if in PHY LAYER mode, otherwise return an error */
                        if (pinData.spi3OutputMode == ENVOY_DEV_PIN_SPI3_LINK_MODE)
                        {
                            spi3OutputIfaceDataPtr->outputMode = TXC_IfSPI3_MODE_ENUM_ERR;
                            error = TXC_INVALID_PARM_ERR; /* the CLI will take place */
                        }
                        break;

                    case TXC_IfSPI3_LINK_LAYER_SINGLE_PHY:
                        /* check if in PHY mode, otherwise return an error */
                        if (pinData.spi3OutputMode == ENVOY_DEV_PIN_SPI3_PHY_MODE)
                        {
                            spi3OutputIfaceDataPtr->outputMode = TXC_IfSPI3_MODE_ENUM_ERR;
                            error = TXC_INVALID_PARM_ERR; /* the CLI will take place */
                        }
                        break;

                    case TXC_IfSPI3_LINK_LAYER_MULTI_PHY:
                        /* check if in PHY LAYER mode, otherwise return an error */
                        if (pinData.spi3OutputMode == ENVOY_DEV_PIN_SPI3_PHY_MODE)
                        {
                            spi3OutputIfaceDataPtr->outputMode = TXC_IfSPI3_MODE_ENUM_ERR;
                            error = TXC_INVALID_PARM_ERR; /* the CLI will take place */
                        }
                        break;

                    default:
                        spi3OutputIfaceDataPtr->outputMode = TXC_IfSPI3_MODE_ENUM_ERR;
                        error = TXC_INVALID_PARM_ERR; /* it should never get here */
                        break;
                }
            }
        }


        if (spi3OutputIfaceDataPtr->outputMode >= TXC_IfSPI3_END_OF_MODE_ENUM)
        {
            error = TXC_INVALID_PARM_ERR;
            spi3OutputIfaceDataPtr->outputMode = TXC_IfSPI3_MODE_ENUM_ERR;
        }

        /* Note: the Bus width is pin-configurable in Envoy-CE2/CE4 */
        if (spi3OutputIfaceDataPtr->outputBusWidth > TXC_IfSPI3_BUS_WIDTH_NONE)
        {
            error = TXC_INVALID_PARM_ERR;
            spi3OutputIfaceDataPtr->outputBusWidth = TXC_IfSPI3_BUS_WIDTH_ENUM_ERR;
        }

        if (spi3OutputIfaceDataPtr->outputParityGenerationMode >= TXC_IfSPI3_END_OF_PARITY_ENUM)
        {
            error = TXC_INVALID_PARM_ERR;
            spi3OutputIfaceDataPtr->outputParityGenerationMode = TXC_IfSPI3_PARITY_ENUM_ERR;
        }

        /* Note: enumerations equal or higher than DTPA are not applicable to Envoy-CE2/CE4 */
        if (spi3OutputIfaceDataPtr->outputFlowControlMode >= TXC_IfSPI3_OUTPUT_FLOW_CONTROL_DTPA)
        {
            error = TXC_INVALID_PARM_ERR;
            spi3OutputIfaceDataPtr->outputFlowControlMode = TXC_IfSPI3_OUTPUT_FLOW_CONTROL_ENUM_ERR;
        }

        if (spi3OutputIfaceDataPtr->outputPauseTimerMode >= TXC_IfSPI3_END_OF_OUTPUT_PAUSE_TIMER_ENUM)
        {
            error = TXC_INVALID_PARM_ERR;
            spi3OutputIfaceDataPtr->outputPauseTimerMode = TXC_IfSPI3_OUTPUT_PAUSE_TIMER_ENUM_ERR;
        }

        if ((spi3OutputIfaceDataPtr->outputDeviceExtension.envoyCe2Ce4OutputAttr.outputAggregationEnable != TXC_FALSE)  &&
            (spi3OutputIfaceDataPtr->outputDeviceExtension.envoyCe2Ce4OutputAttr.outputAggregationEnable != TXC_TRUE))
        {
            spi3OutputIfaceDataPtr->outputDeviceExtension.envoyCe2Ce4OutputAttr.outputAggregationEnable = TXC_BOOL_INVALID;
            error = TXC_INVALID_PARM_ERR;
        }

        if (spi3OutputIfaceDataPtr->outputDeviceExtension.envoyCe2Ce4OutputAttr.outputBaseAddress > ENVOY_MAX_SPI3_BASE_ADDR)
        {
            error = TXC_INVALID_PARM_ERR;
            spi3OutputIfaceDataPtr->outputDeviceExtension.envoyCe2Ce4OutputAttr.outputBaseAddress = TXC_U8_INVALID;
        }
    }
    /* return the error code */
    return error;
}



/************************************************************************************/
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
/************************************************************************************

   FUNCTION:  ENVOY_GetSpi3OutputIfaceValid

   DESCRIPTION: This function validates the TXC_IfSPI3_OutputIfaceGet

   INPUTS:   handle: Instance of the Envoy device to configure

             interfaceId: SPI-3 Bus Interface identifier

   RETURNS:  TXC_NO_ERR or an appropriate specific error code listed in appendix.

   CAVEATS:  None.

   REVISION HISTORY:

    Rev #     Date          Author                Description
   -----    -------      ------------         ----------------------
   0.5.0    6/03/04      F. Giannella         Initial release (beta)
-----------------------------------------------------------------------------------*/
TXC_U16BIT ENVOY_GetSpi3OutputIfaceValid(TXC_U16BIT handle, TXC_U8BIT interfaceId)
{
    TXC_U16BIT error;
    
    /* Check the handle and the interfaceId */
    error = ENVOY_VerifySpi3HandleAndIfaceId (handle, interfaceId);

    /* return the error code */
    return error;
}




/************************************************************************************/
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
/************************************************************************************

   FUNCTION:  ENVOY_SetSpi3PortCtrlValid

   DESCRIPTION: This function validates the TXC_IfSPI3_PortCtrlSet

   INPUTS:   same as TXC_IfSPI3_PortCtrlSet
  
   RETURNS:  TXC_NO_ERR or an appropriate specific error code listed in appendix.

   CAVEATS:  None.

   REVISION HISTORY:

    Rev #     Date          Author                Description
   -----    -------      ------------         ----------------------
   0.5.0    6/03/04      F. Giannella         Initial release (beta)
-----------------------------------------------------------------------------------*/
TXC_U16BIT ENVOY_SetSpi3PortCtrlValid(TXC_U16BIT handle, TXC_U8BIT interfaceId,
                     TXC_U16BIT port, TXC_IfSPI3_PORT_CTRL_STRUCT  *spi3PortCtrlPtr)

{
    TXC_U16BIT error;
    
    /* first, check the handle, the interfaceId and the port  */
    error = ENVOY_VerifySpi3HandleIfaceIdAndMultiPort (handle, interfaceId, port);

    if (error == TXC_NO_ERR)
    {
        if (spi3PortCtrlPtr->spi3PortEnableMode >= TXC_IfSPI3_END_OF_PORT_ENABLE_MODE_ENUM)
        {
            spi3PortCtrlPtr->spi3PortEnableMode = TXC_IfSPI3_PORT_ENABLE_MODE_ENUM_ERR;
            error = TXC_INVALID_PARM_ERR;
        }
    }
    /* return the error code */
    return error;
}



/************************************************************************************/
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
/************************************************************************************

   FUNCTION:  ENVOY_GetSpi3PortCtrlValid

   DESCRIPTION: This function validates the TXC_IfSPI3_PortCtrlGet

   INPUTS:   handle: Instance of the Envoy device to configure
 
             interfaceId: SPI-3 Bus Interface identifier

             port: the logical SPI-3 port ID to access

   RETURNS:  TXC_NO_ERR or an appropriate specific error code listed in appendix.

   CAVEATS:  None.

   REVISION HISTORY:

    Rev #     Date          Author                Description
   -----    -------      ------------         ----------------------
   0.5.0    6/03/04      F. Giannella         Initial release (beta)
-----------------------------------------------------------------------------------*/
TXC_U16BIT ENVOY_GetSpi3PortCtrlValid(TXC_U16BIT handle, TXC_U8BIT interfaceId, TXC_U16BIT port)

{
    TXC_U16BIT error;
    
    /* check the handle, the interfaceId and the port  */
    error = ENVOY_VerifySpi3HandleIfaceIdAndSinglePort (handle, interfaceId, port);

    /* return the error code */
    return error;
}


/************************************************************************************/
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
/************************************************************************************

   FUNCTION:  ENVOY_SetSpi3InputFlowCtrlCfgValid

   DESCRIPTION: This function validates the TXC_IfSPI3_InputFlowCtrlCfgSet

   INPUTS:  same as TXC_IfSPI3_InputFlowCtrlCfgSet
  
   RETURNS:  TXC_NO_ERR or an appropriate specific error code listed in appendix.

   CAVEATS:  None.

   REVISION HISTORY:

    Rev #     Date          Author                Description
   -----    -------      ------------         ----------------------
   0.5.0    6/03/04      F. Giannella         Initial release (beta)
-----------------------------------------------------------------------------------*/
TXC_U16BIT ENVOY_SetSpi3InputFlowCtrlCfgValid (TXC_U16BIT handle, TXC_U8BIT interfaceId,
           TXC_U16BIT port, TXC_IfSPI3_INPUT_FLOW_CTRL_STRUCT  *spi3InputFlowCtrlDataPtr)
{
    TXC_U16BIT error;
    ENVOY_DEV_EXT_PIN_STRUCT pinData;

    /* fill the structure with 0 */
    memset ((void *) &pinData, 0, sizeof (pinData));

    /* first, check the handle and the interfaceId */
    error = ENVOY_VerifySpi3HandleAndIfaceId (handle, interfaceId);

    if (error == TXC_NO_ERR)
    {

        if (port != ENVOY_MAC_ALL_PORTS)  /* for Envoy-CE2/CE4 the flow control is across the SPI-3 Input Interface */
        {
            return error = TXC_INVALID_CHANNEL_ERR;
        }

        /* Verify if in PHY-Layer Mode, otherwise issue a WARNING */

        /* checking of the inputMode */
        error = TXC_ENVOY_DeviceExPinRtrv (handle, &pinData);
        if (error == TXC_NO_ERR)
        {
            if ((pinData.spi3InputMode != ENVOY_DEV_PIN_SPI3_PHY_MODE) &&
               ((spi3InputFlowCtrlDataPtr->inputHiPhyWmarkStpa >= ISPI_MIN_FLOW_CTRL_THRSLD) ||
                (spi3InputFlowCtrlDataPtr->inputLoPhyWmarkStpa >= ISPI_MIN_FLOW_CTRL_THRSLD) ||
                (spi3InputFlowCtrlDataPtr->inputHiPhyWmarkPtpa >= ISPI_MIN_FLOW_CTRL_THRSLD) ||
                (spi3InputFlowCtrlDataPtr->inputLoPhyWmarkPtpa >= ISPI_MIN_FLOW_CTRL_THRSLD)))
            {
                error = TXC_LINK_LAYER_WARNING;
            }

            if ((spi3InputFlowCtrlDataPtr->inputHiPhyWmarkStpa > ISPI_MAX_FLOW_CTRL_THRSLD) ||
                (spi3InputFlowCtrlDataPtr->inputHiPhyWmarkStpa < ISPI_MIN_FLOW_CTRL_THRSLD))
            {
                spi3InputFlowCtrlDataPtr->inputHiPhyWmarkStpa = TXC_U16_INVALID;
                error = TXC_INVALID_PARM_ERR;
            }
            if ((spi3InputFlowCtrlDataPtr->inputLoPhyWmarkStpa > ISPI_MAX_FLOW_CTRL_THRSLD) ||
               (spi3InputFlowCtrlDataPtr->inputLoPhyWmarkStpa < ISPI_MIN_FLOW_CTRL_THRSLD))
            {
                spi3InputFlowCtrlDataPtr->inputLoPhyWmarkStpa = TXC_U16_INVALID;
                error = TXC_INVALID_PARM_ERR;
            }
            if ((spi3InputFlowCtrlDataPtr->inputHiPhyWmarkPtpa > ISPI_MAX_FLOW_CTRL_THRSLD) ||
               (spi3InputFlowCtrlDataPtr->inputHiPhyWmarkPtpa < ISPI_MIN_FLOW_CTRL_THRSLD))
            {
                spi3InputFlowCtrlDataPtr->inputHiPhyWmarkPtpa = TXC_U16_INVALID;
                error = TXC_INVALID_PARM_ERR;
            }
            if ((spi3InputFlowCtrlDataPtr->inputLoPhyWmarkPtpa > ISPI_MAX_FLOW_CTRL_THRSLD) ||
               (spi3InputFlowCtrlDataPtr->inputLoPhyWmarkPtpa < ISPI_MIN_FLOW_CTRL_THRSLD))
            {
                spi3InputFlowCtrlDataPtr->inputLoPhyWmarkPtpa = TXC_U16_INVALID;
                error = TXC_INVALID_PARM_ERR;
            }
        }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -