1、USB Device Support in Zephyr RTOS From the ApplicationPerspectiveEOSS 2023Johann Fischerjohann.fischernordicsemi.nobPrague,Czech Republic/June 28,20231.Contents2/31Contents I1.Introduction2.How to enable USB device support3.Supported Classes3.1 CDC ACM3.2 Mass Storage Class3.3 Bluetooth HCI USB tran
2、sport layer3.4 Networking3.5 Human Interface Devices(HID)support3.6 Audio Class3.7 USB DFU4.References3.How to enable USB device support3/31Devicetreezephyr_udc0:&usbd status=”okay”;Kconfig options and configuration files#prj.confCONFIG_USB_DEVICE_STACK=yCONFIG_USB_DEVICE_VID=0 x2FE3CONFIG_USB_DEVIC
3、E_PID=0 x1234CONFIG_USB_DEVICE_MANUFACTURER=”Nice company”CONFIG_USB_DEVICE_PRODUCT=”Good product”CONFIG_USB_DEVICE_SN=”0123456789ABCDEF”CONFIG_USB_SELF_POWERED=nCONFIG_USB_MAX_POWER=123.3.How to enable USB device support4/31Runtime code for configuration and activation/*main.c*/#include#include#inc
4、lude staticbool configured;staticvoid status_cb(enum usb_dc_status_code status,constuint8_t*param)i f(status=USB_DC_RESET)configured=false;i f(status=USB_DC_CONFIGURED&!configured)configured=true;int main(void)return usb_enable(status_cb);3.How to enable USB device support5/31Useful Kconfig optionsC
5、ONFIG_USB_COMPOSITE_DEVICE=nFunction Interface”Use class code info from Interface Descriptors”3bDeviceClass=0bInterfaceClass,e.g USB_BCC_MASS_STORAGEbDeviceSubClass=0bInterfaceSubClass,e.g.SCSI_TRANSPARENT_SUBCLASSbDeviceProtocol=0bInterfaceProtocol,e.g.BULK_ONLY_TRANSPORT_PROTOCOLCONFIG_USB_COMPOSI
6、TE_DEVICE=y”Use Interface Association Descriptor code triple”1”IAD Descriptor is used to describe that two or more interfaces are associated to the same function.”2bDeviceClass=0 xEFbInterfaceClass or IAD bFunctionClassbDeviceSubClass=0 x02bInterfaceSubClass or IAD bFunctionSubClassbDeviceProtocol=0