aboutsummaryrefslogtreecommitdiff
path: root/cores/arduino
diff options
context:
space:
mode:
authorGergely Nagy <algernon@keyboard.io>2018-12-11 00:01:57 +0100
committerGergely Nagy <algernon@keyboard.io>2018-12-11 00:01:57 +0100
commitc87bc7ba9a94cbeca3b652ea068c4bdb38c76b6c (patch)
treef0273b3438592913f5414d6d08045bd82f922c13 /cores/arduino
parent2663be17272e19f00c55f3f2d8f1ebfac47158d6 (diff)
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>
Diffstat (limited to 'cores/arduino')
-rw-r--r--cores/arduino/USBAPI.h2
-rw-r--r--cores/arduino/USBCore.cpp6
2 files changed, 8 insertions, 0 deletions
diff --git a/cores/arduino/USBAPI.h b/cores/arduino/USBAPI.h
index 479ced9..701a14f 100644
--- a/cores/arduino/USBAPI.h
+++ b/cores/arduino/USBAPI.h
@@ -65,6 +65,8 @@ public:
void detach(); // Serial port goes down too...
void poll();
bool wakeupHost(); // returns false, when wakeup cannot be processed
+
+ bool isSuspended();
};
extern USBDevice_ USBDevice;
diff --git a/cores/arduino/USBCore.cpp b/cores/arduino/USBCore.cpp
index 81f689d..c0a4c7c 100644
--- a/cores/arduino/USBCore.cpp
+++ b/cores/arduino/USBCore.cpp
@@ -855,4 +855,10 @@ bool USBDevice_::wakeupHost()
return false;
}
+bool USBDevice_::isSuspended()
+{
+ return (_usbSuspendState & (1 << SUSPI));
+}
+
+
#endif /* if defined(USBCON) */