Skip to content

🪲Bug: Ibus not working with inverted RX on RP2040 Microcontroller #26

@gandy92

Description

@gandy92

Describe the bug
Using the ibus receiver class with an inverted line connected to a RP2040 mcu only yields 0 for all channels. The reason being that the ibus.setup() routine has architecture dependent code which does not honor the ibus._inverted flag.

A valid workaround is to add the inverting calls to the main sketch:

ibus receiver(&Serial1, SBUS_RX_PIN, SBUS_TX_PIN, true);  // RP2040 requires a TX_PIN so to not hang up the mcu
void setup()
{
  Serial1.setInvertRX(true);
  Serial1.setInvertTX(true);
  receiver.begin();

To Reproduce
I can try to provide an example sketch that demonstrates using the ibus protocol with the rp2040, if this is required.

Additional context
The problematic code can be seen in this line:

serialPort->begin(IBUS_BAUDRATE, SERIAL_8N1);

The issue is resolved by adding two lines with calls to serialPort->setInvertRC() and serialPort->setInvertTX() before serialPort->begin(), changing the code to:

#elif defined(ARDUINO_ARCH_RP2040)
  SerialUART *serialPort = (SerialUART *)_rxPort;
  serialPort->setPinout(_txPin, _rxPin);
  serialPort->setInvertRX(_inverted);
  serialPort->setInvertTX(_inverted);
  serialPort->begin(IBUS_BAUDRATE, SERIAL_8N1);
#else

Metadata

Metadata

Labels

bug 🐛Something isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions