Skip to content

feat: skip redundant DAC data writes via shadow registers - #27

Merged
chmanie merged 1 commit into
mainfrom
feat/dac-data-shadow
Jul 14, 2026
Merged

feat: skip redundant DAC data writes via shadow registers#27
chmanie merged 1 commit into
mainfrom
feat/dac-data-shadow

Conversation

@chmanie

@chmanie chmanie commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a per-port shadow of the REG_DAC_DATA registers so that writes with an unchanged value skip the SPI transaction entirely, mirroring the existing gpodat shadow pattern for GPOs.

This moves DAC write dedup into the driver where it belongs (motivated by the review of faderpunk PR #556, which had implemented it firmware-side with a cross-task dirty-flag race). Inside the driver, &mut self serialization makes the dedup race-free by construction, and every consumer of the crate benefits.

Changes

  • New dac_data: [Option<u16>; 20] shadow, initialized to None so the first write always reaches the chip.
  • Single choke point write_dac_data used by all writers of the shared data register: _dac_set_value, _gpo_configure_level, and _gpi_configure_threshold. The shadow is only updated after a successful SPI transfer.
  • Bulk variant write_dac_data_many for Multiport::set_values: skips the transaction when every value matches its shadow.
  • _configure_port invalidates the port's shadow entry, since a mode transition may clobber or reinterpret the data register. The typed into_configured_port/into_mode paths now route through _configure_port so they get the same invalidation.

@chmanie
chmanie merged commit 2271e7e into main Jul 14, 2026
1 check passed
@chmanie
chmanie deleted the feat/dac-data-shadow branch July 14, 2026 21:41
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