Skip to content

Add half-duplex support to HardwareSerial.#643

Merged
fpistm merged 1 commit intostm32duino:masterfrom
ghent360:half-duplex
Oct 11, 2019
Merged

Add half-duplex support to HardwareSerial.#643
fpistm merged 1 commit intostm32duino:masterfrom
ghent360:half-duplex

Conversation

@ghent360
Copy link
Copy Markdown
Contributor

@ghent360 ghent360 commented Sep 9, 2019

Summary
TMC2209 and 2208 drivers use UART communication with a single wire. Enabling half-duplex support in the HardwareSerial class would enable using these drivers without wasting another pin for the RX signal.

Proposed API is to enable half-duplex mode if the RX pin on the serial port is NC. Also added a method to set the half-duplex mode explicitly.

Validation

Copy link
Copy Markdown
Member

@fpistm fpistm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ghent360
Thanks for the PR.
Some minor remarks.

Comment thread cores/arduino/stm32/uart.c Outdated
Comment thread cores/arduino/stm32/uart.c Outdated
Comment thread cores/arduino/stm32/uart.c Outdated
@AnHardt
Copy link
Copy Markdown
Contributor

AnHardt commented Sep 9, 2019

Proposed API is to enable half-duplex mode if the RX pin on the serial port is NC. Also added a method to set the half-duplex mode explicitly.

Could also be nice if TX_pin == RX_pin would set up half-duplex.

@fpistm
Copy link
Copy Markdown
Member

fpistm commented Sep 9, 2019

Proposed API is to enable half-duplex mode if the RX pin on the serial port is NC. Also added a method to set the half-duplex mode explicitly.

Could also be nice if TX_pin == RX_pin would set up half-duplex.

With a SoftwareSerial this could be possible but with HardwareSerial there no U(S)ART RX and TX on the same pin, as far as I know.

@fpistm fpistm added the waiting feedback Further information is required label Sep 13, 2019
@ghent360 ghent360 requested a review from fpistm September 14, 2019 02:59
Implement suggestions from fpistm.
Fix style issues.
@fpistm
Copy link
Copy Markdown
Member

fpistm commented Sep 14, 2019

Thanks @ghent360 , I have to test it. Do you have a sketch example to test this? Else I will write one.

@fpistm fpistm added this to the 1.8.0 milestone Sep 25, 2019
@fpistm fpistm added Review on going and removed waiting feedback Further information is required labels Sep 25, 2019
@fpistm
Copy link
Copy Markdown
Member

fpistm commented Oct 10, 2019

Proposed API is to enable half-duplex mode if the RX pin on the serial port is NC. Also added a method to set the half-duplex mode explicitly.

Could also be nice if TX_pin == RX_pin would set up half-duplex.

With a SoftwareSerial this could be possible but with HardwareSerial there no U(S)ART RX and TX on the same pin, as far as I know.

My bad, after some read some documentations this would be possible.
I'm currently reviewing this PR and it seems there is an issue on how the Tx pin is configured.
Documentation recommend this:

The USART can be configured to follow a single-wire half-duplex protocol where the Tx and Rx lines are internally connected. In this communication mode, only the Tx pin is used forboth transmission and reception.
The Tx pin is always released when no data is transmitted, thus, it acts as a standard I/O in idle or
reception modes.
This means that the I/O must be configured so that the Tx pin is configured as an alternate function open-drain with an external pull-up.

Currently this is not the case as by default it is set in PushPull

Copy link
Copy Markdown
Member

@fpistm fpistm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will provide a PR to extend how enable half-duplex.
And a small fix when Serial is disabled.

@fpistm fpistm merged commit 2a64163 into stm32duino:master Oct 11, 2019
@fpistm fpistm added enhancement New feature or request and removed New feature labels Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants