Skip to content

Commit be2174b

Browse files
Fix SoftwareSerial/SerialPIO inversion and build (#2423)
SWSerial wasn't even building due to a typo in the header, and SerialPIO needs to set the OE-invert flag after PIO initialization for transmit. Fixes #2419
1 parent 70b2735 commit be2174b

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

cores/rp2040/SerialPIO.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ void SerialPIO::begin(unsigned long baud, uint16_t config) {
201201

202202
digitalWrite(_tx, HIGH);
203203
pinMode(_tx, OUTPUT);
204-
gpio_set_outover(_tx, _invertTX);
205204

206205
pio_tx_program_init(_txPIO, _txSM, off, _tx);
207206
pio_sm_clear_fifos(_txPIO, _txSM); // Remove any existing data
@@ -212,6 +211,7 @@ void SerialPIO::begin(unsigned long baud, uint16_t config) {
212211
pio_sm_exec(_txPIO, _txSM, pio_encode_mov(pio_isr, pio_osr));
213212

214213
// Start running!
214+
gpio_set_outover(_tx, _invertTX);
215215
pio_sm_set_enabled(_txPIO, _txSM, true);
216216
}
217217
if (_rx != NOPIN) {

cores/rp2040/SoftwareSerial.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ class SoftwareSerial : public SerialPIO {
3737
};
3838

3939
void begin(unsigned long baud, uint16_t config) override {
40-
setInvertTX(invert);
41-
setInvertRX(invert);
40+
setInvertTX(_invert);
41+
setInvertRX(_invert);
4242
SerialPIO::begin(baud, config);
4343
}
4444

keywords.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Dir KEYWORD1
1313
File KEYWORD1
1414
timeval KEYWORD1
1515
time_t KEYWORD1
16+
SoftwareSerial KEYWORD1
1617

1718
#######################################
1819
# Methods and Functions (KEYWORD2)

0 commit comments

Comments
 (0)