Skip to content

Add optional FrSky SmartPort (S.Port) telemetry#372

Open
robthomson wants to merge 3 commits into
am32-firmware:mainfrom
robthomson:sport
Open

Add optional FrSky SmartPort (S.Port) telemetry#372
robthomson wants to merge 3 commits into
am32-firmware:mainfrom
robthomson:sport

Conversation

@robthomson

Copy link
Copy Markdown

Add optional FrSky SmartPort (S.Port) telemetry

Branch: sportmain

Summary

Adds FrSky S.Port ESC slave telemetry as an optional compile-time feature. When enabled, the ESC responds to S.Port polls from a FrSky/ELRS receiver directly, replacing KISS telemetry on the signal wire. All existing behaviour is unchanged when the flag is not set.

Build with:

make <TARGET> USE_SPORT_TELEMETRY=1

What's included

New files

  • Inc/sport_telemetry.h — protocol constants and public API
  • Inc/telemetry_protocol.h — baud-rate abstraction (57600 vs 115200) used by MCU UART init
  • Src/sport_telemetry.c — S.Port slave state machine, frame builder, and ESC config protocol

Makefile

  • USE_SPORT_TELEMETRY=1 adds -DUSE_SPORT_TELEMETRY to CFLAGS; no effect on any existing build

All MCU serial_telemetry.c files

All changes guarded by #ifdef USE_SPORT_TELEMETRY:

  • GPIO reconfigured to push-pull + pull-down
  • Hardware TX/RX pin inversion (STM32 G0/G4/L4/F4/F0; non-inverting targets emit a #warning — external inverter required)
  • Baud rate switched to 57600
  • USART direction set to RX-only at init; half-duplex switching handled in ISR/DMA callbacks
  • Receive timeout (26 char periods) used to trigger response after poll is received

Mcu/g071/Src/stm32g0xx_it.c

USART1_IRQHandler added (sport only): handles RXNE byte receipt, RTO-triggered DMA transmit, and TC-triggered switchback to RX. DMA CH3 TC/TE handlers extended for sport TX teardown.

Src/main.c

Sport path clears send_telemetry flag without calling KISS functions; KISS info-packet path guarded.

Src/kiss_telemetry.c

aTxBuffer definition and KISS functions wrapped in #ifndef USE_SPORT_TELEMETRY to prevent linker conflict.

Telemetry data sent

Round-robin across 6 slots per poll:

App ID Data
0x0B70 Temperature (°C)
0x0400 Unused
0x0210 Voltage (VFAS)
0x0200 Current
0x0B30 Fuel / mAh consumed
0x0500 eRPM

ESC config protocol

S.Port config sensor (physical ID 0x0D) supports PING / GET / SET / SAVE commands over the same wire. 28 parameters are accessible:

# Parameter Range Notes
1 Motor poles 2–64
2 Reverse direction bool Runtime effect
3 Bidirectional bool Runtime effect
4 Beep volume 0–11
5 PWM frequency 8–144 kHz
6 Max ramp 1–200
7 Minimum duty 0–50
8 Sine start bool
9 Complementary PWM bool
10 Stuck rotor protection bool
11 Startup power 50–150
12 Drag brake 1–10
13 Driving brake 1–10
14 Variable PWM 0–2 0=off, 1=fixed, 2=auto
15 Timing advance 0–30 User range; firmware applies +10 EEPROM offset
16 Motor kV 0–255 Raw byte; actual kV = (value × 40) + 20
17 Brake on stop bool
18 Stall protection bool
19 Low voltage cutoff bool
20 Cell voltage floor 0–100 Raw; mV/cell = (value + 250) × 10
21 RC car reverse bool
22 Hall sensors bool
23 Sine changeover 5–25%
24 Temperature limit 70–255°C 255 = disabled
25 Current limit 0–100 A 0 = disabled
26 Sine power 1–10
27 Input type 0–5 0=Auto, 1=DShot, 2=Servo, 3=Serial, 4=EDT Arm, 5=DroneCAN
28 Auto advance bool

advance_level is exposed as user range 0–30; the firmware transparently applies the +10 EEPROM offset, consistent with the DroneCAN parameter table.

Configuration

An ethos lua app to configure the esc via s.port can be found here

https://github.com/robthomson/am32-ethos-configurator

Tested on

  • SEQURE_HV_G071 (STM32G071, 64KB flash) with FrSky receiver

@robthomson

Copy link
Copy Markdown
Author

In an idea world for this PR; the epprom would have change to allow the protocol to be set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant