Add CDC Host class driver EVENT_CDC_Host_ControLineStateChanged() event.
[pub/USBasp.git] / Demos / Device / LowLevel / MassStorage / Lib / DataflashManager.c
index 2bd03c9..9cd0279 100644 (file)
@@ -68,11 +68,8 @@ void DataflashManager_WriteBlocks(const uint32_t BlockAddress, uint16_t TotalBlo
        Dataflash_SendAddressBytes(0, CurrDFPageByte);\r
 \r
        /* Wait until endpoint is ready before continuing */\r
-       while (!(Endpoint_IsReadWriteAllowed()))\r
-       {\r
-               if (USB_DeviceState == DEVICE_STATE_Unattached)\r
-                 return;\r
-       }\r
+       if (Endpoint_WaitUntilReady())\r
+         return;\r
        \r
        while (TotalBlocks)\r
        {\r
@@ -88,11 +85,8 @@ void DataflashManager_WriteBlocks(const uint32_t BlockAddress, uint16_t TotalBlo
                                Endpoint_ClearOUT();\r
                                \r
                                /* Wait until the host has sent another packet */\r
-                               while (!(Endpoint_IsReadWriteAllowed()))\r
-                               {\r
-                                       if (USB_DeviceState == DEVICE_STATE_Unattached)\r
-                                         return;\r
-                               }\r
+                               if (Endpoint_WaitUntilReady())\r
+                                 return;\r
                        }\r
 \r
                        /* Check if end of dataflash page reached */\r
@@ -203,11 +197,8 @@ void DataflashManager_ReadBlocks(const uint32_t BlockAddress, uint16_t TotalBloc
        Dataflash_SendByte(0x00);\r
        \r
        /* Wait until endpoint is ready before continuing */\r
-       while (!(Endpoint_IsReadWriteAllowed()))\r
-       {\r
-               if (USB_DeviceState == DEVICE_STATE_Unattached)\r
-                 return;\r
-       }\r
+       if (Endpoint_WaitUntilReady())\r
+         return;\r
        \r
        while (TotalBlocks)\r
        {\r
@@ -223,11 +214,8 @@ void DataflashManager_ReadBlocks(const uint32_t BlockAddress, uint16_t TotalBloc
                                Endpoint_ClearIN();\r
                                \r
                                /* Wait until the endpoint is ready for more data */\r
-                               while (!(Endpoint_IsReadWriteAllowed()))\r
-                               {\r
-                                       if (USB_DeviceState == DEVICE_STATE_Unattached)\r
-                                         return;\r
-                               }\r
+                               if (Endpoint_WaitUntilReady())\r
+                                 return;\r
                        }\r
                        \r
                        /* Check if end of dataflash page reached */\r