From 317bf1e7c651bb9d2e02db3aa0f64aabb6af2d17 Mon Sep 17 00:00:00 2001 From: Jarno Rantanen Date: Sat, 21 Oct 2017 14:54:38 +0300 Subject: [PATCH] Update USB libs from wixel-SDK. This fixes a compilation issue on a more recent SDCC (3.5.0), that ships with latest stable Raspbian, for example. From: https://github.com/pololu/wixel-sdk/tree/513d976863a7be68cce523422735dd4a98a3435e Closes: https://github.com/StephenBlackWasAlreadyTaken/wixel-xDrip/issues/52 --- libraries/src/usb/usb.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/libraries/src/usb/usb.c b/libraries/src/usb/usb.c index 2d05b57..12f232b 100644 --- a/libraries/src/usb/usb.c +++ b/libraries/src/usb/usb.c @@ -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 @@ -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) { @@ -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; } @@ -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; }