diff --git a/src/rp2040_arduino_platform.cpp b/src/rp2040_arduino_platform.cpp index dd8dfb93..bac3133a 100644 --- a/src/rp2040_arduino_platform.cpp +++ b/src/rp2040_arduino_platform.cpp @@ -70,7 +70,8 @@ RP2040ArduinoPlatform::RP2040ArduinoPlatform() #endif { #ifndef KNX_NO_DEFAULT_UART - knxUartPins(KNX_UART_RX_PIN, KNX_UART_TX_PIN); + _rxPin = KNX_UART_RX_PIN; + _txPin = KNX_UART_TX_PIN; #endif #ifndef USE_RP2040_EEPROM_EMULATION _memoryType = Flash; @@ -86,14 +87,8 @@ RP2040ArduinoPlatform::RP2040ArduinoPlatform( HardwareSerial* s) : ArduinoPlatfo void RP2040ArduinoPlatform::knxUartPins(pin_size_t rxPin, pin_size_t txPin) { - SerialUART* serial = dynamic_cast(_knxSerial); - if(serial) - { - if (rxPin != UART_PIN_NOT_DEFINED) - serial->setRX(rxPin); - if (txPin != UART_PIN_NOT_DEFINED) - serial->setTX(txPin); - } + _rxPin = rxPin; + _txPin = txPin; } void RP2040ArduinoPlatform::setupUart() @@ -101,6 +96,10 @@ void RP2040ArduinoPlatform::setupUart() SerialUART* serial = dynamic_cast(_knxSerial); if(serial) { + if (rxPin != UART_PIN_NOT_DEFINED) + serial->setRX(rxPin); + if (txPin != UART_PIN_NOT_DEFINED) + serial->setTX(txPin); serial->setPollingMode(); } diff --git a/src/rp2040_arduino_platform.h b/src/rp2040_arduino_platform.h index b71b3b4d..b40ac244 100644 --- a/src/rp2040_arduino_platform.h +++ b/src/rp2040_arduino_platform.h @@ -128,6 +128,8 @@ class RP2040ArduinoPlatform : public ArduinoPlatform #endif protected: IPAddress mcastaddr; protected: uint16_t _port; + protected: pin_size_t _rxPin = -1; + protected: pin_size_t _txPin = -1; #endif };