I used the "locate" command on one of the files I work on and found other copies that I have on my system:
/u1/Projects/STM32/F429/libs_stm32f429/00-STM32F429_LIBRARIES/usb_cdc_device/usbd_cdc_vcp.c /u1/Projects/STM32/Arduino_STM32/STM32F4/cores/maple/libmaple/usbF4/VCP/usbd_cdc_vcp.c /u1/Projects/USB/usbF4/vcp/usbd_cdc_vcp.c /u1/Projects/STM32/Hydra/usbF4/vcp/usbd_cdc_vcp.cSo, there we have it. 3 other copies, and the second to last is another copy I made in what looks like and abandoned project in my USB directory. Looking at it, I see dates on the files from December of 2020 and it is just an old copy of what I now call usbF4 inside my Hydra project. It probably should just be deleted.
I want to comment on filenames themselves. Consider filenames like usb_core.c and usbd_core.c, as well as usbh_core.c. Clearly in someone's scheme the first letters of the filename were intended to convey information, and perhaps avoid name collisions if files were looked at by themselves or mistakenly copied into the same directory. I would not do things this way. I could call these all "core.c" and let them be distinguished by the directory they are found in. The file usb_core.c would be driver/core.c. The files usbd_core.c would be library/core.c and usbh_core.c would be host/core.c.
To my way of thinking, short names are quicker and easier to type, and why duplicate information that is conveyed already by what directory they are found in. On my system I can type "locate init.c" and get well over 100 files in various projects and directories.
The Arduino_STM32 directory dates from September 2020 and is clearly a clone of that project. "maple" is the only core under core. "libmaple" includes a lot of drivers for all kinds of stm32F4 hardware. A directory "usbF4" holds all the USB code.
Some imbecile decided that it was smart (but it wasn't) to separate .h files into "inc" directories and .c files into "src" directories. This is just a stupid annoyance and it is annoying enough (as well as stupid and pointless) that I don't hesitate to complain about it.
Under Arduino_STM32/STM32F4/cores/maple/libmaple/usbF4/Library/Class I find several directories
and get excited: audio cdc dfu hid msc.
However, the only one of these with a "src" directory is "cdc" -- the others have only "inc" directories.
The "cdc" directory has 3 files, and we recognize these:
inc/usbd_cdc_core.h inc/usbd_cdc_if_template.h src/usbd_cdc_core.cIn our case, I moved these into our "library" directory.
Doing a "locate" on usbd_cdc_core.h yields some other potential sources of source files for study:
/u1/Projects/Photon/firmware-0.5.3-rc.1/platform/MCU/STM32F2xx/STM32_USB_Device_Driver/inc/usbd_cdc_core.h /u1/Projects/STM32/Arduino_STM32/STM32F4/cores/maple/libmaple/usbF4/STM32_USB_Device_Library/Class/cdc/inc/usbd_cdc_core.h /u1/Projects/STM32/F429/Demo/STM32F429I-Discovery_FW_V1.0.3/Libraries/STM32_USB_Device_Library/Class/cdc/inc/usbd_cdc_core.h /u1/Projects/STM32/F429/libs_stm32f429/00-STM32F429_LIBRARIES/usb_cdc_device/usbd_cdc_core.h
/u1/Projects/STM32/F429/libs_stm32f429/00-STM32F429_LIBRARIES/usb_hid_deviceThis will be worth taking a look at someday. I will note in passing that this fellow is intelligent and does not continue the stupid business of inc and src directories.
CMSIS STemWinLibrary522_4x9i STM32F4xx_StdPeriph_Driver STM32_USB_Device_Library STM32_USB_HOST_Library STM32_USB_OTG_DriverSo we have both host and device code, as well as a driver, alongside of code and drivers for things other than USB. We do have the brain damage with inc and src directories here, so that originated at ST. Inside STM32_USB_Device_Library we have Core and Class. Here "Core" looks exactly like what I have called "library", but Class is quite interesting. Unlike what we found in Arduino_STM32, we have "audio cdc dfu hid msc" and each of these has both src and inc directories with files.
inc/usbd_audio_core.h inc/usbd_audio_out_if.h src/usbd_audio_core.c src/usbd_audio_out_if.cUnder "hid", I see:
inc/usbd_hid_core.h src/usbd_hid_core.cUnder "msc", I see:
inc/usbd_msc_bot.h inc/usbd_msc_core.h inc/usbd_msc_data.h inc/usbd_msc_mem.h inc/usbd_msc_scsi.h src/usbd_msc_bot.c src/usbd_msc_core.c src/usbd_msc_data.c src/usbd_msc_scsi.c src/usbd_storage_template.cSo, I have finally found classes for things other than cdc. Where are VCP files? I do a "locate" on usbd_cdc_vcp.c and find:
/u1/Projects/STM32/F429/libs_stm32f429/00-STM32F429_LIBRARIES/usb_cdc_device/usbd_cdc_vcp.cThis is not part of this distribution, but is part of the collection from Majerle above.
CMSIS SPARK_Firmware_Driver STM32_StdPeriph_Driver STM32_USB_Device_Driver STM32_USB_Host_Driver STM32_USB_OTG_DriverSo this looks like the distribution from ST (but from 2016 and for STM32F2xx parts). The organization is simpler (cleaner?) with audio, cdc, dfu, msc all together in the same directory.
It is hard to know whether this is good or bad. This is older code and for the F2xx parts, but if the class code is device independent, this old 2016 code could be simpler for study.
Tom's Computer Info / tom@mmto.org