diff options
| author | Dean <Dean@d5102386-fcda-11dd-9fdb-3debd5008f28> | 2011-09-21 06:35:28 +0000 |
|---|---|---|
| committer | Dean <Dean@d5102386-fcda-11dd-9fdb-3debd5008f28> | 2011-09-21 06:35:28 +0000 |
| commit | ffc451fbd9631b4e0a45bce36dda3e34facee2de (patch) | |
| tree | cc4e8c2d4fb4b519f80c87cc13c32cdafd4c52d8 /LUFA/Drivers/USB/Class | |
| parent | 44e3311de4c0d12b228bce55edc4ceff690d4f91 (diff) | |
Add LUFA-111009-BETA tag.LUFA-111009-BETA
git-svn-id: http://lufa-lib.googlecode.com/svn/tags/LUFA-111009-BETA@1929 d5102386-fcda-11dd-9fdb-3debd5008f28
Diffstat (limited to 'LUFA/Drivers/USB/Class')
| -rw-r--r-- | LUFA/Drivers/USB/Class/Common/HID.h | 42 | ||||
| -rw-r--r-- | LUFA/Drivers/USB/Class/Common/HIDParser.c | 21 | ||||
| -rw-r--r-- | LUFA/Drivers/USB/Class/Common/HIDParser.h | 8 | ||||
| -rw-r--r-- | LUFA/Drivers/USB/Class/Device/Audio.c | 4 | ||||
| -rw-r--r-- | LUFA/Drivers/USB/Class/Device/MassStorage.c | 12 | ||||
| -rw-r--r-- | LUFA/Drivers/USB/Class/Host/Audio.c | 2 | ||||
| -rw-r--r-- | LUFA/Drivers/USB/Class/Host/Audio.h | 14 | ||||
| -rw-r--r-- | LUFA/Drivers/USB/Class/Host/CDC.c | 2 | ||||
| -rw-r--r-- | LUFA/Drivers/USB/Class/Host/HID.c | 4 | ||||
| -rw-r--r-- | LUFA/Drivers/USB/Class/Host/MIDI.c | 2 | ||||
| -rw-r--r-- | LUFA/Drivers/USB/Class/Host/MassStorage.c | 25 | ||||
| -rw-r--r-- | LUFA/Drivers/USB/Class/Host/MassStorage.h | 3 | ||||
| -rw-r--r-- | LUFA/Drivers/USB/Class/Host/Printer.c | 2 | ||||
| -rw-r--r-- | LUFA/Drivers/USB/Class/Host/RNDIS.c | 2 | ||||
| -rw-r--r-- | LUFA/Drivers/USB/Class/Host/StillImage.c | 6 |
15 files changed, 76 insertions, 73 deletions
diff --git a/LUFA/Drivers/USB/Class/Common/HID.h b/LUFA/Drivers/USB/Class/Common/HID.h index 4e3c701c..74012b67 100644 --- a/LUFA/Drivers/USB/Class/Common/HID.h +++ b/LUFA/Drivers/USB/Class/Common/HID.h @@ -328,43 +328,46 @@ #define HID_KEYBOARD_SC_RIGHT_GUI 0xE7 //@} - /** \name Standard HID Device Report Descriptors */ + /** \name Common HID Device Report Descriptors */ //@{ /** \hideinitializer - * A list of HID report item array elements that describe a typical HID USB Joystick. The resulting report descriptor - * is structured according to the following layout: + * A list of HID report item array elements that describe a typical HID USB Joystick. The resulting report + * descriptor is structured according to the following layout: * * \code * struct * { - * uintA_t Buttons; // Pressed buttons bitmask * intB_t X; // Signed X axis value * intB_t Y; // Signed Y axis value + * int8_t Z; // Signed Z axis value + * // Additional axis elements here + * uintA_t Buttons; // Pressed buttons bitmask * } Joystick_Report; * \endcode * * Where \c uintA_t is a type large enough to hold one bit per button, and \c intB_t is a type large enough to hold the * ranges of the signed \c MinAxisVal and \c MaxAxisVal values. * - * \param[in] MinAxisVal Minimum X/Y logical axis value. - * \param[in] MaxAxisVal Maximum X/Y logical axis value. - * \param[in] MinPhysicalVal Minimum X/Y physical axis value, for movement resolution calculations. - * \param[in] MaxPhysicalVal Maximum X/Y physical axis value, for movement resolution calculations. - * \param[in] Buttons Total number of buttons in the device. + * \param[in] NumAxis Number of axis in the joystick (8-bit) + * \param[in] MinAxisVal Minimum logical axis value (16-bit). + * \param[in] MaxAxisVal Maximum logical axis value (16-bit). + * \param[in] MinPhysicalVal Minimum physical axis value, for movement resolution calculations (16-bit). + * \param[in] MaxPhysicalVal Maximum physical axis value, for movement resolution calculations (16-bit). + * \param[in] Buttons Total number of buttons in the device (8-bit). */ - #define HID_DESCRIPTOR_JOYSTICK(MinAxisVal, MaxAxisVal, MinPhysicalVal, MaxPhysicalVal, Buttons) \ + #define HID_DESCRIPTOR_JOYSTICK(NumAxis, MinAxisVal, MaxAxisVal, MinPhysicalVal, MaxPhysicalVal, Buttons) \ HID_RI_USAGE_PAGE(8, 0x01), \ HID_RI_USAGE(8, 0x04), \ HID_RI_COLLECTION(8, 0x01), \ HID_RI_USAGE(8, 0x01), \ HID_RI_COLLECTION(8, 0x00), \ - HID_RI_USAGE(8, 0x30), \ - HID_RI_USAGE(8, 0x31), \ + HID_RI_USAGE_MINIMUM(8, 0x30), \ + HID_RI_USAGE_MAXIMUM(8, (0x30 + (NumAxis - 1))), \ HID_RI_LOGICAL_MINIMUM(16, MinAxisVal), \ HID_RI_LOGICAL_MAXIMUM(16, MaxAxisVal), \ HID_RI_PHYSICAL_MINIMUM(16, MinPhysicalVal), \ HID_RI_PHYSICAL_MAXIMUM(16, MaxPhysicalVal), \ - HID_RI_REPORT_COUNT(8, 0x02), \ + HID_RI_REPORT_COUNT(8, NumAxis), \ HID_RI_REPORT_SIZE(8, ((((MinAxisVal >= -0xFF) && (MaxAxisVal <= 0xFF)) ? 8 : 16))), \ HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \ HID_RI_END_COLLECTION(0), \ @@ -395,8 +398,7 @@ * } Keyboard_Report; * \endcode * - * \param[in] MaxKeys Number of simultaneous keys that can be reported at the one time (a value between 1 and - * (ENDPOINT_SIZE - 2) ). + * \param[in] MaxKeys Number of simultaneous keys that can be reported at the one time (8-bit). */ #define HID_DESCRIPTOR_KEYBOARD(MaxKeys) \ HID_RI_USAGE_PAGE(8, 0x01), \ @@ -449,11 +451,11 @@ * Where \c intA_t is a type large enough to hold one bit per button, and \c intB_t is a type large enough to hold the * ranges of the signed \c MinAxisVal and \c MaxAxisVal values. * - * \param[in] MinAxisVal Minimum X/Y logical axis value. - * \param[in] MaxAxisVal Maximum X/Y logical axis value. - * \param[in] MinPhysicalVal Minimum X/Y physical axis value, for movement resolution calculations. - * \param[in] MaxPhysicalVal Maximum X/Y physical axis value, for movement resolution calculations. - * \param[in] Buttons Total number of buttons in the device. + * \param[in] MinAxisVal Minimum X/Y logical axis value (16-bit). + * \param[in] MaxAxisVal Maximum X/Y logical axis value (16-bit). + * \param[in] MinPhysicalVal Minimum X/Y physical axis value, for movement resolution calculations (16-bit). + * \param[in] MaxPhysicalVal Maximum X/Y physical axis value, for movement resolution calculations (16-bit). + * \param[in] Buttons Total number of buttons in the device (8-bit). * \param[in] AbsoluteCoords Boolean true to use absolute X/Y coordinates (e.g. touchscreen). */ #define HID_DESCRIPTOR_MOUSE(MinAxisVal, MaxAxisVal, MinPhysicalVal, MaxPhysicalVal, Buttons, AbsoluteCoords) \ diff --git a/LUFA/Drivers/USB/Class/Common/HIDParser.c b/LUFA/Drivers/USB/Class/Common/HIDParser.c index bd0937ba..903b039d 100644 --- a/LUFA/Drivers/USB/Class/Common/HIDParser.c +++ b/LUFA/Drivers/USB/Class/Common/HIDParser.c @@ -255,19 +255,16 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData, CurrReportIDInfo->ReportSizeBits[NewReportItem.ItemType] += CurrStateTable->Attributes.BitSize; - if (ParserData->LargestReportSizeBits < NewReportItem.BitOffset) - ParserData->LargestReportSizeBits = NewReportItem.BitOffset; + ParserData->LargestReportSizeBits = MAX(ParserData->LargestReportSizeBits, CurrReportIDInfo->ReportSizeBits[NewReportItem.ItemType]); - if (!(ReportItemData & HID_IOF_CONSTANT) && CALLBACK_HIDParser_FilterHIDReportItem(&NewReportItem)) - { - if (ParserData->TotalReportItems == HID_MAX_REPORTITEMS) - return HID_PARSE_InsufficientReportItems; + if (ParserData->TotalReportItems == HID_MAX_REPORTITEMS) + return HID_PARSE_InsufficientReportItems; - memcpy(&ParserData->ReportItems[ParserData->TotalReportItems], - &NewReportItem, sizeof(HID_ReportItem_t)); + memcpy(&ParserData->ReportItems[ParserData->TotalReportItems], + &NewReportItem, sizeof(HID_ReportItem_t)); - ParserData->TotalReportItems++; - } + if (!(ReportItemData & HID_IOF_CONSTANT) && CALLBACK_HIDParser_FilterHIDReportItem(&NewReportItem)) + ParserData->TotalReportItems++; } break; @@ -291,7 +288,7 @@ bool USB_GetHIDReportItemInfo(const uint8_t* ReportData, HID_ReportItem_t* const ReportItem) { if (ReportItem == NULL) - return false; + return false; uint16_t DataBitsRem = ReportItem->Attributes.BitSize; uint16_t CurrentBit = ReportItem->BitOffset; @@ -324,7 +321,7 @@ void USB_SetHIDReportItemInfo(uint8_t* ReportData, HID_ReportItem_t* const ReportItem) { if (ReportItem == NULL) - return; + return; uint16_t DataBitsRem = ReportItem->Attributes.BitSize; uint16_t CurrentBit = ReportItem->BitOffset; diff --git a/LUFA/Drivers/USB/Class/Common/HIDParser.h b/LUFA/Drivers/USB/Class/Common/HIDParser.h index 7b9dd9db..e4912133 100644 --- a/LUFA/Drivers/USB/Class/Common/HIDParser.h +++ b/LUFA/Drivers/USB/Class/Common/HIDParser.h @@ -295,7 +295,7 @@ * \returns Boolean \c true if the item to retrieve was located in the given report, \c false otherwise. */ bool USB_GetHIDReportItemInfo(const uint8_t* ReportData, - HID_ReportItem_t* const ReportItem) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); + HID_ReportItem_t* const ReportItem) ATTR_NON_NULL_PTR_ARG(1); /** Retrieves the given report item's value out of the \c Value member of the report item's * \ref HID_ReportItem_t structure and places it into the correct position in the HID report @@ -311,7 +311,7 @@ * \param[in] ReportItem Pointer to the report item of interest in a \ref HID_ReportInfo_t ReportItem array. */ void USB_SetHIDReportItemInfo(uint8_t* ReportData, - HID_ReportItem_t* const ReportItem) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); + HID_ReportItem_t* const ReportItem) ATTR_NON_NULL_PTR_ARG(1); /** Retrieves the size of a given HID report in bytes from its Report ID. * @@ -331,6 +331,10 @@ * \ref HID_ReportInfo_t structure. This can be used to filter only those items the application will be using, so that * no RAM is wasted storing the attributes for report items which will never be referenced by the application. * + * Report item pointers passed to this callback function may be cached by the user application for later use + * when processing report items. This provides faster report processing in the user application than would + * a search of the entire parsed report item table for each received or sent report. + * * \param[in] CurrentItem Pointer to the current report item for user checking. * * \return Boolean \c true if the item should be stored into the \ref HID_ReportInfo_t structure, \c false if diff --git a/LUFA/Drivers/USB/Class/Device/Audio.c b/LUFA/Drivers/USB/Class/Device/Audio.c index 0b47b34a..cdbe1a0d 100644 --- a/LUFA/Drivers/USB/Class/Device/Audio.c +++ b/LUFA/Drivers/USB/Class/Device/Audio.c @@ -52,10 +52,10 @@ void Audio_Device_ProcessControlRequest(USB_ClassInfo_Audio_Device_t* const Audi bool EndpointFilterMatch = false; EndpointFilterMatch |= (AudioInterfaceInfo->Config.DataINEndpointNumber && - ((uint8_t)USB_ControlRequest.wIndex == (ENDPOINT_DESCRIPTOR_DIR_IN | AudioInterfaceInfo->Config.DataINEndpointNumber))); + ((uint8_t)USB_ControlRequest.wIndex == (ENDPOINT_DIR_IN | AudioInterfaceInfo->Config.DataINEndpointNumber))); EndpointFilterMatch |= (AudioInterfaceInfo->Config.DataOUTEndpointNumber && - ((uint8_t)USB_ControlRequest.wIndex == (ENDPOINT_DESCRIPTOR_DIR_OUT | AudioInterfaceInfo->Config.DataOUTEndpointNumber))); + ((uint8_t)USB_ControlRequest.wIndex == (ENDPOINT_DIR_OUT | AudioInterfaceInfo->Config.DataOUTEndpointNumber))); if (!(EndpointFilterMatch)) return; diff --git a/LUFA/Drivers/USB/Class/Device/MassStorage.c b/LUFA/Drivers/USB/Class/Device/MassStorage.c index 4f1542ae..9d5ff7d2 100644 --- a/LUFA/Drivers/USB/Class/Device/MassStorage.c +++ b/LUFA/Drivers/USB/Class/Device/MassStorage.c @@ -165,10 +165,6 @@ static bool MS_Device_ReadInCommandBlock(USB_ClassInfo_MS_Device_t* const MSInte (sizeof(MS_CommandBlockWrapper_t) - 16), &BytesProcessed) == ENDPOINT_RWSTREAM_IncompleteTransfer) { - #if !defined(INTERRUPT_CONTROL_ENDPOINT) - USB_USBTask(); - #endif - if (MSInterfaceInfo->State.IsMassStoreReset) return false; } @@ -191,10 +187,6 @@ static bool MS_Device_ReadInCommandBlock(USB_ClassInfo_MS_Device_t* const MSInte MSInterfaceInfo->State.CommandBlock.SCSICommandLength, &BytesProcessed) == ENDPOINT_RWSTREAM_IncompleteTransfer) { - #if !defined(INTERRUPT_CONTROL_ENDPOINT) - USB_USBTask(); - #endif - if (MSInterfaceInfo->State.IsMassStoreReset) return false; } @@ -235,10 +227,6 @@ static void MS_Device_ReturnCommandStatus(USB_ClassInfo_MS_Device_t* const MSInt sizeof(MS_CommandStatusWrapper_t), &BytesProcessed) == ENDPOINT_RWSTREAM_IncompleteTransfer) { - #if !defined(INTERRUPT_CONTROL_ENDPOINT) - USB_USBTask(); - #endif - if (MSInterfaceInfo->State.IsMassStoreReset) return; } diff --git a/LUFA/Drivers/USB/Class/Host/Audio.c b/LUFA/Drivers/USB/Class/Host/Audio.c index adcf162b..d8665e4e 100644 --- a/LUFA/Drivers/USB/Class/Host/Audio.c +++ b/LUFA/Drivers/USB/Class/Host/Audio.c @@ -87,7 +87,7 @@ uint8_t Audio_Host_ConfigurePipes(USB_ClassInfo_Audio_Host_t* const AudioInterfa USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t); - if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN) + if ((EndpointData->EndpointAddress & ENDPOINT_DIR_MASK) == ENDPOINT_DIR_IN) DataINEndpoint = EndpointData; else DataOUTEndpoint = EndpointData; diff --git a/LUFA/Drivers/USB/Class/Host/Audio.h b/LUFA/Drivers/USB/Class/Host/Audio.h index 2c78b411..310d21c0 100644 --- a/LUFA/Drivers/USB/Class/Host/Audio.h +++ b/LUFA/Drivers/USB/Class/Host/Audio.h @@ -146,8 +146,6 @@ */ uint8_t Audio_Host_StartStopStreaming(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo, const bool EnableStreaming) ATTR_NON_NULL_PTR_ARG(1); - uint8_t Audio_Host_StartStopStreaming(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo, - const bool EnableStreaming); /** Gets or sets the specified property of a streaming audio class endpoint that is bound to a pipe in the given * class instance. @@ -169,12 +167,6 @@ const uint8_t EndpointControl, const uint16_t DataLength, void* const Data) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(6); - uint8_t Audio_Host_GetSetEndpointProperty(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo, - const uint8_t DataPipeIndex, - const uint8_t EndpointProperty, - const uint8_t EndpointControl, - const uint16_t DataLength, - void* const Data); /* Inline Functions: */ /** General management task for a given Audio host class interface, required for the correct operation of @@ -338,6 +330,8 @@ static inline void Audio_Host_WriteSample8(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo, const int8_t Sample) { + (void)AudioInterfaceInfo; + Pipe_Write_8(Sample); if (!(Pipe_IsReadWriteAllowed())) @@ -362,6 +356,8 @@ static inline void Audio_Host_WriteSample16(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo, const int16_t Sample) { + (void)AudioInterfaceInfo; + Pipe_Write_16_LE(Sample); if (!(Pipe_IsReadWriteAllowed())) @@ -386,6 +382,8 @@ static inline void Audio_Host_WriteSample24(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo, const int32_t Sample) { + (void)AudioInterfaceInfo; + Pipe_Write_16_LE(Sample); Pipe_Write_8(Sample >> 16); diff --git a/LUFA/Drivers/USB/Class/Host/CDC.c b/LUFA/Drivers/USB/Class/Host/CDC.c index 2e83365e..2b983599 100644 --- a/LUFA/Drivers/USB/Class/Host/CDC.c +++ b/LUFA/Drivers/USB/Class/Host/CDC.c @@ -86,7 +86,7 @@ uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t); - if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN) + if ((EndpointData->EndpointAddress & ENDPOINT_DIR_MASK) == ENDPOINT_DIR_IN) { if ((EndpointData->Attributes & EP_TYPE_MASK) == EP_TYPE_INTERRUPT) NotificationEndpoint = EndpointData; diff --git a/LUFA/Drivers/USB/Class/Host/HID.c b/LUFA/Drivers/USB/Class/Host/HID.c index 512480b3..bfbe6cf6 100644 --- a/LUFA/Drivers/USB/Class/Host/HID.c +++ b/LUFA/Drivers/USB/Class/Host/HID.c @@ -88,7 +88,7 @@ uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t); - if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN) + if ((EndpointData->EndpointAddress & ENDPOINT_DIR_MASK) == ENDPOINT_DIR_IN) DataINEndpoint = EndpointData; else DataOUTEndpoint = EndpointData; @@ -421,7 +421,7 @@ uint8_t HID_Host_SetReportProtocol(USB_ClassInfo_HID_Host_t* const HIDInterfaceI return HID_ERROR_LOGICAL | ErrorCode; } - uint8_t LargestReportSizeBits = HIDInterfaceInfo->Config.HIDParserData->LargestReportSizeBits; + uint16_t LargestReportSizeBits = HIDInterfaceInfo->Config.HIDParserData->LargestReportSizeBits; HIDInterfaceInfo->State.LargestReportSize = (LargestReportSizeBits >> 3) + ((LargestReportSizeBits & 0x07) != 0); return 0; diff --git a/LUFA/Drivers/USB/Class/Host/MIDI.c b/LUFA/Drivers/USB/Class/Host/MIDI.c index 944ecc3e..9f7bbd4e 100644 --- a/LUFA/Drivers/USB/Class/Host/MIDI.c +++ b/LUFA/Drivers/USB/Class/Host/MIDI.c @@ -72,7 +72,7 @@ uint8_t MIDI_Host_ConfigurePipes(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceI USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t); - if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN) + if ((EndpointData->EndpointAddress & ENDPOINT_DIR_MASK) == ENDPOINT_DIR_IN) DataINEndpoint = EndpointData; else DataOUTEndpoint = EndpointData; diff --git a/LUFA/Drivers/USB/Class/Host/MassStorage.c b/LUFA/Drivers/USB/Class/Host/MassStorage.c index 65ed6940..36503bf4 100644 --- a/LUFA/Drivers/USB/Class/Host/MassStorage.c +++ b/LUFA/Drivers/USB/Class/Host/MassStorage.c @@ -72,7 +72,7 @@ uint8_t MS_Host_ConfigurePipes(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t); - if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN) + if ((EndpointData->EndpointAddress & ENDPOINT_DIR_MASK) == ENDPOINT_DIR_IN) DataINEndpoint = EndpointData; else DataOUTEndpoint = EndpointData; @@ -226,8 +226,7 @@ static uint8_t MS_Host_WaitForDataReceived(USB_ClassInfo_MS_Host_t* const MSInte if (Pipe_IsStalled()) { - USB_Host_ClearPipeStall(MSInterfaceInfo->Config.DataOUTPipeNumber); - + USB_Host_ClearEndpointStall(Pipe_GetBoundEndpointAddress()); return PIPE_RWSTREAM_PipeStalled; } @@ -237,8 +236,7 @@ static uint8_t MS_Host_WaitForDataReceived(USB_ClassInfo_MS_Host_t* const MSInte if (Pipe_IsStalled()) { - USB_Host_ClearPipeStall(MSInterfaceInfo->Config.DataINPipeNumber); - + USB_Host_ClearEndpointStall(Pipe_GetBoundEndpointAddress()); return PIPE_RWSTREAM_PipeStalled; } @@ -328,6 +326,8 @@ static uint8_t MS_Host_GetReturnedStatus(USB_ClassInfo_MS_Host_t* const MSInterf uint8_t MS_Host_ResetMSInterface(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo) { + uint8_t ErrorCode; + USB_ControlRequest = (USB_Request_Header_t) { .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE), @@ -339,7 +339,20 @@ uint8_t MS_Host_ResetMSInterface(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo) Pipe_SelectPipe(PIPE_CONTROLPIPE); - return USB_Host_SendControlRequest(NULL); + if ((ErrorCode = USB_Host_SendControlRequest(NULL)) != HOST_SENDCONTROL_Successful) + return ErrorCode; + + Pipe_SelectPipe(MSInterfaceInfo->Config.DataINPipeNumber); + + if ((ErrorCode = USB_Host_ClearEndpointStall(Pipe_GetBoundEndpointAddress())) != HOST_SENDCONTROL_Successful) + return ErrorCode; + + Pipe_SelectPipe(MSInterfaceInfo->Config.DataOUTPipeNumber); + + if ((ErrorCode = USB_Host_ClearEndpointStall(Pipe_GetBoundEndpointAddress())) != HOST_SENDCONTROL_Successful) + return ErrorCode; + + return HOST_SENDCONTROL_Successful; } uint8_t MS_Host_GetMaxLUN(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, diff --git a/LUFA/Drivers/USB/Class/Host/MassStorage.h b/LUFA/Drivers/USB/Class/Host/MassStorage.h index 49762974..ff336f8c 100644 --- a/LUFA/Drivers/USB/Class/Host/MassStorage.h +++ b/LUFA/Drivers/USB/Class/Host/MassStorage.h @@ -148,7 +148,8 @@ void* ConfigDescriptorData) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3); /** Sends a MASS STORAGE RESET control request to the attached device, resetting the Mass Storage Interface - * and readying it for the next Mass Storage command. + * and readying it for the next Mass Storage command. This should be called after a failed SCSI request to + * ensure the attached Mass Storage device is ready to receive the next command. * * \param[in,out] MSInterfaceInfo Pointer to a structure containing a MS Class host configuration and state. * diff --git a/LUFA/Drivers/USB/Class/Host/Printer.c b/LUFA/Drivers/USB/Class/Host/Printer.c index 46dc1fa5..576dd36f 100644 --- a/LUFA/Drivers/USB/Class/Host/Printer.c +++ b/LUFA/Drivers/USB/Class/Host/Printer.c @@ -72,7 +72,7 @@ uint8_t PRNT_Host_ConfigurePipes(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceI USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t); - if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN) + if ((EndpointData->EndpointAddress & ENDPOINT_DIR_MASK) == ENDPOINT_DIR_IN) DataINEndpoint = EndpointData; else DataOUTEndpoint = EndpointData; diff --git a/LUFA/Drivers/USB/Class/Host/RNDIS.c b/LUFA/Drivers/USB/Class/Host/RNDIS.c index 2750260c..b942c536 100644 --- a/LUFA/Drivers/USB/Class/Host/RNDIS.c +++ b/LUFA/Drivers/USB/Class/Host/RNDIS.c @@ -88,7 +88,7 @@ uint8_t RNDIS_Host_ConfigurePipes(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfa USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t); - if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN) + if ((EndpointData->EndpointAddress & ENDPOINT_DIR_MASK) == ENDPOINT_DIR_IN) { if ((EndpointData->Attributes & EP_TYPE_MASK) == EP_TYPE_INTERRUPT) NotificationEndpoint = EndpointData; diff --git a/LUFA/Drivers/USB/Class/Host/StillImage.c b/LUFA/Drivers/USB/Class/Host/StillImage.c index be83497b..48aa8643 100644 --- a/LUFA/Drivers/USB/Class/Host/StillImage.c +++ b/LUFA/Drivers/USB/Class/Host/StillImage.c @@ -74,7 +74,7 @@ uint8_t SI_Host_ConfigurePipes(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t); - if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN) + if ((EndpointData->EndpointAddress & ENDPOINT_DIR_MASK) == ENDPOINT_DIR_IN) { if ((EndpointData->Attributes & EP_TYPE_MASK) == EP_TYPE_INTERRUPT) EventsEndpoint = EndpointData; @@ -254,7 +254,7 @@ uint8_t SI_Host_ReceiveBlockHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInf if (Pipe_IsStalled()) { - USB_Host_ClearPipeStall(SIInterfaceInfo->Config.DataOUTPipeNumber); + USB_Host_ClearEndpointStall(Pipe_GetBoundEndpointAddress()); return PIPE_RWSTREAM_PipeStalled; } @@ -264,7 +264,7 @@ uint8_t SI_Host_ReceiveBlockHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInf if (Pipe_IsStalled()) { - USB_Host_ClearPipeStall(SIInterfaceInfo->Config.DataINPipeNumber); + USB_Host_ClearEndpointStall(Pipe_GetBoundEndpointAddress()); return PIPE_RWSTREAM_PipeStalled; } |
