[Compoments][USB]增加对class的非法注册的判断
This commit is contained in:
parent
294223c80b
commit
f73e4c3fc4
|
@ -96,6 +96,13 @@ INIT_BOARD_EXPORT(rt_usbd_class_list_init);
|
||||||
|
|
||||||
rt_err_t rt_usbd_class_register(udclass_t udclass)
|
rt_err_t rt_usbd_class_register(udclass_t udclass)
|
||||||
{
|
{
|
||||||
|
#ifndef RT_USB_DEVICE_COMPOSITE
|
||||||
|
if(!rt_list_isempty(&class_list))
|
||||||
|
{
|
||||||
|
rt_kprintf("[D/USBD] If you want to use usb composite device please define RT_USB_DEVICE_COMPOSITE\n");
|
||||||
|
return RT_ERROR;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
rt_list_insert_before(&class_list,&udclass->list);
|
rt_list_insert_before(&class_list,&udclass->list);
|
||||||
return RT_EOK;
|
return RT_EOK;
|
||||||
}
|
}
|
||||||
|
@ -109,6 +116,11 @@ rt_err_t rt_usb_device_init(void)
|
||||||
rt_list_t *i;
|
rt_list_t *i;
|
||||||
udclass_t udclass;
|
udclass_t udclass;
|
||||||
|
|
||||||
|
if(rt_list_isempty(&class_list))
|
||||||
|
{
|
||||||
|
rt_kprintf("[D/USBD] No class register on usb device\n");
|
||||||
|
return RT_ERROR;
|
||||||
|
}
|
||||||
/* create and startup usb device thread */
|
/* create and startup usb device thread */
|
||||||
rt_usbd_core_init();
|
rt_usbd_core_init();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue