新手入门
- 积分
- 11
- 金钱
- 11
- 注册时间
- 2021-5-17
- 在线时间
- 1 小时
|
1金钱
void uart0_send_char(char ch)
{
while(!(UART0.UTRSTAT0 & (0X1 << 1)));
UART0.UTXH0 = ch;
if(ch == '\n')
{
uart0_send_char('\r');
}
}
void uart0_send_str(char *str)
{
while(*str)
{
uart0_send_char(*(str++));
}
}
char uart0_recv_char(void)
{
char ch;
while (!(UART0.UTRSTAT0 & 0X1));
ch = UART0.URXH0;
return ch;
}
char buf[30] = {0};
char *uart0_recv_str(void)
{
int i = 0 ;
for(i = 0;i < 29 ; i++)
{
buf[i] = uart0_recv_char();
uart0_send_char(buf[i]);
if (buf[i] == '\r')
{
break;
}
}
buf[i] = '\0';
uart0_send_char('\n');
return buf;
}
|
|