00001 #ifndef UART1_H 00002 #define UART1_H 00003 00004 #define COM1_BASE 0x3f8 //3f8~3ff 00005 //#define COM2_BASE 0x2f8 //2f8~2ff..defined in uart2.h 00006 #define COM3_BASE 0x3e8 //3e8~3ef 00007 #define COM4_BASE 0x2e8 //2e8~2ef 00008 00009 #define RXREG 0 //use with DLAB=0 (LCR.7) receive buffer for read,transmitter holding register for write 00010 #define TXREG 0 //USE with DLAB=0 (LCR.7) 00011 #define IER 1 //Interrupt Enable Register 00012 #define IIR 2 //Interrupt Identification Register (read only) 00013 #define FCR 2 //Fifo Control Register (write only) 00014 #define LCR 3 //Line Control Register 00015 #define MCR 4 //Modem Control Register 00016 #define LSR 5 //Line Status Register 00017 #define MSR 6 //Modem Status Register 00018 #define SR 7 //Scratch Register 00019 #define DLLR 0 //use with DLAB=1 (LCR.7) Divisor Latch Low Register 00020 #define DLHR 1 //use with DLAB=1 (LCR.7) Divisor Latch High Register 00021 00022 #define COM1_INT_EDA 0x01 00023 #define COM1_INT_THRE 0x02 00024 #define COM1_INT_RLS 0x04 00025 #define COM1_INT_MS 0x08 00026 00027 #define COM1_INTERRUPTS (COM1_INT_EDA|COM1_INT_THRE|COM1_INT_RLS) 00028 00029 #define COM1_IID_MS 0x00 00030 #define COM1_IID_TXEMPTY 0x01 00031 #define COM1_IID_RXRDY 0x02 00032 #define COM1_IID_RLS 0x03 00033 #define COM1_IID_TIMEOUT 0x06 00034 00035 #define COM1_LSR_DR 0x01 00036 #define COM1_LSR_OE 0x02 00037 #define COM1_LSR_PE 0x04 00038 #define COM1_LSR_FE 0x08 00039 #define COM1_LSR_BI 0x10 00040 #define COM1_LSR_THRE 0x20 00041 #define COM1_LSR_TEMT 0x40 00042 #define COM1_LSR_ER 0x80 00043 00044 00045 // baudrate setting for clock 1.8342mhz...i find this in bochs source code 00046 #define BAUDRATE_115200 0x01 00047 #define BAUDRATE_57600 0x02 00048 #define BAUDRATE_38400 0x03 00049 #define BAUDRATE_19200 0x06 00050 #define BAUDRATE_9600 0x0c 00051 #define BAUDRATE_4800 0x18 00052 #define BAUDRATE_2400 0x30 00053 00054 #define UART1_MAX_BUFFER_SIZE 500 00055 typedef struct{ 00056 U32 Put; 00057 U32 Get; 00058 U8 Data[UART1_MAX_BUFFER_SIZE]; 00059 }UART1_BUFFER_CONTROL; 00060 00061 typedef struct{ 00062 U8 State; 00063 U8 HasData; 00064 U8 Transfered; 00065 U8 RxData; 00066 U8 UartTxTransmit; 00067 UART1_BUFFER_CONTROL TxBuffer; 00068 UART1_BUFFER_CONTROL RxBuffer; 00069 OS_EVENT Uart1Event; 00070 }UART1_CONTROL; 00071 00072 extern UART1_CONTROL Uart1Ctrl; 00073 00074 void Uart1Init(void); 00075 void Uart1Handler(void); 00076 void Uart1Svc(void); 00077 void Uart1BufferReset(void); 00078 U8 Uart1RxBufferCheck(void); 00079 U8 Uart1RxBufferCheckIsr(void); 00080 void Uart1RxBufferPutIsr(U8 Data); 00081 U8 Uart1RxBufferGet(void); 00082 U8 Uart1TxBufferCheck(void); 00083 void Uart1TxBufferPut(U8 Data); 00084 U8 Uart1TxBufferGet(void); 00085 U8 Uart1TxBufferCheckIsr(void); 00086 U8 Uart1TxBufferGetIsr(void); 00087 U8 Uart1TxBufferGetIsr(void); 00088 00089 #endif
1.5.9