//declare memory mapped variables 声明内存映射变量
#define COM_RHR (*(volatile unsigned char *)0x8000)
#define COM_THR (*(volatile unsigned char *)0x8000)
#define COM_IER (*(volatile unsigned char *)0x8001)
#define COM_DLL (*(volatile unsigned char *)0x8000)
#define COM_DLM (*(volatile unsigned char *)0x8001)
#define COM_ISR (*(volatile unsigned char *)0x8002)
#define COM_FCR (*(volatile unsigned char *)0x8002)
#define COM_LCR (*(volatile unsigned char *)0x8003)
#define COM_MCR (*(volatile unsigned char *)0x8004)
#define COM_LSR (*(volatile unsigned char *)0x8005)
#define COM_MSR (*(volatile unsigned char *)0x8006)
#define COM_SPR (*(volatile unsigned char *)0x8007)
void init_COM(void)
{
COM_LCR=0x80;//LCR-bit7=1,配置波特率。
COM_DLL=0x01;//0x01:baud=115.2K.
COM_DLM=0x00;
COM_LCR=0x07;//8 bit数据,无校验,2bit停止位。0000 0111
// COM_FCR=0x0f;//使用FIFO,RX FIFO trigger level=1.(=14时通信出错)
// COM_FCR=0x4f;
// COM_MCR=0x02;
COM_FCR=0;
COM_MCR=0;
COM_IER=0b00000101;//modify by weizl at 2005-03-17.
} |