Skip to content

feat: add e-foc-harware support - #205

Open
gabrielfrasantos wants to merge 31 commits into
mainfrom
feature/board-identity-and-status-leds
Open

feat: add e-foc-harware support#205
gabrielfrasantos wants to merge 31 commits into
mainfrom
feature/board-identity-and-status-leds

Conversation

@gabrielfrasantos

Copy link
Copy Markdown
Contributor

Replace the array-based Leds() with three discrete GPIO accessors (OperationalLed, WarningLed, FailureLed), add BoardId() for 3-bit active-low CAN node identification (PK0-2 on TM4C1294XL), and PowerStatus() for the LM5164 open-drain PG signal (PC6).

Add e-foc-hardware motor board definition and reference submodule. EK-TM4C123GXL gains capability flags (hasBoardIdPins=false, hasPowerStatusPin=false) and placeholder LED pins that avoid conflicts with CAN TX (PF3) and hall sensor inputs.

…PlatformFactory

Replace the array-based Leds() with three discrete GPIO accessors
(OperationalLed, WarningLed, FailureLed), add BoardId() for 3-bit
active-low CAN node identification (PK0-2 on TM4C1294XL), and
PowerStatus() for the LM5164 open-drain PG signal (PC6).

Add e-foc-hardware motor board definition and reference submodule.
EK-TM4C123GXL gains capability flags (hasBoardIdPins=false,
hasPowerStatusPin=false) and placeholder LED pins that avoid conflicts
with CAN TX (PF3) and hall sensor inputs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 30, 2026 20:53
EK-TM4C1294XL now targets E-FOC-HARDWARE as its primary motor board.
EK-TM4C1294XL-FRDM added for builds against the FRDM-MC-LVPMSM shield.
Removes the intermediate EK-TM4C1294XL-efoc preset.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@gabrielfrasantos

gabrielfrasantos commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

⚠️MegaLinter analysis: Success with warnings

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ ACTION actionlint 8 0 0 0.24s
✅ CPP clang-format 232 11 0 0 2.41s
✅ DOCKERFILE hadolint 1 0 0 0.1s
✅ JSON jsonlint 14 0 0 0.37s
✅ JSON prettier 14 9 0 0 0.86s
⚠️ MARKDOWN markdownlint 36 4 105 0 3.18s
✅ MARKDOWN markdown-table-formatter 36 11 0 0 0.52s
✅ REPOSITORY betterleaks yes no no 1.2s
✅ REPOSITORY checkov yes no no 29.58s
✅ REPOSITORY git_diff yes no no 0.07s
✅ REPOSITORY grype yes no no 68.22s
✅ REPOSITORY ls-lint yes no no 0.01s
✅ REPOSITORY osv-scanner yes no no 11.24s
✅ REPOSITORY secretlint yes no no 3.65s
✅ REPOSITORY syft yes no no 2.2s
✅ REPOSITORY trivy yes no no 16.89s
✅ REPOSITORY trivy-sbom yes no no 0.27s
✅ REPOSITORY trufflehog yes no no 10.6s
⚠️ SPELL lychee 139 4 0 1.07s
✅ YAML prettier 22 4 0 0 1.03s
✅ YAML v8r 22 0 0 7.99s
✅ YAML yamllint 22 0 0 1.0s

Detailed Issues

⚠️ SPELL / lychee - 4 errors
📝 Summary
---------------------
🔍 Total...........81
🔗 Unique..........43
✅ Successful......63
⏳ Timeouts.........0
🔀 Redirected.......2
👻 Excluded........14
❓ Unknown..........0
🚫 Errors...........4
⛔ Unsupported......4

Errors in .github/agents/orchestrator.agent.md
[ERROR] file://numerical-toolbox/.github/copilot-instructions.md (at 57:33) | File not found. Check if file exists and path is correct

Errors in .github/workflows/static-analysis.yml
[403] https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$ (at 39:21) | Rejected status code: 403 Forbidden

Errors in README.md
[ERROR] file://infra/embedded-infra-lib/README.md (at 234:3) | File not found. Check if file exists and path is correct
[ERROR] file://infra/numerical-toolbox/README.md (at 235:3) | File not found. Check if file exists and path is correct

