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

📄 dma.c

📁 S3C2410底层keil版--UART
💻 C
字号:
#include "2410lib.h"
#include "head.h"

INT8U  isDone;
INT8U  UARTBUFFER[100];
INT32 uart0RxStr;



void __irq Uart0_RxDmaOrErr(void)
{
    rINTSUBMSK|=(BIT_SUB_RXD0|BIT_SUB_TXD0|BIT_SUB_ERR0);
    if(rSUBSRCPND&BIT_SUB_ERR0)
	     uart_printf("Error : UART0 Rx Interrupt is occured!!!\n");
    //else __sub_Uart0_RxErrInt();
    
    ClearPending(BIT_UART0);
    rSUBSRCPND=(BIT_SUB_ERR0);	// Clear Sub int pending    
    rINTSUBMSK&=~(BIT_SUB_ERR0);    
}

void __irq Uart0_RxDmaDone(void)
{
    rDMASKTRIG0=0x0;	//DMA0 Channel Off
    isDone=0;
    UARTBUFFER[5]='\0';
    rINTMSK|=(BIT_DMA0);
    ClearPending(BIT_DMA0);
}

init_uart()
{
    isDone=1;
    uart0RxStr=(INT32)&UARTBUFFER;
    uart_printf("\n[Uart channel 0 DMA0 Rx Test]\n");
    uart_printf("Type any five keys!!!\n");    
    uart_printf("Then you will see what you typed.\n");

    pISR_DMA0=(INT32U)Uart0_RxDmaDone;
    pISR_UART0=(INT32U)Uart0_RxDmaOrErr;
    
    rULCON0=(0<<6)|(0<<3)|(0<<2)|(3);	// Normal,No parity,One stop bit, 8bit
    rUCON0 &= 0x400;	// For the PCLK <-> UCLK fuction    
    rUCON0 |= (1<<9)|(1<<8)|(0<<7)|(1<<6)|(0<<5)|(0<<4)|(1<<2)|(2);
    //Clock,Tx:Def,Rx:Def,Rx timeout:x,Rx error int:o,Loop-back:x,Send break:x,Tx:int,Rx:dma0

    /***DMA0 init***/
    rDISRC0=(INT32U)URXH0;			// Start address
    rDISRCC0=(1<<1)|(1);		// APB,Fixed
    rDIDST0=(INT32U)uart0RxStr;	        // Memory buffer Address
    rDIDSTC0= (0<<1)|(0);		// AHB,Increment
    rDCON0=(0x80000000)|(0<<30)|(1<<29)|(0<<28)|(0<<27)|(1<<24)|(1<<23)|(1<<22)|(0<<20)|(5);
    //handshake, sync PCLK, TC int, single tx, single service, Uart0, H/W request,auto-reload off, Byte size Tx, Tx count value

    // Clear Int Pending and Unmask    
    ClearPending(BIT_UART0);
    rINTMSK=~(BIT_DMA0|BIT_UART0);
    rSUBSRCPND=(BIT_SUB_TXD0|BIT_SUB_RXD0|BIT_SUB_ERR0);        
    rINTSUBMSK=~(BIT_SUB_ERR0);
    rDMASKTRIG0=(0<<2)|(1<<1)|(0);    //no-stop, DMA0 channel on, no-SW trigger 
}

/*********************************************************************************************
* name:		main
* func:		memory test
* para:		none
* ret:		none
* modify:
* comment:		
*********************************************************************************************/
void uart0_dma_test()
{
	init_uart();

    while(isDone);

	uart_printf("%s\n",uart0RxStr);
}

⌨️ 快捷键说明

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