Fixes UART detach. Fixes #3878 (#3894)

* Fixes UART detach.  Fixes #3878

* 0 is not a good holder value for pins!

* 0 is not a good holder value for pins!
This commit is contained in:
lbernstone
2020-09-30 06:04:18 -06:00
committed by GitHub
parent 8b6d020352
commit 80418fadcf
4 changed files with 16 additions and 9 deletions

View File

@ -53,6 +53,8 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in
}
_uart = uartBegin(_uart_nr, baud ? baud : 9600, config, rxPin, txPin, 256, invert);
_tx_pin = txPin;
_rx_pin = rxPin;
if(!baud) {
uartStartDetectBaudrate(_uart);
@ -70,6 +72,8 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in
} else {
log_e("Could not detect baudrate. Serial data at the port must be present within the timeout for detection to be possible");
_uart = NULL;
_tx_pin = 255;
_rx_pin = 255;
}
}
}
@ -84,7 +88,8 @@ void HardwareSerial::end()
if(uartGetDebug() == _uart_nr) {
uartSetDebug(0);
}
uartEnd(_uart);
log_v("pins %d %d",_tx_pin, _rx_pin);
uartEnd(_uart, _tx_pin, _rx_pin);
_uart = 0;
}