nuttx/arch/xtensa/src
Max Kriegleder fe7eff404e arch/xtensa/esp32s3: Release RS-485 DIR on TX_DONE.
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.

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.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Max Kriegleder <max.kriegleder@gmail.com>
2026-09-29 09:09:24 +08:00
..
cmake cmake: Use NUTTX(_DIR/_BIN_DIR) instead CMAKE(_SRC_DIR/_BIN_DIR) 2026-08-09 11:13:08 -03:00
common espressif/esp_pm.c: restore GPIO config after using it as a wake source 2026-09-23 08:36:17 -03:00
esp32 sched/semaphore: Fix pre-existing nxstyle issues in the touched files 2026-09-25 10:37:43 +02:00
esp32s2 sched/semaphore: Fix pre-existing nxstyle issues in the touched files 2026-09-25 10:37:43 +02:00
esp32s3 arch/xtensa/esp32s3: Release RS-485 DIR on TX_DONE. 2026-09-29 09:09:24 +08:00
lx6 arch, boards, cmake: Build C++ ELF modules without __cxa_atexit. 2026-09-04 15:44:24 -03:00
lx7 xtensa: Support BUILD_KERNEL. 2026-09-10 23:28:43 +08:00
.gitignore
CMakeLists.txt
Makefile xtensa: Support BUILD_KERNEL. 2026-09-10 23:28:43 +08:00