示例#1
0
void init_uart()
{
     DMA_start(hDmaRx);
     /* Start the MCBSP and Sample Rate Generator */
     MCBSP_start(C55XX_UART_hMcbsp, MCBSP_SRGR_START, 0xFFFF);
     /* Take MCBSP receive and transmit out of reset */
     MCBSP_start(C55XX_UART_hMcbsp, MCBSP_XMIT_START | MCBSP_RCV_START, 0xFFFF);
     MCBSP_write32(C55XX_UART_hMcbsp, 0xffffffff); /* kickstart the serial port */
     DEBUG_putc('d');
     DEBUG_puts("ebug_printf_ok\r\n");

}
示例#2
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.
   /////
}
/**
 *  \brief  Function to test the CSL UART DMA mode operation
 *
 *   This function configures the UART in DMA mode for communicating
 *   with the HyperTerminal on the host PC. This function sends/receives
 *   data to/from the HyperTerminal using CSL DMA module.
 *
 *  \param  none
 *
 *  \return Test result
 */
CSL_Status CSL_uartDmaTest(void)
{
    CSL_UartHandle    hUart;
    CSL_Status        status;
    int               looper;
    Uint32            sysClk;

    sysClk = getSysClk();

    mySetup.clkInput = sysClk;

    /* Initialize CSL UART module */
    status = UART_init(&uartObj,CSL_UART_INST_0,UART_POLLED);
    if(CSL_SOK != status)
    {
        printf("UART_init failed error code %d\n",status);
        return(status);
    }
    else
    {
        printf("UART_init Successful\n");
    }

    /* Handle created*/
    hUart = (CSL_UartHandle)(&uartObj);

    /* Configure the DMA channel for UART transmit */
#if (defined(CHIP_C5505_C5515) || defined(CHIP_C5504_C5514))
    dmaConfig.pingPongMode = CSL_DMA_PING_PONG_DISABLE;
#endif
    dmaConfig.autoMode = CSL_DMA_AUTORELOAD_DISABLE;
    dmaConfig.burstLen = CSL_DMA_TXBURST_1WORD;
    dmaConfig.trigger  = CSL_DMA_EVENT_TRIGGER;
    dmaConfig.dmaEvt   = CSL_DMA_EVT_UART_TX;
    dmaConfig.dmaInt   = CSL_DMA_INTERRUPT_DISABLE;
    dmaConfig.chanDir  = CSL_DMA_WRITE;
    dmaConfig.trfType  = CSL_DMA_TRANSFER_IO_MEMORY;
    dmaConfig.dataLen  = CSL_UART_WRBUF_SIZE;
    dmaConfig.srcAddr  = (Uint32)guartDmaWriteBuf;
    dmaConfig.destAddr = (Uint32)&(hUart->uartRegs->THR);

    dmaWrHandle = CSL_configDmaForUart(&dmaWrChanObj, CSL_DMA_CHAN4);
    if(dmaWrHandle == NULL)
    {
        printf("DMA Config for Uart Write Failed!\n!");
        return(CSL_TEST_FAILED);
    }

    /* Start Dma transfer */
    status = DMA_start(dmaWrHandle);
    if(status != CSL_SOK)
    {
        printf("Uart Dma Write Failed!!\n");
        return(status);
    }

    /* Configure UART registers using setup structure */
    status = UART_setup(hUart,&mySetup);
    if(CSL_SOK != status)
    {
        printf("UART_setup failed error code %d\n",status);
        return status;
    }
    else
    {
        printf("UART_setup Successful\n");
    }

    /* Check transfer complete status */
    while(DMA_getStatus(dmaWrHandle));

    /* Configure the DMA channel for UART receive */
#if (defined(CHIP_C5505_C5515) || defined(CHIP_C5504_C5514))
    dmaConfig.pingPongMode = CSL_DMA_PING_PONG_DISABLE;
#endif
    dmaConfig.autoMode = CSL_DMA_AUTORELOAD_DISABLE;
    dmaConfig.burstLen = CSL_DMA_TXBURST_1WORD;
    dmaConfig.trigger  = CSL_DMA_EVENT_TRIGGER;
    dmaConfig.dmaEvt   = CSL_DMA_EVT_UART_RX;
    dmaConfig.dmaInt   = CSL_DMA_INTERRUPT_DISABLE;
    dmaConfig.chanDir  = CSL_DMA_READ;
    dmaConfig.trfType  = CSL_DMA_TRANSFER_IO_MEMORY;
    dmaConfig.dataLen  = CSL_UART_RDBUF_SIZE;
    dmaConfig.srcAddr  = (Uint32)&(hUart->uartRegs->THR);
    dmaConfig.destAddr = (Uint32)guartDmaReadBuf;

    dmaRdHandle = CSL_configDmaForUart(&dmaRdChanObj,CSL_DMA_CHAN4);
    if(dmaRdHandle == NULL)
    {
        printf("DMA Config for DMA Read Failed!\n!");
        return(CSL_TEST_FAILED);
    }

    /* Start Dma transfer */
    status = DMA_start(dmaRdHandle);
    if(status != CSL_SOK)
    {
        printf("Uart Dma Write Failed!!\n");
        return(status);
    }

    /* Check transfer complete status */
    while(DMA_getStatus(dmaRdHandle));

    /* Send a message to HyperTerminal to inform that the reading has been stopped */
    status = UART_fputs(hUart,"\r\n\nPlease stop typing, reading already stopped...!!!",0);
    if(CSL_SOK != status)
    {
        printf("UART_fputs failed error code %d\n",status);
        return(status);
    }

    printf("\nMessage Received from the HyperTerminal: ");

    /* Display the Message Read from the HyperTerminal */
    for(looper = 1; looper <  (NO_OF_CHAR_TO_READ*2); looper+=2)
    {
        printf("%c",guartDmaReadBuf[looper]);
    }
    printf("\n");

    status = UART_fputs(hUart,"\r\n\nPlease Verify The Text Displayed In The CCS stdout Window!!\r\n",0);
    if(CSL_SOK != status)
    {
        printf("UART_fputs failed error code %d\n",status);
        return(status);
    }

    return(CSL_SOK);
}