Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix STM32H5 UCPD reception #3811

Merged
merged 1 commit into from
Jan 26, 2025
Merged

Conversation

elagil
Copy link
Contributor

@elagil elagil commented Jan 26, 2025

On STM32H5 (with GPDMA), I saw some USB PD reception appearing to be empty, when packets were arriving quickly back-to-back.

When calling receive on the UCPD driver, you would usually provide a buffer big enough to cover the biggest standard packet type (e.g. 30 byte). The DMA will store data in the buffer, until its number of transfers are reached, even if this means handling multiple UCPD requests.

It turns out that the DMA got two requests from the UCPD peripheral during one receive operation and advanced the memory pointer by itself. The UCPD driver did not stop the DMA after receiving a full message. Multiple messages ended up in the same buffer, concatenated.

This PR stops the DMA after receiving a packet, or a hard reset.

Tested with https://github.com/elagil/usbpd/tree/main/examples/embassy-nucleo-h563zi

Copy link
Member

@Dirbaio Dirbaio left a comment

Choose a reason for hiding this comment

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

thanks!

@Dirbaio Dirbaio added this pull request to the merge queue Jan 26, 2025
Merged via the queue into embassy-rs:main with commit 3064318 Jan 26, 2025
10 checks passed
@elagil elagil deleted the fix_stm32h5_ucpd branch January 26, 2025 20:25
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