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
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
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
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
#define LEDMASK_USB_BUSY (LEDS_LED2)\r
\r
/** Total number of logical drives within the device - must be non-zero. */\r
- #define TOTAL_LUNS 2\r
+ #define TOTAL_LUNS 1\r
\r
/** Blocks in each LUN, calculated from the total capacity divided by the total number of Logical Units in the device. */\r
#define LUN_MEDIA_BLOCKS (VIRTUAL_MEMORY_BLOCKS / TOTAL_LUNS)\r
if (!(LineEncoding.BaudRateBPS))\r
return -1;\r
\r
- while (!(Endpoint_IsReadWriteAllowed()))\r
- {\r
- if (USB_DeviceState != DEVICE_STATE_Configured)\r
- return -1;\r
- }\r
+ if (Endpoint_WaitUntilReady())\r
+ return -1;\r
\r
Endpoint_Write_Byte(c);\r
Endpoint_ClearIN();\r
\r
for (;;)\r
{\r
- while (!(Endpoint_IsReadWriteAllowed()))\r
- {\r
- if (USB_DeviceState != DEVICE_STATE_Configured)\r
- return -1;\r
- }\r
+ if (Endpoint_WaitUntilReady())\r
+ return -1;\r
\r
if (!(Endpoint_BytesInEndpoint()))\r
{\r
if (IsFull)\r
{\r
/* Wait until the endpoint is ready for another packet */\r
- while (!(Endpoint_IsINReady()))\r
- {\r
- if (USB_DeviceState == DEVICE_STATE_Unattached)\r
- return;\r
- }\r
+ Endpoint_WaitUntilReady();\r
\r
/* Send an empty packet to ensure that the host does not buffer data sent to it */\r
Endpoint_ClearIN();\r
Endpoint_ClearIN();\r
\r
/* Wait until the endpoint is ready for another packet */\r
- while (!(Endpoint_IsINReady()))\r
- {\r
- if (USB_DeviceState == DEVICE_STATE_Unattached)\r
- return;\r
- }\r
+ Endpoint_WaitUntilReady();\r
\r
/* Send an empty packet to ensure that the host does not buffer data sent to it */\r
Endpoint_ClearIN();\r
Endpoint_ClearIN();\r
\r
/* Wait until the endpoint is ready for the next packet */\r
- while (!(Endpoint_IsINReady()))\r
- {\r
- if (USB_DeviceState == DEVICE_STATE_Unattached)\r
- return;\r
- }\r
+ Endpoint_WaitUntilReady();\r
\r
/* Send an empty packet to prevent host buffering */\r
Endpoint_ClearIN();\r
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
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
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
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
/** Total number of Logical Units (drives) in the device. The total device capacity is shared equally between\r
* each drive - this can be set to any positive non-zero amount.\r
*/\r
- #define TOTAL_LUNS 2\r
+ #define TOTAL_LUNS 1\r
\r
/** Blocks in each LUN, calculated from the total capacity divided by the total number of Logical Units in the device. */\r
#define LUN_MEDIA_BLOCKS (VIRTUAL_MEMORY_BLOCKS / TOTAL_LUNS) \r
if ((Tx_Buffer.Elements) && LineEncoding.BaudRateBPS)\r
{\r
/* Wait until Serial Tx Endpoint Ready for Read/Write */\r
- while (!(Endpoint_IsReadWriteAllowed()))\r
- {\r
- if (USB_DeviceState == DEVICE_STATE_Unattached)\r
- return;\r
- }\r
+ Endpoint_WaitUntilReady();\r
\r
/* Write the bytes from the buffer to the endpoint while space is available */\r
while (Tx_Buffer.Elements && Endpoint_IsReadWriteAllowed())\r
if (IsFull && !(Tx_Buffer.Elements))\r
{\r
/* Wait until Serial Tx Endpoint Ready for Read/Write */\r
- while (!(Endpoint_IsReadWriteAllowed()))\r
- {\r
- if (USB_DeviceState == DEVICE_STATE_Unattached)\r
- return;\r
- }\r
+ Endpoint_WaitUntilReady();\r
\r
/* Send an empty packet to terminate the transfer */\r
Endpoint_ClearIN();\r
if (!(Endpoint_IsReadWriteAllowed()))\r
{\r
Endpoint_ClearIN();\r
-\r
- while (!(Endpoint_IsReadWriteAllowed()))\r
- {\r
- if (USB_DeviceState == DEVICE_STATE_Unattached)\r
- return;\r
- }\r
+ Endpoint_WaitUntilReady();\r
} \r
\r
Endpoint_ClearIN();\r
if (!(Endpoint_IsReadWriteAllowed()))\r
{\r
Endpoint_ClearIN();\r
- \r
- while (!(Endpoint_IsReadWriteAllowed()))\r
- {\r
- if (USB_DeviceState == DEVICE_STATE_Unattached)\r
- return; \r
- }\r
+ Endpoint_WaitUntilReady();\r
}\r
\r
Endpoint_Write_Byte(Data); \r
}\r
\r
#if defined(INTERRUPT_CONTROL_ENDPOINT)\r
-ISR(USB_COM_vect, ISR_NOBLOCK)\r
+ISR(USB_COM_vect, ISR_BLOCK)\r
{\r
uint8_t PrevSelectedEndpoint = Endpoint_GetCurrentEndpoint();\r
\r
\r
USB_INT_Clear(USB_INT_ENDPOINT_SETUP);\r
\r
- Endpoint_SelectEndpoint(PrevSelectedEndpoint); \r
+ Endpoint_SelectEndpoint(PrevSelectedEndpoint);\r
}\r
#endif\r