Make HID device class driver reselect the correct endpoint after the user callbacks...
[pub/USBasp.git] / Demos / Device / LowLevel / MassStorage / MassStorage.c
index cf276fd..c41b577 100644 (file)
@@ -37,7 +37,6 @@
 #define  INCLUDE_FROM_MASSSTORAGE_C\r
 #include "MassStorage.h"\r
 \r
-/* Global Variables */\r
 /** Structure to hold the latest Command Block Wrapper issued by the host, containing a SCSI command to execute. */\r
 CommandBlockWrapper_t  CommandBlock;\r
 \r
@@ -47,8 +46,9 @@ CommandStatusWrapper_t CommandStatus = { .Signature = CSW_SIGNATURE };
 /** Flag to asynchronously abort any in-progress data transfers upon the reception of a mass storage reset command. */\r
 volatile bool          IsMassStoreReset = false;\r
 \r
+\r
 /** Main program entry point. This routine configures the hardware required by the application, then\r
- *  starts the scheduler to run the application tasks.\r
+ *  enters a loop to run the application tasks in sequence.\r
  */\r
 int main(void)\r
 {\r
@@ -189,15 +189,15 @@ void MassStorage_Task(void)
                        if (CommandBlock.Flags & COMMAND_DIRECTION_DATA_IN)\r
                          Endpoint_SelectEndpoint(MASS_STORAGE_IN_EPNUM);\r
 \r
-                       /* Decode the received SCSI command */\r
-                       SCSI_DecodeSCSICommand();\r
+                       /* Decode the received SCSI command, set returned status code */\r
+                       CommandStatus.Status = SCSI_DecodeSCSICommand() ? Command_Pass : Command_Fail;          \r
 \r
                        /* Load in the CBW tag into the CSW to link them together */\r
                        CommandStatus.Tag = CommandBlock.Tag;\r
 \r
                        /* Load in the data residue counter into the CSW */\r
                        CommandStatus.DataTransferResidue = CommandBlock.DataTransferLength;\r
-\r
+                       \r
                        /* Stall the selected data pipe if command failed (if data is still to be transferred) */\r
                        if ((CommandStatus.Status == Command_Fail) && (CommandStatus.DataTransferResidue))\r
                          Endpoint_StallTransaction();\r