00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef UARTINTR_H
00019 #define UARTINTR_H
00020
00021 #include "global.h"
00022 #include "buffer.h"
00023 #include "LPC2000.h"
00024
00025
00026
00027
00028
00029
00030
00031
00032 #define UART_BAUD(baud) (uint16_t)((PCLK+baud*8L)/(baud*16))
00033
00034
00035 #define UART_8N1 (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_NO + ULCR_STOP_1)
00036 #define UART_7N1 (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_NO + ULCR_STOP_1)
00037 #define UART_8N2 (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_NO + ULCR_STOP_2)
00038 #define UART_7N2 (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_NO + ULCR_STOP_2)
00039 #define UART_8E1 (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_EVEN + ULCR_STOP_1)
00040 #define UART_7E1 (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_EVEN + ULCR_STOP_1)
00041 #define UART_8E2 (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_EVEN + ULCR_STOP_2)
00042 #define UART_7E2 (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_EVEN + ULCR_STOP_2)
00043 #define UART_8O1 (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_ODD + ULCR_STOP_1)
00044 #define UART_7O1 (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_ODD + ULCR_STOP_1)
00045 #define UART_8O2 (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_ODD + ULCR_STOP_2)
00046 #define UART_7O2 (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_ODD + ULCR_STOP_2)
00047
00048
00049 #define UART_FIFO_OFF (0x00)
00050 #define UART_FIFO_1 (uint8_t)(UFCR_FIFO_ENABLE + UFCR_FIFO_TRIG1)
00051 #define UART_FIFO_4 (uint8_t)(UFCR_FIFO_ENABLE + UFCR_FIFO_TRIG4)
00052 #define UART_FIFO_8 (uint8_t)(UFCR_FIFO_ENABLE + UFCR_FIFO_TRIG8)
00053 #define UART_FIFO_14 (uint8_t)(UFCR_FIFO_ENABLE + UFCR_FIFO_TRIG14)
00054
00055
00056
00057 #ifndef UART0_TX_BUFFER_SIZE
00058 #define UART0_TX_BUFFER_SIZE 0x0010
00059 #endif
00060 #ifndef UART0_RX_BUFFER_SIZE
00061 #define UART0_RX_BUFFER_SIZE 0x0080
00062 #endif
00063 #ifndef UART1_TX_BUFFER_SIZE
00064 #define UART1_TX_BUFFER_SIZE 0x0010
00065 #endif
00066 #ifndef UART1_RX_BUFFER_SIZE
00067 #define UART1_RX_BUFFER_SIZE 0x0080
00068 #endif
00069
00070
00071
00072
00073
00074 void uart0Init(uint16_t baud, uint8_t mode, uint8_t fifomode);
00075 void uart1Init(uint16_t baud, uint8_t mode, uint8_t fifomode);
00076
00077
00078
00079 void uart0InitBuffers(void);
00080 void uart1InitBuffers(void);
00081
00082 cBuffer* uart0GetRxBuffer(void);
00083 cBuffer* uart1GetRxBuffer(void);
00084
00085
00086 int uart0SendByte(int data);
00087 int uart1SendByte(int data);
00088
00089
00090 int uart0GetByte(void);
00091 int uart1GetByte(void);
00092
00093
00094 void uart0Service(void) __attribute__((interrupt));
00095 void uart1Service(void) __attribute__((interrupt));
00096
00097 #endif