diff options
| author | hathach <[email protected]> | 2019-03-29 16:37:08 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2019-03-29 16:37:08 +0700 |
| commit | 3a38cde53dc7118b39eafd4fd1f69be4fd7dcd14 (patch) | |
| tree | 99b2806910385a2ebee223c8de5b71d1d2a9c890 | |
| parent | 1c2beba85c223bcf401f877b0c29025490fcdaa4 (diff) | |
support set/clear feature Device_remote_wakeup
| -rw-r--r-- | src/device/usbd.c | 12 | ||||
| -rw-r--r-- | 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 5127cfaab..7a0d1bca9 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 6bf7eca02..eb99337e3 100644 --- a/src/device/usbd.h +++ b/src/device/usbd.h @@ -37,7 +37,7 @@ //--------------------------------------------------------------------+
// INCLUDE
//--------------------------------------------------------------------+
-#include <common/tusb_common.h>
+#include "common/tusb_common.h"
#include "device/dcd.h"
//--------------------------------------------------------------------+
|
