Implement hardware flow control on SAMD busio.UART #6434
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The current atmel-samd port does not support RTS/CTS for hardware flow control, even though the underlying SAMx2x/SAMx5x chips are capable of using this mode on async UARTs. This change enables hardware flow control by allowing assignment of pins to RTS/CTS, and enabling selection of the correct pad configuration for the pinout via the CTRLA.TXPO register.
An example of working code looks like this (using the pin configs on the Sparkfun SAMD51 MicroMod):
I have tested this with on the MicroMod, and it works as expected when the other side is set up for hardware flow control. To fully confirm it, I disabled hardware flow control in picocom, attached to an FTDI USB-to-serial board wired to the UART RX/TX/RTS/CTS lines on the MicroMod, then used picocom's toggle features to assert RTS and CTS to prevent reads or writes as desired. I also confirmed that normal operation of the UART when hardware flow control is not specified works as it did prior to this change.
A note re confirming this PR: while RTS/CTS flow control is available on the SAMx2x/SAMx5x chips, it's only happenstance that a given dev board exposes the correct pins used for the given SERCOM underlying the UART(s) exposed via hardware. I found that several boards did not have the pins I need even connected. The MicroMod was one where I was able to find the right pads connected to pins.