March 3, 2025

Black Pill boards - F411 USB -- Enumeration part 1

Let's look again at that first call we make to get the USB subsystem going:
USBD_Init ( &USB_OTG_dev,
            USB_OTG_FS_CORE_ID,
            &USR_desc,
            &USBD_CDC_cb,
            &USR_cb);
Take a look at "USR_desc", which we have so far ignored.

This is defined in vcp/usbd_desc.c as follows:

USBD_DEVICE USR_desc =
{
  USBD_USR_DeviceDescriptor,
  USBD_USR_LangIDStrDescriptor,
  USBD_USR_ManufacturerStrDescriptor,
  USBD_USR_ProductStrDescriptor,
  USBD_USR_SerialStrDescriptor,
  USBD_USR_ConfigStrDescriptor,
  USBD_USR_InterfaceStrDescriptor,
};
We have a struct once again, and each item in the struct is once again a function pointer (callback). These are callbacks, but with a different flavor. Here the callbacks return information that will be used to respond to requests that take place during enumeration.

Sometimes the information is a string, but it may be a "descriptor". In either case, the routine returns the address of the descriptor and its length.

Note that this is in the VCP directory. These descriptors are specific to the VCP identity that the CDC device is supporting.

More to come

We will look at enumeration in more detail, probably once we actually start running the code and watching what it does.

We should take a careful look at endpoints soon, not to mention the VCP class (as well as how it fine tunes the CDC class). How many endpoints are required for a VCP device? You would think just one IN and one OUT, but things may be more complex and I think they are. An additional endpoint may have to do with out of band data and/or events.

Also as a side comment. A device talks about endpoints. A host talks about channels. We will only talk about endpoints and won't have anything to say about channels.

Another question (this is all about thinking up worthwhile questions and then answering them). What is the purpose of the continual SOF interrupts? There is a README file in the F103 usb code that warns that there is a price for having even an idle USB device due to these interrupts.

Also another comment. The F4xx USB controller allows only 3 endpoints aside from the endpoint 0 (which is dedicated to setup traffic). This puts some limitation on "dual role" USB where a device can be a mass storage device and a VCP at the same time. The F103 allows up to 16 endpoints (but a limit will be encountered far before that due to limited USB ram space). Note how the F103 embedded in the F429 discovery board can be three things at once. It can be a mass storage device, a USB serial device (VCP), as well as the ST-Link device. This is very handy.


Feedback? Questions? Drop me a line!

Tom's Computer Info / tom@mmto.org