From eed7d4df6ae3da8616ec294d303ceea26078c707 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Mon, 3 May 2010 07:41:22 +0000 Subject: 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. --- LUFA/Drivers/USB/LowLevel/Endpoint.c | 2 ++ LUFA/Drivers/USB/LowLevel/Endpoint.h | 20 ++++++++++++++++---- .../LowLevel/Template/Template_Endpoint_Control_R.c | 4 ++++ .../LowLevel/Template/Template_Endpoint_Control_W.c | 6 +++++- LUFA/ManPages/ChangeLog.txt | 4 +++- LUFA/ManPages/FutureChanges.txt | 1 - LUFA/ManPages/LUFAPoweredProjects.txt | 1 + 7 files changed, 31 insertions(+), 7 deletions(-) (limited to 'LUFA') diff --git a/LUFA/Drivers/USB/LowLevel/Endpoint.c b/LUFA/Drivers/USB/LowLevel/Endpoint.c index 81fef1c2e..5560c8092 100644 --- a/LUFA/Drivers/USB/LowLevel/Endpoint.c +++ b/LUFA/Drivers/USB/LowLevel/Endpoint.c @@ -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; diff --git a/LUFA/Drivers/USB/LowLevel/Endpoint.h b/LUFA/Drivers/USB/LowLevel/Endpoint.h index b18ff456d..93412f500 100644 --- a/LUFA/Drivers/USB/LowLevel/Endpoint.h +++ b/LUFA/Drivers/USB/LowLevel/Endpoint.h @@ -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: */ diff --git a/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_R.c b/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_R.c index 6948296a5..92b5396d7 100644 --- a/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_R.c +++ b/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_R.c @@ -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; diff --git a/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_W.c b/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_W.c index 7868060fe..8a5be11f1 100644 --- a/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_W.c +++ b/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_W.c @@ -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; diff --git a/LUFA/ManPages/ChangeLog.txt b/LUFA/ManPages/ChangeLog.txt index 81e718965..8d5a7ab6a 100644 --- a/LUFA/ManPages/ChangeLog.txt +++ b/LUFA/ManPages/ChangeLog.txt @@ -13,6 +13,8 @@ * - Added new Relay Controller Board project (thanks to OBinou) * - Added board hardware driver support for the Teensy, USBTINY MKII, Benito and JM-DB-U2 lines of third party USB AVR boards * - Added new ATTR_NO_INIT variable attribute for global variables that should not be automatically cleared on startup + * - 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 * * Changed: * - AVRISP programmer project now has a more robust timeout system, allowing for an increase of the software USART speed @@ -32,7 +34,7 @@ * for them to be enabled (thanks to Andrei Krainev) * - The Audio_Device_IsSampleReceived() and Audio_Device_IsReadyForNextSample() functions are now inline, to reduce overhead * - Removed the cast to uint16_t on the set baud rate in the USBtoSerial project, so that the higher >1M baud rates can be - * selected (thanks to Steffan) + * selected (thanks to Steffan Woltjer) * * Fixed: * - Fixed software PDI/TPI programming mode in the AVRISP project not correctly toggling just the clock pin diff --git a/LUFA/ManPages/FutureChanges.txt b/LUFA/ManPages/FutureChanges.txt index b0e31e8f7..04a5fc6c2 100644 --- a/LUFA/ManPages/FutureChanges.txt +++ b/LUFA/ManPages/FutureChanges.txt @@ -30,7 +30,6 @@ * -# Alternative (USB-IF endorsed) USB-CDC Ethernet Class * -# USB Test and Measurement Class * -# Finish BluetoothHost demo - * -# Finish MIDI class Bootloader * -# Finish SideShow demo * -# Finish StandaloneProgrammer project * -# Finish MIDIToneGenerator project diff --git a/LUFA/ManPages/LUFAPoweredProjects.txt b/LUFA/ManPages/LUFAPoweredProjects.txt index 75c2d6abb..41a41ae90 100644 --- a/LUFA/ManPages/LUFAPoweredProjects.txt +++ b/LUFA/ManPages/LUFAPoweredProjects.txt @@ -40,6 +40,7 @@ * - CAMTRIG, a remote Camera Trigger device: http://code.astraw.com/projects/motmot/camtrig * - CD Driver Emulator Dongle for ISO Files: http://cdemu.blogspot.com/ * - ClockTamer, a configurable clock generator: http://code.google.com/p/clock-tamer/ + * - EMUCOMBOX, a USB-RS422 adapter for E-Mu Emax samplers: http://users.skynet.be/emxp/EMUCOMBOX.htm * - "Fingerlicking Wingdinger" (WARNING: Bad Language if no Javascript), a MIDI controller: http://noisybox.net/electronics/wingdinger/ * - Garmin GPS USB to NMEA standard serial sentence translator: http://github.com/nall/garmin-transmogrifier/tree/master * - Generic HID Device Creator: http://generichid.sourceforge.net/ -- cgit v1.2.3