Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c87bc7b

Browse files
committed
Add USBDevice.isSuspended()
Based on code originally by Rob van der Veer <rob.c.veer@gmail.com>, 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 <algernon@keyboard.io>
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‎

Lines changed: 2 additions & 0 deletions
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‎

Lines changed: 6 additions & 0 deletions
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)

AltStyle によって変換されたページ (->オリジナル) /