cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 Cube-based USB Device Microphone in Audio Class streaming to Host PC

maggie
Associate III
Posted on October 10, 2014 at 04:04

Hi,

Ideally, I'd like to have a firmware that has the following support:

  1. Cube-based
  2. Works in STM32F4
  3. Works as a dual-mode USB Device (not Host) in Audio Device Class, where these 2 endpoints are configured:

  • (a) 1 isochronous IN endpoint to handle audio coming from a host PC (to act as speaker)
  • (b) 1 isochronous OUT endpoint to handle audio coming out to a host PC (to act as microphone)

I already have a firmware that satisfies (1), (2) and (3.a) which is described in another

/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https%3a//my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/STM32F4Discovery%20Cube-based%20USB%20Speaker%20application%20not%20working&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=116

, but I'm having problems accomplishing (3.b).

Of course I already checked the ''Audio_playback_and_record'' common among STM32F4 and available in STM32CubeF4 package, however, the recording part there is configured as USB Host, not to mention that the USB Class is Mass Storage Class, not Audio Device Class.

I can see related post

/public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=https%3a//my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/USB%20Audio%20Device%20with%20I2S%20microphone&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F&currentviews=2355

, but no conclusive answers (there was one saying he was able to do it but no details as to how were posted).

At this

/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https%3a//my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/STM32F4Discovery%20Cube-based%20USB%20Speaker%20application%20not%20working&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=116

post, I was informed by someone from the Cube team that there isn't such a program yet for USB Device microphone where audio is configured to go to host PC (as of September 2014).

However,

/public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=https%3a//my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/USB%20Audio%20Device%20with%20I2S%20microphone&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F&currentviews=2355

post I mentioned reached almost 2400 views, so that only means many people are searching for the same topic and still searching answers up until now (no other posts have more info aside from this one)...

So I created this post.

Anyone who can provide reference for us to allow STM32F4 to support ''USB Device microphone where audio is configured to go to host PC''?

Any reference that could give us a jump start would do - then we can keep this thread rolling.

BTW, I have STM32F4-Discovery with STM32F407VGx on hand.

Since it has on-board CS43L22 DAC, a MP45DT02 MEMS microphone, DAC OUT for earphones, and of course USB Device mode port - it's the perfect device I can use for evaluation.

Thanks in advance to those who can contribute to this post.

Regards,

Maj

#stm32cubef4-usb-microphone-audio
11 REPLIES 11

Any suggestion how to use the expansion package for the same?

WFila.1
Associate

@SKris.1616​ , the expansion package is not what you think. The way I understand it, it is not intended to enrich the CubeMX GUI with new features adding mic usb profile or similar, it is only a handwritten example that you can take and adapt.

I tried to do the same as what is suggested in this thread, and I have to admit that it is not a trivial thing. The expansion example has a rewritten USB class middleware, so not easy to cut the middleware only, the whole example has to be ported. Also, of course CubeMX IDE does not allow to change the target, so a new example has to be re created if the target is different. Also if you do not want to run it on the exact same example board, the BSP has to be re-written and cut out of all dependencies.

What I learned from my investigation is that USB is not something like a serial port application that you can easily port, multiple API levels have to be edited depending on the needs. And especially if connection with DMA is required, then you'd have to touch the metal to do that.

I initiated a github repo where I added a flow diagram analyzing the USB stack in different examples.

My goal is similar to this thread, the first step I had as a goal when starting with an STM audio device is to create a loopback device, inject something into the STM from a host PC and then get it back, that is the basis of testing and tooling to check if what is happening in the STM is really what we intend to do. I also would like to use the black pill (STM32F411) otherwise as a fallback an STM32F407, but in both cases a custom board and not an existing discovery demo.

This is going to be long and difficult especially if I only work on this as a hobby in my free time, if someone wants to help to achieve this together, feel free to get in touch with me :

https://github.com/STM32Libs/black_pill_audio