summaryrefslogtreecommitdiff
path: root/src/device
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2021-03-03 15:12:28 +0700
committerGitHub <[email protected]>2021-03-03 15:12:28 +0700
commit7b162ec93f57426a26b351512f2f05156b8fa8b1 (patch)
tree75dc4432c2494aff690b610a35b883dc86176228 /src/device
parentd56fad5f38ae77d4d83c3a7e0e4919147a8ab5fc (diff)
parenta298045f6c57ed3bad23ce44a1944016a882e08c (diff)
Merge pull request #692 from hathach/improve-rp2040
Improve rp2040
Diffstat (limited to 'src/device')
-rw-r--r--src/device/usbd.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/device/usbd.c b/src/device/usbd.c
index 4fc221888..911977eb0 100644
--- a/src/device/usbd.c
+++ b/src/device/usbd.c
@@ -992,11 +992,15 @@ void dcd_event_handler(dcd_event_t const * event, bool in_isr)
switch (event->event_id)
{
case DCD_EVENT_UNPLUGGED:
- _usbd_dev.connected = 0;
- _usbd_dev.addressed = 0;
- _usbd_dev.cfg_num = 0;
- _usbd_dev.suspended = 0;
- osal_queue_send(_usbd_q, event, in_isr);
+ // UNPLUGGED event can be bouncing, only processing if we are currently connected
+ if ( _usbd_dev.connected )
+ {
+ _usbd_dev.connected = 0;
+ _usbd_dev.addressed = 0;
+ _usbd_dev.cfg_num = 0;
+ _usbd_dev.suspended = 0;
+ osal_queue_send(_usbd_q, event, in_isr);
+ }
break;
case DCD_EVENT_SOF:
@@ -1004,9 +1008,10 @@ void dcd_event_handler(dcd_event_t const * event, bool in_isr)
break;
case DCD_EVENT_SUSPEND:
- // NOTE: When plugging/unplugging device, the D+/D- state are unstable and can accidentally meet the
- // SUSPEND condition ( Idle for 3ms ). Some MCUs such as SAMD doesn't distinguish suspend vs disconnect as well.
- // We will skip handling SUSPEND/RESUME event if not currently connected
+ // NOTE: When plugging/unplugging device, the D+/D- state are unstable and
+ // can accidentally meet the SUSPEND condition ( Bus Idle for 3ms ).
+ // In addition, some MCUs such as SAMD or boards that haven no VBUS detection cannot distinguish
+ // suspended vs disconnected. We will skip handling SUSPEND/RESUME event if not currently connected
if ( _usbd_dev.connected )
{
_usbd_dev.suspended = 1;