Hint: Followed 2 redirects. You might want to consider replacing redirecting URLs with the resolved URLs. Use verbose mode (`-v`/`-vv`) to see redirection details.
Hint: You can configure accepted/rejected response codes with `-a` or `--accept`
⚠️ MARKDOWN / markdownlint - 105 errors
.claude/agents/executor.md:8 error MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "You are the executor agent for..."]
.claude/agents/orchestrator.md:8 error MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "You are the orchestrator agent..."]
.claude/agents/planner.md:8 error MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "You are the planner agent for ..."]
.claude/agents/reviewer.md:8 error MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "You are the reviewer agent for..."]
.claude/agents/reviewer.md:27 error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
.github/agents/executor.agent.md:11 error MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "You are the executor agent for..."]
.github/agents/orchestrator.agent.md:18 error MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "You are the orchestrator agent..."]
.github/agents/orchestrator.agent.md:26:401 error MD013/line-length Line length [Expected: 400; Actual: 482]
.github/agents/planner.agent.md:11 error MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "You are the planner agent for ..."]
.github/agents/planner.agent.md:102:401 error MD013/line-length Line length [Expected: 400; Actual: 441]
.github/agents/planner.agent.md:134:401 error MD013/line-length Line length [Expected: 400; Actual: 418]
.github/agents/reviewer.agent.md:14 error MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "You are the reviewer agent for..."]
.github/instructions/foc-cpp.instructions.md:82:401 error MD013/line-length Line length [Expected: 400; Actual: 455]
.github/prompts/orchestrate.prompt.md:8:401 error MD013/line-length Line length [Expected: 400; Actual: 559]
.github/prompts/orchestrate.prompt.md:8 error MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "Analyze the following task for..."]
documentation/architecture/system.md:137:401 error MD013/line-length Line length [Expected: 400; Actual: 500]
documentation/architecture/system.md:139:401 error MD013/line-length Line length [Expected: 400; Actual: 500]
documentation/architecture/system.md:140:401 error MD013/line-length Line length [Expected: 400; Actual: 500]
documentation/architecture/system.md:141:401 error MD013/line-length Line length [Expected: 400; Actual: 500]
documentation/architecture/system.md:142:401 error MD013/line-length Line length [Expected: 400; Actual: 500]
documentation/architecture/system.md:143:401 error MD013/line-length Line length [Expected: 400; Actual: 500]
documentation/architecture/system.md:144:401 error MD013/line-length Line length [Expected: 400; Actual: 500]
documentation/architecture/system.md:160:208 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
documentation/architecture/system.md:161:208 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
documentation/architecture/system.md:162:208 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
documentation/architecture/system.md:184:401 error MD013/line-length Line length [Expected: 400; Actual: 539]
documentation/architecture/system.md:213:19 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
documentation/architecture/system.md:213:57 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
documentation/architecture/system.md:214:19 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
documentation/architecture/system.md:214:57 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
documentation/architecture/system.md:236:266 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
documentation/architecture/system.md:334:401 error MD013/line-length Line length [Expected: 400; Actual: 431]
documentation/architecture/system.md:336:401 error MD013/line-length Line length [Expected: 400; Actual: 415]
documentation/architecture/system.md:336:129 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
documentation/architecture/system.md:336:415 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
documentation/architecture/system.md:337:401 error MD013/line-length Line length [Expected: 400; Actual: 431]
documentation/architecture/system.md:338:401 error MD013/line-length Line length [Expected: 400; Actual: 431]
documentation/architecture/system.md:350:401 error MD013/line-length Line length [Expected: 400; Actual: 540]
documentation/architecture/system.md:402:54 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
documentation/architecture/system.md:402:93 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
documentation/architecture/system.md:402:215 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
documentation/design/error-handling.md:44:401 error MD013/line-length Line length [Expected: 400; Actual: 561]
documentation/design/error-handling.md:58:401 error MD013/line-length Line length [Expected: 400; Actual: 505]
documentation/design/foc-position.md:80 error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
documentation/design/foc-position.md:219:224 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
documentation/design/foc-speed.md:82 error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
documentation/design/foc-speed.md:86:401 error MD013/line-length Line length [Expected: 400; Actual: 430]
documentation/design/foc-speed.md:129:32 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
documentation/design/foc-speed.md:129:96 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
documentation/design/foc-speed.md:129:286 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
documentation/design/foc-speed.md:130:32 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
documentation/design/foc-speed.md:130:96 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
documentation/design/foc-speed.md:130:265 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
documentation/design/foc-speed.md:208:153 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
documentation/design/foc-torque.md:157:149 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
documentation/design/foc-transforms.md:58 error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
documentation/design/foc-transforms.md:79 error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
documentation/design/foc-transforms.md:88 error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
documentation/design/foc-transforms.md:99 error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
documentation/design/integration-testing.md:49:401 error MD013/line-length Line length [Expected: 400; Actual: 536]
documentation/design/service-electrical-ident.md:67 error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
documentation/design/service-electrical-ident.md:78 error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
documentation/design/service-electrical-ident.md:86 error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
documentation/design/service-electrical-ident.md:95:401 error MD013/line-length Line length [Expected: 400; Actual: 563]
documentation/design/service-electrical-ident.md:103:401 error MD013/line-length Line length [Expected: 400; Actual: 476]
documentation/design/service-electrical-ident.md:130:401 error MD013/line-length Line length [Expected: 400; Actual: 441]
documentation/design/service-electrical-ident.md:132:401 error MD013/line-length Line length [Expected: 400; Actual: 704]
documentation/design/service-electrical-ident.md:146 error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
documentation/design/service-electrical-ident.md:196:401 error MD013/line-length Line length [Expected: 400; Actual: 657]
documentation/design/service-mechanical-ident.md:53 error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
documentation/design/service-mechanical-ident.md:72 error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
documentation/design/service-mechanical-ident.md:84 error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
documentation/design/service-mechanical-ident.md:92 error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
documentation/design/service-mechanical-ident.md:102 error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
documentation/design/service-mechanical-ident.md:108 error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
documentation/design/service-mechanical-ident.md:114 error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
documentation/design/service-mechanical-ident.md:120 error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
documentation/design/service-mechanical-ident.md:126 error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
documentation/design/service-mechanical-ident.md:216:401 error MD013/line-length Line length [Expected: 400; Actual: 500]
documentation/design/state-machine.md:327:226 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
documentation/design/state-machine.md:328:276 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
documentation/design/state-machine.md:343:43 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
documentation/design/state-machine.md:343:127 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
documentation/design/state-machine.md:343:241 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
documentation/design/state-machine.md:344:46 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
documentation/design/state-machine.md:344:134 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
documentation/design/state-machine.md:344:215 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
documentation/templates/requirements.md:8 error MD025/single-title/single-h1 Multiple top-level headings in the same document [Context: "Requirements Specification"]
documentation/theory/alignment.md:200 error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
documentation/theory/alignment.md:212 error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
documentation/theory/foc.md:369 error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
documentation/theory/foc.md:393:80 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
documentation/theory/friction-inertia-estimation.md:237 error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
documentation/theory/resistance-inductance-estimation.md:46:69 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
documentation/theory/resistance-inductance-estimation.md:46:79 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
documentation/theory/resistance-inductance-estimation.md:217 error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
documentation/theory/resistance-inductance-estimation.md:258 error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
documentation/theory/resistance-inductance-estimation.md:281:86 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
documentation/theory/resistance-inductance-estimation.md:282:86 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
documentation/theory/resistance-inductance-estimation.md:284:86 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
documentation/theory/resistance-inductance-estimation.md:286:26 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
documentation/theory/resistance-inductance-estimation.md:287:86 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
README.md:1 error MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "[![Quality Gate Status](https:..."]
README.md:68 error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
README.md:185 error MD024/no-duplicate-heading Multiple headings with the same content [Context: "Architecture"]

