Skip to content

Enable PCNT on ESP32-S31, rework API - #6191

Draft
bugadani wants to merge 3 commits into
esp-rs:mainfrom
bugadani:pcnt
Draft

Enable PCNT on ESP32-S31, rework API#6191
bugadani wants to merge 3 commits into
esp-rs:mainfrom
bugadani:pcnt

Conversation

@bugadani

@bugadani bugadani commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

PCNT now follows the one channel - one singleton pattern. There is no common setup, just a bit of mutexing because of some shared register.

Changelog

esp-hal

  • Added: PCNT support for ESP32-S31
  • Changed: PCNT units are constructed from PCNTn_UNITm singletons instead of a Pcnt driver.

Migration guide

esp-hal/PCNT driver

Construct units from singletons

Pcnt::new and the unit0unitN fields are gone. Build a Unit from a PCNTn_UNITm singleton (PCNT is block 0). Unit no longer has a unit-index type parameter.

-let pcnt = Pcnt::new(peripherals.PCNT);
-let mut unit0 = pcnt.unit0;
+let mut unit0 = Unit::new(peripherals.PCNT0_UNIT0);

On ESP32-S31, PCNT1_UNIT0...PCNT1_UNIT3 is also available.

Register interrupt handlers on the unit (unit0.set_interrupt_handler(...)). The hardware still has one IRQ per register block; the driver dispatches to the unit whose status bit is set.

bugadani and others added 3 commits August 24, 2026 14:55
Co-authored-by: Cursor <cursoragent@cursor.com>
@bugadani

Copy link
Copy Markdown
Contributor Author

/hil full

@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown

Triggered full HIL run for #6191.

Run: https://github.com/esp-rs/esp-hal/actions/runs/32751192791

Status update: HIL (full) run is still in progress or status unknown.

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.

1 participant