I2S MASTER with USB AUDIO

Discussions about USB Audio on XMOS devices
lmariotti
Member++
Posts: 30
Joined: Mon Nov 21, 2022 5:38 pm

I2S MASTER with USB AUDIO

Post by lmariotti »

Hello everyone,

So far I have managed to integrate the USB audio library into my custom hardware and it works fine.
Now I need to add an ADC to the board as fallback when there is no USB connected, the MCU should act as I2S MASTER using the same I2S line shared with the USB.

My question is: can the I2S line controlled by the USB be controlled ‘manually’ when the USB is not connected? If yes, is there any documentation or example on this?

Thank you all.
User avatar
fabriceo
XCore Addict
Posts: 246
Joined: Mon Jan 08, 2018 4:14 pm

Post by fabriceo »

hi lmariotti
with the USB Software V9.0 you need to consider a solution where you reboot the device in fallback mode with another firmware version in which you disable the USB stack. I m not sure about the detailed configuration but probably the documentation will help. Otherwise you just create an I2S bridge with the I2S library.

My approach with the V6.15.2 was different, I managed to break the link between the Decouple task and the I2S Audiohub task, continuing to run the USB Stack at is expected speed with the feedback endpoint reporting a dummy frequency aligned with the USB Host expectation, while the I2S Audio task was doing some sort of copy paste between the ADC (or spdif receiver) and DAC at its own frequency... this was a lot of effort.

let us know how you handle this please
MaximLiadov
XCore Addict
Posts: 179
Joined: Mon Apr 16, 2018 9:14 am

Post by MaximLiadov »

I also subscribe to this topic. It's a very important scenario. Please, everyone, share any information you've got.

I swear, in my case it was possible without much effort in terms of reworking the code. Just 3 years of R&D. My devices were developed before the modern sample code was released. So I used version 6.15.2 with the modern libraries added and it has no problem working standalone with/without USB connection, no reset or any user action required. No multiple booting. Within the standard I2S procedure, SPDIF and analogue input could be routed to analogue output. Just used a hardware ASRC IC for SPDIF input. USB, SPDIF and ADC could be played in the mix simultaneously or separately. A custom mixer with a limiter was used. Everything works fine. My device has 4 channels 32 bit 384 kHz, XCORE freq 480/5x96 MHz. Doesn't matter. In any case, it is definitely possible.
lmariotti
Member++
Posts: 30
Joined: Mon Nov 21, 2022 5:38 pm

Post by lmariotti »

Hello everyone,

thanks for your reply. This seems to be not an easy task at all (not for me at least).
Maybe the easiest way is to add an additional I2S line dedicated to the ADC and some switches for the DAC I2S INPUT to select I2S USB or I2S ADC.
With this configuration maybe and can add a task dedicated to I2S ADC and keep all the USB core unchanged.
MaximLiadov
XCore Addict
Posts: 179
Joined: Mon Apr 16, 2018 9:14 am

Post by MaximLiadov »

If it's not classified, which version of the sample code and model of MCU are you using?
lmariotti
Member++
Posts: 30
Joined: Mon Nov 21, 2022 5:38 pm

Post by lmariotti »

Hi MaximLiadov,

I've selected XU316-1024-QF60B-C32 as MCU.
Regarding usb lib I was thinking of using the most recent release v9.0.0 but we don't really have any requests for it, for the old board we used the previous release v8.1.0