Skip to content

esp32c5: expose LEDC gamma RAM peripheral#397

Open
Veanir wants to merge 2 commits intoesp-rs:mainfrom
Veanir:fix/esp32c5-ledc-gamma-ram-pac
Open

esp32c5: expose LEDC gamma RAM peripheral#397
Veanir wants to merge 2 commits intoesp-rs:mainfrom
Veanir:fix/esp32c5-ledc-gamma-ram-pac

Conversation

@Veanir
Copy link
Copy Markdown

@Veanir Veanir commented Feb 11, 2026

Summary

  • keep LEDC_GAMMA_RAM on ESP32-C5 at 0x6000_7400, but model the RAM with hardware structure instead of a flattened array
  • switch SVD patching to CHANNEL%s cluster (dim: 6, dimIncrement: 0x40) with per-channel ENTRY%s registers (dim: 16, dimIncrement: 0x4)
  • regenerate PAC accessors so downstream code can use typed channel(n).entry(m) access rather than manual idx = ch * 16 + range

Verification

  • svdtools patch esp32c5/svd/patches/esp32c5.yaml /tmp/esp32c5-pr-validate.svd
  • in a clean clone: cargo run -p xtask --target x86_64-unknown-linux-gnu -- generate esp32c5
  • downstream E2E check in esp-hal with this generated PAC: xtask run tests esp32c5 --test ledc --toolchain nightly --repeat 3 (all passes)

Comment thread esp32c5/svd/patches/_ledc_gamma_ram.yml Outdated
CH_GAMMA_RANGE%s:
description: LEDC gamma fade configuration RAM entry %s.
addressOffset: 0x0
dim: 96
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.

Where does this 96 come from? The TRM defines a 64 byte memory block, and esp-idf uses it as an array of 16 entries.

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.

Ah, per channel, right?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yep - per channel.
The TRM’s 64-byte block is one channel (16 x 32-bit entries). ESP32-C5 has 6 LEDC channels, so the gamma RAM window is 6 * 16 = 96 entries (0x180 bytes) starting at DR_REG_LEDC_BASE + 0x400.
In the SVD patch I flattened the 2D [channel][range] layout into a single dim array; index = channel * 16 + range. Happy to restructure it into a 6x16 cluster layout if you’d prefer.

Copy link
Copy Markdown
Contributor

@bugadani bugadani Feb 12, 2026

Choose a reason for hiding this comment

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

That might be a good idea, this and this could look considerably better if the PAC looked just a bit more structured.

Add the LEDC_GAMMA_RAM peripheral at 0x60007400 and model all 96 gamma range entries with typed duty fields. This provides PAC-level access needed by esp-hal to configure C5 hardware fades without raw MMIO offsets.
Match the hardware layout (channel[6].entry[16]) so downstream HAL code can use typed channel/range access without manual index math.
@Veanir Veanir force-pushed the fix/esp32c5-ledc-gamma-ram-pac branch from 2a4bc63 to 5a505fa Compare February 12, 2026 18:31
@bugadani
Copy link
Copy Markdown
Contributor

bugadani commented Mar 4, 2026

Companion PR

size: 0x180
usage: "Registers"

LEDC_GAMMA_RAM:
Copy link
Copy Markdown
Contributor

@bugadani bugadani Mar 4, 2026

Choose a reason for hiding this comment

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

This shouldn't be its own peripheral, but a register block under LEDC, I think? Similar to how ECC and the other crypto drivers define their own little memories.

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