dmaallocchannel.c

来自「CC1110点对多点FDMA传输方式C源码」· C语言 代码 · 共 68 行

C
68
字号
/******************************************************************************
*                                                                             *
*    ****       ******       ****
*     ****     ********     ****
*      ****   ****  ****   ****
*       **** ****    **** ****              wxl
*        *******      *******
*         *****        *****                    成都无线龙通讯科技有限公司
*                                                                             *
*******************************************************************************
Target:       cc1110                          使用芯片:       cc1110
Author:       WXL                             程 序 员:      无线龙
data:         1/12-2007                       日    期:      1/12-2007
******************************************************************************/
/**********************************头文件**************************************/

#include "cul.h"

extern DMA_DESC dmaChannel1to4[4];
extern DMA_TABLE_ENTRY dmaTable[DMA_ADM_NUMBER_OF_CHANNELS];

//-----------------------------------------------------------------------------
// See cul.h for a description of this function.
//-----------------------------------------------------------------------------
DMA_DESC* culDmaAllocChannel(UINT8* pDmaChannelNumber, FUNCTION* callBackFunction){
   DMA_DESC* dmaDesc;
   BYTE savedIntEnable = 0x00;
   INT8 i;

   // Checking for an unassigned DMA channel
   for(i = 1; i <= DMA_ADM_NUMBER_OF_CHANNELS; i++){
      if(dmaTable[i].assigned == FALSE){
         break;
      }
   }

   // If no channel is available, the function returns.
   if(i > DMA_ADM_NUMBER_OF_CHANNELS){
      *pDmaChannelNumber = 0x00;
      dmaDesc = NULL;
   }
   // An available table entry was found
   else {
      // Deactivating the channel and erasing old interrupt flag
      DMA_ABORT_CHANNEL(i);
      DMAIRQ &= ~(1 << i);

      // Storing interrupt enable register and turning off interrupts.
      savedIntEnable = IEN0;
      INT_GLOBAL_ENABLE(INT_OFF);

      // Reserving the DMA channel.
      dmaTable[i].assigned = TRUE;
      dmaTable[i].callBackFunction = callBackFunction;
      *pDmaChannelNumber = i;

      // Restoring old interrupt enable register.
      IEN0 = savedIntEnable;

      dmaDesc = &dmaChannel1to4[i-1];
   }

   // Returning pointer to the DMA descriptor
   return dmaDesc;
} // ends culDmaAlloc()


⌨️ 快捷键说明

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