Esempio n. 1
0
void Uart_Uclk_En(int ch,int baud)
{
    /*
    int ch, baud;
    Uart_Printf("\nSelect UART channel[0:UART0/1:UART1/2:UART2]:\n");
    ch=Uart_GetIntNum();
    Uart_Printf("\nSelect baud rate :\n");
    baud=Uart_GetIntNum();
    */
    if(ch == 0) {
   	Uart_Select(0);
    	rUCON0|=0x400;	// Select UCLK
     	rUBRDIV0=( (int)(UCLK/16./baud) -1 );	//Baud rate divisior register
    	Uart_Printf("UCLK is enabled by UART0.\n"); 
    	}
    else if(ch==1){
    	Uart_Select(1);
    	rUCON1|=0x400;	// Select UCLK
        rUBRDIV1=( (int)(UCLK/16./baud) -1 );	//Baud rate divisior register
        Uart_Select(0);
        Uart_Printf("UCLK is enabled by UART1.\n");
    	}
    else {
    	Uart_Select(2);
    	rUCON2|=0x400;	// Select UCLK
        rUBRDIV2=( (int)(UCLK/16./baud) -1 );	//Baud rate divisior register
        Uart_Select(0);
        Uart_Printf("UCLK is enabled by UART2.\n");
    	}
    //for(i=0;i<100;i++);	// For the satble operation
}
Esempio n. 2
0
void Test_Uart0_AfcRx(void)
{
    unsigned int i;
    rx_cnt=0;
    rx_end=0;
    afc_err=0;
    rxdataCk=(volatile U8 *)UARTBUFFER;
    rxdataPt=(volatile U8 *)UARTBUFFER;
    Uart_Port_Set(); 
    Uart_Select(0);
    Uart_Printf("[Uart channel 0 AFC Rx Test]\n");
    Uart_Printf("This test should be configured two boards.\n");
    Uart_Printf("Connect Tx and Rx Board with twitsted(rx/tx, nCTS/nRTS) cable .\n");
    
    Uart_Printf("\nConnect PC[COM1 or COM2] and UART1 of SMDK2410 with a serial cable!!! \n");
    Uart_Printf("Then, press any key........\n");
    Uart_Select(1);	// Change the uart port    
    Uart_Getch();
    Uart_Printf("Press any key to start Rx and then Star Tx....\n");
    Uart_Getch();

    pISR_UART0=(unsigned) Uart0_AfcRxOrErr;

    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)|(1<<7)|(1<<6)|(0<<5)|(0<<4)|(1<<2)|(1);
    //Clock,Tx:Lev,Rx:Lev,Rx timeout:o,Rx error int:o,Loop-back:x,Send break:x,Tx:o,Rx:o
    
    rUFCON0=(1<<6)|(0<<4)|(1<<2)|(1<<1)|(1);
    //Tx and Rx FIFO Trigger Level:4byte,Tx and Rx FIFO Reset,FIFO on
    rUMCON0=0x10;   // Enable Uart0 AFC 
    rINTMSK=~(BIT_UART0);
    rINTSUBMSK=~(BIT_SUB_RXD0|BIT_SUB_TXD0|BIT_SUB_ERR0);

    while(!rx_end);
    
    rINTSUBMSK|=(BIT_SUB_RXD0|BIT_SUB_TXD0|BIT_SUB_ERR0);
    rUFCON0=(3<<6)|(2<<4)|(1<<2)|(1<<1)|(0);
    //Tx and Rx FIFO Trigger Level:12byte,Tx and Rx FIFO Reset,FIFO off
    Uart_Printf("\nEnd Rx, receive data count=%d\n",rx_cnt);
    for(i=0;i<AFC_BUFLEN;i++) 
    	if(i-(*rxdataCk++)) {
    		Uart_Printf("i=%d\n",i);
    		afc_err++;
    		}
    if(afc_err)
    	Uart_Printf("AFC test fail!! Error count=%d\n",afc_err);
    else
    	Uart_Printf("AFC test is good!!\n");

    Uart_Printf("\nConnect PC[COM1 or COM2] and UART0 of SMDK2410 with a serial cable!!! \n");
    Uart_Printf("Then, press any key........\n");
    Uart_Select(0);
    Uart_Getch();
    Uart_Port_Return();
}
Esempio n. 3
0
void Camera_Test(void)
{
	int i;
	
	SetSysFclk(FCLK_220M);  //设置系统时钟 220M     
	ChangeClockDivider(1, 1);      //设置分频 1:2:4
	CalcBusClk();           //计算总线频

	Uart_Select(0);
    Uart_Init(0, 115200);
	
	Uart_Printf("\nCamera Preview Test\n");

	CamReset();

	// Initializing camif
	rCLKCON |= (1<<19); // enable camclk
	CamPortSet();	
	ChangeUPllValue(56, 2, 1);		// UPLL clock = 96MHz, PLL input 12MHz
	rCLKDIVN|=(1<<3); // UCLK 48MHz setting for UPLL 96MHz
	// 0:48MHz, 1:24MHz, 2:16MHz, 3:12MHz...
	// Camera clock = UPLL/[(CAMCLK_DIV+1)X2]

	SetCAMClockDivider(CAMCLK24000000); //Set Camera Clock 24MHz s5x532, OV9650

	i = Test_OV9650();
	if( i )
	{
		Uart_Printf("\nTest is failed!!!\n");
		return ;
	}

	Uart_Printf("Initializing end...\n");
	
	Test_CamPreview() ;
	
	Uart_Printf("\nCamera Preview Test End\n");

	rCLKCON &= ~(1<<19); // disable camclk
	
	TFT_Init();
	
	SetSysFclk(FCLK_400M);  //设置系统时钟 400M     
	ChangeClockDivider(2, 1);      //设置分频 1:4:8
	CalcBusClk();           //计算总线频

	Uart_Select(0);
    Uart_Init(0, 115200);
	
}
Esempio n. 4
0
void Test_Uart0_AfcTx(void)
{
    int i;
    tx_cnt=0;
    tx_end=0;
    txdataFl=(volatile U8 *)UARTBUFFER;
    txdataPt=(volatile U8 *)UARTBUFFER;
    for(i=0;i<AFC_BUFLEN;i++) *txdataFl++=i;	// Initialize the AFC data
    Uart_Port_Set(); 
    Uart_Select(0);
    Uart_Printf("[Uart channel 0 AFC Tx Test]\n");
    Uart_Printf("This test should be configured two boards.\n");
    Uart_Printf("Connect Tx and Rx Board with twitsted(rx/tx, nCTS/nRTS) cable .\n");
    Uart_Printf("\nConnect PC[COM1 or COM2] and UART1 of SMDK2410 with a serial cable!!! \n");

    Uart_Printf("Then, press any key........\n");
    Uart_Select(1);	// Change the uart port    
    Uart_Getch();
    Uart_Printf("Start Rx first and then press any key to start Tx.....\n");
    Uart_Getch();

    pISR_UART0=(unsigned) Uart0_AfcTx;

    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)|(0<<6)|(0<<5)|(0<<4)|(1<<2)|(1);
    //Clock,Tx:Lev,Rx:Lev,Rx timeout:x,Rx error int:x,Loop-back:x,Send break:x,Tx:int,Rx:int
    rUFCON0=(1<<6)|(0<<4)|(1<<2)|(1<<1)|(1);
    //Tx and Rx FIFO Trigger Level:4byte,Tx and Rx FIFO Reset,FIFO on
    rUMCON0=0x10;   // Enable Uart0 AFC 
    rINTMSK=~(BIT_UART0);
    rINTSUBMSK=~(BIT_SUB_RXD0|BIT_SUB_TXD0|BIT_SUB_ERR0);

    while(!tx_end);

    rINTSUBMSK|=(BIT_SUB_RXD0|BIT_SUB_TXD0|BIT_SUB_ERR0);
    rUFCON0=(3<<6)|(2<<4)|(1<<2)|(1<<1)|(0);
    //Tx and Rx FIFO Trigger Level:12byte,Tx and Rx FIFO Reset,FIFO off
    Uart_Printf("\nEnd Tx, transfer data count=%d\n",tx_cnt);

    Uart_Printf("\nConnect PC[COM1 or COM2] and UART0 of SMDK2410 with a serial cable!!! \n");
    Uart_Printf("Then, press any key........\n");
    Uart_Select(0);
    Uart_Getch();
    Uart_Port_Return();
}
Esempio n. 5
0
File: Target.c Progetto: Gewin/Ucos
void TargetInit(void)
{
	int i;
	U8 key;
	U32 mpll_val=0;
	#if ADS10   
	__rt_lib_init(0,0); //for ADS 1.0
 
	#endif
    
	i = 2 ;	//use 400M!
		
	switch ( i ) {
	case 0:	//200
		key = 12;
		mpll_val = (92<<12)|(4<<4)|(1);
		break;
	case 1:	//300
		key = 14;
		mpll_val = (67<<12)|(1<<4)|(1);
		break;
	case 2:	//400
		key = 14;
		mpll_val = (92<<12)|(1<<4)|(1);
		break;
	case 3:	//440!!!
		key = 14;
		mpll_val = (102<<12)|(1<<4)|(1);
		break;
	default:
		key = 14;
		mpll_val = (92<<12)|(1<<4)|(1);
		break;
	}
	
	//init FCLK=400M
	ChangeClockDivider(key, 12);    
	ChangeMPllValue((mpll_val>>12)&0xff, (mpll_val>>4)&0x3f, mpll_val&3);

	//MMU_EnableICache();
	//MMU_EnableDCache();
    
	MMU_DisableICache();
	MMU_DisableDCache();
 	Port_Init();
	MMU_Init();

	Delay(0);
	Uart_Init(0,115200);
	Uart_Select(0);
	Uart_SendString("Board init complete.\n");
}
Esempio n. 6
0
void Main(void)
{
	//硬件初始化
	var_Init();//初始化定时器相关的参数
	Port_Init();//IO端口初始化
	Isr_Init();//中断初始化
	Uart_Init(0,115200);//串口初始化
	Uart_Select(0);
	_init_alloc(0x32500000,0x333fffff);//初始化堆地址:15M,使能malloc等存储分配函数
	setlocale(LC_ALL,"C");//使能本地函数,如sprintf等
	Timer4_Init();
	lcdTest();
}	
Esempio n. 7
0
void Main(void)
{
    Port_Init();		//IO端口初始化
	Isr_Init();			//中断初始化

    Uart_Init(0,115200);//串口初始化
    Uart_Select(0);

    Uart_Printf("\n\nDM2410 Experiment System (ADS) Ver1.10\n") ;//打印系统信息
    
    Test_SDI();
    
}
Esempio n. 8
0
void Main(void)
{
	memcpy((unsigned char *)0x0,(unsigned char *)0x30000000,0x1000);
	
	SetSysFclk(FCLK_400M);  //设置系统时钟 400M     
	ChangeClockDivider(2, 1);      //设置分频 1:4:8
	CalcBusClk();           //计算总线频
	
	Uart_Select(0);
	Uart_Init(0, 115200);
	
	Test_Nand();
	while(1);
}
Esempio n. 9
0
void Test_Uart0_Int(void)
{
    Uart_Port_Set(); 
    Uart_Select(0);    
    /*********** UART0 Tx test with interrupt ***********/  
    isTxInt=1;
    uart0TxStr="ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890->UART0 Tx interrupt test is good!!!!\r\n";
    Uart_Printf("[Uart channel 0 Tx Interrupt Test]\n");

    pISR_UART0=(unsigned)Uart0_TxInt;

    rULCON0=(0<<6)|(0<<3)|(0<<2)|(3);	// Normal,No parity,One stop bit, 8bit
    rUCON0 &= 0x400;	// For the PCLK <-> UCLK fuction
    rUCON0 |= (TX_INTTYPE<<9)|(RX_INTTYPE<<8)|(0<<7)|(0<<6)|(0<<5)|(0<<4)|(1<<2)|(1);
    //Clock,Tx:Def,Rx:Def,Rx timeout:x,Rx error int:x,Loop-back:x,Send break:x,Tx:int,Rx:int
    Uart_TxEmpty(0); //wait until tx buffer is empty.
    rINTMSK=~(BIT_UART0);
    rINTSUBMSK=~(BIT_SUB_TXD0);

    while(isTxInt);
    
    /*********** UART0 Rx test with interrupt ***********/
    isRxInt=1;
    uart0RxStr=(char *)UARTBUFFER;
    Uart_Printf("\n[Uart channel 0 Rx Interrupt Test]:\n");
    Uart_Printf("After typing ENTER key, you will see the characters which was typed by you.");
    Uart_Printf("\nTo quit, press ENTER key.!!!\n");
    Uart_TxEmpty(0); //wait until tx buffer is empty.
    pISR_UART0 =(unsigned)Uart0_RxIntOrErr;
    rULCON0=(0<<6)|(0<<3)|(0<<2)|(3);	// Normal,No parity,One stop bit, 8bit
    rUCON0 &= 0x400;	// For the PCLK <-> UCLK fuction
    rUCON0 |= (TX_INTTYPE<<9)|(RX_INTTYPE<<8)|(0<<7)|(1<<6)|(0<<5)|(0<<4)|(1<<2)|(1);
    //Clock,Tx:pulse,Rx:pulse,Rx timeout:x,Rx error int:o,Loop-back:x,Send break:x,Tx:int,Rx:int

    // Clear Int Pending and Unmask    
    ClearPending(BIT_UART0);
    rINTMSK=~(BIT_UART0);
    rSUBSRCPND=(BIT_SUB_TXD0|BIT_SUB_RXD0|BIT_SUB_ERR0);    
    rINTSUBMSK=~(BIT_SUB_RXD0|BIT_SUB_ERR0);
    
    while(isRxInt);
    
    rINTSUBMSK|=(BIT_SUB_RXD0|BIT_SUB_ERR0);
    rINTMSK|=(BIT_UART0);
 
    Uart_Printf("%s\n",(char *)UARTBUFFER);
    Uart_Port_Return();
}
Esempio n. 10
0
void TargetInit(void)
{
	int i;
	U8 key;
	U32 mpll_val=0;

    
	i = 2 ;	//use 400M!
		
	switch ( i ) {
	case 0:	//200
		key = 12;
		mpll_val = (92<<12)|(4<<4)|(1);
		break;
	case 1:	//300
		key = 14;
		mpll_val = (67<<12)|(1<<4)|(1);
		break;
	case 2:	//400
		key = 14;
		mpll_val = (92<<12)|(1<<4)|(1);
		break;
	case 3:	//440!!!
		key = 14;
		mpll_val = (102<<12)|(1<<4)|(1);
		break;
	default:
		key = 14;
		mpll_val = (92<<12)|(1<<4)|(1);
		break;
	}
	
	//init FCLK=400M, so change MPLL first
	ChangeMPllValue((mpll_val>>12)&0xff, (mpll_val>>4)&0x3f, mpll_val&3);
	ChangeClockDivider(key, 12);    

    
	MMU_DisableICache();
	MMU_DisableDCache();
 	Port_Init();
	MMU_Init();
	_init_alloc(0x17fe000, 0x17ff000);/*分配堆的起始地址和结束地址,4k的空间*/
	Delay(0);
	Uart_Init(0,115200);
	Uart_Select(0);
	Uart_SendString("Board init complete.\n");
}
Esempio n. 11
0
/********************************************************************
// 语法格式	: void Main(void)
// 功能描述 : DMA操作实验主程序
//            实现功能:
//                实现DMA方式内存到内存的拷贝动作,修改DMA设置
//                并比较其工作效率,实验包括:DMA0-DMA3
// 入口参数		: 无
// 出口参数     : 无
*********************************************************************/
void Main(void)
{
	memcpy((U8 *)0x0,(U8 *)0x30000000,0x1000);
	
	SetSysFclk(FCLK_400M);  			//设置系统时钟 400M
    ChangeClockDivider(2,1);      		//设置分频 1:4:8
	CalcBusClk();           //计算总线频

	Uart_Select(0); 
    Uart_Init(0,115200);
    
	Uart_Printf("\n---DMA操作实验主程序---\n");
	
    Test_DMA();
    
    Uart_Printf("\nDMA测试结束\n");
	while(1);
}
Esempio n. 12
0
 char Uart()
{
	char id[20]={};
 	char nz[]={0x37,0x34,0x39};
	char sj;
 
 	char x,xx;
 	char y=0;
 	int data;
 	Uart_Init(0,9600);
 	Uart_Select(1);
	bz=0;
	 	
	if(rUTRSTAT1 & 0x1)
	{
		for(y=0;y<8;y++)
 		{
	 		sj=Uart_Getch();
	 		id[y]=sj;
	 	}
	}
	 
	if(id[2]==nz[1])
	{
	 	
	 	bz=1;
	}
	else
	 	bz=0;
	 	
 	if(id[0]!=0)
 	{
 		x = id[1];
 		xx=id[2];
 	 	
 	}

 	

 	return bz;	

}
Esempio n. 13
0
//====================================================
// 语法格式:void Main(void)
// 功能描述: 主函数
// 入口参数: 无
// 出口参数: 无
//====================================================
void Main(void)
{
	memcpy((unsigned char *)0x0,(unsigned char *)0x30000000,0x1000);
    
	SetSysFclk(FCLK_400M);  //设置系统时钟 400M     
	ChangeClockDivider(2, 1);      //设置分频 1:4:8
	CalcBusClk();           //计算总线频
	
	Uart_Select(0);    
	Uart_Init(0, 115200);   //设置端口 波特率115200  无数据流检测   数据位= 8位
	
	Select_Device(IrDA);
	IrDA_Port_Set();
		
	Uart_Printf("\2440 IrDA Test start\n");   
    
    while(1)
    {
		Test_IrDA_Tx();
	}
 }
