From 3a38cde53dc7118b39eafd4fd1f69be4fd7dcd14 Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 29 Mar 2019 16:37:08 +0700 Subject: [PATCH] support set/clear feature Device_remote_wakeup --- src/device/usbd.c | 12 +++++++++++- src/device/usbd.h | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/device/usbd.c b/src/device/usbd.c index 5127cfaa..7a0d1bca 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -167,13 +167,21 @@ bool usbd_control_xfer_cb (uint8_t rhport, uint8_t ep_addr, xfer_result_t event, void usbd_control_set_complete_callback( bool (*fp) (uint8_t, tusb_control_request_t const * ) ); //--------------------------------------------------------------------+ -// APPLICATION API +// Application API //--------------------------------------------------------------------+ bool tud_mounted(void) { return _usbd_dev.config_num > 0; } +bool tud_remote_wakeup(void) +{ + // only wake up host if this feature is enabled + if (_usbd_dev.remote_wakeup_en ) dcd_remote_wakeup(TUD_OPT_RHPORT); + + return _usbd_dev.remote_wakeup_en; +} + //--------------------------------------------------------------------+ // USBD Task //--------------------------------------------------------------------+ @@ -357,6 +365,7 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const if ( TUSB_REQ_FEATURE_REMOTE_WAKEUP == p_request->wValue ) { // Host enable remote wake up before suspending especially HID device + _usbd_dev.remote_wakeup_en = true; } break; @@ -364,6 +373,7 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const if ( TUSB_REQ_FEATURE_REMOTE_WAKEUP == p_request->wValue ) { // Host disable remote wake up after resuming + _usbd_dev.remote_wakeup_en = false; } break; diff --git a/src/device/usbd.h b/src/device/usbd.h index 6bf7eca0..eb99337e 100644 --- a/src/device/usbd.h +++ b/src/device/usbd.h @@ -37,7 +37,7 @@ //--------------------------------------------------------------------+ // INCLUDE //--------------------------------------------------------------------+ -#include +#include "common/tusb_common.h" #include "device/dcd.h" //--------------------------------------------------------------------+