Skip to content

Commit

Permalink
Merge pull request #3 from jareware/master
Browse files Browse the repository at this point in the history
Update USB libs from wixel-SDK.
  • Loading branch information
jamorham authored Oct 22, 2017
2 parents a15cd96 + 317bf1e commit 6f3cf6a
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions libraries/src/usb/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

extern uint8 CODE usbConfigurationDescriptor[];

void usbStandardDeviceRequestHandler();
static void usbStandardDeviceRequestHandler();

#define CONTROL_TRANSFER_STATE_NONE 0
#define CONTROL_TRANSFER_STATE_WRITE 1
Expand Down Expand Up @@ -223,6 +223,12 @@ void usbPoll()

USBINDEX = 0; // Select EP0 again because the functions above might have changed USBINDEX.

// Modify the count so that we don't send more data than the host requested.
if(controlTransferBytesLeft > usbSetupPacket.wLength)
{
controlTransferBytesLeft = usbSetupPacket.wLength;
}

// Prepare for the first transaction after the SETUP packet.
if (controlTransferState == CONTROL_TRANSFER_STATE_NONE)
{
Expand Down Expand Up @@ -336,7 +342,11 @@ static void usbStandardDeviceRequestHandler()
{
if ((usbSetupPacket.wValue & 0xFF) >= usbStringDescriptorCount)
{
// Invalid string index.
// This is either an invalid string index or it is 0xEE,
// which is defined by Microsoft OS Descriptors 1.0.
// This library provides no features for handling such requests,
// but we call the user's callback in case they want to.
usbCallbackClassDescriptorHandler();
return;
}

Expand All @@ -358,14 +368,6 @@ static void usbStandardDeviceRequestHandler()
}
}

// Modify the count so that we don't send more data than the host requested.
// We MUST use the local variable wLength instead of usbSetupPacket.wLength because
// USB_SETUP_PACKET may have been over-written by the serial number handler.
if(controlTransferBytesLeft > usbSetupPacket.wLength)
{
controlTransferBytesLeft = usbSetupPacket.wLength;
}

controlTransferState = CONTROL_TRANSFER_STATE_READ;
return;
}
Expand Down

0 comments on commit 6f3cf6a

Please sign in to comment.