-
Notifications
You must be signed in to change notification settings - Fork 769
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
feat(usb): Prepare embassy-usb
for USB Audio, and add USB Audio Class 1.0 (playback only)
#3212
base: main
Are you sure you want to change the base?
Conversation
Awesome! Do you have a basic usage example to include? |
Thanks! I just fixed formatting. I could add an example for the STM32H7, because I can test that. However, such an example would still be a bit useless without explicit feedback. There will be jumps in the audio due to the rate discrepancies of SAI output and USB input. Measuring the value that has to be provided over the feedback endpoint is hardware dependent. I will try to make something useful. |
I guess I have to do this first, in order to create an example: embassy-rs/stm32-data#509 Maybe some details for the reasoning: |
a66f3fc
to
b4292b7
Compare
embassy-usb
for USB Audioembassy-usb
for USB Audio, and add USB Audio Class 1.0 (playback only)
1190b76
to
42905b2
Compare
42905b2
to
ea748d5
Compare
This should now be ready for review. You can go through the commits one-by-one:
The class is meant to be extended by more "applications" in the future. I implemented only a "speaker" application, where the device receives audio from the host. It has the following features:
Disclaimer: I did not test the example on the STM32F4 platform, because I don't have that hardware. I only tested on my STM32H723, which does not exist as an example platform, and I feel like it makes more sense to use the more common F4. Can someone please test it? For example, print the measured feedback value (in the |
2d75f14
to
90e7292
Compare
90e7292
to
14de351
Compare
ISO endpoint support itself in the USB drivers was split off to #3314. Therefore, this depends on the other PR and does not build without it. |
14de351
to
29de089
Compare
Is this PR still blocked by something? |
No, it should be fine. I am only waiting for review and maybe for someone to restart the build job. I may also rebase it. |
29de089
to
3a1f07e
Compare
Looks great to me! |
@elagil I am trying out your code on my Blackpill (STM32F401 with a PCM5102 DAC without MCLK (I2S3)). I am the feeling that you are using the SOF capture not in the way it was intended. Ideally you can run timer2 in normal mode and use channel 1 as a capture channel. One crucial part is setting the option registers.
This is how I currently have wire it. Other thing I see is that something is flaky. Like issue in USB driver
Index out of bound
BufferOverflow in USB
When it works and I change the volume, then I see the change in the probe-rs output.
I have the feeling that the stm32-usb driver is buggy. I am using embassy commit 8eb80c6 |
Yes, you are right. By just reading the counter value in the interrupt, there will be some error due to delays. Using capture should fix that. I will also enable the missing routing of the trigger input for F4.
That looks like it, unfortunately. Do you have an idea what might cause it? I think I have some F401 board that I can test this on as well. The H7 (that I tested with) and the F4 use the same synopsis OTG driver, but there are some device-specific config-functions. I will have a look at those. Another idea is that there is some issue with the FIFO sizes. |
@vDorst I can reproduce your issues with some custom F401 board that I have. Some configuration values are not received correctly. For example, in
Some investigation will be required. |
@elagil I have no idea what is causes it. I have seen these dmesg items too. I also looked at the USB description.
But I don´t see any strange values |
3a1f07e
to
ba91b32
Compare
Hello,
I implemented a UAC 1.0 device, but this required some extensions and fixes to the implementation of
embassy-usb
.Some changes are taken from or inspired by #2736.
Here is an example of where this is in use (still rough): https://github.com/blus-audio/firmware-rs
The feedback endpoint is not yet in use.
Features:
extra_fields
that can be appended to an endpoint descriptor. This is required for UAC (e.g.bRefresh
andbSynchAddress
fields for UAC1.0)synch
endpoint must follow the audio streaming endpoint, but the descriptor of the latter must contain the endpoint index of the former. So I allocate the endpoints first, then write the descriptors with the information about the endpoints. Find an implementation of that approach here: https://github.com/blus-audio/firmware-rs/blob/main/firmware/src/uac1/mod.rs#L223Fixes: