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

📄 zl5011xtdm.c

📁 Zalink50114----TDMoIP芯片驱动源码
💻 C
📖 第 1 页 / 共 5 页
字号:
      par->osExclusionEnable = ZL5011X_TRUE;
   }

   return status;
}

/*******************************************************************************

 Function:
   zl5011xWanRxGetPayloadLength

 Description:
   Returns the payload length in bits and bytes of a context as it is currently.
   That is, if a context is in modification, the new payload length is returned.

 Inputs:
   zl5011xParams   Pointer to the structure for this device instance
   par            Pointer to the structure for configuration items. See below:

 Structure inputs:
   context        context to be used
   osExclusionEnable ZL5011X_TRUE to enable OS exclusion

 Structure outputs:
   lengthBits     payload length in bits
   lengthBytes    payload length in bytes

 Returns:
   zlStatusE

 Remarks:
   None

*******************************************************************************/

zlStatusE zl5011xWanRxGetPayloadLength(zl5011xParamsS *zl5011xParams,
      zl5011xWanRxGetPayloadLengthS *par)
{
   zlStatusE status = ZL5011X_OK;
   zl5011xBooleanE gotDevice = ZL5011X_FALSE;

   /* do some parameter checking */
   status = ZL5011X_CHECK_POINTERS(zl5011xParams, par);

   if (status == ZL5011X_OK)
   {
      status = ZL5011X_CHECK_RUNNING(zl5011xParams);
   }

   if ((status == ZL5011X_OK) && (par->osExclusionEnable == ZL5011X_TRUE))
   {
      /* get access to the device */
      status = zl5011xGetDevice(zl5011xParams, ZL5011X_GET_DEVICE_TIMEOUT_MODE);

      if (status == ZL5011X_OK)
      {
         gotDevice = ZL5011X_TRUE;
      }
   }

   /* check that the Wan Rx context is valid */
   if (status == ZL5011X_OK)
   {
      status = zl5011xContextCheckRx(zl5011xParams, par->context, ZL5011X_CHECK_CONTEXT_IN_USE);
   }

   /* main function code starts */

   if (status == ZL5011X_OK)
   {
      ZL5011X_TRACE_CONTEXT(ZL5011X_TDM_FN_ID, par->context,
            "zl5011xWanRxGetPayloadLength: ctxt %3d",
            par->context, 0, 0, 0, 0, 0);

      /* calculate the payload length before updating the context */
      if (zl5011xParams->wanIf.wanConnectionMode == ZL5011X_WAN_CONNECTION_UNFRAMED)
      {
         status = zl5011xWanCalcUnframedPayloadLengthEx(zl5011xParams->wanIf.clock.async.stream[par->context].streamFrequency,
               zl5011xParams->wanIf.plaCurrent.context[par->context].payloadFrames,
               zl5011xParams->wanIf.plaCurrent.context[par->context].payloadBytes,
               zl5011xParams->wanIf.wanBitStuffingEnabled,
               zl5011xParams->wanIf.plaCurrent.context[par->context].unframedForceMultiple64Bits,
               &(par->lengthBits), &(par->lengthBytes));
      }
      else
      {
         /* Framed mode. Calculate size from the numberOfFrames and number of channels per frame */
         par->lengthBytes = zl5011xParams->wanIf.plaCurrent.context[par->context].payloadFrames *
               zl5011xParams->wanIf.plaCurrent.context[par->context].numChannels;
         par->lengthBits = par->lengthBytes * 8;
      }
   }

   if (gotDevice == ZL5011X_TRUE)
   {
      if (status == ZL5011X_OK)
      {
         status = zl5011xReleaseDevice(zl5011xParams);
      }
      else
      {
         /* already have an error code, so don't overwrite it */
         (void)zl5011xReleaseDevice(zl5011xParams);
      }
   }

   return status;
}

/*******************************************************************************

 Function:
   zl5011xContextUpdateRxStructInit

 Description:
   Initialises structure used by zl5011xContextUpdateRx function.

 Inputs:
   zl5011xParams   Pointer to the structure for this device instance
   par            Pointer to the structure for configuration items.
                  See main function

 Returns:
   zlStatusE

 Remarks:
   None

*******************************************************************************/

