From 8a63c315d877c0d89a8e2bb7d80eef923db836c2 Mon Sep 17 00:00:00 2001 From: Michael Geramb Date: Sun, 31 Dec 2023 13:31:51 +0100 Subject: [PATCH] Fix for RP2040 UART pin handling: Setting of uart pins moved setupUart method. --- src/rp2040_arduino_platform.cpp | 17 ++++++++--------- src/rp2040_arduino_platform.h | 2 ++ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/rp2040_arduino_platform.cpp b/src/rp2040_arduino_platform.cpp index dd8dfb93..c8d10423 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..1fa50349 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 = KNX_UART_RX_PIN; + protected: pin_size_t _txPin = KNX_UART_RX_PIN; #endif };