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

drivers: usb: stm32: add support for incomplete isochronous in transfer #84622

Merged

Conversation

AlgotAxelzon
Copy link

@AlgotAxelzon AlgotAxelzon commented Jan 27, 2025

Currently the write_sem for an endpoint is only given back if the data was actually read by host (and thus calling HAL_PCD_DataInStageCallback wherin the semaphore is given back).

The problem that occurs is when you want to implement an isochronous endpoint that periodically writes data to the endpoint. As isochronous transfers are not supposed to have any guarantee of delivery it should be possible to send data again and again without a host having to read/receive them. With the current design this is not possible.

To solve this problem another HAL callback was implemented in a similar fashion to HAL_PCD_DataInStageCallback. This other callback function is named HAL_PCD_ISOINIncompleteCallback, and as its name suggests it is being called when data in an isochronous in endpoint has not been "delivered". So, in this callback the write semaphore is given back allowing for sequent writes.

Please let me know if you have any input on this!

@zephyrbot zephyrbot added platform: STM32 ST Micro STM32 area: USB Universal Serial Bus labels Jan 27, 2025
Copy link

Hello @AlgotAxelzon, and thank you very much for your first pull request to the Zephyr project!
Our Continuous Integration pipeline will execute a series of checks on your Pull Request commit messages and code, and you are expected to address any failures by updating the PR. Please take a look at our commit message guidelines to find out how to format your commit messages, and at our contribution workflow to understand how to update your Pull Request. If you haven't already, please make sure to review the project's Contributor Expectations and update (by amending and force-pushing the commits) your pull request if necessary.
If you are stuck or need help please join us on Discord and ask your question there. Additionally, you can escalate the review when applicable. 😊

@AlgotAxelzon AlgotAxelzon force-pushed the stm32-usb-isochronous-support branch from e84297a to b406134 Compare January 27, 2025 20:33
@AlgotAxelzon AlgotAxelzon changed the title Implement weak HAL callback for incomplete isochronous IN transfer driver: usb: stm32: add support for incomplete isochronous in transfer Jan 28, 2025
Implement the HAL callback function `HAL_PCD_ISOINIncompleteCallback` in
which the endpoint write semaphore is given back, thus allowing subsequent
writes to the endpoint after an isochronous transfer has been incompleted
(not read by the host).

This approach was chosen because it is similar to what is done in the
already implemented HAL callback `HAL_PCD_DataInStageCallback` which also
gives the write semaphore back but also calls the endpoint callback
function.

The reason for not also calling the endpoint callback function is because I
do not see any appropriate cb_status (`enum usb_dc_ep_cb_status_code`) to
pass. If passing `USB_DC_EP_DATA_IN` is okay even though "In transaction
done on this EP" is not completely true, then this should also be added.

This has been tested by setting up an isochronous endpoint, writing to it,
and verify that `HAL_PCD_DataInStageCallback` is called and subsequent
writes are possible.

Signed-off-by: Algot Axelzon <[email protected]>
@AlgotAxelzon AlgotAxelzon force-pushed the stm32-usb-isochronous-support branch from b406134 to 27b1a62 Compare January 29, 2025 15:57
@AlgotAxelzon AlgotAxelzon changed the title driver: usb: stm32: add support for incomplete isochronous in transfer drivers: usb: stm32: add support for incomplete isochronous in transfer Jan 29, 2025
@AlgotAxelzon
Copy link
Author

Hi, I updated the commit message again. As stated in there I am unsure if the endpoint callback should be called or not.

@kartben kartben merged commit 3fd7f89 into zephyrproject-rtos:main Jan 31, 2025
25 checks passed
Copy link

Hi @AlgotAxelzon!
Congratulations on getting your very first Zephyr pull request merged 🎉🥳. This is a fantastic achievement, and we're thrilled to have you as part of our community!

To celebrate this milestone and showcase your contribution, we'd love to award you the Zephyr Technical Contributor badge. If you're interested, please claim your badge by filling out this form: Claim Your Zephyr Badge.

Thank you for your valuable input, and we look forward to seeing more of your contributions in the future! 🪁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: USB Universal Serial Bus platform: STM32 ST Micro STM32
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants