Esempio n. 1
0
void init_dma(void)
{
     HWI_Attrs hwiAttrs;
     Uns dmaTxSynEvt, dmaRxSynEvt;
     Uint32 dmaTxDest, dmaRxSrc;
     LgUns tempAdd;
     DMA_Config dmaTxCfg, dmaRxCfg;

     DMA_FSET(DMAGCR,FREE,0); 
     DMA_getConfig(hDmaTx, &dmaTxCfg); 
     dmaTxDest = MCBSP_ADDR(DXR21) << 1;
     /* Setup Tx Side addresses based on MCBSP port */
     dmaTxCfg.dmacdsal = (DMA_AdrPtr)(dmaTxDest & 0xFFFF);
     dmaTxCfg.dmacdsau = ((dmaTxDest >> 15) & 0xFFFF);
     tempAdd = (LgUns)(&txBuffer[0]) << 1; /* byte address */
     dmaTxCfg.dmacssal = (DMA_AdrPtr)(tempAdd & 0xFFFF);
     dmaTxCfg.dmacssau = ((tempAdd >> 15) & 0xFFFF); 
     dmaTxSynEvt = DMA_DMACCR_SYNC_XEVT1;
     dmaTxCfg.dmaccr |= DMA_FMK(DMACCR,SYNC,dmaTxSynEvt); 
     DMA_config(hDmaTx,&dmaTxCfg); 

     /* Setup Rx Side addresses based on MCBSP port */
     DMA_getConfig(hDmaRx, &dmaRxCfg);
     dmaRxSrc  = MCBSP_ADDR(DRR11) << 1; 
     dmaRxCfg.dmacssal = (DMA_AdrPtr)(dmaRxSrc & 0xFFFF);
     dmaRxCfg.dmacssau = ((dmaRxSrc >> 15) & 0xFFFF);
     tempAdd = (LgUns)(rxstart) << 1; /* byte address */
     dmaRxCfg.dmacdsal = (DMA_AdrPtr)(tempAdd & 0xFFFF);
     dmaRxCfg.dmacdsau = ((tempAdd >> 15) & 0xFFFF); 
     dmaRxSynEvt = DMA_DMACCR_SYNC_REVT1;
     dmaRxCfg.dmaccr |= DMA_FMK(DMACCR,SYNC,dmaRxSynEvt); 
     DMA_config(hDmaRx,&dmaRxCfg); 

     /* Configure DMA to be free running */
     DMA_FSET(DMAGCR,FREE,1); 
     /* Obtain Interrupt IDs for Tx and Rx DMAs */
     rxId = DMA_getEventId(hDmaRx);
     txId = DMA_getEventId(hDmaTx); 
     /* plug in the ISR */
     hwiAttrs.ier0mask = UARTHW_MCBSP_IER_MASK_DEFAULT;
     hwiAttrs.ier1mask = UARTHW_MCBSP_IER_MASK_DEFAULT;
     hwiAttrs.arg = NULL;
     HWI_dispatchPlug(rxId, (Fxn)rxIsr, &hwiAttrs);
     hwiAttrs.ier0mask = UARTHW_MCBSP_IER_MASK_DEFAULT;
     hwiAttrs.ier1mask = UARTHW_MCBSP_IER_MASK_DEFAULT;
     HWI_dispatchPlug(txId, (Fxn)txIsr, &hwiAttrs); 
     IRQ_enable(txId); 
     IRQ_enable(rxId);
}
/**
 *  \brief  Configures Dma
 *
 *  \param  chanNum - Dma channel number
 *
 *  \return Dma handle
 */
CSL_DMA_Handle CSL_configDmaForUart(CSL_DMA_ChannelObj    *dmaChanObj,
                                    CSL_DMAChanNum        chanNum)
{
    CSL_DMA_Handle    dmaHandle;
    CSL_Status        status;

    dmaHandle = NULL;

    /* Initialize Dma */
    status = DMA_init();
    if (status != CSL_SOK)
    {
        printf("DMA_init Failed!\n");
    }

    /* Open A Dma channel */
    dmaHandle = DMA_open(chanNum, dmaChanObj, &status);
    if(dmaHandle == NULL)
    {
        printf("DMA_open Failed!\n");
    }

    /* Configure a Dma channel */
    status = DMA_config(dmaHandle, &dmaConfig);
    if(status != CSL_SOK)
    {
        printf("DMA_config Failed!\n");
        dmaHandle = NULL;
    }

    return(dmaHandle);
}
Esempio n. 3
0
   /////                                  program flow reaches expected exit point(s).
   /////
