To obj_ptr->desc_callback.set_configuration() or not to obj_ptr->desc_callback.set_configuration(), that is the question.

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

To obj_ptr->desc_callback.set_configuration() or not to obj_ptr->desc_callback.set_configuration(), that is the question.

880件の閲覧回数
johnstrohm
Contributor III

Found something interesting.

While researching the set_configuration() callback, I got curious, and did a find/grep, to find everyone who called it.

c:\Freescale_BM_USB_Stack_v5.0\Src\usb_core\device\sources\classes>find . -name *.[ch] | xargs grep set_configuration

./cdc/usb_cdc.c:        cdc_obj_ptr->desc_callback.set_configuration((uint32_t)cdc_obj_ptr->controller_handle, (uint8_t)(*(uint16_t*)val));

./msd/usb_msc.c:        msc_dev_ptr->desc_callback.set_configuration((uint32_t)msc_dev_ptr->controller_handle, (uint8_t)(*(uint16_t *)val));

It appears that only the CDC and MSC classes pass the SetConfiguration event to the application.  The Audio, DFU, HID, and PHDC classes do not.

A composite device that combined both a CDC and an MSC would hit the callback twice.  Conversely, an Audio/HID composite device would never hit the callback.

Possibly similar lines should be added to the Audio, DFU, HID, and PHDC device class drivers.

Possibly, those lines should be guarded with #if !USBCFG_DEV_COMPOSITE/#endif, and an unguarded similar line added to usb_composite.c.

All such lines should certainly be guarded with lines of the form:

    if (cdc_obj_ptr->desc_callback.set_configuration)


or

    if (msc_dev_ptr->desc_callback.set_configuration)

to make certain nobody crashes their device by passing a NULL callback.

ラベル(2)
0 件の賞賛
返信
1 返信

712件の閲覧回数
Kan_Li
NXP TechSupport
NXP TechSupport

Hi John,

Thanks for the report! I have passed it to our USB stack team, and will let you when I have any more information!

Thanks and Best Regards,

Kan

0 件の賞賛
返信