maxikrie opened a new pull request, #20389:
URL: https://github.com/apache/nuttx/pull/20389

   ## Summary
   
   In RS-485 mode the driver released the direction (DE) pin only on 
TX_BRK_IDLE_DONE. That interrupt belongs to the break feature (UART_TXD_BRK), 
which this driver never enables, so it never fired and DIR stayed asserted 
after the first transmit. The board then kept driving the bus and collided with 
every reply. The interrupt was also never cleared, so had it fired, the handler 
would have re-entered forever.
   
   TX_DONE cannot simply replace it: the upper half calls txint(false) as soon 
as its software buffer drains, which disabled TX_DONE while the last bytes were 
still in the FIFO (see #15888).
   
   * Keep TX_DONE enabled in txint(false) while in RS-485 mode.
   * In the handler, on TX_DONE with the software buffer and TX FIFO empty, 
wait (bounded) for the transmitter FSM to go idle so the last stop bit is not 
clipped, release DIR and disable TX_DONE. This is how ESP-IDF's RS-485 
half-duplex mode handles it.
   * Make txempty() use FIFO count and FSM state, as ESP-IDF's 
uart_ll_is_tx_idle() does. The raw TX_DONE bit reads 0 before the first 
transmission and is now cleared by the handler, which would make tcdrain() wait 
for its full timeout.
   
   ## Impact
   
   This affects only the ESP32-S3 family and its boards.
   
   ## Testing
   
   Tested on an ESP32-S3 board with an SP3485 transceiver (DE/RE on GPIO21) at 
115200 baud, doing Modbus RTU reads against a servo drive: without the patch 
every request timed out; with it DIR drops right after the last stop bit and 
all reads succeed.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to