Notices

📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining SECURITY_SUGGESTIONS: false)

See detailed reports in MegaLinter artifacts

Your project could benefit from a custom flavor, which would allow you to run only the linters you need, and thus improve runtime performances. (Skip this info by defining FLAVOR_SUGGESTIONS: false)

  • Documentation: Custom Flavors
  • Command: npx mega-linter-runner@9.6.0 --custom-flavor-setup --custom-flavor-linters ACTION_ACTIONLINT,CPP_CLANG_FORMAT,DOCKERFILE_HADOLINT,JSON_JSONLINT,JSON_PRETTIER,MARKDOWN_MARKDOWNLINT,MARKDOWN_MARKDOWN_TABLE_FORMATTER,REPOSITORY_CHECKOV,REPOSITORY_GIT_DIFF,REPOSITORY_BETTERLEAKS,REPOSITORY_GRYPE,REPOSITORY_LS_LINT,REPOSITORY_OSV_SCANNER,REPOSITORY_SECRETLINT,REPOSITORY_SYFT,REPOSITORY_TRIVY,REPOSITORY_TRIVY_SBOM,REPOSITORY_TRUFFLEHOG,SPELL_LYCHEE,YAML_PRETTIER,YAML_YAMLLINT,YAML_V8R

MegaLinter is graciously provided by OX Security
Show us your support by starring ⭐ the repository

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the platform abstraction layer (PAL) to support richer board integration by replacing the prior LED array accessor with three explicit status LED GPIO accessors, and by adding optional board-identity and power-good signals. It also introduces an E-FOC-HARDWARE motor board definition and wiring via CMake presets/submodule.

