Skip to content

Commit c87bc7b

Browse files
committed
Add USBDevice.isSuspended()
Based on code originally by Rob van der Veer <[email protected]>, this adds USBDevice.isSuspended(), so user sketches can run custom code in their `loop` methods after checking if the device is suspended or not. Signed-off-by: Gergely Nagy <[email protected]>
1 parent 2663be1 commit c87bc7b

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

cores/arduino/USBAPI.h

+2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ class USBDevice_
6565
void detach(); // Serial port goes down too...
6666
void poll();
6767
bool wakeupHost(); // returns false, when wakeup cannot be processed
68+
69+
bool isSuspended();
6870
};
6971
extern USBDevice_ USBDevice;
7072

cores/arduino/USBCore.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -855,4 +855,10 @@ bool USBDevice_::wakeupHost()
855855
return false;
856856
}
857857

858+
bool USBDevice_::isSuspended()
859+
{
860+
return (_usbSuspendState & (1 << SUSPI));
861+
}
862+
863+
858864
#endif /* if defined(USBCON) */

0 commit comments

Comments
 (0)