/*\r
LUFA Library\r
- Copyright (C) Dean Camera, 2009.\r
+ Copyright (C) Dean Camera, 2010.\r
\r
dean [at] fourwalledcubicle [dot] com\r
www.fourwalledcubicle.com\r
*/\r
\r
/*\r
- Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
-\r
- Permission to use, copy, modify, and distribute this software\r
- and its documentation for any purpose and without fee is hereby\r
- granted, provided that the above copyright notice appear in all\r
- copies and that both that the copyright notice and this\r
- permission notice and warranty disclaimer appear in supporting\r
- documentation, and that the name of the author not be used in\r
- advertising or publicity pertaining to distribution of the\r
+ Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this \r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in \r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting \r
+ documentation, and that the name of the author not be used in \r
+ advertising or publicity pertaining to distribution of the \r
software without specific, written prior permission.\r
\r
The author disclaim all warranties with regard to this\r
#define INCLUDE_FROM_MS_CLASS_DEVICE_C\r
#include "MassStorage.h"\r
\r
-static USB_ClassInfo_MS_Device_t* CallbackMSInterfaceInfo;\r
+static volatile bool* CallbackIsResetSource;\r
\r
void MS_Device_ProcessControlRequest(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)\r
{\r
\r
Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataOUTEndpointNumber);\r
Endpoint_ClearStall();\r
+ Endpoint_ResetDataToggle();\r
Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataINEndpointNumber);\r
Endpoint_ClearStall();\r
+ Endpoint_ResetDataToggle();\r
\r
MSInterfaceInfo->State.IsMassStoreReset = false;\r
}\r
{\r
Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataOUTEndpointNumber);\r
\r
- CallbackMSInterfaceInfo = MSInterfaceInfo;\r
- Endpoint_Read_Stream_LE(&MSInterfaceInfo->State.CommandBlock,\r
- (sizeof(MS_CommandBlockWrapper_t) - 16),\r
- StreamCallback_MS_Device_AbortOnMassStoreReset);\r
-\r
+ CallbackIsResetSource = &MSInterfaceInfo->State.IsMassStoreReset;\r
+ if (Endpoint_Read_Stream_LE(&MSInterfaceInfo->State.CommandBlock,\r
+ (sizeof(MS_CommandBlockWrapper_t) - 16),\r
+ StreamCallback_MS_Device_AbortOnMassStoreReset))\r
+ {\r
+ return false;\r
+ }\r
+ \r
if ((MSInterfaceInfo->State.CommandBlock.Signature != MS_CBW_SIGNATURE) ||\r
(MSInterfaceInfo->State.CommandBlock.LUN >= MSInterfaceInfo->Config.TotalLUNs) ||\r
(MSInterfaceInfo->State.CommandBlock.Flags & 0x1F) ||\r
return false;\r
}\r
\r
- CallbackMSInterfaceInfo = MSInterfaceInfo;\r
- Endpoint_Read_Stream_LE(&MSInterfaceInfo->State.CommandBlock.SCSICommandData,\r
- MSInterfaceInfo->State.CommandBlock.SCSICommandLength,\r
- StreamCallback_MS_Device_AbortOnMassStoreReset);\r
- \r
+ CallbackIsResetSource = &MSInterfaceInfo->State.IsMassStoreReset;\r
+ if (Endpoint_Read_Stream_LE(&MSInterfaceInfo->State.CommandBlock.SCSICommandData,\r
+ MSInterfaceInfo->State.CommandBlock.SCSICommandLength,\r
+ StreamCallback_MS_Device_AbortOnMassStoreReset))\r
+ {\r
+ return false;\r
+ }\r
+\r
Endpoint_ClearOUT();\r
\r
- return !(MSInterfaceInfo->State.IsMassStoreReset);\r
+ return true;\r
}\r
\r
static void MS_Device_ReturnCommandStatus(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)\r
\r
while (Endpoint_IsStalled())\r
{\r
+ #if !defined(INTERRUPT_CONTROL_ENDPOINT)\r
USB_USBTask();\r
+ #endif\r
\r
if (MSInterfaceInfo->State.IsMassStoreReset)\r
return;\r
\r
while (Endpoint_IsStalled())\r
{\r
+ #if !defined(INTERRUPT_CONTROL_ENDPOINT)\r
USB_USBTask();\r
-\r
+ #endif\r
+ \r
if (MSInterfaceInfo->State.IsMassStoreReset)\r
return;\r
}\r
\r
- CallbackMSInterfaceInfo = MSInterfaceInfo;\r
- Endpoint_Write_Stream_LE(&MSInterfaceInfo->State.CommandStatus, sizeof(MS_CommandStatusWrapper_t),\r
- StreamCallback_MS_Device_AbortOnMassStoreReset);\r
- \r
- Endpoint_ClearIN();\r
+ CallbackIsResetSource = &MSInterfaceInfo->State.IsMassStoreReset;\r
+ if (Endpoint_Write_Stream_LE(&MSInterfaceInfo->State.CommandStatus, sizeof(MS_CommandStatusWrapper_t),\r
+ StreamCallback_MS_Device_AbortOnMassStoreReset))\r
+ {\r
+ return;\r
+ }\r
\r
- if (MSInterfaceInfo->State.IsMassStoreReset)\r
- return;\r
+ Endpoint_ClearIN();\r
}\r
\r
static uint8_t StreamCallback_MS_Device_AbortOnMassStoreReset(void)\r
{\r
- MS_Device_USBTask(CallbackMSInterfaceInfo);\r
+ #if !defined(INTERRUPT_CONTROL_ENDPOINT)\r
+ USB_USBTask();\r
+ #endif\r
\r
- if (CallbackMSInterfaceInfo->State.IsMassStoreReset)\r
+ if (*CallbackIsResetSource)\r
return STREAMCALLBACK_Abort;\r
else\r
return STREAMCALLBACK_Continue;\r