properly drop characters when buffer is full

fix by David Kopf
This commit is contained in:
Mariano Alvira 2010-07-06 09:34:23 -04:00
parent beb75cd355
commit 7e5ebe88f7

View file

@ -65,8 +65,9 @@ void uart1_putc(char c) {
u1_head += 1;
if (u1_head >= sizeof(u1_tx_buf))
u1_head = 0;
if (u1_head == u1_tail) /* drop chars when no room */
return;
if (u1_head == u1_tail) { /* drop chars when no room */
if (u1_head) { u1_head -=1; } else { u1_head = sizeof(u1_tx_buf); }
}
enable_irq(UART1);
}
}