Skip to content

Align RF helpers with CANDev API - #4

Merged
seofernando25 merged 1 commit into
fix/rf-serial-command-contractfrom
refactor/candev-compatible-rf-api
Aug 4, 2026
Merged

Align RF helpers with CANDev API#4
seofernando25 merged 1 commit into
fix/rf-serial-command-contractfrom
refactor/candev-compatible-rf-api

Conversation

@seofernando25

Copy link
Copy Markdown
Contributor

Summary

  • align the RF control API with the naming and compact helper structure used in the STM32Beamforming CANDev branch
  • restore familiar names including PhaseStateEnum.h, optimizedPhaseState_e, OPTIMIZED_STATE_n, reverseBits(), MakePSCommand(), pe448spisetup(), and f0480spisetup()
  • add GetOptimizedPhaseState() so the sequential CAN state index is explicitly converted to the calibrated, nonsequential 9-bit enum value before command packing
  • keep MakePSCommand() as a short hardware-focused helper that extracts OPT, reverses the phase and address fields, and forms the 13-bit PE44820 word
  • expose the familiar helpers from PhaseShifter.h and Vga.h
  • update the old RF unit-test examples to use the calibrated enum path and remove misleading readback examples

Preserved behavior

This refactor does not change the verified RF wire protocol from the parent PR:

  • calibrated 2.4 GHz phase mapping remains unchanged
  • PE44820 commands remain 13 bits and use the enum's independent OPT bit
  • F0480 attenuation remains every integer from 0 through 23 dB
  • invalid phase addresses are rejected by the control planner
  • guarded SPI writes, bounded waits, fault propagation, and transmit-only/no-readback semantics remain in place

CANDev style comparison

  • CANDev reverseBits(): 11 lines; this version: 11 lines
  • CANDev MakePSCommand(): 12 lines; this version: 15 lines
  • comments remain adjacent to the bit manipulation and device setup they describe
  • PhaseStateEnum.h contains the named enum values, while the sequential-index mapping stays private to the command implementation

Validation

  • Ruff lint and formatting checks
  • mypy
  • 75 Python tests
  • all native STM32 tests
  • protocol vector and Python/C contract checks
  • STM32 node-1 ARM cross-build
  • Docker + SocketCAN + Renode virtual end-to-end simulation
  • verified emitted phase and VGA SPI commands are unchanged

Dependency

This is a stacked PR based on fix/rf-serial-command-contract. Review and merge the RF serial-contract PR first, then retarget or merge this compatibility refactor.

@seofernando25
seofernando25 requested a review from etarabey August 3, 2026 21:17
@seofernando25

Copy link
Copy Markdown
Contributor Author

Superseded by PR #2. The CANDev-compatible RF helper commit has been fast-forwarded onto fix/rf-serial-command-contract so the protocol, calibrated lookup, and compatibility refactor can be reviewed together.

@seofernando25
seofernando25 merged commit 0a4a5fa into fix/rf-serial-command-contract Aug 4, 2026
5 checks passed
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