Add companion_radio_serial env for XIAO nRF52840 🤖🤖 - #3191
Open
jpmartineau wants to merge 1 commit into
Open
Conversation
The SERIAL_RX/SERIAL_TX companion interface only builds on ESP32 and RP2040: it declares HardwareSerial companion_serial(1) and calls setPins(), neither of which exists on the Adafruit nRF52 core, where HardwareSerial is abstract and Serial1 is the concrete Uart instance. Use Serial1 there. Uart::setPins(pin_rx, pin_tx) takes the same arguments in the same order, so the call site is unchanged. The new env also has to move I2C. variants/xiao_nrf52 maps PIN_WIRE_SCL and PIN_WIRE_SDA onto D6/D7, and both XiaoNrf52Board::begin() and sensors.begin() call Wire on them, so the TWIM peripheral takes the pads back after setup() and the UART goes quiet with no other symptom. The env unsets those two defines and points I2C at the internal IMU pins instead. Nothing outside the new env changes. Tested on a XIAO nRF52840 with a Wio-SX1262, wired D6/D7 to a Luckfox Lyra's UART1 and talking to a terminal client over /dev/ttyS1.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The XIAO nRF52840 leaves D6/D7 free once the Wio-SX1262 has taken the SPI pins, so it can carry the companion protocol on a hardware UART exactly like
Xiao_S3_WIO_companion_radio_serialalready does on the ESP32-S3 side. Two things were in the way.HardwareSerial. The
SERIAL_RXblock declaresHardwareSerial companion_serial(1)and callssetPins()on it. The Adafruit nRF52 core has no numbered constructor andHardwareSerialis abstract there, so the env doesn't compile:Serial1is the concreteUartinstance the core always defines on the nRF52840, andUart::setPins(pin_rx, pin_tx)takes the same two arguments in the same order as the ESP32 method, so a reference to it leaves the call site untouched.I2C is mapped onto the same two pins.
variants/xiao_nrf52setsPIN_WIRE_SCL=D6andPIN_WIRE_SDA=D7, and bothXiaoNrf52Board::begin()andsensors.begin()callWireon them.sensors.begin()runs aftersetup()has configured the UART, so TWIM takes the pads back as open-drain I2C and the link goes quiet with correct wiring and nothing logged anywhere — it took me a while to find. The new env unsets those two defines and points I2C at the internal IMU pins (16/17), which is where the variant header suggests they belong.That remap is scoped to the new env with
build_unflagsrather than changed in the shared[Xiao_nrf52]flags, so the ble, usb, repeater, room server and kiss modem builds are unaffected. Nothing outside the new env changes.Tested on a XIAO nRF52840 with a Wio-SX1262, D6/D7 wired to a Luckfox Lyra's UART1 (crossed, common ground, powered from 3V3). The node has been up on the mesh since I flashed it and answers a companion client on
/dev/ttyS1at 115200 — self info, contacts, config reads and writes, clock sync.I also built
Xiao_nrf52_companion_radio_usbandXiao_S3_WIO_companion_radio_serialto check both sides of the new#if; neither regressed.Context: I need this to use my Seeed nRF52840 in my Clockwork PicoCalc, using GPIO.