-
Notifications
You must be signed in to change notification settings - Fork 352
Description
Problem
esp-hal/src/i2s/master.rs has grown to roughly 2.7 kLOC. The single file now mixes configuration objects, clock math, hardware/register plumbing, blocking driver logic, async helpers, and per-chip special cases, which makes the driver hard to navigate, reason about, and review.
Proposed Solution
Reorganize i2s::master as a directory module so each concern lives in its own file while preserving the existing public path, esp_hal::i2s::master. The async submodule keeps the current asynch spelling because async is reserved and downstream code already depends on that name.
esp-hal/src/i2s/master/
├── mod.rs // existing docs + re-exports (replaces master.rs)
├── config.rs // Config/UnitConfig/ConfigError and validation helpers (~460 lines)
├── clock.rs // I2S clock divider math (~100 lines)
├── hardware.rs // “private” hardware abstraction, register access, per-SoC logic (~1,200 lines)
├── driver.rs // Blocking driver types (I2s/I2sTx/I2sRx), DMA plumbing (~500 lines)
└── asynch.rs // Async DMA wrappers and futures (~220 lines)
Benefits
- Maintainability: Focused modules map to clear responsibilities, easing reviews.
- Readability: Developers can jump straight to config, clocks, driver, async, etc.
- Compilation ergonomics: Smaller translation units reduce incremental build churn.
- Extensibility: Leaves headroom for new features without re-inflating a single file.
- No API churn: master/mod.rs re-exports the same items, so downstream crates continue to compile unchanged.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status