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> |
||
|---|---|---|
| .github | ||
| arch | ||
| audio | ||
| binfmt | ||
| boards | ||
| cmake | ||
| crypto | ||
| Documentation | ||
| drivers | ||
| dummy | ||
| fs | ||
| graphics | ||
| include | ||
| libs | ||
| mm | ||
| net | ||
| openamp | ||
| pass1 | ||
| sched | ||
| syscall | ||
| tools | ||
| video | ||
| wireless | ||
| .asf.yaml | ||
| .codespell-ignore-lines | ||
| .codespellrc | ||
| .editorconfig | ||
| .gitignore | ||
| .gitmessage | ||
| .mcp.json | ||
| .pre-commit-config.yaml | ||
| .yamllint | ||
| AUTHORS | ||
| CMakeLists.txt | ||
| CONTRIBUTING.md | ||
| INVIOLABLES.md | ||
| Kconfig | ||
| LICENSE | ||
| Makefile | ||
| NOTICE | ||
| README.md | ||
| ReleaseNotes | ||
Apache NuttX is a real-time operating system (RTOS) with an emphasis on standards compliance and small footprint. Scalable from 8-bit to 64-bit microcontroller environments, the primary governing standards in NuttX are POSIX and ANSI standards. Additional standard APIs from Unix and other common RTOSs (such as VxWorks) are adopted for functionality not available under these standards, or for functionality that is not appropriate for deeply-embedded environments (such as fork()).
For brevity, many parts of the documentation will refer to Apache NuttX as simply NuttX.
Getting Started
First time on NuttX? Read the Getting Started guide! If you don't have a board available, NuttX has its own simulator that you can run on terminal.
Documentation
You can find the current NuttX documentation on the Documentation Page.
Alternatively, you can build the documentation yourself by following the Documentation Build Instructions.
The old NuttX documentation is still available in the Apache wiki.
Supported Boards
NuttX supports a wide variety of platforms. See the full list on the Supported Platforms page.
Contributing
If you wish to contribute to the NuttX project, read the Contributing guidelines for information on Git usage, coding standard, workflow and the NuttX principles.
License
The code in this repository is under either the Apache 2 license, or a license compatible with the Apache 2 license. See the License Page for more information.