[Compoments][USB]增加对class的非法注册的判断

This commit is contained in:
ZYH 2018-10-09 11:41:38 +08:00
parent 294223c80b
commit f73e4c3fc4
1 changed files with 12 additions and 0 deletions

View File

@ -96,6 +96,13 @@ INIT_BOARD_EXPORT(rt_usbd_class_list_init);
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);
return RT_EOK;
}
@ -109,6 +116,11 @@ rt_err_t rt_usb_device_init(void)
rt_list_t *i;
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 */
rt_usbd_core_init();