while(!(UART0->rUtrStat & 0x1)); //Receive data ready
ch = UART0->rUrxh;
if(ch == '\r')
{
while(!(UART0->rUtrStat & 0x2)); //wait utill transmit buffer empty
UART0->rUtxh = '\n';
while(!(UART0->rUtrStat & 0x2)); //wait utill transmit buffer empty
UART0->rUtxh = '\r';
}
else
{
if(ch == '\b')
{
while(!(UART0->rUtrStat & 0x2)); //wait utill transmit buffer empty
UART0->rUtxh = '\b';
while(!(UART0->rUtrStat & 0x2)); //wait utill transmit buffer empty
UART0->rUtxh = ' ';
while(!(UART0->rUtrStat & 0x2)); //wait utill transmit buffer empty
UART0->rUtxh = '\b';
}
else if(ch == 127)
{
Uart_Printf("11111111111111111111111111!\n\r");
}
else
{
while(!(UART0->rUtrStat & 0x2));
UART0->rUtxh=ch;
}
我的if(ch == 127)是用来判断delete键的,也有网上说是46,但是还是没用。我现在只用打印语句判断是否接受delete键传来的信号,具体怎么实现还没写。