Skip to content

feat(dmac): add shared hardware CRC channel support - #398

Open
crabel99 wants to merge 2 commits into
adafruit:masterfrom
crabel99:feature/dmac-crc
Open

crabel99 wants to merge 2 commits into
adafruit:masterfrom
crabel99:feature/dmac-crc

Conversation

@crabel99

@crabel99 crabel99 commented Oct 1, 2026 •

Copy link
Copy Markdown

Expose the SAMD DMAC CRC engine without making consumers program CRC registers or arbitrate shared ownership. The DMA owner retains descriptors, scheduling and completion callbacks.

This PR adds only cores/arduino/DmacCrc.h and .cpp. Channel mode observes an allocated DMA channel. Input mode feeds the same hardware through CRCDATAIN when a transfer uses interrupt-driven bytes, and enables its clock without allocating a DMA channel. Both modes share ownership, reject competing callers, preserve interrupt state, and release after abort without publishing a partial checksum. Persistent owner/source state is two bytes; there is no heap or payload allocation.

CRC-16 and CRC-32 accept explicit seeds. D21, D51 and SAME53/54 register layouts are covered. The module does not append or verify wire trailers; optional Wire integration is in #395.

Validation:

  • Native register/ownership tests cover all three families; the complete Framework test suite passes 43 cases.
  • D21 and E54 hardware passed ten DMA cases covering known answers, 255/256 bytes, linked descriptors, ownership contention, abort and reuse.
  • E54 passed all eight additional hardware-input cases, including CRC16/CRC32 and the 259-byte residue check. Paired D21/E54 dI2C tests verified input-mode CRC32 at full payload capacity.
  • E54 concurrent DMA matched CRC 0x6626D95D while an unrelated channel remained active before and at CRC completion. Both copies completed successfully.
  • Input-mode timing, full-capacity transfers, corrupt/truncated frames and recovery were validated on the physical pair at 100 kHz.

The standalone D21 input-mode CRC16 vector has not been run physically. D21 DMA CRC16 and dI2C input-mode CRC32 have been verified.

Base: upstream master e914db6. The narrow branch contains none of the integration bundle's other changes.

All 12 local Arduino CI configurations pass on exact branch commit 5d6fd59d92e40aba6891a1d7d9b71135c51d47cc, including TinyUSB builds using that branch's own pinned library. Earlier interrupted/overridden-library runs remain recorded separately.

Configure CRC16 or CRC32 for an allocated DMA channel, preserve interrupt state, and release ownership after completion or abort.
crabel99 added a commit to crabel99/SimIOFramework that referenced this pull request Oct 1, 2026
Apply CRC source commit a9e6e44 from adafruit#398. Local 12-board CI matrix, 35 native CTests, and 10 RedBoard DMA hardware checks pass. SAME54 hardware validation remains pending.
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