📄 uart.h
字号:
/***************************************** Copyright (c) 2001-2002 Sigma Designs, Inc. All Rights Reserved Proprietary and Confidential *****************************************//* This file is part of the Jasper DVD boot loader */#ifndef __UART_H__#define __UART_H__#include "config.h"#define CPU_WR_32BIT_REG(base, port, value) do { *(volatile unsigned int *)(base+port)=value; } while(0)#define CPU_RD_32BIT_REG(base, port) (*(volatile unsigned int *)(base+port))#ifdef ENABLE_UART//------------------------------------------------------// UART REGISTERs// UART1 0050_0500// UART2 0050_1300//------------------------------------------------------#define UART1_BASE 0x00500500#define UART2_BASE 0x00501300#define UART_RBR 0x00#define UART_TBR 0x04#define UART_IER 0x08#define UART_IIR 0x0C#define UART_FCR 0x10#define UART_LCR 0x14#define UART_MCR 0x18#define UART_LSR 0x1C#define UART_MSR 0x20#define UART_SCRATCH 0x24#define UART_CLKDIV 0x28#define UART_CLKSEL 0x2C/* Line Control Register */#define UART_LCR_SBC 0x40 /* Set break control */#define UART_LCR_SPAR 0x20 /* Stick parity (?) */#define UART_LCR_EPAR 0x10 /* Even parity select */#define UART_LCR_PARITY 0x08 /* Parity Enable */#define UART_LCR_STOP 0x04 /* Stop bits: 0 = 1 stop bit, 1 = 2 stop bits */#define UART_LCR_WLEN5 0x00 /* Wordlength: 5 bits */#define UART_LCR_WLEN6 0x01 /* Wordlength: 6 bits */#define UART_LCR_WLEN7 0x02 /* Wordlength: 7 bits */#define UART_LCR_WLEN8 0x03 /* Wordlength: 8 bits */#define UART_LCR_N81 0x03 /* None, 8 bit, 1 bit */#define UART_PARITY_NONE 0x00#define UART_PARITY_ODD 0x08#define UART_PARITY_EVEN 0x18// default configuration#define DEFAULT_UART_PORT 0#define DEFAULT_BAUDRATE 38400 // 300, 1200, 2400, 4800, 9600, // 19200, 38400, 57600, 115200, 230400#define DEFAULT_DATABITS 8 // 5 - 8#define DEFAULT_STOPBITS 1 // 1 - 2#define DEFAULT_PARITY UART_PARITY_NONE // none, even, odd//// function prototypes//// initializationvoid InitUartPort(int port, int baudrate);void InitUart(void);// output#define PrintUart(x...) PrintString(x)void PrintChar(int ch);void PrintString (char *t, int maxlen);void PrintByte(unsigned char b);void PrintShort (unsigned short s);void PrintLong (unsigned long h);int PrintFormat(const char *fmt, ...);// inputenum { GETSTR_ESCAPE = 0x01, GETSTR_APPEND = 0x02, GETSTR_APPENDDISP = 0x04};int PeekChar(void);int GetChar(void);char *GetString(char *str, int maxlen, int flag);char *GetCommand(char *str);char *GetRawString(char *str, int maxlen);#else /* ENABLE_UART */#define PrintUart(x...) while (0)#define PrintChar(ch) while (0)#define PrintString(t, maxlen) while (0)#define PrintByte(b) while (0)#define PrintShort(s) while (0)#define PrintLong(h) while (0)#define PrintFormat(x...) while (0)#endif /* ENABLE_UART */#endif /* __UART_H__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -