-
Notifications
You must be signed in to change notification settings - Fork 328
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
Usb Alternate example #186
Comments
I've not explicited tried alternates like this, but you can have alternate configurations, those are demoed in the gadget-zero tests. If you want to add an alternate setting there too, feel very welcome. https://github.com/libopencm3/libopencm3/blob/master/tests/gadget-zero/usb-gadget0.c#L79 |
Hi karlp, thanks for the reply, ive seen that example. But the nice thing about this 'alternate' method is that one can quickly switch between endpoint-types, atleast according to the theory. But simply registering two |
Hello @VincentGijsen Something like this:
Idea was to store alternative setting in a variable provided by user (pointer) when Consideration: if the pointer is NULL ( Reference: Hope this solves your problem. |
Tip: Usually BULK endpoint containing interface is usually the alternate-setting 0 instead of 1 because BULK endpoint do not require allocation of any bandwidth but INTERRUPT interface require allocation of bandwidth. |
Thanks for the eleborate help/pointers, I'll be sure to give it a try, seems to me you're way more into the USB-stack versed than I am 👍 |
Edit: ok... ignore below! I didn't catch that all endpoinds are defined together in the alt interface, so both INTERRUPT + BULK..., so the descripter denotes 3 endpoints in ALT 1 So i think its now works, turns out, the client-code somehow messed-up the alternate stuff. So to clearify, in order to make a correct example: I now have a devices with a single interface, and two alt's the first bulk, second interrupt. When I then want to do a bulk transfer, I first all and do the bulk tranfser by calling something like But this is done async on the host, and when the application than moves back to 'interrupt' mode, it messes up the transfer if not completed sending all (8k) bytes in background. Somehow in the original code (atmels stack + libusb) , the author only switches to alt_setting (0, 1) a single time, does some Interupt endpoint stuff and than mixes BULK and INTERRUPT traffic without doing any explicit switching alt-modeswhere if I try that, libusb gives an error that the endpoint isn't available the original host code: and the bulk to write chunks of data: https://github.com/Grix/helios_dac/blob/ca9cdeae14800db7389a725aaf7cbd05a3cfc9a9/sdk/HeliosDac.cpp#L363 So my question is; is using two alts interfaces without switching supposed to work (so there is still an issue in my code somehwere) , or is my understanding correct that one needs to swap between modes, given the need to do interrupt or bulk transfers (and the atmel-stack magically works somehow) ? |
Hi,
Ive tried various ways to get USB Alternate function on an interface running. I seem to miss something as some mailing-lists seem to imply this functionality should be working. I guess an example would be most helpful for the user-base of libopencm3.
so far i have usb functionality running with both a BULK and Interrupt endpoint combo, but when i try to register them both on the same interface, and make the bulk interface an alternate, windows doens't like my usbdev anymore.
I'm using an stm32f1 with libusb
so far i have these descriptors:
but setting the **bAlternateSetting = 1 ** doesnt seem to be enough (besides the callbacks for BULK and INTERRUPT).
There is also this function in the doc:
but i'm not sure if and if so, how to use it.
Any thoughs/help on fixing this (and perhaps turning it into a example for all to benefit?)
The text was updated successfully, but these errors were encountered: