📄 urt_defs.h
字号:
/*******************************************************************************/
/* These are the required 16 bit divisor values for the internal baud rate based on a 1.8MHz Clock */
#define DLM_50_Baud 0x09
#define DLL_50_Baud 0x00
#define DLM_110_Baud 0x04
#define DLL_110_Baud 0x17
#define DLM_150_Baud 0x03
#define DLL_150_Baud 0x00
#define DLM_300_Baud 0x01
#define DLL_300_Baud 0x5c
#define DLM_600_Baud 0x00
#define DLL_600_Baud 0xc0
#define DLM_1200_Baud 0x00
#define DLL_1200_Baud 0x60
#define DLM_2400_Baud 0x00
#define DLL_2400_Baud 0x30
#define DLM_4800_Baud 0x00
#define DLL_4800_Baud 0x18
#define DLM_7200_Baud 0x00
#define DLL_7200_Baud 0x10
#define DLM_9600_Baud 0x00
#define DLL_9600_Baud 0x0c
#define DLM_19200_Baud 0x00
#define DLL_19200_Baud 0x06
#define DLM_38400_Baud 0x00
#define DLL_38400_Baud 0x03
#define DLM_56000_Baud 0x00
#define DLL_56000_Baud 0x02
#define DLM_115200_Baud 0x00
#define DLL_115200_Baud 0x01
/* Defines for use by applications */
#define UART_A_RXINT 0x0100
#define UART_B_RXINT 0x0200
#define UART_A_VECTOR 17
#define UART_B_VECTOR 18
#define ICBASE (0x0A000000) /* Interrupt Controller Base */
#define IRQStatus ((volatile int *)ICBASE)
#define IRQRawStatus ((volatile int *)(ICBASE + 0x04))
#define IRQEnable ((volatile int *)(ICBASE + 0x08))
#define IRQEnableSet ((volatile int *)(ICBASE + 0x08))
#define IRQEnableClear ((volatile int *)(ICBASE + 0x0c))
#define IRQSoft ((volatile int *)(ICBASE + 0x10))
#define PARITY_ENABLE LCR_Parity_Enable
#define PARITY_NONE 0x00
// #define PARITY_NONE ~(LCR_Parity_Enable)
#define PARITY_EVEN LCR_Parity_Even
#define PARITY_ODD 0x00
//#define PARITY_ODD ~(LCR_Parity_Even)
#define PARITY_SET LCR_Parity_Set
#define BREAK_SET LCR_Break_Set
#define NO_BREAK 0x00
//#define NO_BREAK ~(LCR_Break_Set)
#define DIV_LATCH_ENABLE LCR_Divisor_Latch
#define WORD_LENGTH_5 LCR_5_Bit_Word
#define WORD_LENGTH_6 LCR_6_Bit_Word
#define WORD_LENGTH_7 LCR_7_Bit_Word
#define WORD_LENGTH_8 LCR_8_Bit_Word
#define STOP_BITS_1 LCR_Stop_Bit_1
#define STOP_BITS_1p5 LCR_Stop_Bit_1p5
#define STOP_BITS_2 LCR_Stop_Bit_2
#define RX_CHARRDY LSR_Rx_Data_Ready
#define RX_ERR LSR_Fifo_Error
#define RX_OVRRUN LSR_Overrun_Error
#define RX_FRMERR LSR_Framing_Error
#define RX_PRERR LSR_Parity_Error
/* UART error codes */
#define UART_INVALID_PARITY -1
#define UART_INVALID_DATA_BITS -2
#define UART_INVALID_STOP_BITS -3
#define UART_INVALID_BAUD -4
#define UART_INVALID_COM_PORT -5
typedef struct UART_INIT_STRUCT
{
unsigned com_port;
unsigned word_length;
unsigned stop_bits;
unsigned parity;
unsigned set_break;
unsigned baud_rate;
} UART_INIT;
#define BUFFER_SIZE 100
#define UART_BUFFER_FULL -1
#define UART_BUFFER_DATA -2
#define UART_BUFFER_EMPTY -3
typedef struct BUFFER_STRUCT
{
char *head;
char *tail;
char *read;
char *write;
INT status;
char buffer[BUFFER_SIZE];
} BUFFER;
// ----- Begin PID code
#define UART_A 0
#define UART_B 1
#define COM1 UART_A
#define COM2 UART_B
#define UART_A_BASE 0x0D800000
#define UART_B_BASE 0x0D800020
/* Interrupt bit masks */
#define RxReadyInt 0x0001
#define TxReadyInt 0x0010
#define RxLineInt 0x0100
#define ModemInt 0x1000
/* Line Status Register bits */
#define LSRRxData 0x00000001
#define LSROverrun 0x00000010
#define LSRParity 0x00000100
#define LSRFraming 0x00001000
#define LSRBreak 0x00010000
#define LSRTxHoldEmpty 0x00100000
#define LSRTxEmpty 0x01000000
#define LSRFIFOError 0x10000000
/* Clock Divisors for various Baud rates (assuming that
the PID is using a 1.843 MHz clock for the UART) */
#define Baud1200 0x0060
#define Baud2400 0x0030
#define Baud4800 0x0018
#define Baud9600 0x000c
#define Baud19200 0x0006
#define Baud38400 0x0003
#define Baud56000 0x0002 /* 2.77% error */
#define Baud57600 0x0002 /* 0% error */
#define Baud115200 0x0001
/* Serial Port A */
#define SerA_RHR ((volatile int *)(NISA_SER_A + 0x00)) /* Rx holding data */
#define SerA_THR ((volatile int *)(NISA_SER_A + 0x00)) /* Tx holding data */
#define SerA_IER ((volatile int *)(NISA_SER_A + 0x04)) /* Interrupt enable */
#define SerA_FCR ((volatile int *)(NISA_SER_A + 0x08)) /* Fifo control */
#define SerA_ISR ((volatile int *)(NISA_SER_A + 0x08)) /* Interrupt status */
#define SerA_LCR ((volatile int *)(NISA_SER_A + 0x0C)) /* Line control */
#define SerA_MCR ((volatile int *)(NISA_SER_A + 0x10)) /* Modem control */
#define SerA_LSR ((volatile int *)(NISA_SER_A + 0x14)) /* Line status */
#define SerA_MSR ((volatile int *)(NISA_SER_A + 0x18)) /* Modem status */
#define SerA_SPR ((volatile int *)(NISA_SER_A + 0x1C)) /* Scratchpad */
#define SerA_DLL ((volatile int *)(NISA_SER_A + 0x00)) /* LSB divisor latch */
#define SerA_DLM ((volatile int *)(NISA_SER_A + 0x04)) /* MSB divisor latch */
/* Serial Port B */
#define SerB_RHR ((volatile int *)(NISA_SER_B + 0x00)) /* Rx holding data */
#define SerB_THR ((volatile int *)(NISA_SER_B + 0x00)) /* Tx holding data */
#define SerB_IER ((volatile int *)(NISA_SER_B + 0x04)) /* Interrupt enable */
#define SerB_FCR ((volatile int *)(NISA_SER_B + 0x08)) /* Fifo control */
#define SerB_ISR ((volatile int *)(NISA_SER_B + 0x08)) /* Interrupt status */
#define SerB_LCR ((volatile int *)(NISA_SER_B + 0x0C)) /* Line control */
#define SerB_MCR ((volatile int *)(NISA_SER_B + 0x10)) /* Modem control */
#define SerB_LSR ((volatile int *)(NISA_SER_B + 0x14)) /* Line status */
#define SerB_MSR ((volatile int *)(NISA_SER_B + 0x18)) /* Modem status */
#define SerB_SPR ((volatile int *)(NISA_SER_B + 0x1C)) /* Scratchpad */
#define SerB_DLL ((volatile int *)(NISA_SER_B + 0x00)) /* LSB divisor latch */
#define SerB_DLM ((volatile int *)(NISA_SER_B + 0x04)) /* MSB divisor latch */
/* Macros describing the NISA Bus */
#define NISA_BASE 0x0C000000 /* NISA Base address */
#define NISA_IO_BASE (NISA_BASE)
#define NISA_PCMCIA (NISA_IO_BASE + 0x7C0) /* PCMCIA control registers */
#define NISA_SER_A (NISA_IO_BASE + 0x01800000) /* Serial port A */
#define NISA_SER_B (NISA_IO_BASE + 0x01800020) /* Serial port B */
#define NISA_PAR (NISA_IO_BASE + 0x01800040) /* Parallel port */
#define NISA_PCMEM 0x0E000000 /* PCMCIA memory base */
#define NISA_TOP 0x10000000 /* Top of NISA Space */
#endif /* EOF for urt_defs.h */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -