Skip to content

Conversation

@SuGlider
Copy link
Collaborator

@SuGlider SuGlider commented Sep 7, 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 7, 2023
@SuGlider SuGlider linked an issue Sep 7, 2023 that may be closed by this pull request
1 task
Copy link
Member

@P-R-O-C-H-Y P-R-O-C-H-Y left a comment

Choose a reason for hiding this comment

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

@SuGlider PTAL

@P-R-O-C-H-Y P-R-O-C-H-Y added the Peripheral: UART Related to the UART peripheral or its functionality. label Sep 8, 2023
@SuGlider
Copy link
Collaborator Author

SuGlider commented Sep 8, 2023

Closing it in favor of #8619 -- for rebasing it to master branch

@SuGlider SuGlider closed this Sep 8, 2023
@SuGlider SuGlider deleted the UART_pinSet branch September 8, 2023 21: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

None yet

Development

Successfully merging this pull request may close these issues.

HardwareSerial::setPins does not unset previous pin

2 participants