TinyUSB UAC2 2x2 + CDC serial I/O for the Daisy Seed

Hi,
following my previous UAC1 USB input interface from the daisy, I have been experimenting with tinyusb library for a more polished and comprehensive solution. Ended up with a UAC2 48KHz/16bit stereo in and out plus serial in and out. This is based on the tinyusb library with a custom wrapper. As most of my work lately, this is a joint effort from Claude and ChatGPT. It works well as far as I tested it although there is no explicit feedback EP for audio in or out (let me know if you get any noticeable audio drops or if you know how to implement such feedback EP). block size should be 48 samples to fit the 1mS USB frame. Not tested with other block sizes or sample rates.

I stripped the code from my big project so it may not be 100% clean. I will try to make a blank project with just the USB part. I am using BOOT_SRAM option but it should work fine with default Flash.

seed_usb.zip (1.3 MB)

Wow! Thanks for that code!

What is ‘feedback EP’?

I am no USB stack expert, but what I understood is that Feedback End Point (EP) is rate feedback (usually for a speaker) for the source to adapt its packet size. This helps to overcome drift caused by the non-synced clock of the Daisy and the PC. TinyUSB should take care of it for the speaker case with a dedicated EP reporting the actual rate so the PC can adapt. For input mic, there is no feedback. The Daisy sends occasional 47 or 49 samples (instead of the standard 48 packet) to not flood/underrun its buffer. In the daisy case I think there is also drift between the codec clock and the USB frame clock.
Tiny USB has built in solutions for both corrections, but for some reason with speaker EP feedback the USB device does not enumerate properly, and with the mic flow control I still get occasional drops. Nothing major, but still…