question

jack-1513 avatar image
0 Votes"
jack-1513 asked ScottAzureRTOS answered

USBX HOST support customer defined class

I'm working with USBX HOST , need to drive an LTE cellular module who has customer defined class\PID\VID, how could I start with that? I found UX_HOST_CLASS_DPUMP related API which may help but when I register such class and modify following with ours, I get 580 error code.

Can you give me an example how to let it work? Thanks.

(../User/usbx/app_usbx_host.c ux_host_error_callback:580)Enumeration Failure


define UX_HOST_CLASS_DPUMP_CLASS 0x99

define UX_HOST_CLASS_DPUMP_SUBCLASS 0x99

define UX_HOST_CLASS_DPUMP_PROTOCOL 0x99

azure-rtos
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello @jack-1513 Welcome to Microsoft Q&A Platform and thanks for your query. Community SME's on this topic or our team will review your scenario and circle back at the possible earliest time.

0 Votes 0 ·

1 Answer

ScottAzureRTOS avatar image
1 Vote"
ScottAzureRTOS answered

Hi @jack-1513

This is from my colleague CQ:

DPUMP is just a demo class to support our custom class with interface class/subclass/protocol is defined as UX_HOST_CLASS_DPUMP_CLASS/UX_HOST_CLASS_DPUMP_SUBCLASS/UX_HOST_CLASS_DPUMP_PROTOCOL. Try to detect custom device with this class returns enumeration fail since it does not find class/subclass/protocol it expects in query stage.

Refer to the command dispatch code for command UX_HOST_CLASS_COMMAND_QUERY in ux_host_class_dpump_entry.c for the details.


If customer want’s VID/PID detect, HUB implement can be referenced, since VID/PID is provided while querying device class driver. Check the UX_HOST_CLASS_COMMAND_QUERY handling in ux_host_class_hub_entry.c.

If a custom device needs host class driver, you can start from existing dpump/cdc_acm for a interface/function class driver, or from existing hub for a device class driver.


In an interface/function class driver, in UX_HOST_CLASS_COMMAND_QUERY confirm command usage is UX_HOST_CLASS_COMMAND_USAGE_CSP and check class/subclass/protocol to see if the driver should be linked to the interface.

In a device class driver, in UX_HOST_CLASS_COMMAND_QUERY confirm command usage is UX_HOST_CLASS_COMMAND_USAGE_DCSP and check VID/PID to see if the driver should be linked to the entire device.


After the driver is linked when runs to final step of enumeration, UX_HOST_CLASS_COMMAND_ACTIVATE is sent to driver to activate the interface/function driver or device driver. Check the implement of activate and deactivate functions for more details.


For new customer-defined class a new driver should be created any way:
1. Implement a _entry(UX_HOST_CLASS_COMMAND *) function.
2. Inside _entry function handle at least following requests
a. UX_HOST_CLASS_COMMAND_QUERY: link the driver so it will be called for activate and deactivate on enumeration end or disconnection.
b. UX_HOST_CLASS_COMMAND_ACTIVATE: allocate driver instance and do activation.
c. UX_HOST_CLASS_COMMAND_DEACTIVATE: free driver instance
Refer to existing DPUMP, CDC_ACM or HUB implement for more details.
3. The class can be registered with ux_host_stack_class_register(custom_class_name, _entry)




5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.