#define GLOBAL_CLK 1
#include "def.h"
#include "option.h"
#include "2440addr.h"
#include "2440lib.h"
#include "2440slib.h"
#define PCLK 50000000
#define UART_BAUD_RATE 115200
void uart0_init(void);
unsigned char getchar(void);
void putchar(unsigned char);
int Main(void)
{
uart0_init();
while (1)
{
putchar(getchar() + 1);
}
return 0;
}
void uart0_init(void)
{
rGPGCON = 0xa0; //端口 G 的 2、3 设置为串口模式
rGPHUP = 0x0c; //2、3 使用内部上拉
rULCON0 = 0x03; //8 位数据,1 位停止,无校验。正常模式,非红
外
rUCON0 = 0x05; //查询方式收发数据,非中断
rUFCON0 = 0x0; //不使用 FIFO
rUMCON0 = 0x0; //不使用流量控制
rUBRDIV0 = (int)(PCLK / UART_BAUD_RATE / 16) - 1; //波特率为 115200