Spektrum SRXL2 ESC: enable the driver and fix protocol decoding - #2
Open
RobertoD91 wants to merge 4 commits into
Open
Spektrum SRXL2 ESC: enable the driver and fix protocol decoding#2RobertoD91 wants to merge 4 commits into
RobertoD91 wants to merge 4 commits into
Conversation
Drives a Spektrum Smart ESC (Avian/Firma) from a UART TX pad over the single-wire half-duplex SRXL2 bus, replacing PWM and carrying ESC telemetry (RPM, voltage, current, FET temperature) back to the FC. The FC implements the SRXL2 bus-master role (device ID 0x21) following the official SpektrumRC/SRXL2 device state machine: addressed handshake polls every 50ms, reply to the ESC's unprompted requests, final 0xFF broadcast handshake, then 100Hz control frames with a telemetry poll every 10th frame and a 300us half-duplex turnaround guard. Channel values use the Spektrum +/-100% band (0x2AA0..0xD554). Includes: PWM_TYPE_SRXL2 motor protocol (no hardware timer), FUNCTION_SRXL2_ESC serial function (bit 28), USE_SRXL2_ESC gate (>512KB flash targets), esc_sensor integration (vbat_meter_type = ESC), MOTOR REVERSE mode (permanentId 70) driving the ESC reverse channel for reversible ESCs, DEBUG_SRXL2 debug mode, and docs/SRXL2_ESC.md. Bench-validated on MATEKF405SE + Spektrum Smart ESC: handshake completes, motor responds to throttle, ESC answers telemetry polls. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GroYFi23gHDgj43xrTAVaY
RobertoD91
force-pushed
the
claude/esc-spektrum-protocol-check-i5b6jx
branch
from
July 29, 2026 15:38
4d5807c to
b76dc7e
Compare
|
Test firmware build ready — commit 243 targets built. Find your board's
|
The ESC reports electrical RPM; convert to shaft RPM with motor_poles (default 14), matching how DSHOT telemetry is handled. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GroYFi23gHDgj43xrTAVaY
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GroYFi23gHDgj43xrTAVaY
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GroYFi23gHDgj43xrTAVaY
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.
Spektrum SRXL2 Smart ESC support
Drives a Spektrum Smart ESC (Avian/Firma) directly from a UART TX pad over the single-wire half-duplex SRXL2 bus, replacing PWM and carrying ESC telemetry (RPM, voltage, current, FET temperature) back to the FC. The FC implements the SRXL2 bus-master role (device ID 0x21) per the official SpektrumRC/SRXL2 state machine.
Bench-validated on MATEKF405SE + Spektrum Smart ESC: handshake completes, motor responds to throttle, ESC answers telemetry polls.
Full documentation:
docs/SRXL2_ESC.md(wiring, configuration, protocol details,debug_mode = SRXL2reference, development notes).What's included
src/main/drivers/srxl2_esc.c/h: SRXL2 master driver — official handshake sequence (50ms addressed polls → ESC reply → final 0xFF broadcast handshake), 100Hz control frames, telemetry polling every 10th frame, 300µs half-duplex turnaround guard,DEBUG_SRXL2counters.PWM_TYPE_SRXL2motor protocol (no hardware timer),FUNCTION_SRXL2_ESCserial function (bit 28),USE_SRXL2_ESCgate (targets >512KB flash).vbat_meter_type = ESC).Issues found and fixed along the way
SERIAL_BIDIR(open-drain + pull-up, Betaflight-proven).SERIAL_BIDIR_PPfloats the line between frames — reverted.destId 0handshake is a request to answer, not a confirmation; the final0xFFbroadcast is required for the ESC to enter Running.baudSupported = 0: advertising 400k (as the original code did) makes the ESC switch baud on the broadcast handshake and drop off the bus.pwmCompleteMotorUpdateguard) and fork CI (check-pg-versions.sh,log.cVLA folding,osd.cSTATIC_ASSERT float literal on Apple clang).Known limitations / follow-ups
Companion configurator PR: RobertoD91/inav-configurator#5
🤖 Generated with Claude Code
https://claude.ai/code/session_01GroYFi23gHDgj43xrTAVaY