diff options
| author | Ha Thach <[email protected]> | 2021-08-17 17:29:13 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-08-17 17:29:13 +0700 |
| commit | 0411810bc0ae3b9dce84d4852506706d72a29d93 (patch) | |
| tree | 4ad7ba05f0809fdcc89a5582438306527f21787d /src | |
| parent | 7cbb11a86cd75198e466416d43557d06c1ebcd10 (diff) | |
| parent | 9b869463ddd7277befa30f8e781b9d72ae005c07 (diff) | |
Merge pull request #1026 from hathach/suspend-resume-followup
skipped suspend/resume if not connected
Diffstat (limited to 'src')
| -rw-r--r-- | src/device/usbd.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/device/usbd.c b/src/device/usbd.c index 538964a3d..e8a50352c 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -559,13 +559,28 @@ void tud_task (void) break; case DCD_EVENT_SUSPEND: - TU_LOG2(": Remote Wakeup = %u\r\n", _usbd_dev.remote_wakeup_en); - if (tud_suspend_cb) tud_suspend_cb(_usbd_dev.remote_wakeup_en); + // NOTE: When plugging/unplugging device, the D+/D- state are unstable and + // can accidentally meet the SUSPEND condition ( Bus Idle for 3ms ), which result in a series of event + // e.g suspend -> resume -> unplug/plug. Skip suspend/resume if not connected + if ( _usbd_dev.connected ) + { + TU_LOG2(": Remote Wakeup = %u\r\n", _usbd_dev.remote_wakeup_en); + if (tud_suspend_cb) tud_suspend_cb(_usbd_dev.remote_wakeup_en); + }else + { + TU_LOG2(" Skipped\r\n"); + } break; case DCD_EVENT_RESUME: - TU_LOG2("\r\n"); - if (tud_resume_cb) tud_resume_cb(); + if ( _usbd_dev.connected ) + { + TU_LOG2("\r\n"); + if (tud_resume_cb) tud_resume_cb(); + }else + { + TU_LOG2(" Skipped\r\n"); + } break; case DCD_EVENT_SOF: |