Changes:

  • Replace Leds() with OperationalLed(), WarningLed(), and FailureLed() across targets, platform implementations, and mocks.
  • Add PAL accessors BoardId() const (3-bit active-low) and PowerStatus() const (power-good input), implemented for TI and stubbed for Host/ST.
  • Add E-FOC-HARDWARE motor board characteristics + build preset and register the infra/e-foc-hardware submodule.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
targets/sync_foc_sensored/main/instantiations/Logic.cpp Switch debug LED wiring to OperationalLed()
targets/hardware_test/instantiations/Logic.cpp Switch debug LED wiring to OperationalLed()
core/platform_abstraction/PlatformFactory.hpp PAL API change: three LED accessors + BoardId() + PowerStatus()
documentation/architecture/system.md Document new PAL LEDs / board ID / power status responsibilities
targets/platform_implementations/ti/implementation/PlatformFactoryImpl.hpp Add new PAL method overrides (TI)
targets/platform_implementations/ti/implementation/PlatformFactoryImpl.cpp Implement new LED/BoardId/PowerStatus accessors (TI)
targets/platform_implementations/ti/EK-TM4C1294XL/PinsAndPeripherals.hpp Define discrete LED pins + board-id pins + power-good pin + capability flags
targets/platform_implementations/ti/EK-TM4C123GXL/PinsAndPeripherals.hpp Define discrete LED pins + capability flags disabling board-id/power-good
targets/platform_implementations/st/implementation/PlatformFactoryImpl.hpp Add new PAL method overrides (ST)
targets/platform_implementations/st/implementation/PlatformFactoryImpl.cpp Stub new LED/BoardId/PowerStatus accessors (ST)
targets/platform_implementations/host/implementation/PlatformFactoryImpl.hpp Add new PAL method overrides (Host)
targets/platform_implementations/host/implementation/PlatformFactoryImpl.cpp Stub new LED/BoardId/PowerStatus accessors (Host)
targets/hardware_test/components/test/TestTerminal.cpp Update PlatformFactory mock to new PAL API
integration_tests/software_in_the_loop/support/PlatformFactoryMock.hpp Update PlatformFactory mock to new PAL API
targets/platform_implementations/motor_boards/E-FOC-HARDWARE/CMakeLists.txt Add new motor board interface target + header define
targets/platform_implementations/motor_boards/E-FOC-HARDWARE/BoardCharacteristics.hpp Add E-FOC-HARDWARE analog scaling + thresholds
CMakePresets.json Add EK-TM4C1294XL + E-FOC-HARDWARE build presets
.gitmodules Add infra/e-foc-hardware submodule

Comment thread targets/platform_implementations/ti/EK-TM4C123GXL/PinsAndPeripherals.hpp Outdated
Comment thread documentation/architecture/system.md
@github-actions

github-actions Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

SIL Integration Test Results

  1 files  ±0    1 suites  ±0   0s ⏱️ ±0s
104 tests ±0  104 ✅ ±0  0 💤 ±0  0 ❌ ±0 
107 runs  ±0  107 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 8867f02. ± Comparison against base commit 79c2559.

