//115200,8,n,1
void uart0_init()
{
//GPH2,3用于TXD0,RXD0
GPHCON &= ~((3<<4) |(3<<6));
GPHCON |= ((2<<4) | (2<<6));
//使能内部上拉
GPHUP &= ~((1<<2) |(1<<3));
//设置波特率
//UBRDIVn = (int)( UART clock / ( buad ratex 16) ) –1
// = 50000000 / (115200 * 16) - 1
// = 26
UBRDIV0 = 26;
UCON0 = 0x5;
ULCON0 = 0x3;
}
int putchar(int c)
{
/* UTRSTAT0 */
/* UTXH0 */
while (!(UTRSTAT0 & (1<<2)));
UTXH0 = (unsigned char)c;
}
int puts(const char *s)
{
while (*s)
{
putchar(*s);
s++;
}
}