Added new ENDPOINT_*_BusSuspended error code to the Endpoint function, so that the stream functions early-abort if the bus is suspended before or during a transfer.

This commit is contained in:
Dean Camera 2010-05-03 07:41:22 +00:00
parent 5c0c0327d5
commit eed7d4df6a
9 changed files with 34 additions and 10 deletions

View file

@ -120,6 +120,8 @@ uint8_t Endpoint_WaitUntilReady(void)
if (USB_DeviceState == DEVICE_STATE_Unattached)
return ENDPOINT_READYWAIT_DeviceDisconnected;
else if (USB_DeviceState == DEVICE_STATE_Suspended)
return ENDPOINT_READYWAIT_BusSuspended;
else if (Endpoint_IsStalled())
return ENDPOINT_READYWAIT_EndpointStalled;

View file

@ -442,8 +442,12 @@
*/
ENDPOINT_READYWAIT_DeviceDisconnected = 2, /**< Device was disconnected from the host while
* waiting for the endpoint to become ready.
*/
ENDPOINT_READYWAIT_Timeout = 3, /**< The host failed to accept or send the next packet
*/
ENDPOINT_READYWAIT_BusSuspended = 3, /**< The USB bus has been suspended by the host and
* no USB endpoint traffic can occur until the bus
* has resumed.
*/
ENDPOINT_READYWAIT_Timeout = 4, /**< The host failed to accept or send the next packet
* within the software timeout period set by the
* \ref USB_STREAM_TIMEOUT_MS macro.
*/
@ -462,11 +466,15 @@
ENDPOINT_RWSTREAM_DeviceDisconnected = 2, /**< Device was disconnected from the host during
* the transfer.
*/
ENDPOINT_RWSTREAM_Timeout = 3, /**< The host failed to accept or send the next packet
ENDPOINT_RWSTREAM_BusSuspended = 3, /**< The USB bus has been suspended by the host and
* no USB endpoint traffic can occur until the bus
* has resumed.
*/
ENDPOINT_RWSTREAM_Timeout = 4, /**< The host failed to accept or send the next packet
* within the software timeout period set by the
* \ref USB_STREAM_TIMEOUT_MS macro.
*/
ENDPOINT_RWSTREAM_CallbackAborted = 4, /**< Indicates that the stream's callback function
ENDPOINT_RWSTREAM_CallbackAborted = 5, /**< Indicates that the stream's callback function
* aborted the transfer early.
*/
};
@ -482,6 +490,10 @@
ENDPOINT_RWCSTREAM_DeviceDisconnected = 2, /**< Device was disconnected from the host during
* the transfer.
*/
ENDPOINT_RWCSTREAM_BusSuspended = 3, /**< The USB bus has been suspended by the host and
* no USB endpoint traffic can occur until the bus
* has resumed.
*/
};
/* Inline Functions: */

View file

@ -12,6 +12,8 @@ uint8_t TEMPLATE_FUNC_NAME (void* Buffer, uint16_t Length)
if (USB_DeviceState == DEVICE_STATE_Unattached)
return ENDPOINT_RWCSTREAM_DeviceDisconnected;
else if (USB_DeviceState == DEVICE_STATE_Suspended)
return ENDPOINT_RWCSTREAM_BusSuspended;
if (Endpoint_IsOUTReceived())
{
@ -29,6 +31,8 @@ uint8_t TEMPLATE_FUNC_NAME (void* Buffer, uint16_t Length)
{
if (USB_DeviceState == DEVICE_STATE_Unattached)
return ENDPOINT_RWCSTREAM_DeviceDisconnected;
else if (USB_DeviceState == DEVICE_STATE_Suspended)
return ENDPOINT_RWCSTREAM_BusSuspended;
}
return ENDPOINT_RWCSTREAM_NoError;

View file

@ -18,6 +18,8 @@ uint8_t TEMPLATE_FUNC_NAME (const void* Buffer, uint16_t Length)
if (USB_DeviceState == DEVICE_STATE_Unattached)
return ENDPOINT_RWCSTREAM_DeviceDisconnected;
else if (USB_DeviceState == DEVICE_STATE_Suspended)
return ENDPOINT_RWCSTREAM_BusSuspended;
if (Endpoint_IsINReady())
{
@ -38,7 +40,9 @@ uint8_t TEMPLATE_FUNC_NAME (const void* Buffer, uint16_t Length)
while (!(Endpoint_IsOUTReceived()))
{
if (USB_DeviceState == DEVICE_STATE_Unattached)
return ENDPOINT_RWCSTREAM_DeviceDisconnected;
return ENDPOINT_RWCSTREAM_DeviceDisconnected;
else if (USB_DeviceState == DEVICE_STATE_Suspended)
return ENDPOINT_RWCSTREAM_BusSuspended;
}
return ENDPOINT_RWCSTREAM_NoError;