Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rtl872x] Fix unintentional pin changes for Serial1 RTS/CTS #2703

Merged
merged 1 commit into from
Oct 6, 2023

Conversation

eberseth
Copy link
Contributor

@eberseth eberseth commented Oct 3, 2023

Problem

Starting Serial1 causes the RTS and CTS lines to be assigned as hardware handshake signals without regard to whether they are previously set for GPIO.

Solution

Check if flow control is requested on the given interface and if the pins are assigned already. Configure for handshaking only if requested; otherwise, leave pins alone.

Before:

         ___________________
RTS   __/                     ...
          ________  _________
CTS   ___/        ||          ...
          <------->
             50ms

After:

         ___________           ______
RTS   __/           \_________/       ...
          ___________           _____
CTS   ___/           \_________/      ...
          <---------><--------->
              150ms      100ms

Steps to Reproduce

#define SERIAL          (Serial1)
#define SERIAL_RTS      (RTS)
#define SERIAL_CTS      (CTS)

// #define SERIAL          (Serial2)
// #define SERIAL_RTS      (RTS1)
// #define SERIAL_CTS      (CTS1)

// #define SERIAL          (Serial3)
// #define SERIAL_RTS      (RTS2)
// #define SERIAL_CTS      (CTS2)

void setup() {
  Serial.begin(115200);
  waitFor(Serial.isConnected, 10000);  // Wait until we're ready to capture waveforms

  pinMode(SERIAL_RTS, OUTPUT);
  digitalWrite(SERIAL_RTS, HIGH);
  pinMode(SERIAL_CTS, OUTPUT);
  digitalWrite(SERIAL_CTS, HIGH);
  delay(50);
  SERIAL.begin(115200);
  //SERIAL.begin(115200, SERIAL_FLOW_CONTROL_RTS_CTS);
  delay(100);
  digitalWrite(SERIAL_RTS, LOW);
  digitalWrite(SERIAL_CTS, LOW);
  delay(100);
  digitalWrite(SERIAL_RTS, HIGH);
  digitalWrite(SERIAL_CTS, HIGH);
}

References

sc-118986


Completeness

  • User is totes amazing for contributing!
  • Contributor has signed CLA (Info here)
  • Problem and Solution clearly stated
  • Run unit/integration/application tests on device
  • Added documentation
  • Added to CHANGELOG.md after merging (add links to docs and issues)

@avtolstoy avtolstoy added this to the 5.6.0 milestone Oct 3, 2023
@eberseth eberseth merged commit 7140b5f into develop Oct 6, 2023
1 check passed
@eberseth eberseth deleted the fix/sc-118986/mson-rts-cts branch October 6, 2023 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants