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

📄 zl5011xdmampc8260.c

📁 Zalink50114----TDMoIP芯片驱动源码
💻 C
📖 第 1 页 / 共 4 页
字号:
   return(dma->bufferDescrip[descriptorNumber].source);
}

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

 Function:
   zl5011xDmaReadDestinationAddress

 Description:
    This function will read the destination address field of the specified
    buffer descriptor

 Inputs:
    dmaChannel        DMA channel
    descriptorNumber  Descriptor number

 Outputs
   None

 Returns:
   Uint32T            Destination address

 Remarks:

*******************************************************************************/
extern Uint32T zl5011xDmaReadDestinationAddress(zl5011xDmaChannelS *dmaChannel,
                               Uint32T descriptorNumber)
{
   zl5011xDmaStructS *dma = (zl5011xDmaStructS *)dmaChannel->dma;

   ZL5011X_TRACE(ZL5011X_DMA_FN_ID,"zl5011xDmaReadDestinationAddress:", 0, 0, 0, 0, 0, 0);

   return(dma->bufferDescrip[descriptorNumber].destination);
}

/*****************   STATIC FUNCTION DEFINTIONS   *****************************/

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

 Function:
   zl5011xDmaOutOfBuffers

 Description:
    This function is called as a result of the CP being out of buffers interrupt.
    Its purpose is to disconnect the external DREQ to prevent communications to
    the processor from failing.

 Inputs:
   None

 Outputs:
   None

 Returns:
   None

 Remarks:

*******************************************************************************/
static void zl5011xDmaOutOfBuffers(void)
{
   zlStatusE status = ZL5011X_OK;
   zl5011xDmaStatusE dmaStatus;
   Uint32T n;

   ZL5011X_TRACE(ZL5011X_DMA_FN_ID,"zl5011xDmaOutOfBuffers Beginning ",0,0,0,0,0,0);

   while ((IdmaMonitor.goFlag == ZL5011X_TRUE) && (status == ZL5011X_OK))
   {
     for(n=0;n<ZL5011X_DMA_NUMBER_OF_CHANNELS && status == ZL5011X_OK;n++)
     {
       if (IdmaMonitor.channelEnabled[n] == ZL5011X_TRUE)
       {
         dmaStatus = zl5011xDmaDetermineStatus(IdmaMonitor.dmaChannel[n]);
         if (dmaStatus == ZL5011X_DMA_OUT_OF_BUFFERS)
         {
           zl5011xDisconnectDreq(IdmaMonitor.dmaChannel[n]);
         }
       }
     }

     OS_TICK_DELAY(1);
   }

   ZL5011X_TRACE(ZL5011X_DMA_FN_ID,"zl5011xDmaOutOfBuffers terminating with "
          "status %d",status,0,0,0,0,0);
}

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

 Function:
   zl5011xassignDmaPorts

 Description:
    This function will program the DREQ and DACK pins from the device to
    the appropriate DMA channel in the MPC8260

 Inputs:
    dmaChannel        DMA channel

 Outputs:
   None

 Returns:
   None

 Remarks:
   This function is both micro specific and board specific. For the
   _ZARLINK_ZLE5011X_BOARD, DMA channels 0 (corresponding to IDMA1), and 1
   (IDMA2) MUST be used.

    Direction: CPU out
       DMA channel 0 (IDMA1 [DREQ1, DACK1])
       Connection to device made usaing Port C pins 0 and 23

    Direction: CPU in
       DMA channel 1 (IDMA2 [DREQ2, DACK2])
       Connection to device made using Port C pins 1 and 3

*******************************************************************************/
static void zl5011xassignDmaPorts(zl5011xDmaChannelS *dmaChannel)
{
#ifdef _ZARLINK_ZLE5011X_BOARD
   if (dmaChannel->channelNumber == 0)
   {
      /* Setup port C pin assignment (DREQ to be inputs (0), DACK to be
          output (0))                                                            */
      *((volatile Uint32T*)(dmaChannel->imm + PPC8260_IMM_PIO_PDIRC))
           = ((*((volatile Uint32T*)(dmaChannel->imm + PPC8260_IMM_PIO_PDIRC))
                       & ~PPC8260_PORTC_DREQ1_MASK)
                       | PPC8260_PORTC_DACK1_MASK);

      /* Setup PORT C pin functionality (DREQ and DACK to be set to dedicated
          function (1))                                                      */
      *((volatile Uint32T*)(dmaChannel->imm + PPC8260_IMM_PIO_PPARC))
                 |= PPC8260_PORTC_DREQ1_MASK
                     | PPC8260_PORTC_DACK1_MASK;

      /* Set DREQ to be level sensitive (active high)                           */
      *((volatile Uint32T*)(dmaChannel->imm + PPC8260_IMM_CPM_RCCR))
                           |= PPC8260_IMM_CPM_CMD_1;

      /* Connect external DACK to processor                                     */
      /* Set the PSORC bit for DACK1 */
      *((volatile Uint32T*)(dmaChannel->imm + PPC8260_IMM_PIO_PSORC))
                        |= PPC8260_PORTC_DACK1_MASK;
   }
   else  /* Assume that (dmaChannel->channelNumber == 1) */
   {
      /* Setup port C pin assignment (DREQ to be inputs (0), DACK to be
          output (0))                                                            */
      *((volatile Uint32T*)(dmaChannel->imm + PPC8260_IMM_PIO_PDIRC))
           = ((*((volatile Uint32T*)(dmaChannel->imm + PPC8260_IMM_PIO_PDIRC))
                       & ~PPC8260_PORTC_DREQ2_MASK)
                       |  PPC8260_PORTC_DACK2_MASK);

      /* Setup PORT C pin functionality (DREQ and DACK to be set to dedicated
          function (1))                                                      */
      *((volatile Uint32T*)(dmaChannel->imm + PPC8260_IMM_PIO_PPARC))
                 |= PPC8260_PORTC_DREQ2_MASK
                     | PPC8260_PORTC_DACK2_MASK;

      /* Set DREQ to be level sensitive (active high)                           */
      *((volatile Uint32T*)(dmaChannel->imm + PPC8260_IMM_CPM_RCCR))
                           |= PPC8260_IMM_CPM_CMD_2;

      /* Connect external DACK to processor                                     */
      /* Set the PSORC bit for DACK2 */
      *((volatile Uint32T*)(dmaChannel->imm + PPC8260_IMM_PIO_PSORC))
                        |= PPC8260_PORTC_DACK2_MASK;
   }

   zl5011xDisconnectDreq(dmaChannel);
#endif
}


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

 Function:
   zl5011xConnectDreq

 Description:
    This function will connect the specified DREQ to the processor core

 Inputs:
   dmaChannel        DMA channel

 Outputs:
   None

 Returns:
   None

 Remarks:

