//====================================================
// 语法格式:void myUart_Send (char *str)
// 功能描述: 发送字符串
// 入口参数: 字符串指针
// 出口参数: 无
//====================================================================
void myUart_Send (char *str)
{
myUart_Init(0,115200);
while (*str)
myUart_SendByte(*str++);
}
char myUart_ReceiveByte(void)
{
if(UartNum==0)
{
while(!(rUTRSTAT0 & 0x1)); //等待接收数据
return RdURXH0();
}
else if(UartNum==1)
{
while(!(rUTRSTAT1 & 0x1)); //等待接收数据
return RdURXH1();
}
return 0;
}
void myUart_receive(char *string)
{
char *string2 ;
char c;
string2 = string;
myUart_Init(0,115200);
while((c = myUart_ReceiveByte())!='\r')
{
if(c=='\b')
{
if( (int)string2 < (int)string )
{
printf("\b \b");
string--;
}
}
else
{
*string++ = c;
myUart_SendByte(c);
}
}
*string='\0';
myUart_SendByte('\n');
}
void myUart_Printf(char *fmt,...)
{
va_list ap;
char string[256];
va_start(ap,fmt);
vsprintf(string,fmt,ap);
myUart_Send(string);
va_end(ap);
}
U-boot中配置串口:
board/TX2440/TX2440.c中的board_init函数
int board_init (void)
{
S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
gpio->GPGUP = 0x0000FFFF;()
gpio->GPHCON = 0x002AFAAA;(串口0和串口1的nCTS, nRTS, TXD,RXD,还有时钟)
gpio->GPHUP = 0x000007FF;
……
} |