summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsakimisu <[email protected]>2023-05-17 20:59:38 +0800
committersakimisu <[email protected]>2023-05-17 20:59:38 +0800
commit386172875105c901478e61cda78a2b09ff93d283 (patch)
treebfd659ba74e8f081e2755f7df7924af89cb466d8
parent9172223fe61d2be0dc7bc5a262063f95c09f1e8a (diff)
add remote wakeup event
-rw-r--r--core/usbd_core.c11
-rw-r--r--core/usbd_core.h6
2 files changed, 14 insertions, 3 deletions
diff --git a/core/usbd_core.c b/core/usbd_core.c
index d78e8fd8..4d1701cb 100644
--- a/core/usbd_core.c
+++ b/core/usbd_core.c
@@ -517,6 +517,11 @@ static bool usbd_std_device_req_handler(struct usb_setup_packet *setup, uint8_t
case USB_REQUEST_CLEAR_FEATURE:
case USB_REQUEST_SET_FEATURE:
if (value == USB_FEATURE_REMOTE_WAKEUP) {
+ if (setup->bRequest == USB_REQUEST_SET_FEATURE) {
+ usbd_event_handler(USBD_EVENT_SET_REMOTE_WAKEUP);
+ } else {
+ usbd_event_handler(USBD_EVENT_CLR_REMOTE_WAKEUP);
+ }
} else if (value == USB_FEATURE_TEST_MODE) {
#ifdef CONFIG_USBDEV_TEST_MODE
usbd_core_cfg.test_mode = true;
@@ -554,7 +559,6 @@ static bool usbd_std_device_req_handler(struct usb_setup_packet *setup, uint8_t
usbd_core_cfg.configured = true;
usbd_class_event_notify_handler(USBD_EVENT_CONFIGURED, NULL);
usbd_event_handler(USBD_EVENT_CONFIGURED);
- usbd_configure_done_callback();
}
*len = 0;
break;
@@ -1294,6 +1298,11 @@ __WEAK void usbd_event_handler(uint8_t event)
case USBD_EVENT_SUSPEND:
break;
case USBD_EVENT_CONFIGURED:
+ usbd_configure_done_callback();
+ break;
+ case USBD_EVENT_SET_REMOTE_WAKEUP:
+ break;
+ case USBD_EVENT_CLR_REMOTE_WAKEUP:
break;
default:
diff --git a/core/usbd_core.h b/core/usbd_core.h
index 3273b5e3..3328cffe 100644
--- a/core/usbd_core.h
+++ b/core/usbd_core.h
@@ -35,8 +35,10 @@ enum usbd_event_type {
USBD_EVENT_RESUME, /** USB connection resumed by the HOST */
/* USB DEVICE STATUS */
- USBD_EVENT_CONFIGURED, /** USB configuration done */
- USBD_EVENT_SET_INTERFACE, /** USB interface selected */
+ USBD_EVENT_CONFIGURED, /** USB configuration done */
+ 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_UNKNOWN
};