6/22/2012

How to Know real speed the usb stack work in

In the structure of fd_desc_t, there is a member :current_speed
When usb enumeration process has finished and host send set configure message, the related function driver will be enabled, and this attribute will include the real speed that is used between the device and host.

The host negotiate with device for the speed, both host and device support high speed, then the device will work in high speed mode, other wise, in full speed mode, each fd will be same on the same hub port.

For your own function driver based on mtp example, you can get it in fd_desc_t structure directly.

For obex, you shall be able to get by cdc_ctx_t.desc.current_speed when hsu_al_ser_obex_enabled is called. but as cdc_ctx_t will not be passed to hsu_al_ser_obex_enabled, you need to do some trick. When obex_init is called, the first paramter cdc_handle_t handle is just the cdc_ctx_t point, so need to store it at some place like it in *ctx. see get_avail_obex_data_slot_for_fd(), you can add a new member in hsu_al_ser_obex_data structure to store the point to cdc_ctx_t structure. you can also just simply store it to a global variable.

No comments:

Post a Comment