improve Serial repeated begin/baud change

This commit is contained in:
me-no-dev 2017-08-02 00:32:42 +03:00
parent 4495659ac5
commit a1bef8b5c3
2 changed files with 5 additions and 0 deletions

View File

@ -11,6 +11,9 @@ HardwareSerial::HardwareSerial(int uart_nr) : _uart_nr(uart_nr), _uart(NULL) {}
void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, int8_t txPin) void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, int8_t txPin)
{ {
if(_uart) {
end();
}
if(_uart_nr == 0 && rxPin < 0 && txPin < 0) { if(_uart_nr == 0 && rxPin < 0 && txPin < 0) {
rxPin = 3; rxPin = 3;
txPin = 1; txPin = 1;

View File

@ -223,6 +223,8 @@ void uartEnd(uart_t* uart)
UART_MUTEX_LOCK(); UART_MUTEX_LOCK();
if(uart->queue != NULL) { if(uart->queue != NULL) {
uint8_t c;
while(xQueueReceive(uart->queue, &c, 0));
vQueueDelete(uart->queue); vQueueDelete(uart->queue);
} }