Fixed SPI driver init function not clearing SPI2X bit when not needed.
[pub/USBasp.git] / Demos / Host / MassStorageHost / MassStoreCommands.c
index 4ebc67a..16f1d60 100644 (file)
@@ -89,10 +89,9 @@ static uint8_t MassStore_SendCommand(void)
 \r
        /* Send the data in the OUT pipe to the attached device */\r
        Pipe_ClearOUT();\r
-\r
-       /* Some buggy devices require a delay here before the pipe freezing or they will lock up */\r
-       USB_Host_WaitMS(1);\r
        \r
+       while(!(Pipe_IsOUTReady()));\r
+\r
        /* Freeze pipe after use */\r
        Pipe_Freeze();\r
        \r
@@ -199,10 +198,9 @@ static uint8_t MassStore_SendReceiveData(void* BufferPtr)
 \r
                /* Acknowledge the packet */\r
                Pipe_ClearOUT();\r
+               \r
+               while (!(Pipe_IsOUTReady()));\r
        }\r
-\r
-       /* Some buggy devices require a delay here before the pipe freezing or they will lock up */\r
-       USB_Host_WaitMS(1);\r
        \r
        /* Freeze used pipe after use */\r
        Pipe_Freeze();\r
@@ -219,7 +217,7 @@ static uint8_t MassStore_GetReturnedStatus(void)
        uint8_t ErrorCode = PIPE_RWSTREAM_ERROR_NoError;\r
 \r
        /* If an error in the command ocurred, abort */\r
-       if ((ErrorCode == MassStore_WaitForDataReceived()) != PIPE_RWSTREAM_ERROR_NoError)\r
+       if ((ErrorCode = MassStore_WaitForDataReceived()) != PIPE_RWSTREAM_ERROR_NoError)\r
          return ErrorCode;\r
 \r
        /* Select the IN data pipe for data reception */\r
@@ -232,9 +230,6 @@ static uint8_t MassStore_GetReturnedStatus(void)
          \r
        /* Clear the data ready for next reception */\r
        Pipe_ClearIN();\r
-\r
-       /* Some buggy devices require a delay here before the pipe freezing or they will lock up */\r
-       USB_Host_WaitMS(1);\r
        \r
        /* Freeze the IN pipe after use */\r
        Pipe_Freeze();\r
@@ -587,7 +582,7 @@ uint8_t MassStore_ReadCapacity(const uint8_t LUNIndex, SCSI_Capacity_t* const Ca
                                {\r
                                        .Signature          = CBW_SIGNATURE,\r
                                        .Tag                = MassStore_Tag,\r
-                                       .DataTransferLength = 8,\r
+                                       .DataTransferLength = sizeof(SCSI_Capacity_t),\r
                                        .Flags              = COMMAND_DIRECTION_DATA_IN,\r
                                        .LUN                = LUNIndex,\r
                                        .SCSICommandLength  = 10\r
@@ -680,7 +675,7 @@ uint8_t MassStore_PreventAllowMediumRemoval(const uint8_t LUNIndex, const bool P
        MassStore_SendCommand();\r
 \r
        /* Read in the returned CSW from the device */\r
-       if ((ReturnCode = MassStore_GetReturnedStatus()) != PIPE_RWSTREAM_ERROR_NoError)\r
+       if ((ReturnCode = MassStore_GetReturnedStatus()))\r
        {\r
                Pipe_Freeze();\r
                return ReturnCode;\r