uart_write should block until all bytes are sent out, so wait for transmit fifo to empty before returning.