diff options
author | David Madison <dmadison@users.noreply.github.com> | 2019-02-21 11:42:06 -0500 |
---|---|---|
committer | David Madison <dmadison@users.noreply.github.com> | 2019-02-21 11:42:06 -0500 |
commit | 49456f49d0d18d023e5617dc87ff4a5192a1f497 (patch) | |
tree | 230ff4b7bd7a6a6ce26cc9ddc5f027b9d6a77325 /cores/arduino/USBCore.cpp | |
parent | a7b370bf9657dccc9038d6611ea289d996b53621 (diff) |
Add USB receive callback to USB ISR
Using the OUT endpoint interrupt
Diffstat (limited to 'cores/arduino/USBCore.cpp')
-rw-r--r-- | cores/arduino/USBCore.cpp | 13 |
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; |