void UART_Putc(char c)
{
if (c == 'n')
*(unsigned int *)(UART0_ADDR + 0X00) = 'r';
delay_x(0x800);
*(unsigned int *)(UART0_ADDR + 0X00) = c;
}
unsigned int val_i=0;
void UART_Print(const char *str,...)
{
va_list unnamed_p;
char *sval;
unsigned int tmp=0;
va_start( unnamed_p, str);
while (*str)
{
//
if(*str=='%')
{
switch(*++str)
{
case 'd'://输出十进制
break;
case 'c'://输出字符
break;
case 's'://输出字符串
for(sval = va_arg(unnamed_p,char*);*sval;sval++)
{
UART_Putc(*sval);
}
str++;
break;
case 'X'://输出16十进制
case 'x'://输出16十进制
val_i = va_arg(unnamed_p,unsigned int);
//
UART_Putc('0');delay_x(0X800);
UART_Putc('x');delay_x(0X800);
for(i=0;i<8;i++)
{
delay_x(0X800);
tmp = val_i>>(4*(7-i));
val_i = val_i&(~(0xff< //
if(tmp<10)
UART_Putc('0'+tmp);
else
UART_Putc('A'+tmp-10);
//
}
//
str++;
break;
default://输出字符
break;
}
}
//
UART_Putc(*str++);
}
}