add usbd init and deinit event macro
This commit is contained in:
@@ -1202,19 +1202,28 @@ bool usb_device_is_configured(void)
|
||||
|
||||
int usbd_initialize(void)
|
||||
{
|
||||
return usb_dc_init();
|
||||
int ret;
|
||||
|
||||
ret = usb_dc_init();
|
||||
usbd_class_event_notify_handler(USBD_EVENT_INIT, NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int usbd_deinitialize(void)
|
||||
{
|
||||
g_usbd_core.intf_offset = 0;
|
||||
usb_dc_deinit();
|
||||
usbd_class_event_notify_handler(USBD_EVENT_DEINIT, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
__WEAK void usbd_event_handler(uint8_t event)
|
||||
{
|
||||
switch (event) {
|
||||
case USBD_EVENT_INIT:
|
||||
break;
|
||||
case USBD_EVENT_DEINIT:
|
||||
break;
|
||||
case USBD_EVENT_RESET:
|
||||
break;
|
||||
case USBD_EVENT_CONNECTED:
|
||||
|
||||
@@ -38,6 +38,8 @@ enum usbd_event_type {
|
||||
USBD_EVENT_SET_INTERFACE, /** USB interface selected */
|
||||
USBD_EVENT_SET_REMOTE_WAKEUP, /** USB set remote wakeup */
|
||||
USBD_EVENT_CLR_REMOTE_WAKEUP, /** USB clear remote wakeup */
|
||||
USBD_EVENT_INIT, /** USB init done when call usbd_initialize */
|
||||
USBD_EVENT_DEINIT, /** USB deinit done when call usbd_deinitialize */
|
||||
USBD_EVENT_UNKNOWN
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user