Skip to content

Add USBDevice.isSuspended() #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
  • Loading branch information
algernon committed Dec 10, 2018
commit c87bc7ba9a94cbeca3b652ea068c4bdb38c76b6c
2 changes: 2 additions & 0 deletions cores/arduino/USBAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class USBDevice_
void detach(); // Serial port goes down too...
void poll();
bool wakeupHost(); // returns false, when wakeup cannot be processed

bool isSuspended();
};
extern USBDevice_ USBDevice;

Expand Down
6 changes: 6 additions & 0 deletions cores/arduino/USBCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -855,4 +855,10 @@ bool USBDevice_::wakeupHost()
return false;
}

bool USBDevice_::isSuspended()
{
return (_usbSuspendState & (1 << SUSPI));
}


#endif /* if defined(USBCON) */