Add PM5 CEP transport for Flipper Zero (WITH_CEP)

Wire up the previously-dead Flipper Zero handshake/SPI code from
at32_unit_test.c into a real WITH_CEP platform extra, independent of
BWM (new g_reply_via_cep flag, not reusing BWM's g_reply_via_fpc, so
both transports can run concurrently).

Fixes a real reconnect bug found during hardware bring-up: the
handshake listener was gated on a CC-controller attach edge that
didn't reliably fire on every FAP relaunch, requiring a physical
cable replug to reconnect. Now watches for a fresh incoming byte any
time the link reports attached, with a bounded receive timeout so a
stray byte can never hang the main loop.

RF/FPGA-dependent functionality (hf/lf reads) is out of scope here -
tracked separately. Closes #3667.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Tom HarknessandClaude Sonnet 5 committed 2026-09-26 09:45:51 -04:00
1 parent fc024c8038
commit 2b5e3e51eb
9 files changed
+573 -21

No files matched your search

+11
View File
@@ -50,6 +50,8 @@ Known definitions:
+--------------------------------------------+
| BWM | PM5 Battery Wireless Mod |
+--------------------------------------------+
| CEP | PM5 Flipper Zero (CEP) |
+--------------------------------------------+
| NO_LOWBATT_BEEP | PM5 disable low-batt beep|
+--------------------------------------------+
|NO_LOWBATT_SHUTDOWN| PM5 no low-batt cutoff |
@@ -227,6 +229,15 @@ ifneq (,$(findstring BWM,$(PLATFORM_EXTRAS_TMP)))
PLATFORM_DEFS += -DWITH_BWM_FORWARD -DWITH_BWM_STATUS -DWITH_PM5_PWR_LED -DWITH_PM5_AUTOOFF -DWITH_BWM_LOWBATT_BEEP -DWITH_PM5_LOWBATT_SHUTDOWN
PLATFORM_EXTRAS_TMP := $(strip $(filter-out BWM,$(PLATFORM_EXTRAS_TMP)))
endif
# Flipper Zero over the Type-C extended port (CEP). Independent of BWM - both
# may be enabled together (unlike e.g. BTADDON/FPC_USART_DEV above).
ifneq (,$(findstring CEP,$(PLATFORM_EXTRAS_TMP)))
ifneq ($(PLATFORM),PM5)
$(error PLATFORM_EXTRAS token CEP is only valid on PLATFORM=PM5)
endif
PLATFORM_DEFS += -DWITH_CEP
PLATFORM_EXTRAS_TMP := $(strip $(filter-out CEP,$(PLATFORM_EXTRAS_TMP)))
endif
ifneq (,$(findstring NO_LOWBATT_SHUTDOWN,$(PLATFORM_EXTRAS_TMP)))
ifneq ($(PLATFORM),PM5)
$(error PLATFORM_EXTRAS token NO_LOWBATT_SHUTDOWN is only valid on PLATFORM=PM5)