mirror of
https://github.com/CTCaer/hekate.git
synced 2024-11-26 11:42:09 +00:00
uart: Decreases timeouts to reduce latency
This commit is contained in:
parent
48f84c5cf4
commit
157e415636
2 changed files with 12 additions and 18 deletions
|
@ -85,27 +85,24 @@ void uart_send(u32 idx, const u8 *buf, u32 len)
|
|||
u32 uart_recv(u32 idx, u8 *buf, u32 len)
|
||||
{
|
||||
uart_t *uart = (uart_t *)(UART_BASE + uart_baseoff[idx]);
|
||||
u32 timeout = get_tmr_us() + 1000;
|
||||
u32 timeout = get_tmr_us() + 250;
|
||||
u32 i;
|
||||
|
||||
for (i = 0; ; i++)
|
||||
{
|
||||
while (!(uart->UART_LSR & UART_LSR_RDR))
|
||||
{
|
||||
if (!len)
|
||||
{
|
||||
if (timeout < get_tmr_us())
|
||||
break;
|
||||
}
|
||||
else if (len < i)
|
||||
if (len && len < i)
|
||||
break;
|
||||
}
|
||||
if (timeout < get_tmr_us())
|
||||
break;
|
||||
|
||||
buf[i] = uart->UART_THR_DLAB;
|
||||
timeout = get_tmr_us() + 1000;
|
||||
};
|
||||
timeout = get_tmr_us() + 250;
|
||||
}
|
||||
|
||||
return i ? (len ? (i - 1) : i) : 0;
|
||||
}
|
||||
|
|
|
@ -85,27 +85,24 @@ void uart_send(u32 idx, const u8 *buf, u32 len)
|
|||
u32 uart_recv(u32 idx, u8 *buf, u32 len)
|
||||
{
|
||||
uart_t *uart = (uart_t *)(UART_BASE + uart_baseoff[idx]);
|
||||
u32 timeout = get_tmr_us() + 1000;
|
||||
u32 timeout = get_tmr_us() + 250;
|
||||
u32 i;
|
||||
|
||||
for (i = 0; ; i++)
|
||||
{
|
||||
while (!(uart->UART_LSR & UART_LSR_RDR))
|
||||
{
|
||||
if (!len)
|
||||
{
|
||||
if (timeout < get_tmr_us())
|
||||
break;
|
||||
}
|
||||
else if (len < i)
|
||||
if (len && len < i)
|
||||
break;
|
||||
}
|
||||
if (timeout < get_tmr_us())
|
||||
break;
|
||||
|
||||
buf[i] = uart->UART_THR_DLAB;
|
||||
timeout = get_tmr_us() + 1000;
|
||||
};
|
||||
timeout = get_tmr_us() + 250;
|
||||
}
|
||||
|
||||
return i ? (len ? (i - 1) : i) : 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue