nuttx/arch
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
..
arm arch/arm/mps: Let user code run modules from the text and data heaps. 2026-09-28 16:46:05 -03:00
arm64 arch/arm64/imx9: add key store, signing and persistence to the ELE 2026-09-28 21:50:43 +08:00
avr arch, boards, cmake: Build C++ ELF modules without __cxa_atexit. 2026-09-04 15:44:24 -03:00
ceva arch/atomic: remove up_testset in spinlock 2026-09-08 08:58:54 +08:00
dummy
hc tools: fix stale archive members surviving a Kconfig-driven CSRCS change 2026-07-28 21:26:03 -03:00
mips arch, boards, cmake: Build C++ ELF modules without __cxa_atexit. 2026-09-04 15:44:24 -03:00
misoc arch, boards, cmake: Build C++ ELF modules without __cxa_atexit. 2026-09-04 15:44:24 -03:00
or1k arch, boards, cmake: Build C++ ELF modules without __cxa_atexit. 2026-09-04 15:44:24 -03:00
renesas nuttx/libc: refine the atomic related Kconfig 2026-08-24 13:20:45 +08:00
risc-v arch/risc-v/eic7700x: Describe the pads through procfs. 2026-09-28 16:19:01 +08:00
sim arch/sim: buffer several mouse reports 2026-09-25 10:36:28 +02:00
sparc arch/atomic: remove up_testset in spinlock 2026-09-08 08:58:54 +08:00
tricore arch/atomic: remove up_testset in spinlock 2026-09-08 08:58:54 +08:00
x86 arch/x86: Add -P to CPP to suppress linemarkers. 2026-09-17 16:21:59 +08:00
x86_64 arch/x86_64: Implement up_addrenv_fork() and provide POSIX fork(). 2026-09-24 18:02:36 -03:00
xtensa arch/xtensa/esp32s3: Release RS-485 DIR on TX_DONE. 2026-09-29 09:09:24 +08:00
z16 tools: fix stale archive members surviving a Kconfig-driven CSRCS change 2026-07-28 21:26:03 -03:00
z80
CMakeLists.txt cmake: Use NUTTX(_DIR/_BIN_DIR) instead CMAKE(_SRC_DIR/_BIN_DIR) 2026-08-09 11:13:08 -03:00
Kconfig arch/xtensa: Provide POSIX fork() on the ESP32-S3. 2026-09-26 11:13:57 -03:00