Added PRNT_Host_SendByte() and PRNT_Host_Flush() functions to the Host mode Printer...
[pub/USBasp.git] / LUFA / Drivers / USB / Class / Host / MassStorage.c
index 82746cd..dfa954c 100644 (file)
@@ -166,19 +166,21 @@ static uint8_t MS_Host_SendCommand(USB_ClassInfo_MS_Host_t* const MSInterfaceInf
 
 static uint8_t MS_Host_WaitForDataReceived(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo)
 {
-       uint16_t TimeoutMSRem = COMMAND_DATA_TIMEOUT_MS;
+       uint16_t TimeoutMSRem        = COMMAND_DATA_TIMEOUT_MS;
+       uint16_t PreviousFrameNumber = USB_Host_GetFrameNumber();
 
        Pipe_SelectPipe(MSInterfaceInfo->Config.DataINPipeNumber);
        Pipe_Unfreeze();
 
        while (!(Pipe_IsINReceived()))
        {
-               if (USB_INT_HasOccurred(USB_INT_HSOFI))
+               uint16_t CurrentFrameNumber = USB_Host_GetFrameNumber();
+               
+               if (CurrentFrameNumber != PreviousFrameNumber)
                {
-                       USB_INT_Clear(USB_INT_HSOFI);
-                       TimeoutMSRem--;
+                       PreviousFrameNumber = CurrentFrameNumber;
 
-                       if (!(TimeoutMSRem))
+                       if (!(TimeoutMSRem--))
                          return PIPE_RWSTREAM_Timeout;
                }
        
@@ -546,7 +548,7 @@ uint8_t MS_Host_ReadDeviceBlocks(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
                                        (BlockAddress >> 16),
                                        (BlockAddress >> 8),
                                        (BlockAddress & 0xFF),  // LSB of Block Address
-                                       0x00,                   // Unused (reserved)
+                                       0x00,                   // Reserved
                                        0x00,                   // MSB of Total Blocks to Read
                                        Blocks,                 // LSB of Total Blocks to Read
                                        0x00                    // Unused (control)
@@ -590,7 +592,7 @@ uint8_t MS_Host_WriteDeviceBlocks(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo
                                        (BlockAddress >> 16),
                                        (BlockAddress >> 8),
                                        (BlockAddress & 0xFF),  // LSB of Block Address
-                                       0x00,                   // Unused (reserved)
+                                       0x00,                   // Reserved
                                        0x00,                   // MSB of Total Blocks to Write
                                        Blocks,                 // LSB of Total Blocks to Write
                                        0x00                    // Unused (control)