AnsweredAssumed Answered

UVC+CDC USB Composite device on STM32F411

Question asked by johnson.seth on Aug 1, 2016
Latest reply on Aug 15, 2016 by johnson.seth
Overall objective: Using this project as a base, add a USB serial port interface (which would replace the DEBUG functionality it has currently).

I have read through multiple posts here regarding composite devices and after about a day of work I have an attempt at the modified firmware running on the device. The video device works fine, and Device Manager shows a new COM port with no errors. So far so good.

The problem occurs when I try to open the serial port - the terminal software throws an error trying to open the port. I feel like I've almost got it, but I'm not quite there.

I haven't implemented certain things like handling GET_LINE_CODING control code, etc. Is that needed to open the port?

Should I use [0x00, 0x00, 0x00] (use interface descriptions) or [0xEF, 0x02, 0x01] (misc) for [DeviceClass, SubClass, Protocol] on the main USB description? Doesn't seem to make a difference. I am using two IADs: one for the UVC group and a second for the CDC group. The IADs are [0x0E, 0x03, 0x00] and [2,2,1], respectively.

I might have to modify an INI file somewhere, but I'm not sure which one or how. Device Manager shows no errors (although the CDC device does appear as a "Serial Device" not a "Serial Port").

I see the chip I am using (STM32F411CEU6) supports "4 endpoints" (that's in the datasheet, but I can't find any more info than that). The original UVC interfaces uses two endpoints (UVC_IN_EP and UVC_CMD_EP) and the CDC interfaces use three (CDC_IN_EP, CDC_OUT_EP, and CDC_CMD_EP). That's 5 endpoints, but only four are IN, and one is OUT. I can't find any info on if one of the endpoints is used by default (EP0), or if the specified max 4 endpoints are actually 4 bidirectional or 8 unidirectional or some combination thereof.

One snippit (the original usbd_conf.c):
HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_FS, 0x80);
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 0, 0x40);
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 1, 0x80);

I assume I need to add a few lines here for the new CDC endpoints, but am not sure exactly which values to use. I've tried:
HAL_PCD_SetTxFiFo(&hpcd_USB_OTG_FS, 2, 0x10);
HAL_PCD_SetTxFiFo(&hpcd_USB_OTG_FS, 3, 0x20);
Tweaking values didn't seem to help.

Should I be using different pairs of TX/RX buffers for the UVC/CDC interfaces or just a single buffer pair for the whole USB device? I don't think that should prevent a port from being opened, right?

Any help is appreciated. Thanks!