Repository navigation
V2 firmware: pin map and XBee over UART - #117
Merged
Merged
Conversation
Add a V2 build (pio run -e esp32s3_v2, -D SNIPS_BOARD_V2) for the ESP32-S3-MINI-1U board, with its own pin map and the XBee on the optional UART carrier. - pin_assignment.h: V2 map from PCB/v2.x/snips/GPIO_table.md beside the unchanged V1 map. IMU uses V2's mounting table. - XBee transport split: XbeeLink (frame in/out) with XbeeSpi (V1) and XbeeUart (V2) as thin adapters, and the AT/transmit/receive logic moved out of the SPI adapter into the pure, tested XbeeApi. - XbeeFrameReader assembles API frames from the UART byte stream. - XbeeUartSetup gets the carrier's XBee to API mode (AP=1) at 115200 from whatever state it's in (factory transparent 9600, API 9600, or transparent 115200), saving the change with WR. - No carrier: CTS (pulled up) reads high, so the link is skipped and every XBee call fails cleanly. No hardware flow control, so a missing or sleeping module can't block writes. - CI builds both boards. xbee_uart.cpp joins xbee_spi.cpp in the coverage exclusion list as a Serial1 adapter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Firmware for the V2 board (ESP32-S3-MINI-1U), so it's ready when the boards arrive. Build it with
pio run -e esp32s3_v2.pio runstill builds V1.Pin map
include/pin_assignment.hnow has V2's map, copied fromPCB/v2.x/snips/GPIO_table.md, beside the unchanged V1 map. The board is picked at build time with-D SNIPS_BOARD_V2.Serialis native USB, so UART0 is never started on it.XBee transport
XbeeLinkXbeeSpiXbeeUartSerial1at 115200, API mode (AP=1)XbeeApiXbeeFrameReaderXbeeUartSetupSetup: a factory XBee 3 is in transparent mode (AP=0) at 9600.
XbeeUartSetuptries, in order:BD7,WR,AC+++command mode, thenATAP1,ATBD7,ATWR,ATCNIt saves the result with WR, so the multi-second command-mode path only runs on a module's first boot.
No carrier: a fitted XBee drives CTS low (default D7=1). With no carrier, CTS is pulled up and reads high, so the link is skipped in about 20 ms. Every XBee call then fails cleanly, which the firmware already treats as "no XBee". CTS, DOUT and ON/SLEEP get pull-ups, as
GPIO_table.mdasks. A carrier XBee with CTS turned off (D7=0) would also read as absent.No hardware flow control: traffic is a ~31-byte frame each way every 50 ms, well within 115200 baud and the XBee's buffers. Using flow control would let a missing or sleeping module block every write. Writes are dropped, not blocked, if the UART buffer is ever full.
For you to decide: coverage exclusion
xbee_uart.cppjoinsxbee_spi.cppin the coverage exclusion lists inplatformio.iniandci.yml. It talks toSerial1and can't compile natively. I kept it thin: the setup sequence, frame assembly and API logic are pure and tested, and moving the API logic out ofxbee_spi.cppactually brings code that used to be excluded under coverage. Your notes make exclusion-list changes a deliberate human call, so please confirm you're OK with it.CI and docs
PCB/v2.x/snips/GPIO_table.mdlist the V2 build command.Testing
pio test -e native: 474 tests pass. New:test_xbee_api(AT replies, other frames and IDs, error status, timeout, truncation, transmit and receive) andtest_xbee_uart(frame reader with noise, a 0x7E inside a frame, bad checksum and length, reset; setup from each starting state, no module, and a failed write).pio run -e esp32s3andpio run -e esp32s3_v2: both build. The V2 binary contains the UART carrier code and the V1 binary doesn't.🤖 Generated with Claude Code