Esempio n. 14
0
void TargetInit(void)
{
    int i;
	U8 key;
	U32 mpll_val=0;
    #if ADS10   
   //_rt_lib_init(0,0); //for ADS 1.0
 
    #endif
    
	i = 2 ;	//use 400M!
		
	switch ( i ) {
	case 0:	//200
		key = 12;
		mpll_val = (92<<12)|(4<<4)|(1);
		break;
	case 1:	//300
		key = 14;
		mpll_val = (67<<12)|(1<<4)|(1);
		break;
	case 2:	//400
		key = 14;
		mpll_val = (92<<12)|(1<<4)|(1);
		break;
	case 3:	//440!!!
		key = 14;
		mpll_val = (102<<12)|(1<<4)|(1);
		break;
	default:
		key = 14;
		mpll_val = (92<<12)|(1<<4)|(1);
		break;
	}
	
	//init FCLK=400M, so change MPLL first
	ChangeMPllValue((mpll_val>>12)&0xff, (mpll_val>>4)&0x3f, mpll_val&3);
	ChangeClockDivider(key, 12);    

    //MMU_EnableICache();
    //MMU_EnableDCache();
    
    MMU_DisableICache();
    MMU_DisableDCache();
  	Port_Init();
    MMU_Init();
	Touch_init();
    Delay(0);
    Uart_Init(0,115200);
    Uart_Select(1);
    //Uart_SendString("hello,FriendlyARM\n");
    /*若使用printf语句,将使目标代码增加很多*/
    // Uart_Printf("hello,qq2440, printf\n");

    
   rGPBCON = 0x00555555;
   rGPBDAT = 0x0000;
//   rGPBDAT = 0x07ff;
	rGPFDAT = 0x00;
	rGPFDAT = 0x00;
 //  Delay(0);
 	
 }
