driver/serial : Fixed unwanted disabling of TX Interrupt
1. Do not disable Tx interrut if dev->xmit buffer is initially found empty
2. No bytes will be copied to DMA send VFIFO
3. Allow waiting processes to write to dev->xmit.head
@@ -103,6 +103,11 @@ void uart_xmitchars(FAR uart_dev_t *dev)
/* Send while we still have data in the TX buffer & room in the fifo */
+ if (dev->xmit.head == dev->xmit.tail){
+ nbytes++;
+ goto xmit_empty;
+ }
+
while (dev->xmit.head != dev->xmit.tail && uart_txready(dev)) {
/* Send the next byte */
@@ -118,14 +123,9 @@ void uart_xmitchars(FAR uart_dev_t *dev)
/* When all of the characters have been sent from the buffer disable the TX
* interrupt.
- *
- * Potential bug? If nbytes == 0 && (dev->xmit.head == dev->xmit.tail) &&
- * dev->xmitwaiting == true, then disabling the TX interrupt will leave
- * the uart_write() logic waiting to TX to complete with no TX interrupts.
- * Can that happen?
*/
- if (dev->xmit.head == dev->xmit.tail) {
+ if ((dev->xmit.head == dev->xmit.tail) && (!nbytes)){
uart_disabletxint(dev);
}
@@ -133,9 +133,12 @@ void uart_xmitchars(FAR uart_dev_t *dev)
* space available.
*/
+xmit_empty:
if (nbytes) {
- uart_datasent(dev);
+ dev->sent(dev);
}
+
+ return;
}
/************************************************************************************