♻️ This comment has been updated with latest results.

gabrielfrasantos and others added 2 commits July 2, 2026 18:05
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

🏎️ Cycle Analysis Results

Worst case (position) | EK-TM4C1294XL

CPU Utilization Budget

Loop Rate Available Cycles Min Usage Max Usage Status
1 kHz 120000 1806 (1.5%) 2272 (1.9%) 🟢 OK
10 kHz 12000 1806 (15.0%) 2272 (18.9%) 🟢 OK
20 kHz 6000 1806 (30.1%) 2272 (37.9%) 🟢 OK
Click to expand full details

Cycle Estimation Report

Target: EK-TM4C1294XL | Build: RelWithDebInfo | Clock: 120 MHz
Path: ADC ISR → FOC Position (worst case: inner + outer loop + all estimators) → PWM Output

Executive Summary

Metric Value
Estimated Cycles (min) 1806
Estimated Cycles (max) 2272
Total Instructions 1239
Total Code Size 4216 bytes
FPU Operations 309
Path Stages 9

CPU Utilization Budget

Loop Rate Available Cycles Min Usage Max Usage Status
1 kHz 120000 1806 (1.5%) 2272 (1.9%) 🟢 OK
10 kHz 12000 1806 (15.0%) 2272 (18.9%) 🟢 OK
20 kHz 6000 1806 (30.1%) 2272 (37.9%) 🟢 OK

Path Breakdown

  ISR Entry (exception overhead)       █░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░    12–29   cycles (  1.3%)
                                       │
  ADC ISR + Callback Dispatch          ██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░    93–150  cycles (  6.6%)
                                       │
  Encoder Read                         ███░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░   138–182  cycles (  8.0%)
                                       │
  FOC Inner Loop (Calculate)           █░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░     5–8    cycles (  0.4%)
                                       │
  FOC Outer Loop (LowPriorityHandler)  ██████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░   248–344  cycles ( 15.1%)
                                       │
  Online Mechanical Estimator (RLS)    ██████████████░░░░░░░░░░░░░░░░░░░░░░░░░░   726–838  cycles ( 36.9%)
                                       │
  Online Electrical Estimator (RLS)    ███████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░   383–421  cycles ( 18.5%)
                                       │
  PWM Output                           ████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░   189–271  cycles ( 11.9%)
                                       │
  ISR Exit (exception return)          █░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░    12–29   cycles (  1.3%)
Stage Min Cycles Max Cycles Instructions Code Size FPU Ops Functions
ISR Entry (exception overhead) (hw overhead) 12 29 0 0 B 0 0
ADC ISR + Callback Dispatch 93 150 72 196 B 0 6
Encoder Read 138 182 88 292 B 21 5
FOC Inner Loop (Calculate) 5 8 5 12 B 0 1
FOC Outer Loop (LowPriorityHandler) 248 344 173 612 B 49 3
Online Mechanical Estimator (RLS) 726 838 511 1772 B 147 7
Online Electrical Estimator (RLS) 383 421 246 912 B 92 4
PWM Output 189 271 144 420 B 0 7
ISR Exit (exception return) (hw overhead) 12 29 0 0 B 0 0
TOTAL 1806 2272 1239 4216 B 309

Per-Function Detail — FOC Inner Loop (Calculate)

