Skip to content

Commit e6a5b68

Browse files
ewasscherme-no-dev
authored andcommitted
Added argument to HardwareSerial.begin to specify whether the logic levels of the UART rx and tx lines should be inverted (espressif#719)
1 parent cabc4c5 commit e6a5b68

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Diff for: cores/esp32/HardwareSerial.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ HardwareSerial Serial(0);
99

1010
HardwareSerial::HardwareSerial(int uart_nr) : _uart_nr(uart_nr), _uart(NULL) {}
1111

12-
void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, int8_t txPin)
12+
void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, int8_t txPin, bool invert)
1313
{
1414
if(0 > _uart_nr || _uart_nr > 2) {
1515
log_e("Serial number is invalid, please use 0, 1 or 2");
@@ -30,7 +30,7 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in
3030
rxPin = 16;
3131
txPin = 17;
3232
}
33-
_uart = uartBegin(_uart_nr, baud, config, rxPin, txPin, 256, false);
33+
_uart = uartBegin(_uart_nr, baud, config, rxPin, txPin, 256, invert);
3434
}
3535

3636
void HardwareSerial::end()

Diff for: cores/esp32/HardwareSerial.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class HardwareSerial: public Stream
3737
public:
3838
HardwareSerial(int uart_nr);
3939

40-
void begin(unsigned long baud, uint32_t config=SERIAL_8N1, int8_t rxPin=-1, int8_t txPin=-1);
40+
void begin(unsigned long baud, uint32_t config=SERIAL_8N1, int8_t rxPin=-1, int8_t txPin=-1, bool invert=false);
4141
void end();
4242
int available(void);
4343
int peek(void);

0 commit comments

Comments
 (0)