#include "s3c24xx.h"
#include "uart.h"
void uart_init(){
GPHCON &= ~((3<<4) | (3<<6)); /*设置引脚为UART0*/
GPHCON |= ((2<<4) | (2<<6));
GPHUP &= ~((1<<2) | (1<<3));
UCON0 = 0x00000005; //时钟选择
UBRDIV0 = 26; //UBRDIVn = uart clock /波特率*16 -1 = 50M/115200*16 -1 = 26
ULCON0 = 0x00000003; //8,n,1
}
int putchar(int c){
while(!(UTRSTAT0 & (1<<2)));
UTXH0 = (unsigned char)c;
}
int getchar(void){
while(!(UTRSTAT0 & (1<<0)));
return URXH0;
}
int puts(const char *s)
{
while(*s)
{
putchar(*s);
s++;
}
}