/*
 * MICETEK International Inc., (shanghai) 
 * 	By Qinwei , 2003.05.28 (CopyRight)
 * 
 *  Version 0.1
 */

#ifndef __UART_EV4510_

#define __UART_EV4510_

int dev_uart_init (int sys_clock, int reg_base, int ch);
//dev_uart_init returns non-negative number on  succuess, 0 on failing.

int crtio (int baund);
//crtio returns the old baund rate on success, 0 on failing.

void outbyte (int);
//outbyte returns the written char on success or EOF on failing.

int inbyte (void);
//inbyte returns the byte it reads on success or EOF on failing.

//S3C44B0 uart register
#define ULCON	0x0
#define UCON	0x4
#define UFCON	0x8
#define UMCON	0xC
#define UTRSTAT	0x10
#define UERSTAT	0x14
#define UFSTAT  0x18
#define UMSTAT  0x1C
#define UTXH    0x20
#define URXH    0x24
#define UBRDIV  0x28
//clock register
#define PLLCON  0x01D80000
//watchdog
#define rWTCON		(*(volatile unsigned *)0x1d30000)
#define rWTDAT		(*(volatile unsigned *)0x1d30004)
#define rWTCNT		(*(volatile unsigned *)0x1d30008)
#define rUTRSTAT0	(*(volatile unsigned *)0x1d00010)
#define WrUTXH0(ch)	(*(volatile unsigned char *)(0x1d00020))=(unsigned char)(ch)
//port E and F group
#define rPCONE		(*(volatile unsigned *)0x1d20028)
#define rPDATE		(*(volatile unsigned *)0x1d2002c)
#define rPUPE		(*(volatile unsigned *)0x1d20030)
#define rPCONF		(*(volatile unsigned *)0x1d20034)
#define rPDATF		(*(volatile unsigned *)0x1d20038)
#define rPUPF		(*(volatile unsigned *)0x1d2003c)



#define DTR			0x00000010
#define	RDV			0x00000001
#define	TH_empty		0x00000002
#define	TC			0x00000080
#define MCLK                    40000000


//USE MCLK 40M
#define B9600	259
#define B19200	129
#define B38400	64
#define B57600	42
#define B115200	21



#endif //__UART_EV4510_


