/*
 * 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.

int 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.

#define PS_PCER         0xFFFF4004
#define PIO_PDR         0xFFFF0004
#define US_CR		0x0
#define US_MR		0x04
#define US_IER		0x08
#define US_IDR		0x0C
#define US_IMR		0x10
#define US_CSR		0x14
#define US_RHR 		0x18
#define US_THR	 	0x1C
#define US_BRGR		0x20
#define US_RTOR		0x24
#define US_TTGR		0x28
#define US_RPR		0x30
#define US_RCR 		0x34
#define US_TPR		0x38
#define US_TCR		0x3C

#define US_RSTRX                0x0004      /* Reset Receiver */
#define US_RSTTX                0x0008      /* Reset Transmitter */
#define US_RXEN                 0x0010      /* Receiver Enable */
#define US_RXDIS                0x0020      /* Receiver Disable */
#define US_TXEN                 0x0040      /* Transmitter Enable */
#define US_TXDIS                0x0080      /* Transmitter Disable */
#define US_RSTSTA               0x0100      /* Reset Status Bits */
#define US_STTBRK               0x0200      /* Start Break */
#define US_STPBRK               0x0400      /* Stop Break */
#define US_STTTO                0x0800      /* Start Time-out */
#define US_SENDA                0x1000      /* Send Address */

#define US_RXRDY            0x1       /* Receiver Ready */
#define US_TXRDY            0x2       /* Transmitter Ready */
#define US_TXEMPTY          0x200       /* Transmitter Empty */

#define US_ENDRX            0x8       /* End of Receiver PDC Transfer */
#define US_ENDTX            0x10       /* End of Transmitter PDC Transfer */


#if 0
/*This is using system clock as uart clock*/
#define B9600		9600	
#define B19200		19200
#define B38400		38400
#define B57600		57600
#define B115200		115200
#else
/*This is using external 33M clock as usrt clock*/
#define B9600		213	
#define B19200		106
#define B38400		53
#define B57600		35
#define B115200		17
#endif



#endif //__UART_EV4510_
