Skip to content

Commit

Permalink
Fix for RP2040 UART pin handling: Setting of uart pins moved setupUar…
Browse files Browse the repository at this point in the history
…t method.
  • Loading branch information
Michael Geramb committed Dec 31, 2023
1 parent 7215f47 commit 1878370
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/rp2040_arduino_platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -86,21 +87,19 @@ RP2040ArduinoPlatform::RP2040ArduinoPlatform( HardwareSerial* s) : ArduinoPlatfo

void RP2040ArduinoPlatform::knxUartPins(pin_size_t rxPin, pin_size_t txPin)
{
SerialUART* serial = dynamic_cast<SerialUART*>(_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()
{
SerialUART* serial = dynamic_cast<SerialUART*>(_knxSerial);
if(serial)
{
if (_rxPin != UART_PIN_NOT_DEFINED)
serial->setRX(_rxPin);
if (_txPin != UART_PIN_NOT_DEFINED)
serial->setTX(_txPin);
serial->setPollingMode();
}

Expand Down
2 changes: 2 additions & 0 deletions src/rp2040_arduino_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ class RP2040ArduinoPlatform : public ArduinoPlatform
#endif
protected: IPAddress mcastaddr;
protected: uint16_t _port;
protected: pin_size_t _rxPin = UART_PIN_NOT_DEFINED;
protected: pin_size_t _txPin = UART_PIN_NOT_DEFINED;
#endif
};

Expand Down

0 comments on commit 1878370

Please sign in to comment.