Function Calls Min Cycles Max Cycles FPU Load/Store Branch ALU
foc::FocPositionImpl::Calculate(foc::PhaseCurrents const&, i... 1x 5 8 0 0 1 4

Instruction Mix

  FPU          ████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░  309 ( 24.9%)
  Load/Store   ████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░  509 ( 41.1%)
  Branch       ████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░  114 (  9.2%)
  ALU          ████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░  303 ( 24.5%)
  Mul/Div      ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░    4 (  0.3%)

Optimization Quality Indicators

  • ⚠️ Moderate FPU utilization (25%) — some overhead from non-FPU ops
  • High load/store ratio (41%) — register spilling or poor data locality
  • FMA instructions detected — fused multiply-add in use
  • ⚠️ vsqrt/vdiv detected — 14 cycles each; consider LUT approximations

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

📦 Memory budget (multi-mode)

Unified binary

📦 Memory budget

EK-TM4C1294XL (M4, RelWithDebInfo) — flash 105.85 KiB · static RAM 25.64 KiB · stack 0 B · heap 0 B

Region Used Free Total %
FLASH 105.84 KiB 918.16 KiB 1.00 MiB 10.3%
RAM 25.64 KiB 230.36 KiB 256.00 KiB 10.0%

Top symbols

Show top symbols
# Symbol Section Size Source
1 main::hardware .bss 16.54 KiB
2 main::logic .bss 4.11 KiB
3 foc::detail::sineLUT .data 2.00 KiB
4 __kernel_rem_pio2f .text 1.65 KiB
5 application::PlatformFactoryImpl::Peripherals::Peripherals() .text 1.10 KiB /__w/e-foc/e-foc/targets/platform_implementations/ti/implementation/../../../../targets/platform_implementations/ti/implementation/PlatformFactoryImpl.hpp
6 application::PlatformFactoryImpl::Peripherals::Peripherals() .text 1.10 KiB /__w/e-foc/e-foc/targets/platform_implementations/ti/implementation/../../../../targets/platform_implementations/ti/implementation/PlatformFactoryImpl.hpp
7 application::PlatformFactoryImpl::PlatformFactoryImpl(infra::Function<void (), 8u> const&) .text 1.07 KiB /__w/e-foc/e-foc/targets/platform_implementations/ti/implementation/PlatformFactoryImpl.cpp
8 application::PlatformFactoryImpl::PlatformFactoryImpl(infra::Function<void (), 8u> const&) .text 1.07 KiB /__w/e-foc/e-foc/targets/platform_implementations/ti/implementation/PlatformFactoryImpl.cpp
9 application::Logic::~Logic() .text 1.07 KiB /__w/e-foc/e-foc/targets/platform_implementations/ti/implementation/../../../../targets/sync_foc_sensored/main/instantiations/Logic.hpp
10 application::Logic::~Logic() .text 1.07 KiB /__w/e-foc/e-foc/targets/platform_implementations/ti/implementation/../../../../targets/sync_foc_sensored/main/instantiations/Logic.hpp

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.

Comment thread targets/platform_implementations/ti/implementation/PlatformFactoryImpl.hpp Outdated
Comment thread scripts/install-caveman.sh
gabrielfrasantos and others added 2 commits July 5, 2026 16:54
TM4C123 silicon lacks PWM FLTSRC1 digital comparator routing, making
hardware fault protection impossible on that board. EK-TM4C1294XL is
the only supported TI target going forward.

- Delete EK-TM4C123GXL platform implementation
- Collapse all hasFaultComparators branches in PlatformFactoryImpl to
  the async (fault-comparator) path unconditionally
- Remove SyncPwmConfig, syncPwm optional, and related includes
- Remove syncPwmPhases stubs and hasFaultComparators from EK-TM4C1294XL
- Remove EK-TM4C123GXL from CMake presets and CI build matrices
- Update CLAUDE.md and architecture doc to reflect single supported board

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread .github/workflows/ci.yml
- Host/ST: return distinct operationalPin/warningPin/failurePin stubs
  from OperationalLed(), WarningLed(), FailureLed() so callers
  cannot accidentally observe interference between the three signals
- TI: restore hardware overvoltage protection via DCMP1 — step 4
  (powerSupplyVoltage) is redirected to digital comparator 1 which
  feeds PWM FLTSRC1 bit 1 and tristates all motor PWM outputs
  instantly when the overvoltage threshold is exceeded; also expand
  currentPhaseAnalogPins array from 4 to 5 elements accordingly
- TI: restore SynchronousQuadratureEncoder.hpp include dropped in
  c9485ae (refactor), fixing EK-TM4C1294XL build failure
- scripts/install-caveman.sh: guard Node.js /usr/local extraction
  with an early root check so non-root users get a clear error
…ent ADC

Overvoltage is monitored by AdcForPowerSupplyMeasurementImpl (synchronous
ADC1, sequencer 0) via Pins::powerSupplyVoltage. Adding that pin as step 4
of the phase-current ADC sequencer with a digital comparator was wrong:
  - DCMP1 (Peripheral::OvervoltageComparatorIndex) was not needed there
  - It caused Pins::powerSupplyVoltage to be passed to hal::tiva::AnalogPin
    twice (also in powerSupplyAnalogPins), configuring the GPIO twice

Revert digitalComparators and currentPhaseAnalogPins to 4 entries each
(steps 0–2: phase currents to FIFO; step 3: currentTotal → DCMP0 overcurrent).
GDB 17.1 has debuginfod enabled and MIEngine turns it on at debug start.
The container's default DEBUGINFOD_URLS points at debuginfod.ubuntu.com,
which is unreachable offline, so GDB blocks during shared-library loading
and the debug session stalls (GUI never appears, Pause/Stop do nothing).

Clear GDB's debuginfod URL list via miDebuggerArgs (-iex "set debuginfod urls")
in each cppdbg config, and empty DEBUGINFOD_URLS in the devcontainer containerEnv
as the root-cause fix for all container tooling.
Add list_can_interfaces.py to discover CAN adapters via python-can,
candle_driver, and serial ports, with table/JSON output. Wire a
--list-can (and --json) flag into bridge_server.py, and add unit tests.
Comment thread .vscode/launch.json
Comment thread .vscode/launch.json
Comment thread .vscode/launch.json
Comment thread .vscode/launch.json
Comment thread .vscode/launch.json
…r removal

The board-identity refactor removed PlatformAdapter and switched to the async
hal::tiva::Pwm driver, so the cycle-analysis PWM Output stage matched no
functions and the analysis failed. Update the PWM Output patterns to
PlatformFactoryImpl::ThreePhasePwmOutput and hal::tiva::Pwm::{Start,SetComparator,Sync},
and the Encoder Read pattern to PlatformFactoryImpl::Read. Verified all required
stages match against the RelWithDebInfo ELF.
Replace the verbose fully-qualified hal::Percent (infra::Quantity<...>) triple
signature with a readable Quantity-based wildcard that matches the 3-phase
Start overload using only basic regex (engine-agnostic).
Comment thread targets/sync_foc_sensored/main/cycle-analysis.json
gabrielfrasantos and others added 8 commits July 11, 2026 20:41
…nd integral method

Replace the single-point V/I resistance and 63.2%-threshold inductance
estimation, which baked dead-time, switch-drop and current-sensor offsets
into the result and quantised tau to one sample.

- Resistance: multi-point differential fit (V_j = R*I_ss_j + V_err) via
  numerical LinearRegression; slope is offset-immune, intercept exports the
  inverter voltage error as diagnostic data.
- Inductance: integral method over the probe transient (offset cancels in
  the integrand, sub-sample resolution).
- Auto-scale excitation levels to target current fractions of the drive
  maximum using a coarse pre-probe, with a fit-quality residual gate.
- Apply the Delta winding correction (1.5x) to both R and L.
- Return a single ResistanceInductanceResult struct (R, L, V_err, quality)
  instead of two optionals; propagate the new callback through the state
  machine, SIL fixtures, simulator wiring and mocks.
- Remove the redundant TerminalElectricalParametersIdentification helper.
- Update the theory and integration-testing documentation to match.
…irs in foc

- Add "ident" command to run electrical parameter identification (R, L and
  pole pairs) with an optional winding type and tunable config, storing the
  result for later use.
- Add "align" command that reuses the identified pole pairs and fails fast
  when identification has not been run.
- Make pole pairs a mandatory argument of the "foc" simulation command and
  remove the now-redundant "motor" command.
- Wire the electrical identification and alignment services into the target,
  raise the terminal command capacity, and update the HIL cycle-budget step.
Update voltageToVolts from 18.433 to 21.25 and drop the two bring-up
threshold static_asserts that no longer match the recalibrated scaling.
- Orchestrator: convert to triage advisor (no Agent tool, model→sonnet);
  subagents cannot spawn subagents so routing was broken
- Planner/executor: remove clarifying-questions instructions; subagents
  have no interactive channel — state assumptions and proceed instead
- Planner: add Write tool, write plan to .claude/plans/<task>.md for
  executor handoff; strip duplicated constraints checklist (→ CLAUDE.md ref)
- Executor: strip all constraint sections duplicated from CLAUDE.md; add
  Grep/Glob tools; add plan-file reading step
- Reviewer: model→sonnet; add Grep/Glob; diff-first approach; slim
  15-section checklist to 10 by referencing CLAUDE.md; merge duplicate
  heap/real-time items from §1+§2
- CLAUDE.md: fix Clarke label power-invariant→amplitude-invariant (2/3
  scaling is amplitude-invariant; power-invariant uses √(2/3)); add
  agent workflow note about clarifying before dispatch

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…x current at 3A

Remove the step-3 currentTotal -> DCMP0 overcurrent redirect and the currentTotal ADC channel (4 -> 3 phase channels) while investigating current-measurement bias; the hardware overcurrent trip via the ADC digital comparator is off in this configuration.

Source MaxCurrentSupported() from BoardCharacteristics::maxCurrentAmps instead of a hardcoded 15 A, and lower maxCurrentAmps/overcurrentThresholdAmps from 15/12 A to 3/3 A.
…amp)

