Skip to content

Conversation

@SuGlider
Copy link
Collaborator

@SuGlider SuGlider commented Sep 8, 2023

Description of Change

There is a bug in HardwareSerial::setPins() that sets the UART pins internally to the wrong value at the end of the operation, which may lead to errors in HardwareSerial::end(), not dettaching the right GPIO from UART.

This PR also makes sure that sequential HardwareSerial::setPins() will always detach previous attached GPIOs.

Tests scenarios

// Check previous GPIOs with a Logic Analyzer
void setup() {
  Serial.begin(115200);  // sets default RX and TX
  Serial.println("This will go out in the default TX pin");
  Serial.flush();
  
  Serial.setPins(-1, 2);  // Now TX shall be GPIO2 and default TX GPIO can't send any data
  Serial.println("This line can't be seen in the default TX GPIO!");
  Serial.flush();
}

void loop(){
}

Related links

Closes #8607

@SuGlider SuGlider self-assigned this Sep 8, 2023
@SuGlider
Copy link
Collaborator Author

SuGlider commented Sep 8, 2023

@me-no-dev - I had to create a new PR in order to rebase it to master branch.

@SuGlider SuGlider added this to the 3.0.0 milestone Sep 8, 2023
@SuGlider SuGlider added the Peripheral: UART Related to the UART peripheral or its functionality. label Sep 8, 2023
@SuGlider SuGlider marked this pull request as draft September 10, 2023 14:17
@me-no-dev me-no-dev modified the milestones: 3.0.0, 2.0.13 Sep 12, 2023
@SuGlider
Copy link
Collaborator Author

@me-no-dev - This PR will remain as draft. Please review and merge #8629 to 2.0.13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Peripheral: UART Related to the UART peripheral or its functionality.

Projects

Development

Successfully merging this pull request may close these issues.

HardwareSerial::setPins does not unset previous pin

2 participants