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

📄 uart_afc.c

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


#define AFC_BUFLEN  199

INT8  isDone;
INT8  rx_cnt;
INT8  rx_end;
INT32 *txdataPt;
INT32 *txdataFl;
INT32 UARTBUFFER[200];
INT32U a;

void __irq Uart1_AfcTx(void)
{
    rINTSUBMSK|=(BIT_SUB_RXD1|BIT_SUB_TXD1|BIT_SUB_ERR1);
    if(rx_cnt < AFC_BUFLEN) 
    {
//	*txdataPt=rURXH1;
//	uart_printf("%d,",*txdataPt++);
//	uart_printf("ok");

    rUTXH1 =*txdataPt++;
	rx_cnt++;

	ClearPending(BIT_UART1);
        rSUBSRCPND=(BIT_SUB_TXD1);
        rINTSUBMSK&=~(BIT_SUB_TXD1);
    }
    if(rx_cnt == AFC_BUFLEN) 
    {
   	rx_end=1;
    	while(rUFSTAT1 & 0x2f0);	//Until FIFO is empty
        ClearPending(BIT_UART1);
        rSUBSRCPND=(BIT_SUB_TXD1);
    	rINTMSK|=BIT_UART1;
    }
	
}



init_uart()
{
    INT8U i;
    rx_cnt=0;
    rx_end=0;
    txdataFl=(int *)UARTBUFFER;
    txdataPt=(int *)UARTBUFFER;

   
    for(i=0;i<AFC_BUFLEN;i++) *txdataFl++=i+0x30;;	// Initialize the AFC data


//    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");
  

    rULCON1=(0<<6)|(0<<3)|(0<<2)|(3);	// Normal,No parity,One stop bit, 8bit
    rUCON1 &= 0x400;	// For the PCLK <-> UCLK fuction    
    rUCON1 |= (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
    rUFCON1=0;
//	rUBRDIV1=( (int)(PCLK/16./115200) -1 );
    //Tx and Rx FIFO Trigger Level:4byte,Tx and Rx FIFO Reset,FIFO on
//    rUMCON1=0x10;   // Enable Uart0 AFC 
    

	pISR_UART1=(unsigned) Uart1_AfcTx;
	rINTMSK=~(BIT_UART1);
    rINTSUBMSK=~(BIT_SUB_RXD1|BIT_SUB_TXD1|BIT_SUB_ERR1);
	


}

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


    while(!rx_end);

     rINTSUBMSK|=(BIT_SUB_RXD1|BIT_SUB_TXD1|BIT_SUB_ERR1);
    rUFCON1=(3<<6)|(2<<4)|(1<<2)|(1<<1)|(0);
    //Tx and Rx FIFO Trigger Level:12byte,Tx and Rx FIFO Reset,FIFO off
//    sys_init(); 
	uart_printf("\nEnd Tx, transfer data count=%d\n",rx_cnt);
}

⌨️ 快捷键说明

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