Esempio n. 15
0
void Test_Uart0_Fifo(void)
{
    Uart_Port_Set(); 
    Uart_Select(0);
    /******* UART0 Tx FIFO test with interrupt ********/     
    Uart_Printf("[Uart channel 0 Tx FIFO Interrupt Test]\n");
    Uart_TxEmpty(0);	//wait until tx buffer is empty.
    
    /* <Tx Trigger Level:8Byte> */    
    uart0TxStr="ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890->UART0 Tx FIFO interrupt(8byte) test is good!!!!\r\n";
    pISR_UART0=(U32)Uart0_TxFifo;
    rULCON0=(0<<6)|(0<<3)|(0<<2)|(3);	// Normal,No parity,One stop bit, 8bit
    rUCON0 &= 0x400;	// For the PCLK <-> UCLK fuction    
    rUCON0 |= (TX_INTTYPE<<9)|(RX_INTTYPE<<8)|(0<<7)|(0<<6)|(0<<5)|(0<<4)|(1<<2)|(0);
    //Clock,Tx:Def,Rx:Def,Rx timeout:x,Rx error int:x,Loop-back:x,Send break:x,Tx:int,Rx:x
    rUFCON0=(2<<6)|(1<<4)|(1<<2)|(1<<1)|(1);
    //Tx and Rx FIFO Trigger Level:8byte,Tx and Rx FIFO Reset,FIFO on
    rINTMSK=~(BIT_UART0);
    rINTSUBMSK=~(BIT_SUB_TXD0);
    Delay(500);
    rUFCON0=(2<<6)|(1<<4)|(1<<2)|(1<<1)|(0);
    //Tx and Rx FIFO Trigger Level:8byte,Tx and Rx FIFO Reset,FIFO off

    /* <Tx Trigger Level:12Byte> */    
    uart0TxStr="ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890->UART0 Tx FIFO interrupt(12byte) test is good!!!!\r\n";
    pISR_UART0=(unsigned)Uart0_TxFifo;
    rULCON0=(0<<6)|(0<<3)|(0<<2)|(3);	// Normal,No parity,One stop bit, 8bit
    rUCON0 &= 0x400;	// For the PCLK <-> UCLK fuction    
    rUCON0 |= (TX_INTTYPE<<9)|(RX_INTTYPE<<8)|(0<<7)|(0<<6)|(0<<5)|(0<<4)|(1<<2)|(0);
    //Clock,Tx:Def,Rx:Def,Rx timeout:x,Rx error int:x,Loop-back:x,Send break:x,Tx:int,Rx:x
    rUFCON0=(3<<6)|(2<<4)|(1<<2)|(1<<1)|(1);
    //Tx and Rx FIFO Trigger Level:12byte,Tx and Rx FIFO Reset,FIFO on
    rINTMSK=~(BIT_UART0);
    rINTSUBMSK=~(BIT_SUB_RXD0|BIT_SUB_TXD0|BIT_SUB_ERR0);
    Delay(500);
    rUFCON0=(3<<6)|(2<<4)|(1<<2)|(1<<1)|(0);
    //Tx and Rx FIFO Trigger Level:12byte,Tx and Rx FIFO Reset,FIFO off

    
    /******* UART0 Rx FIFO test with interrupt ********/     
    rx_dncs=0;
    rx_point=0;
    rx_isdone=1;
    rx_filesize=0;
    rx_checksum=0;
    Uart_Printf("[Uart channel 0 Rx FIFO Interrupt Test]\n");
//----------------------------------------------------
    pISR_UART0=(unsigned)Uart0_RxFifoOrErr;

    rULCON0=(0<<6)|(0<<3)|(0<<2)|(3);	// Normal,No parity,One stop bit, 8bit
    rUCON0 &= 0x400;	// For the PCLK <-> UCLK fuction
    rUCON0 |= (TX_INTTYPE<<9)|(RX_INTTYPE<<8)|(1<<7)|(1<<6)|(0<<5)|(0<<4)|(1<<2)|(1);
    //Clock,Tx:Def,Rx:Def,Rx timeout:o,Rx error int:o,Loop-back:x,Send break:x,Tx:int,Rx:int
    rUFCON0=(1<<6)|(0<<4)|(1<<2)|(1<<1)|(1);
    //Tx and Rx FIFO Trigger Level:4byte,Tx and Rx FIFO Reset,FIFO on

    // Clear Int Pending and Unmask 
    ClearPending(BIT_UART0);
    rINTMSK=~(BIT_UART0);
    rSUBSRCPND=(BIT_SUB_RXD0|BIT_SUB_TXD0|BIT_SUB_ERR0);
    rINTSUBMSK=~(BIT_SUB_RXD0|BIT_SUB_ERR0);

    Uart_Printf("Download the target file[*.bin] by Uart0\n");
	
    while(rx_isdone);

    rINTMSK |= (BIT_UART0);	
    rINTSUBMSK|=(BIT_SUB_RXD0|BIT_SUB_TXD0|BIT_SUB_ERR0);

    rUFCON0=(3<<6)|(2<<4)|(1<<2)|(1<<1)|(0);
    //Tx and Rx FIFO Trigger Level:12byte,Tx and Rx FIFO Reset,FIFO off
			
    if(rx_dncs==(rx_checksum&0xffff)) 
	Uart_Printf("\nDownload test OK!!!\n");
    else 
	Uart_Printf("\nError!!!\n");
    Uart_Port_Return();	
}
Esempio n. 16
0
void Test_Uart0_Dma(void)
{
    Uart_Port_Set(); 
    Uart_Select(0);    
    /*********** UART0 Tx test with DMA0 ***********/ 
    isDone=1;
    uart0TxStr="ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890->UART0 Tx Test by DMA0 is good!!!!\r\n";
    Uart_Printf("\n[Uart channel 0 DMA0 Tx Test]\n");
    Uart_TxEmpty(0);
    
    pISR_DMA0  =(unsigned)Uart0_TxDmaDone;

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

    /***DMA0 init***/
    rDISRC0=(U32)uart0TxStr;	// Start address
    rDISRCC0=(0<<1)|(0);		// AHB,Increment
    rDIDST0=(U32)UTXH0;			// Memory buffer Address
    rDIDSTC0=(1<<1)|(1);		// APB,Fixed
    rDCON0=(1<<31)|(0<<30)|(1<<29)|(0<<28)|(0<<27)|(1<<24)|(1<<23)|(1<<22)|(0<<20)|strlen((char*)uart0TxStr);
    //handshake, sync PCLK, TC int, single tx, single service, Uart0, H/W request,auto-reload off, Byte size Tx, Tx count value
    rINTMSK=~(BIT_DMA0);
    rDMASKTRIG0=(0<<2)|(1<<1)|(0);    //no-stop, DMA0 channel on, no-SW trigger 

    while(isDone);

    /*********** UART0 Rx test with DMA0 ***********/ 
    isDone=1;
    uart0RxStr=(char *)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=(unsigned)Uart0_RxDmaDone;
    pISR_UART0=(unsigned)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 |= (TX_INTTYPE<<9)|(RX_INTTYPE<<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=(U32)URXH0;			// Start address
    rDISRCC0=(1<<1)|(1);		// APB,Fixed
    rDIDST0=(U32)uart0RxStr;	        // Memory buffer Address
    rDIDSTC0= (0<<1)|(0);		// AHB,Increment
    rDCON0=(1<<31)|(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 

    while(isDone);

    Uart_Printf("%s\n",uart0RxStr);
    Uart_Port_Return();
}