Sadly, documentation for the FreeRTOS USB stack in SDK is woefully inadequate. If one simply wants to use a template and replace a few constants or rewrite a few methods, it's fine. But, if one wants to understand how the stack works, then too much time is required. The problem is that global macros used to choose between different running options are usually only documented by a comment. Let's take USB_DEVICE_CONFIG_USE_TASK as an example. Here's the entry from usb_device_config.h.
/*! @brief Whether the device task is enabled. */
#define USB_DEVICE_CONFIG_USE_TASK (0U)
The default is for the task to be disabled. However, in the example, USB appears to work. So, what does this global do? Ah, as a desperate measure, let's check out the documentation. The USB Stack Device reference Manual gives a hint:
#define USB_DEVICE_CONFIG_USE_TASK (0U)
Whether the device task is enabled.
The USB Stack User's Guide omits the Macros. The USB Stack Composite Device User's Guide adds:
10. Poll the device task when the “USB_DEVICE_CONFIG_USE_TASK” is none-zero. Poll the
HID keyboard and HID generic task when these tasks are implemented.
#if USB_DEVICE_CONFIG_USE_TASK #if defined(USB_DEVICE_CONFIG_EHCI) && (USB_DEVICE_CONFIG_EHCI > 0U)
USB_DeviceEhciTaskFunction(g_UsbDeviceComposite.deviceHandle); #endif
#if defined(USB_DEVICE_CONFIG_KHCI) && (USB_DEVICE_CONFIG_KHCI > 0U)
USB_DeviceKhciTaskFunction(g_UsbDeviceComposite.deviceHandle); #endif
#endif
Which brings two more undefined macros into the mix. One would have thought that USB_DEVICE_CONFIG_USE_TASK would have needed to be 1 for the example to work, yet it appears just the opposite. The amount of time needed to wind through the example code is such that it might be quicker to simply write the usb driver one's self.