USB classes, composite devices, can I? - Page 1
Forum section: electronics / general

author: CJay
author_rank: Super Contributor
timestamp: February 21, 2021, 02:28:48 pm
content: The inner workings of USB is a bit of a 'black box' to me, I know the basic details of classes, I've never really needed to understand the deep dark secrets as I've always left the 'stack' side of it to the authors and just implemented the 'function' bit *Now I've an idea which would need me to dig a little deeper and implement what's essentially a USB Sound card and UART in one package.First question, I assume from some light reading that a composite device with 'mixed' classes possible, I don't see why it wouldn't be but would like the benefit of advice from someone more experienced to confirm or reject so I'm not spending days chasing a unicorn?Second question can anyone recommend a reference resource (or even an example application) that's not going to take me months of study and a small mortgage to get my head round or am I just dreaming of unicorns again?It doesn't have to be specific to any one manufacturer but ARM C code would be nice to have as well?* USB HID device which 'performed' configuration tasks on freshly built PCs when plugged in, nice gadget which amused me.* USB UART interface for GPS* modified version of Brian Schmalz's Ultimate Bit Whacker* USB LCD display controller* Others

author: SiliconWizard
author_rank: Super Contributor
timestamp: February 21, 2021, 03:44:18 pm
content: Quote from: CJay on February 21, 2021, 02:28:48 pmYes it's absolutely possible. Actually many off-the-shelf usb sound cards do this, for instance those with an extra MIDI interface.Quote from: CJay on February 21, 2021, 02:28:48 pmNot sure what "ARM C code" means. Any USB device implementation (I'm assuming you want to do this on a microcontroller that has an embedded USB device core) will depend on the microcontroller/vendor you choose. STM32 and NXP MCUs are examples of MCUs with which you could implement that, and both have middleware libraries providing all the basic infrastructure to implement an USB device.

author: CJay
author_rank: Super Contributor
timestamp: February 21, 2021, 06:29:58 pm
content: Quote from: SiliconWizard on February 21, 2021, 03:44:18 pmYes, kind of realise it's a bit of a nonsense request and I'm not sure what I was thinking there when I said ARM C, I was meaning I wanted something like the TinyUSB tusb_config.h file or similar that had been set up as a composite device to give me an idea of how it might work.

author: ataradov
author_rank: Super Contributor
timestamp: February 21, 2021, 07:13:02 pm
content: Quote from: CJay on February 21, 2021, 06:29:58 pmIf you just want to see a descriptor of a composite device, then here is a HID + VCPhttps://github.com/ataradov/free-dap/blob/master/platform/samd11_vcp/usb_descriptors.c

author: SiliconWizard
author_rank: Super Contributor
timestamp: February 21, 2021, 08:01:20 pm
content: Well, you can have a look at one of the libraries available for some of the MCUs supporting USB.For instance:https://github.com/STMicroelectronics/stm32_mw_usb_device

author: newbrain
author_rank: Super Contributor
timestamp: February 21, 2021, 08:43:26 pm
content: For a general overview on how the descriptors in USB work, including providing more than one interface, have a lookhere.The site has a good introduction to the USB complexities.For tinyusb config files with two interfaces,thisandthisare an example, one CDC (UART) and one vendor specific HID.

author: CJay
author_rank: Super Contributor
timestamp: February 21, 2021, 09:48:24 pm
content: Brilliant, thank you, SiliconWizard, atadorov, newbrain, what look at a glance like some good references to be reading.

author: rstofer
author_rank: Super Contributor
timestamp: February 24, 2021, 03:43:01 am
content: I notice that the Teensy 4.1 has USB Host and USB Device capabilities. I haven't followed along but some years back, I used an earlier Teensy with 'rawhid' to interface knobs, switches and dials to Microsoft Flight Simulator. It seems the 4.1 version device has Flight Simulator device built in.https://www.pjrc.com/store/teensy41.html

author: rstofer
author_rank: Super Contributor
timestamp: February 24, 2021, 03:45:37 am
content: It's a few years old at this point but "USB Complete, 5th Edition" may be useful.https://www.amazon.com/USB-Complete-Developers-Guide-Guides/dp/1931448280

author: CJay
author_rank: Super Contributor
timestamp: February 24, 2021, 10:06:45 am
content: Thanks Rstofer, I was aware of Jan's other books and had bought Parallel port Complete in the dim, distant past when PIC programmers were home made.Completely forgot she'd written a USB one as well, it may be more than I need as it seems there may be a realtively simple way to get to my objective but I'll order a copy anyway as it seems I may need to learn more for future projects.

author: SiliconWizard
author_rank: Super Contributor
timestamp: February 24, 2021, 03:00:35 pm
content: Quote from: rstofer on February 24, 2021, 03:43:01 amYes. I have bought one and have managed to implement a USB device in "no time" using NXP's SDK (it comes with a lot of examples.) Not tried USB host yet. (Well the longest part was to properly design my own build environment, as I'm not using CMake which NXP uses for their SDK and examples.) Now if you're OK with CMake, it should really be straightforward.Note that this is quite a complex chip though, so understanding how XIP works (running code in external flash), how the IO MUX works, how all the internal clocking works, all that takes a while.

author: CJay
author_rank: Super Contributor
timestamp: February 24, 2021, 05:21:58 pm
content: As it happens, I've had a Teensy 3.6 looking for an application for ages so I dug it out, I'd ordered up one of the SGTL5000 audio boards to use with a Pi Pico, I've just tested it with the Teensy and got a USB sound card up and running in about 20 minutes.Need to see if I can implement a USB-UART on the same board, if I can it might do all I need and save the Teensy from being lost in a cupboard until it's worthless.I still want to try running up a Pi Pico as a composite device though.