1
\$\begingroup\$

I have a project to implement a simple webcam on an STM32F4 dev board. My start point is the STM32 middleware libraries. From these I could build an example project which functions as a USB audio output.

My game plan is as follows:

  1. modify the project so the dev board becomes an audio input (to the HOST, a windows/linux PC)
  2. write a simple routine to make the dev board become an audio tone generator
  3. add code to sample from a microphone to fill the buffer (also addressing need to sync)
  4. add USB interface and endpoints so the board becomes a UVC device
  5. fill a bugger with video data and capture it on the host
  6. capture frames from a camera and use then to fill the buffer

At the moment the board is recognised as a microphone source on the PC - this by changing the descriptors in the middleware header files (I used an example in the USB 1.0 spec as a guide). Device Manager shows it as working correctly and I can select it as an audio source although of course I cannot record from it.

Now I am looking for the place in the code where I need to fill a buffer, but I don't find it. There are some likely looking routines in the middleware but they don't seem to run. I have found what looks like some config handler for EP0 which needs to be implemented, but I am not sure how.

Next I intend to connect the board to a laptop with wireshark and see what transfers are taking place when the dev board is plugged in.

My question is just to ask whether anyone has any useful tips or references on how to get this going. I am making progress but it is slow going. Anything that would help me understand the STM32 middleware and USB configuration process would be helpful.

(I have downloaded another STM32 extension library which claims to support recording, but when I look into the code, some critical routines do not seem to be implemented, so it seems less than helpful.)

\$\endgroup\$
3
  • 1
    \$\begingroup\$ This project is probably not workable; the processor and its resources probably aren't up to it. But even if it were, your question is far too broad to fit here. The only real practical advice that can be given is not to use a microcontroller for this! You should probably just use an off-the-shelf USB camera or video capture device. \$\endgroup\$ Jun 24, 2020 at 2:51
  • 1
    \$\begingroup\$ For halfway decent framerates you might want to consider using a micro with a hardware JPEG codec like something in the STM32F7 range. But aside from that it should be possible to achieve your target on an STM32F4. When you looked at the X-CUBE-USB-AUDIO library, did you open any of the example application projects? Those should be fully functional and shouldn't need too much modification to run on a different 32F4 if you're not using the 446 device. \$\endgroup\$
    – brhans
    Jun 24, 2020 at 11:57
  • \$\begingroup\$ thanks for the advice. In the end we are taking another route, but the info has been useful. \$\endgroup\$
    – danmcb
    Jun 26, 2020 at 7:08

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.