feat(epwm): EPWM driver implementation and host unit tests #94

Merged
hoogv merged 1 commit from feat/93-epwm-driver into dev 2026-07-23 15:25:27 +00:00
Owner

Description

Adds hal/mss/epwm/hal_epwm.c/.h — the ePWM (Enhanced Pulse Width Modulator) driver: fixed-frequency, adjustable-duty-cycle waveform generation on the EPWMxA output pin. hal_epwm_init() searches the 8x8 HSPCLKDIV/CLKDIV prescale combination space for a working time-base period, configures Time-Base/Counter-Compare/Action-Qualifier submodules (immediate/non-shadowed mode), hal_epwm_set_duty_cycle() reprograms CMPA, and hal_epwm_start()/hal_epwm_stop() toggle the counter mode. All three ePWM instances supported. Polling-only, no IRQ path — the TRM states the interrupt line is generated entirely by the Event-Trigger submodule, which this driver deliberately doesn't model (documented in hal_epwm.h's top-of-file comment). Self-contained — no cross-module dependency.

Why

Continues the driver-implementation phase started by GPIO (#75/#76), ESM (#77/#78), UART (#79/#80), I2C (#81/#82), SPI (#83/#84), ADCBUF (#85/#86), CBUFF (#87/#88), HWA (#89/#90), and DMM (#91/#92).

Closes #93

Type of Change

  • New feature

Impact Assessment

  • Functional impact: None — self-contained addition alongside the already-landed GPIO/ESM/UART/I2C/SPI/ADCBUF/CBUFF/HWA/DMM drivers.
  • Regulatory impact: None.
  • QMS impact: None.
  • Risk impact: No — existing risk coverage sufficient.

Testing

  • CI pipeline passes (compile, unit tests, integration tests, static analysis)
  • Manually tested: built and ran testing/mss/unit/hal_functionality/test_epwm locally (14 test cases, 103 assertions, all passing) alongside the full existing ctest suite (293/293 passing, no regressions); ran a full MISRA C:2025 pass (0 unsuppressed findings, -DENABLE_EPWM_MODULE added); reformatted and re-verified against the exact clang-format 18.1.3 the CI runner uses; sanity-checked by changing the Action-Qualifier's ZRO event action from SET to CLEAR, confirming the test suite fails (1 test case, 2 assertions), then reverting.
  • No regressions observed in related areas

PR Size

  • XL (> 300 lines) — must split unless exemption declared

Size justification / exemption (if L or XL):

827 raw lines across 9 files, all hand-reviewed (no mechanically-generated content). Not split further — the driver (hal_epwm.c/.h, 470 lines) and its comprehensive Catch2 spec (test_epwm.c, 340 lines, covering the prescale-search math, duty-cycle programming, and start/stop sequencing across all three instances) don't decompose into independently-reviewable sub-PRs, same rationale as prior driver PRs (#78, #80, #82, #84, #86, #88, #90, #92). The remaining files are small CMake/Kconfig/MISRA wiring diffs, also not independently reviewable apart from the driver they enable.

Checklist

  • Commit messages follow type(scope): description convention with Relates to #<issue> footer
  • PR template filled in completely
  • No unverified external binaries introduced (see QMS-GITFLOW-001 Binary Security section)
  • All commits leave the codebase in a compilable, passing-tests state (Commit Integrity Rule)

Summary

  • hal/mss/epwm/hal_epwm.c/.h: ePWM driver (prescale search, Time-Base/Counter-Compare/Action-Qualifier config, duty-cycle update, start/stop) — EPWMxB, Dead-Band, PWM-Chopper, Trip-Zone, Digital-Compare, Event-Trigger, and phase sync all out of scope, documented in the header's top-of-file comment
  • testing/mss/unit/hal_functionality/test_epwm.c (+ CMakeLists.txt): Catch2 functional test suite. No naming collision — no ti_hal_comparison/test_epwm.c exists (no TI CSL header or existing driver to cross-check against).
  • zephyr/Kconfig / zephyr/CMakeLists.txt / hal/util/hal_config_mss.h: HAL_AWR6843_EPWM Kconfig option and ENABLE_EPWM_MODULE bridge, same pattern as every other landed driver
  • tools/misra/run_misra.sh: -DENABLE_EPWM_MODULE added
## Description Adds `hal/mss/epwm/hal_epwm.c`/`.h` — the ePWM (Enhanced Pulse Width Modulator) driver: fixed-frequency, adjustable-duty-cycle waveform generation on the EPWMxA output pin. `hal_epwm_init()` searches the 8x8 HSPCLKDIV/CLKDIV prescale combination space for a working time-base period, configures Time-Base/Counter-Compare/Action-Qualifier submodules (immediate/non-shadowed mode), `hal_epwm_set_duty_cycle()` reprograms CMPA, and `hal_epwm_start()`/`hal_epwm_stop()` toggle the counter mode. All three ePWM instances supported. Polling-only, no IRQ path — the TRM states the interrupt line is generated entirely by the Event-Trigger submodule, which this driver deliberately doesn't model (documented in `hal_epwm.h`'s top-of-file comment). Self-contained — no cross-module dependency. ## Why Continues the driver-implementation phase started by GPIO (#75/#76), ESM (#77/#78), UART (#79/#80), I2C (#81/#82), SPI (#83/#84), ADCBUF (#85/#86), CBUFF (#87/#88), HWA (#89/#90), and DMM (#91/#92). ## Related Issue Closes #93 ## Type of Change - [x] New feature ## Impact Assessment - **Functional impact:** None — self-contained addition alongside the already-landed GPIO/ESM/UART/I2C/SPI/ADCBUF/CBUFF/HWA/DMM drivers. - **Regulatory impact:** None. - **QMS impact:** None. - **Risk impact:** No — existing risk coverage sufficient. ## Testing - [x] CI pipeline passes (compile, unit tests, integration tests, static analysis) - [x] Manually tested: built and ran `testing/mss/unit/hal_functionality/test_epwm` locally (14 test cases, 103 assertions, all passing) alongside the full existing `ctest` suite (293/293 passing, no regressions); ran a full MISRA C:2025 pass (0 unsuppressed findings, `-DENABLE_EPWM_MODULE` added); reformatted and re-verified against the exact clang-format 18.1.3 the CI runner uses; sanity-checked by changing the Action-Qualifier's ZRO event action from `SET` to `CLEAR`, confirming the test suite fails (1 test case, 2 assertions), then reverting. - [x] No regressions observed in related areas ## PR Size - [x] XL (> 300 lines) — must split unless exemption declared **Size justification / exemption (if L or XL):** 827 raw lines across 9 files, all hand-reviewed (no mechanically-generated content). Not split further — the driver (`hal_epwm.c`/`.h`, 470 lines) and its comprehensive Catch2 spec (`test_epwm.c`, 340 lines, covering the prescale-search math, duty-cycle programming, and start/stop sequencing across all three instances) don't decompose into independently-reviewable sub-PRs, same rationale as prior driver PRs (#78, #80, #82, #84, #86, #88, #90, #92). The remaining files are small CMake/Kconfig/MISRA wiring diffs, also not independently reviewable apart from the driver they enable. ## Checklist - [x] Commit messages follow `type(scope): description` convention with `Relates to #<issue>` footer - [x] PR template filled in completely - [x] No unverified external binaries introduced (see QMS-GITFLOW-001 Binary Security section) - [x] All commits leave the codebase in a compilable, passing-tests state (Commit Integrity Rule) ## Summary - `hal/mss/epwm/hal_epwm.c`/`.h`: ePWM driver (prescale search, Time-Base/Counter-Compare/Action-Qualifier config, duty-cycle update, start/stop) — EPWMxB, Dead-Band, PWM-Chopper, Trip-Zone, Digital-Compare, Event-Trigger, and phase sync all out of scope, documented in the header's top-of-file comment - `testing/mss/unit/hal_functionality/test_epwm.c` (+ `CMakeLists.txt`): Catch2 functional test suite. No naming collision — no `ti_hal_comparison/test_epwm.c` exists (no TI CSL header or existing driver to cross-check against). - `zephyr/Kconfig` / `zephyr/CMakeLists.txt` / `hal/util/hal_config_mss.h`: `HAL_AWR6843_EPWM` Kconfig option and `ENABLE_EPWM_MODULE` bridge, same pattern as every other landed driver - `tools/misra/run_misra.sh`: `-DENABLE_EPWM_MODULE` added
feat(epwm): EPWM driver implementation and host unit tests
All checks were successful
lint / clang-format (pull_request) Successful in 10s
lint / misra (pull_request) Successful in 40s
tests / host-tests (pull_request) Successful in 42s
lint / clang-format (push) Successful in 11s
lint / misra (push) Successful in 39s
tests / host-tests (push) Successful in 44s
482258048e
Adds hal/mss/epwm/hal_epwm.c/.h - fixed-frequency, adjustable-duty-
cycle waveform generation on EPWMxA via a prescale-search over the
8x8 HSPCLKDIV/CLKDIV combination space, immediate-mode Time-Base/
Counter-Compare/Action-Qualifier configuration, and start/stop
sequencing. All three instances supported. Polling-only, no IRQ path
- see hal_epwm.h's top-of-file comment.

Relates to #4, relates to #93
hoogv added this to the Development project 2026-07-23 15:37:12 +00:00
hoogv self-assigned this 2026-07-23 15:37:16 +00:00
Sign in to join this conversation.
No reviewers
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
opendutchsolutions.public/hal_awr6843!94
No description provided.