2018-06-08 08:43 AM
2018-06-10 01:54 AM
I don't have a simple answer, just some related more or less entertaining
http://www.mikrozone.sk/pluginy/userjournals_menu/userjournals.php?blog.62
(in Slovak only, sorry - Marek will understand, for others, no sources and similar, I can't publish those, just just a story of how I used the Cube examples as a basis for a quick and dirty proof-of-concept test - well, dirty, for sure, but quick only for those who understand that several days of intensive work may sometimes be seen as quick...)If you want to use what's provided, you'll need to swallow the bitter pill and spend time studying the sources to understand all the relationships.
Or, spend possibly more time to write your own, with the added benefit of full understanding and ownership.
Or, go and purchase some of the ready-made offerings out there.
JW
2018-06-10 09:49 AM
Hello Jan,
and is there any chance to provide source code of your example?
2018-06-10 09:58 AM
Ok so anyone else who should help?
Many thanks
2018-06-10 10:12 AM
No, sorry.
JW
2018-06-10 12:59 PM
Could you please either tell me how and which structures did you extend ?
2018-06-12 03:27 AM
It was more than a year ago so it was not quite simple to dig it up :)
I extended no structure... (I did, but that was just to add an upstream ring buffer to USBD_AUDIO_HandleTypeDef, used then as data source in USBD_AUDIO_DataIn(), see below).
I started from [F4 Cube]\Projects\STM324xG_EVAL\Applications\USB_Device\AUDIO_Standalone\. That implements downstream and I added upstream, cutting the real tie to hardware (I2S DAC) and looping back data. As I've said in the blog, the key moment was to change
&sharpdefine USBD_MAX_NUM_INTERFACES 1
to 2 so that standard setup requests for the other streaming interface won't be ignored by USBD_StdItfReq(). Normally, this should be also reflected by duplicating the state variables for the second streaming interface - namely alternative number - and correctly handle it per interface in USBD_AUDIO_Setup() for USB_REQ_SET_INTERFACE - but as I've said, this was quick and dirty just to keep the host happy, with no requirements for correct functionality on the device side.
The other key change was to get the ISO data streaming up. There is already an upstream data handler in usbd_audio.c, USBD_AUDIO_DataIn(), so I just inserted some USBD_LL_Transmit() into it to prepare the next chunk of data to be sent up.
These, together with the changed descriptor, roughly made the thing.
There was a long way to the real stuff, though. Here, for example, the class-specific get/set requests (to set mute, volume etc.) were simply neglected - as I explained in the blog, I kept the host happy by disabling all features except mute - mute is already handled for downstream and ignoring the interface number the same handling worked for upstream, too - this is not correct but hosts luckily don't care that the two are 'mixed together'. Also, setting alternatives should involve deep changes in hardware (bitrate, word width, nr of channels), and that also means different packet sizes for the ISO streams. I kept it simple stupid by having only one alternative in the desriptors. But I did not care to fix these things as the real stuff was to be implemented from scratch anyway.
JW