void main(void)
{
	CSL_DMA_ChannelObj  dmaObj;
	CSL_Status 			status;
	Uint16   			chanNumber;
	Uint16   			i;

	printf("\n DMA POLLED MODE TEST!\n");

	for(i = 0; i < CSL_DMA_BUFFER_SIZE; i++)
	{
		dmaSRCBuff[i]  = 0xFFFF;
		dmaDESTBuff[i] = 0x0000;
	}

#if (defined(CHIP_C5505_C5515) || defined(CHIP_C5504_C5514) || defined(CHIP_C5517))
	dmaConfig.pingPongMode = CSL_DMA_PING_PONG_DISABLE;
#endif

	dmaConfig.autoMode     = CSL_DMA_AUTORELOAD_DISABLE;
	dmaConfig.burstLen     = CSL_DMA_TXBURST_8WORD;
	dmaConfig.trigger      = CSL_DMA_SOFTWARE_TRIGGER;
	dmaConfig.dmaEvt       = CSL_DMA_EVT_NONE;
	dmaConfig.dmaInt       = CSL_DMA_INTERRUPT_DISABLE;
	dmaConfig.chanDir      = CSL_DMA_READ;
	dmaConfig.trfType      = CSL_DMA_TRANSFER_MEMORY;
	dmaConfig.dataLen      = CSL_DMA_BUFFER_SIZE * 2;
	dmaConfig.srcAddr      = (Uint32)dmaSRCBuff;
	dmaConfig.destAddr     = (Uint32)dmaDESTBuff;

    status = DMA_init();
    if (status != CSL_SOK)
    {
        printf("DMA_init() Failed \n");
   /////INSTRUMENTATION FOR BATCH TESTING -- Part 2 --
   /////  Reseting PaSs_StAtE to 0 if error detected here.
        PaSs_StAtE = 0x0000; // Was intialized to 1 at declaration.
   /////
    }
	for( chanNumber = 0; chanNumber < CSL_DMA_CHAN_MAX; chanNumber++)
	{
	    printf("\n Test for DMA Channel No : %d \t", chanNumber);

		dmaHandle = DMA_open((CSL_DMAChanNum)chanNumber,&dmaObj, &status);
        if (dmaHandle == NULL)
        {
            printf("DMA_open() Failed \n");
            break;
        }

		status = DMA_config(dmaHandle, &dmaConfig);
        if (status != CSL_SOK)
        {
            printf("DMA_config() Failed \n");
            break;
        }

		status = DMA_getConfig(dmaHandle, &getdmaConfig);
        if (status != CSL_SOK)
        {
            printf("DMA_getConfig() Failed \n");
            break;
        }

		status = DMA_start(dmaHandle);
        if (status != CSL_SOK)
        {
            printf("DMA_start() Failed \n");
            break;
        }

		while(DMA_getStatus(dmaHandle));

		status = DMA_reset(dmaHandle);
        if (status != CSL_SOK)
        {
            printf("DMA_close() Failed \n");
            break;
        }

        status = DMA_close(dmaHandle);
        if (status != CSL_SOK)
        {
            printf("DMA_reset() Failed \n");
            break;
        }

		/* validation for set and get config parameter */
		if((dmaConfig.autoMode) != (getdmaConfig.autoMode))
		{
			printf("Mode not matched\n");
		}

		if(((dmaConfig.burstLen) != (getdmaConfig.burstLen)))
		{
			printf("Burst length not matched\n");
		}

		if(((dmaConfig.trigger) != (getdmaConfig.trigger)))
		{
			printf("Triger type not matched\n");
		}

		if(((dmaConfig.dmaEvt) != (getdmaConfig.dmaEvt)) )
		{
			printf("Event not matched\n");
		}

		if(((dmaConfig.dmaInt) != (getdmaConfig.dmaInt)))
		{
			printf("Interrupt state not matched\n");
		}

		if(((dmaConfig.chanDir) != (getdmaConfig.chanDir)))
		{
			printf("Direction read or write not matched\n");
		}

		if(((dmaConfig.trfType) != (getdmaConfig.trfType)))
		{
			printf("Transfer type not matched\n");
		}

		if(((dmaConfig.dataLen) != (getdmaConfig.dataLen)))
		{
			printf("data length of transfer not matched\n");
		}

		if(((dmaConfig.srcAddr) != (getdmaConfig.srcAddr)))
		{
			printf("Source address not matched\n");
		}

		if(((dmaConfig.destAddr) != (getdmaConfig.destAddr)))
		{
			printf("Destination address not matched\n");
		}

		for(i = 0; i < CSL_DMA_BUFFER_SIZE; i ++)
		{
			if(dmaSRCBuff[i] != dmaDESTBuff[i])
			{
				printf("Buffer miss matched at position %d\n",i);
				break;
			}
		}

		if(i == CSL_DMA_BUFFER_SIZE)
		{
			printf("Success");
		}

		for(i = 0; i < CSL_DMA_BUFFER_SIZE; i++)
		{
			dmaSRCBuff[i]  = 0xFFFF;
			dmaDESTBuff[i] = 0x0000;
		}
	}
	if(chanNumber == 16)
	{
		printf("\n\n DMA POLLED MODE TEST PASSED!!\n");
	}
	else
	{
		printf("\n\n DMA POLLED MODE TEST FAILED!!\n");
   /////INSTRUMENTATION FOR BATCH TESTING -- Part 2 --
   /////  Reseting PaSs_StAtE to 0 if error detected here.
        PaSs_StAtE = 0x0000; // Was intialized to 1 at declaration.
   /////
	}
   /////INSTRUMENTATION FOR BATCH TESTING -- Part 3 --
   /////  At program exit, copy "PaSs_StAtE" into "PaSs".
        PaSs = PaSs_StAtE; //If flow gets here, override PaSs' initial 0 with
   /////                   // pass/fail value determined during program execution.
   /////  Note:  Program should next exit to C$$EXIT and halt, where DSS, under
   /////   control of a host PC script, will read and record the PaSs' value.
   /////
}