*******************************************************************************/
static void zl5011xConnectDreq(zl5011xDmaChannelS *dmaChannel)
{
#ifdef _ZARLINK_ZLE5011X_BOARD
   if (dmaChannel->channelNumber == 0)
   {    /* Clear the PSORC bit for DREQ1 */
      *((volatile Uint32T*)(dmaChannel->imm + PPC8260_IMM_PIO_PSORC))
                    &= ~PPC8260_PORTC_DREQ1_MASK;
   }
   else
   {    /* Clear the PSORC bit for DREQ2 */
      *((volatile Uint32T*)(dmaChannel->imm + PPC8260_IMM_PIO_PSORC))
                    &= ~PPC8260_PORTC_DREQ2_MASK;
   }
#endif
}

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

 Function:
   zl5011xDisconnectDreq

 Description:
    This function will disconnect the specified DREQ to the processor core

 Inputs:
    dmaChannel        DMA channel

 Outputs:
   None

 Returns:
   None

 Remarks:

*******************************************************************************/
static void zl5011xDisconnectDreq(zl5011xDmaChannelS *dmaChannel)
{
#ifdef _ZARLINK_ZLE5011X_BOARD
   if (dmaChannel->channelNumber == 0)
   {    /* Set the PSORC bit for DREQ1*/
      *((volatile Uint32T*)(dmaChannel->imm + PPC8260_IMM_PIO_PSORC))
                    &= ~PPC8260_PORTC_DREQ1_MASK;
   }
   else
   {    /* Set the PSORC bit for DREQ2 */
      *((volatile Uint32T*)(dmaChannel->imm + PPC8260_IMM_PIO_PSORC))
                    |= PPC8260_PORTC_DREQ2_MASK;
   }
#endif
}


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

 Function:
   zl5011xIsDmaBufferDone

 Description:
    Determines whether the DMA buffer complete flag (BC) is set. If it is
    set then this function also clears it.
    The BC flag will only be set if the I flag was set on this buffer
    descriptor.

 Inputs:
    dmaChannel        DMA channel

 Outputs:
   None

 Returns:
   None

 Remarks:

*******************************************************************************/
zl5011xBooleanE zl5011xIsDmaBufferDone(zl5011xDmaChannelS *dmaChannel)
{
   zl5011xDmaStructS *dma = (zl5011xDmaStructS *)dmaChannel->dma;
   Uint32T idsrValue;

   /* Read idsr status register to determine status                         */
   idsrValue = dma->reg->idsr;

   /* Check the buffer complete flag */
   if ((idsrValue & PPC8260_IDMA_IDSR_BC) == 0)
   {
      return ZL5011X_FALSE;
   }
   else
   {
      /* Clear the buffer complete flag. Other flags are left unchanged */
      dma->reg->idsr = PPC8260_IDMA_IDSR_BC;

      return ZL5011X_TRUE;
   }
}

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

 Function:
   zl5011xDmaSetDescriptorInterruptFlag

 Description:
    This function will set or clear the descriptor buffer interrupt flag
    on the specified buffer

 Inputs:
    dmaChannel             DMA channel to set
    zlBooleanE             enable

 Outputs
   None

 Returns:
   None

 Remarks:

*******************************************************************************/
extern void zl5011xDmaSetDescriptorInterruptFlag(zl5011xDmaChannelS *dmaChannel,
                     Uint16T bufferIndex, zl5011xBooleanE enable)
{
   zl5011xDmaStructS *dma = (zl5011xDmaStructS *)dmaChannel->dma;

   ZL5011X_TRACE(ZL5011X_DMA_FN_ID,"zl5011xDmaFreeDescriptorBuffer:", 0, 0, 0, 0, 0, 0);

   /* Set or reset the I bit for the specified descriptor */
   if (enable == ZL5011X_TRUE)
   {
      dma->bufferDescrip[bufferIndex].ctlsts |= PPC8260_IDMA_BD_INT;
   }
   else
   {
      dma->bufferDescrip[bufferIndex].ctlsts &= ~PPC8260_IDMA_BD_INT;
   }
}



/*****************   END   ****************************************************/

⌨️ 快捷键说明

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