zlStatusE zl5011xContextUpdateRxStructInit(zl5011xParamsS *zl5011xParams,
      zl5011xContextS *par)
{
   zlStatusE status = ZL5011X_OK;

   /* do some parameter checking */
   status = ZL5011X_CHECK_POINTERS(zl5011xParams, par);

   if (status == ZL5011X_OK)
   {
      ZL5011X_TRACE(ZL5011X_TDM_FN_ID,
            "zl5011xContextUpdateRxStructInit:",
            0, 0, 0, 0, 0, 0);

      par->context = (Uint32T)ZL5011X_INVALID_CONTEXT;
      par->osExclusionEnable = ZL5011X_TRUE;
   }

   return status;
}

/*******************************************************************************

 Function:
   zl5011xContextUpdateRx

 Description:
   Sets the payload size in bytes, based on the context configuration. The first
   channel is set up and the context update set.

 Inputs:
   zl5011xParams   Pointer to the structure for this device instance
   par            Pointer to the structure for configuration items. See below:

 Structure inputs:
   context        context to be used
   osExclusionEnable ZL5011X_TRUE to enable OS exclusion

 Structure outputs:
   None

 Returns:
   zlStatusE

 Remarks:
   None

*******************************************************************************/

zlStatusE zl5011xContextUpdateRx(zl5011xParamsS *zl5011xParams,
      zl5011xContextS *par)
{
   zlStatusE status = ZL5011X_OK;
   zl5011xWanRxGetPayloadLengthS payloadLength;
   zl5011xBooleanE gotDevice = ZL5011X_FALSE;

   /* do some parameter checking */
   status = ZL5011X_CHECK_POINTERS(zl5011xParams, par);

   if (status == ZL5011X_OK)
   {
      status = ZL5011X_CHECK_RUNNING(zl5011xParams);
   }

   if ((status == ZL5011X_OK) && (par->osExclusionEnable == ZL5011X_TRUE))
   {
      /* get access to the device */
      status = zl5011xGetDevice(zl5011xParams, ZL5011X_GET_DEVICE_TIMEOUT_MODE);

      if (status == ZL5011X_OK)
      {
         gotDevice = ZL5011X_TRUE;
      }
   }

   /* check that the Wan Rx context is valid */
   if (status == ZL5011X_OK)
   {
      status = zl5011xContextCheckRx(zl5011xParams, par->context, ZL5011X_CHECK_CONTEXT_MODIFY);
   }

   /* main function code starts */

   if (status == ZL5011X_OK)
   {
      ZL5011X_TRACE_CONTEXT(ZL5011X_TDM_FN_ID, par->context,
            "zl5011xContextUpdateRx: ctxt %3d",
            par->context, 0, 0, 0, 0, 0);

      status = zl5011xWanRxGetPayloadLengthStructInit(zl5011xParams, &payloadLength);

      payloadLength.context = par->context;
      payloadLength.osExclusionEnable = ZL5011X_FALSE;

      if (status == ZL5011X_OK)
      {
         status = zl5011xWanRxGetPayloadLength(zl5011xParams, &payloadLength);
      }
   }

   if (status == ZL5011X_OK)
   {
      /* set the payload length */
      status = zl5011xPlaSetPayloadLength(zl5011xParams, par->context, payloadLength.lengthBytes);
   }

   /* update the first channel for the context */
   if (status == ZL5011X_OK)
   {
      status = zl5011xPlaUpdateFirstChan(zl5011xParams, par->context);
   }

   /* update the context */
   if (status == ZL5011X_OK)
   {
      status = zl5011xPlaUpdateContext(zl5011xParams, par->context);
   }

   if (gotDevice == ZL5011X_TRUE)
   {
      if (status == ZL5011X_OK)
      {
         status = zl5011xReleaseDevice(zl5011xParams);
      }
      else
      {
         /* already have an error code, so don't overwrite it */
         (void)zl5011xReleaseDevice(zl5011xParams);
      }
   }

   return status;
}

