Fix UART writeBuf and flush

This commit is contained in:
me-no-dev 2016-10-06 16:31:28 +03:00
parent 03f5d62323
commit fb4f1333d2

View File

@ -170,11 +170,13 @@ void uartWrite(uart_t* uart, uint8_t c)
void uartWriteBuf(uart_t* uart, const uint8_t * data, size_t len) void uartWriteBuf(uart_t* uart, const uint8_t * data, size_t len)
{ {
while(len && uart->dev->status.rxfifo_cnt < 0x7F) { while(len) {
while(len && uart->dev->status.txfifo_cnt < 0x7F) {
uart->dev->fifo.rw_byte = *data++; uart->dev->fifo.rw_byte = *data++;
len--; len--;
} }
} }
}
void uartFlush(uart_t* uart) void uartFlush(uart_t* uart)
{ {
@ -189,8 +191,8 @@ void uartFlush(uart_t* uart)
} }
if(uart->txEnabled) { if(uart->txEnabled) {
tmp |= UART_TXFIFO_RST;
while(uart->dev->status.txfifo_cnt); while(uart->dev->status.txfifo_cnt);
tmp |= UART_TXFIFO_RST;
} }
uart->dev->conf0.val |= (tmp); uart->dev->conf0.val |= (tmp);