aboutsummaryrefslogtreecommitdiff
path: root/cores/arduino
diff options
context:
space:
mode:
authorDavid Madison <dmadison@users.noreply.github.com>2019-02-21 11:42:06 -0500
committerDavid Madison <dmadison@users.noreply.github.com>2019-02-21 11:42:06 -0500
commit49456f49d0d18d023e5617dc87ff4a5192a1f497 (patch)
tree230ff4b7bd7a6a6ce26cc9ddc5f027b9d6a77325 /cores/arduino
parenta7b370bf9657dccc9038d6611ea289d996b53621 (diff)
Add USB receive callback to USB ISR
Using the OUT endpoint interrupt
Diffstat (limited to 'cores/arduino')
-rw-r--r--cores/arduino/USBCore.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/cores/arduino/USBCore.cpp b/cores/arduino/USBCore.cpp
index 8794250..f2a2365 100644
--- a/cores/arduino/USBCore.cpp
+++ b/cores/arduino/USBCore.cpp
@@ -360,6 +360,9 @@ void InitEndpoints()
UERST = 0x7E; // Reset endpoints
UERST = 0; // End reset
+
+ SetEP(XINPUT_RX_ENDPOINT); // Select XInput RX endpoint (OUT)
+ UEIENX |= (1 << RXOUTE); // Enable received "OUT" interrupt
}
static int _cmark;
@@ -506,9 +509,17 @@ bool SendDescriptor(USBSetup& setup)
return true;
}
-// Endpoint 0 interrupt
+// Endpoint interrupt
ISR(USB_COM_vect)
{
+ SetEP(XINPUT_RX_ENDPOINT); // Select XInput RX endpoint (OUT)
+ if (UEINTX & (1 << RXOUTI)) { // If data received...
+ UEINTX &= ~(1 << RXOUTI); // Clear interrupt flag
+ if (XInputUSB::RecvCallback != nullptr) {
+ XInputUSB::RecvCallback(); // Call callback function if it exists
+ }
+ }
+
SetEP(0);
if (!ReceivedSetupInt())
return;