Replace the DC-step resistance/inductance estimation, which drove torque into a free rotor and let back-EMF corrupt the result, with high-frequency alpha-axis sinusoidal injection plus synchronous demodulation. Zero-mean AC produces no net torque and the demod rejects the low-frequency back-EMF, so no rotor clamp is needed; R and Ls fall out in one shot from the current amplitude and phase.

- Guards: peak-current abort below MaxCurrentSupported, invalid-frequency and min-current return nullopt, duty clamped to keep the low-side shunt window samplable.
- Compensate the PWM->ADC pipeline lag via voltageToCurrentDelaySamples.
- CLI: ident <wye|delta> [inj_freq_hz] [inj_v%] ...; docs and tests updated.

Pole-pair estimation is unchanged.
Comment thread documentation/theory/resistance-inductance-estimation.md
Comment thread documentation/theory/resistance-inductance-estimation.md

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 68 out of 68 changed files in this pull request and generated 9 comments.

Comment on lines +51 to +55
const auto injectionHz = rlConfig.injectionFrequency.Value();
if (injectionHz == 0 || samplingFrequencyHz % injectionHz != 0)
{
onResistanceAndInductanceDone(std::nullopt);
return;
Comment thread tools/hardware_bridge/server/list_can_interfaces.py
Comment thread .vscode/launch.json
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb",
"miDebuggerArgs": "-iex \"set debuginfod urls\"",
Comment thread .vscode/launch.json
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb",
"miDebuggerArgs": "-iex \"set debuginfod urls\"",
Comment thread .vscode/launch.json
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb",
"miDebuggerArgs": "-iex \"set debuginfod urls\"",
Comment thread .vscode/launch.json
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb",
"miDebuggerArgs": "-iex \"set debuginfod urls\"",
Comment thread .vscode/launch.json
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb",
"miDebuggerArgs": "-iex \"set debuginfod urls\"",
Comment on lines +129 to 133
// Steps 0-2 (phase currents A/B/C) go to the ADC FIFO.
// NOTE: the step-3 currentTotal -> DCMP0 overcurrent redirect is temporarily
// disabled while investigating current-measurement bias — hardware overcurrent
// trip via the ADC digital comparator is OFF in this configuration.

Comment thread .github/workflows/ci.yml
gabrielfrasantos and others added 11 commits July 19, 2026 19:31
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…dent

TerminalMotorAlignment and TerminalMechanicalParametersIdentification were standalone CLI wrappers wired into no target; the application drives the MotorAlignment and MechanicalParametersIdentification services directly. Delete both classes and their unit tests and drop the CMake source/test entries. The underlying services are unchanged.
The prior change disabled the step-3 currentTotal -> DCMP0 overcurrent redirect, leaving the hardware overcurrent protection (ADC -> PWM fault path) off by default, which is unsafe for a motor drive (raised in review).

Restore the digital-comparator config, the currentTotal ADC channel, and the ConfigureAdcAndPwm assignment. Decouple the ADC/comparator full-scale (maxCurrentAmps, 15 A) from the application limit: add ratedCurrentAmps (3 A) returned by MaxCurrentSupported(), and set the overcurrent trip to 12 A (80% of full-scale) so it sits above the rated current with real headroom instead of at ADC saturation.
Comment thread CMakePresets.json
@sonarqubecloud

Copy link
Copy Markdown

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.

2 participants