Fixed GenericHIDHost demo report write routine incorrect for control type requests...
[pub/USBasp.git] / Demos / Host / MassStorageHost / MassStoreCommands.c
index bf736e7..41c59dc 100644 (file)
@@ -88,7 +88,7 @@ static uint8_t MassStore_SendCommand(void)
          return ErrorCode;\r
 \r
        /* Send the data in the OUT pipe to the attached device */\r
-       Pipe_ClearCurrentBank();\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
@@ -117,7 +117,7 @@ static uint8_t MassStore_WaitForDataReceived(void)
        Pipe_Unfreeze();\r
 \r
        /* Wait until data received in the IN pipe */\r
-       while (!(Pipe_ReadWriteAllowed()))\r
+       while (!(Pipe_IsINReceived()))\r
        {\r
                /* Check to see if a new frame has been issued (1ms elapsed) */\r
                if (USB_INT_HasOccurred(USB_INT_HSOFI))\r
@@ -183,6 +183,9 @@ static uint8_t MassStore_SendReceiveData(void* BufferPtr)
                /* Read in the block data from the pipe */\r
                if ((ErrorCode = Pipe_Read_Stream_LE(BufferPtr, BytesRem)) != PIPE_RWSTREAM_ERROR_NoError)\r
                  return ErrorCode;\r
+\r
+               /* Acknowledge the packet */\r
+               Pipe_ClearIN();\r
        }\r
        else\r
        {\r
@@ -193,10 +196,10 @@ static uint8_t MassStore_SendReceiveData(void* BufferPtr)
                /* Write the block data to the pipe */\r
                if ((ErrorCode = Pipe_Write_Stream_LE(BufferPtr, BytesRem)) != PIPE_RWSTREAM_ERROR_NoError)\r
                  return ErrorCode;\r
+\r
+               /* Acknowledge the packet */\r
+               Pipe_ClearOUT();\r
        }\r
-       \r
-       /* Acknowledge the packet */\r
-       Pipe_ClearCurrentBank();\r
 \r
        /* Some buggy devices require a delay here before the pipe freezing or they will lock up */\r
        USB_Host_WaitMS(1);\r
@@ -216,8 +219,8 @@ 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 (MassStore_WaitForDataReceived() != NoError)\r
-         return;\r
+       if ((ErrorCode == MassStore_WaitForDataReceived()) != PIPE_RWSTREAM_ERROR_NoError)\r
+         return ErrorCode;\r
 \r
        /* Select the IN data pipe for data reception */\r
        Pipe_SelectPipe(MASS_STORE_DATA_IN_PIPE);\r
@@ -228,7 +231,7 @@ static uint8_t MassStore_GetReturnedStatus(void)
          return ErrorCode;\r
          \r
        /* Clear the data ready for next reception */\r
-       Pipe_ClearCurrentBank();\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