/*******************************************************************************

 Function:
   zl5011xContextUpdateTxStructInit

 Description:
   Initialises structure used by zl5011xContextUpdateTx function.

 Inputs:
   zl5011xParams   Pointer to the structure for this device instance
   par            Pointer to the structure for configuration items.
                  See main function

 Returns:
   zlStatusE

 Remarks:
   None

*******************************************************************************/

zlStatusE zl5011xContextUpdateTxStructInit(zl5011xParamsS *zl5011xParams,
      zl5011xContextS *par)
{
   zlStatusE status = ZL5011X_OK;

   /* do some parameter checking */
   status = ZL5011X_CHECK_POINTERS(zl5011xParams, par);

   if (status == ZL5011X_OK)
   {
      ZL5011X_TRACE(ZL5011X_TDM_FN_ID,
            "zl5011xContextUpdateTxStructInit:",
            0, 0, 0, 0, 0, 0);

      par->context = (Uint32T)ZL5011X_INVALID_CONTEXT;
      par->osExclusionEnable = ZL5011X_TRUE;
   }

   return status;
}

/*******************************************************************************

 Function:
   zl5011xContextUpdateTx

 Description:
   The first channel is updated and the context updated. If the context is in
   the INIT state, then the queue is resumed (started).
   If in unstructured mode, the stream clock is enabled (to the nominal
   frequency) if it has not already been done.
   If in structured mode, the channel tri-states are updated.

 Inputs:
   zl5011xParams   Pointer to the structure for this device instance
   par            Pointer to the structure for configuration items. See below:

 Structure inputs:
   context        context to be used
   osExclusionEnable ZL5011X_TRUE to enable OS exclusion

 Structure outputs:
   None

 Returns:
   zlStatusE

 Remarks:
   None

*******************************************************************************/

zlStatusE zl5011xContextUpdateTx(zl5011xParamsS *zl5011xParams,
      zl5011xContextS *par)
{
   zlStatusE status = ZL5011X_OK;
   zl5011xBooleanE firstUpdate = ZL5011X_FALSE;
   Uint32T loop;
   zl5011xBooleanE gotDevice = ZL5011X_FALSE;

   /* do some parameter checking */
   status = ZL5011X_CHECK_POINTERS(zl5011xParams, par);

   if (status == ZL5011X_OK)
   {
      status = ZL5011X_CHECK_RUNNING(zl5011xParams);
   }

   if ((status == ZL5011X_OK) && (par->osExclusionEnable == ZL5011X_TRUE))
   {
      /* get access to the device */
      status = zl5011xGetDevice(zl5011xParams, ZL5011X_GET_DEVICE_TIMEOUT_MODE);

      if (status == ZL5011X_OK)
      {
         gotDevice = ZL5011X_TRUE;
      }
   }

   /* check that the Wan Tx context is valid */
   if (status == ZL5011X_OK)
   {
      status = zl5011xContextCheckTx(zl5011xParams, par->context, ZL5011X_CHECK_CONTEXT_MODIFY);
   }

   /* main function code starts */

   if (status == ZL5011X_OK)
   {
      ZL5011X_TRACE_CONTEXT(ZL5011X_TDM_FN_ID, par->context,
            "zl5011xContextUpdateTx: ctxt %3d",
            par->context, 0, 0, 0, 0, 0);

      if (zl5011xParams->wanIf.tfmCurrent.context[par->context].state == ZL5011X_STATE_INIT)
      {
         firstUpdate = ZL5011X_TRUE;
      }

      /* update the first channel for the context */
      status = zl5011xTfmUpdateFirstChan(zl5011xParams, par->context);
   }

   /* update the context */
   if (status == ZL5011X_OK)
   {
      if (zl5011xParams->wanIf.txQueue[par->context].queueInitialised != ZL5011X_TRUE)
      {
         status = ZL5011X_WAN_QUEUE_NOT_INIT;
      }
      else
      {
         status = zl5011xTfmUpdateContext(zl5011xParams, par->context);
      }
   }

   /* if this is a new context, then need to resume the queue */
   if (status == ZL5011X_OK)
   {
      if (firstUpdate == ZL5011X_TRUE)
      {
         status = zl5011xTfqResume(zl5011xParams, par->cont

⌨️ 快捷键说明

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