mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-01-31 11:20:27 +08:00
Merge pull request #95 from grissiom/vcom
usbdevice/core: add reset function to support hotplug
This commit is contained in:
commit
a33e992724
@ -145,6 +145,7 @@ enum udev_msg_type
|
||||
USB_MSG_SETUP_NOTIFY,
|
||||
USB_MSG_DATA_NOTIFY,
|
||||
USB_MSG_SOF,
|
||||
USB_MSG_RESET,
|
||||
};
|
||||
typedef enum udev_msg_type udev_msg_type;
|
||||
|
||||
|
@ -666,6 +666,35 @@ rt_err_t _sof_notify(udevice_t device)
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will reset all class.
|
||||
*
|
||||
* @param device the usb device object.
|
||||
*
|
||||
* @return RT_EOK.
|
||||
*/
|
||||
rt_err_t _reset_notify(udevice_t device)
|
||||
{
|
||||
struct rt_list_node *i;
|
||||
uclass_t cls;
|
||||
|
||||
RT_ASSERT(device != RT_NULL);
|
||||
|
||||
/* to notity every class that sof event comes */
|
||||
for (i=device->curr_cfg->cls_list.next;
|
||||
i!=&device->curr_cfg->cls_list; i=i->next)
|
||||
{
|
||||
cls = (uclass_t)rt_list_entry(i, struct uclass, list);
|
||||
if(cls->ops->stop != RT_NULL)
|
||||
cls->ops->stop(device, cls);
|
||||
|
||||
if(cls->ops->run != RT_NULL)
|
||||
cls->ops->run(device, cls);
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will create an usb device object.
|
||||
*
|
||||
@ -1382,6 +1411,10 @@ static void rt_usbd_thread_entry(void* parameter)
|
||||
case USB_MSG_SETUP_NOTIFY:
|
||||
_setup_request(device, (ureq_t)msg.content.setup_msg.packet);
|
||||
break;
|
||||
case USB_MSG_RESET:
|
||||
if (device->state == USB_STATE_ADDRESS)
|
||||
_reset_notify(device);
|
||||
break;
|
||||
default:
|
||||
rt_kprintf("unknown msg type\n");
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user