\r
USB_INT_Clear(USB_INT_SOFI);\r
\r
- while (!(Endpoint_ReadWriteAllowed()))\r
+ for (;;)\r
{\r
+ if (Endpoint_GetEndpointDirection() == ENDPOINT_DIR_IN)\r
+ {\r
+ if (Endpoint_IsINReady())\r
+ return ENDPOINT_READYWAIT_NoError;\r
+ }\r
+ else\r
+ {\r
+ if (Endpoint_IsOUTReceived())\r
+ return ENDPOINT_READYWAIT_NoError; \r
+ }\r
+ \r
if (!(USB_IsConnected))\r
return ENDPOINT_READYWAIT_DeviceDisconnected;\r
else if (Endpoint_IsStalled())\r
return ENDPOINT_READYWAIT_Timeout;\r
}\r
}\r
- \r
- return ENDPOINT_READYWAIT_NoError;\r
}\r
\r
uint8_t Endpoint_Discard_Stream(uint16_t Length\r
\r
while (Length--)\r
{\r
- if (!(Endpoint_ReadWriteAllowed()))\r
+ if (!(Endpoint_IsReadWriteAllowed()))\r
{\r
- Endpoint_ClearCurrentBank();\r
+ Endpoint_ClearOUT();\r
\r
#if !defined(NO_STREAM_CALLBACKS)\r
if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort))\r
if ((ErrorCode = Endpoint_WaitUntilReady()))\r
return ErrorCode;\r
}\r
-\r
- Endpoint_Discard_Byte();\r
+ else\r
+ {\r
+ Endpoint_Discard_Byte();\r
+ }\r
}\r
\r
return ENDPOINT_RWSTREAM_ERROR_NoError;\r
\r
while (Length--)\r
{\r
- if (!(Endpoint_ReadWriteAllowed()))\r
+ if (!(Endpoint_IsReadWriteAllowed()))\r
{\r
- Endpoint_ClearCurrentBank();\r
+ Endpoint_ClearIN();\r
\r
#if !defined(NO_STREAM_CALLBACKS)\r
if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort))\r
if ((ErrorCode = Endpoint_WaitUntilReady()))\r
return ErrorCode;\r
}\r
-\r
- Endpoint_Write_Byte(*(DataStream++));\r
+ else\r
+ {\r
+ Endpoint_Write_Byte(*(DataStream++));\r
+ }\r
}\r
\r
return ENDPOINT_RWSTREAM_ERROR_NoError;\r
\r
while (Length--)\r
{\r
- if (!(Endpoint_ReadWriteAllowed()))\r
+ if (!(Endpoint_IsReadWriteAllowed()))\r
{\r
- Endpoint_ClearCurrentBank();\r
+ Endpoint_ClearIN();\r
\r
#if !defined(NO_STREAM_CALLBACKS)\r
if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort))\r
if ((ErrorCode = Endpoint_WaitUntilReady()))\r
return ErrorCode;\r
}\r
-\r
- Endpoint_Write_Byte(*(DataStream--));\r
+ else\r
+ {\r
+ Endpoint_Write_Byte(*(DataStream--));\r
+ }\r
}\r
\r
return ENDPOINT_RWSTREAM_ERROR_NoError;\r
\r
while (Length--)\r
{\r
- if (!(Endpoint_ReadWriteAllowed()))\r
+ if (!(Endpoint_IsReadWriteAllowed()))\r
{\r
- Endpoint_ClearCurrentBank();\r
+ Endpoint_ClearOUT();\r
\r
#if !defined(NO_STREAM_CALLBACKS)\r
if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort))\r
if ((ErrorCode = Endpoint_WaitUntilReady()))\r
return ErrorCode;\r
}\r
- \r
- *(DataStream++) = Endpoint_Read_Byte();\r
+ else\r
+ {\r
+ *(DataStream++) = Endpoint_Read_Byte();\r
+ }\r
}\r
\r
return ENDPOINT_RWSTREAM_ERROR_NoError;\r
\r
while (Length--)\r
{\r
- if (!(Endpoint_ReadWriteAllowed()))\r
+ if (!(Endpoint_IsReadWriteAllowed()))\r
{\r
- Endpoint_ClearCurrentBank();\r
+ Endpoint_ClearOUT();\r
\r
#if !defined(NO_STREAM_CALLBACKS)\r
if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort))\r
if ((ErrorCode = Endpoint_WaitUntilReady()))\r
return ErrorCode;\r
}\r
- \r
- *(DataStream--) = Endpoint_Read_Byte();\r
+ else\r
+ {\r
+ *(DataStream--) = Endpoint_Read_Byte();\r
+ }\r
}\r
\r
return ENDPOINT_RWSTREAM_ERROR_NoError;\r
uint8_t* DataStream = (uint8_t*)Buffer;\r
bool SendZLP = true;\r
\r
- while (Length && !(Endpoint_IsSetupOUTReceived()))\r
+ while (Length && !(Endpoint_IsOUTReceived()))\r
{\r
- while (!(Endpoint_IsSetupINReady()));\r
+ while (!(Endpoint_IsINReady()));\r
\r
while (Length && (Endpoint_BytesInEndpoint() < USB_ControlEndpointSize))\r
{\r
}\r
\r
SendZLP = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize);\r
- Endpoint_ClearSetupIN();\r
+ Endpoint_ClearControlIN();\r
}\r
\r
- if (Endpoint_IsSetupOUTReceived())\r
+ if (Endpoint_IsOUTReceived())\r
return ENDPOINT_RWCSTREAM_ERROR_HostAborted;\r
\r
if (SendZLP)\r
{\r
- while (!(Endpoint_IsSetupINReady()));\r
- Endpoint_ClearSetupIN();\r
+ while (!(Endpoint_IsINReady()));\r
+ Endpoint_ClearControlIN();\r
}\r
\r
- while (!(Endpoint_IsSetupOUTReceived()));\r
+ while (!(Endpoint_IsOUTReceived()));\r
\r
return ENDPOINT_RWCSTREAM_ERROR_NoError;\r
}\r
uint8_t* DataStream = (uint8_t*)(Buffer + Length - 1);\r
bool SendZLP = true;\r
\r
- while (Length && !(Endpoint_IsSetupOUTReceived()))\r
+ while (Length && !(Endpoint_IsOUTReceived()))\r
{\r
- while (!(Endpoint_IsSetupINReady()));\r
+ while (!(Endpoint_IsINReady()));\r
\r
while (Length && (Endpoint_BytesInEndpoint() < USB_ControlEndpointSize))\r
{\r
}\r
\r
SendZLP = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize);\r
- Endpoint_ClearSetupIN();\r
+ Endpoint_ClearControlIN();\r
}\r
\r
- if (Endpoint_IsSetupOUTReceived())\r
+ if (Endpoint_IsOUTReceived())\r
return ENDPOINT_RWCSTREAM_ERROR_HostAborted;\r
\r
if (SendZLP)\r
{\r
- while (!(Endpoint_IsSetupINReady()));\r
- Endpoint_ClearSetupIN();\r
+ while (!(Endpoint_IsINReady()));\r
+ Endpoint_ClearControlIN();\r
}\r
\r
- while (!(Endpoint_IsSetupOUTReceived()));\r
+ while (!(Endpoint_IsOUTReceived()));\r
\r
return ENDPOINT_RWCSTREAM_ERROR_NoError;\r
}\r
\r
while (Length)\r
{\r
- while (!(Endpoint_IsSetupOUTReceived()));\r
+ while (!(Endpoint_IsOUTReceived()));\r
\r
while (Length && Endpoint_BytesInEndpoint())\r
{\r
Length--;\r
}\r
\r
- Endpoint_ClearSetupOUT();\r
+ Endpoint_ClearControlOUT();\r
}\r
\r
- while (!(Endpoint_IsSetupINReady()));\r
+ while (!(Endpoint_IsINReady()));\r
\r
return ENDPOINT_RWCSTREAM_ERROR_NoError;\r
}\r
\r
while (Length)\r
{\r
- while (!(Endpoint_IsSetupOUTReceived()));\r
+ while (!(Endpoint_IsOUTReceived()));\r
\r
while (Length && Endpoint_BytesInEndpoint())\r
{\r
Length--;\r
}\r
\r
- Endpoint_ClearSetupOUT();\r
+ Endpoint_ClearControlOUT();\r
}\r
\r
- while (!(Endpoint_IsSetupINReady()));\r
+ while (!(Endpoint_IsINReady()));\r
\r
return ENDPOINT_RWCSTREAM_ERROR_NoError;\r
}\r