From 4a8ac5e474741f14492597880e751b3f806cb965 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Tue, 19 May 2009 10:33:29 +0000 Subject: [PATCH] USB_IsConnected is now cleared before the USB_Disconnect() event is fired in response to VBUS being removed. Minor documentation improvements. --- LUFA/ChangeLog.txt | 1 + LUFA/Doxygen.conf | 2 +- LUFA/Drivers/USB/HighLevel/Events.h | 36 +++++++++++--------- LUFA/Drivers/USB/HighLevel/StreamCallbacks.h | 5 ++- LUFA/Drivers/USB/HighLevel/USBInterrupt.c | 4 +-- LUFA/Drivers/USB/LowLevel/Endpoint.h | 6 ++-- LUFA/Drivers/USB/LowLevel/Pipe.h | 6 +++- LUFA/MainPage.txt | 7 ++-- 8 files changed, 39 insertions(+), 28 deletions(-) diff --git a/LUFA/ChangeLog.txt b/LUFA/ChangeLog.txt index 77599c9ef4..7779576f4f 100644 --- a/LUFA/ChangeLog.txt +++ b/LUFA/ChangeLog.txt @@ -24,6 +24,7 @@ * - Fixed incorrect ENDPOINT_EPNUM_MASK mask preventing endpoints above EP3 from being selected (thanks to Jonathan Oakley) * - Removed STREAM_CALLBACK() macro - callbacks now use regular function definitions to clarify user code * - Removed DESCRIPTOR_COMPARATOR() macro - comparators should now use regular function definitions to clarify user code + * - USB_IsConnected is now cleared before the USB_Disconnect() event is fired in response to VBUS being removed * * * \section Sec_ChangeLog090510 Version 090510 diff --git a/LUFA/Doxygen.conf b/LUFA/Doxygen.conf index afc46813f8..3b94c4bac5 100644 --- a/LUFA/Doxygen.conf +++ b/LUFA/Doxygen.conf @@ -475,7 +475,7 @@ SHOW_DIRECTORIES = YES # This will remove the Files entry from the Quick Index and from the # Folder Tree View (if specified). The default is YES. -SHOW_FILES = NO +SHOW_FILES = YES # Set the SHOW_NAMESPACES tag to NO to disable the generation of the # Namespaces page. This will remove the Namespaces entry from the Quick Index diff --git a/LUFA/Drivers/USB/HighLevel/Events.h b/LUFA/Drivers/USB/HighLevel/Events.h index e65352e3f1..2044a503d5 100644 --- a/LUFA/Drivers/USB/HighLevel/Events.h +++ b/LUFA/Drivers/USB/HighLevel/Events.h @@ -38,7 +38,8 @@ * * Events can be hooked by the user application by declaring a handler function with the same name and parameters * listed here. If an event with no user-associated handler is fired within the library, it by default maps to an - * internal empty stub function. This is achieved through the use of the GCC compiler's "alias" attribute. + * internal empty stub function. This trasparent hook system is achieved through the use of the GCC compiler's + * "alias" attribute. * * Each event must only have one associated event handler, but can be raised by multiple sources. * @@ -63,23 +64,24 @@ /* Pseudo-Functions for Doxygen: */ #if !defined(INCLUDE_FROM_EVENTS_C) || defined(__DOXYGEN__) /** Event for VBUS level change. This event fires when the VBUS line of the USB AVR changes from - * high to low or vice-versa. + * high to low or vice-versa, before the new VBUS level is sampled and the appropriate action + * taken. * * \note This event is only available on USB AVR models which support VBUS notification interrupts. */ void EVENT_USB_VBUSChange(void); - /** Event for VBUS attachment. This event fires when the VBUS line of the USB AVR changes from - * low to high, signalling the attachment of the USB device to a host, before the enumeration - * process has begun. + /** Event for VBUS attachment. On the AVR models with a dedicated VBUS pin, this event fires when + * the VBUS line of the USB AVR changes from low to high (after the VBUS events have been handled), + * signalling the attachment of the USB device to a host, before the enumeration process has begun. * * \note This event is only available on USB AVR models which support VBUS notification interrupts. */ void EVENT_USB_VBUSConnect(void); - /** Event for VBUS detachment. This event fires when the VBUS line of the USB AVR changes from - * high to low, signalling the USB device has been removed from a host whether it has been enumerated - * or not. + /** Event for VBUS attachment. On the AVR models with a dedicated VBUS pin, this event fires when + * the VBUS line of the USB AVR changes from high to low (after the VBUS events have been handled), + * signalling the detatchment of the USB device from a host, regardless of its enumeration state. * * \note This event is only available on USB AVR models which support VBUS notification interrupts. */ @@ -132,7 +134,8 @@ /** Event for USB mode pin level change. This event fires when the USB interface is set to dual role * mode, and the UID pin level has changed to indicate a new mode (device or host). This event fires - * before the mode is switched to the newly indicated mode. + * before the mode is switched to the newly indicated mode but after the \ref USB_Disconnect event has + * fired (if connected before the role change). * * \note This event only exists on USB AVR models which support dual role modes. * @@ -233,7 +236,9 @@ /** Event for USB suspend. This event fires when a the USB host suspends the device by halting its * transmission of Start Of Frame pulses to the device. This is generally hooked in order to move - * the device over to a low power state until the host wakes up the device. + * the device over to a low power state until the host wakes up the device. If the USB interface is + * enumerated with the \ref USB_OPT_AUTO_PLL option set, the library will automatically suspend the + * USB PLL before the event is fired to save power. * * \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see * \ref Group_USBManagement documentation). @@ -245,7 +250,8 @@ /** Event for USB wake up. This event fires when a the USB interface is suspended while in device * mode, and the host wakes up the device by supplying Start Of Frame pulses. This is generally * hooked to pull the user application out of a lowe power state and back into normal operating - * mode. + * mode. If the USB interface is enumerated with the \ref USB_OPT_AUTO_PLL option set, the library + * will automatically restart the USB PLL before the event is fired. * * \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see * \ref Group_USBManagement documentation). @@ -254,11 +260,9 @@ */ void EVENT_USB_WakeUp(void); - /** Event for USB interface reset. This event fires when a the USB interface is in device mode, and - * a the USB host requests that the device reset its interface. This is generally hooked so that - * the USB control endpoint can be switched to interrupt driven mode, by selecting it and calling - * USB_INT_Enable(ENDPOINT_INT_SETUP). Before this event fires, all device endpoints are reset and - * disabled. + /** Event for USB interface reset. This event fires when the USB interface is in device mode, and + * a the USB host requests that the device reset its interface. This event fires after the control + * endpoint has been automatically configured by the library. * * \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see * \ref Group_USBManagement documentation). diff --git a/LUFA/Drivers/USB/HighLevel/StreamCallbacks.h b/LUFA/Drivers/USB/HighLevel/StreamCallbacks.h index a67cc8988a..0d432e72f1 100644 --- a/LUFA/Drivers/USB/HighLevel/StreamCallbacks.h +++ b/LUFA/Drivers/USB/HighLevel/StreamCallbacks.h @@ -58,9 +58,8 @@ /* Type Defines: */ /** Type define for a Stream Callback function (function taking no arguments and retuning a - * uint8_t value). - * - * \see \ref STREAM_CALLBACK macro for more details + * uint8_t value). Stream callback functions should have an identical function signature if they + * are to be used as the callback parameter of the stream functions. */ typedef uint8_t (* const StreamCallbackPtr_t)(void); diff --git a/LUFA/Drivers/USB/HighLevel/USBInterrupt.c b/LUFA/Drivers/USB/HighLevel/USBInterrupt.c index 86dfa855ae..0b9d082236 100644 --- a/LUFA/Drivers/USB/HighLevel/USBInterrupt.c +++ b/LUFA/Drivers/USB/HighLevel/USBInterrupt.c @@ -89,6 +89,8 @@ ISR(USB_GEN_vect, ISR_BLOCK) } else { + USB_IsConnected = false; + EVENT_USB_Disconnect(); USB_Detach(); @@ -96,8 +98,6 @@ ISR(USB_GEN_vect, ISR_BLOCK) USB_PLL_Off(); USB_REG_Off(); - USB_IsConnected = false; - EVENT_USB_VBUSDisconnect(); USB_INT_Clear(USB_INT_VBUS); diff --git a/LUFA/Drivers/USB/LowLevel/Endpoint.h b/LUFA/Drivers/USB/LowLevel/Endpoint.h index bf33848483..3235593201 100644 --- a/LUFA/Drivers/USB/LowLevel/Endpoint.h +++ b/LUFA/Drivers/USB/LowLevel/Endpoint.h @@ -671,7 +671,8 @@ /* Function Prototypes: */ /** Configures the specified endpoint number with the given endpoint type, direction, bank size * and banking mode. Endpoints should be allocated in ascending order by their address in the - * device (i.e. endpoint 1 should be configured before endpoint 2 and so on). + * device (i.e. endpoint 1 should be configured before endpoint 2 and so on) to prevent fragmentation + * of the USB FIFO memory. * * The endpoint type may be one of the EP_TYPE_* macros listed in LowLevel.h and the direction * may be either \ref ENDPOINT_DIR_OUT or \ref ENDPOINT_DIR_IN. @@ -682,7 +683,8 @@ * * The banking mode may be either \ref ENDPOINT_BANK_SINGLE or \ref ENDPOINT_BANK_DOUBLE. * - * The success of this routine can be determined via the \ref Endpoint_IsConfigured() macro. + * \note The default control endpoint does not have to be manually configured, as it is automatically + * configured by the library internally. * * \note This routine will select the specified endpoint, and the endpoint will remain selected * once the routine completes regardless of if the endpoint configuration succeeds. diff --git a/LUFA/Drivers/USB/LowLevel/Pipe.h b/LUFA/Drivers/USB/LowLevel/Pipe.h index befc996a22..f3da9d1cef 100644 --- a/LUFA/Drivers/USB/LowLevel/Pipe.h +++ b/LUFA/Drivers/USB/LowLevel/Pipe.h @@ -709,7 +709,8 @@ /* Function Prototypes: */ /** Configures the specified pipe number with the given pipe type, token, target endpoint number in the * attached device, bank size and banking mode. Pipes should be allocated in ascending order by their - * address in the device (i.e. pipe 1 should be configured before pipe 2 and so on). + * address in the device (i.e. pipe 1 should be configured before pipe 2 and so on) to prevent fragmentation + * of the USB FIFO memory. * * The pipe type may be one of the EP_TYPE_* macros listed in LowLevel.h, the token may be one of the * PIPE_TOKEN_* masks. @@ -722,6 +723,9 @@ * * A newly configured pipe is frozen by default, and must be unfrozen before use via the \ref Pipe_Unfreeze() macro. * + * \note The default control pipe does not have to be manually configured, as it is automatically + * configured by the library internally. + * * \note This routine will select the specified pipe, and the pipe will remain selected once the * routine completes regardless of if the pipe configuration succeeds. * diff --git a/LUFA/MainPage.txt b/LUFA/MainPage.txt index 8ee8f95d9d..030fdba9d9 100644 --- a/LUFA/MainPage.txt +++ b/LUFA/MainPage.txt @@ -88,9 +88,10 @@ * The LUFA library ships with several different host and device demos, located in the /Demos/ subdirectory. * If this directory is missing, please re-download the project from the project homepage. * - * Also included with the library are two fully functional bootloaders, located in the /Bootloaders/ subdirectory. - * The DFU class bootloader is compatible with Atmel's FLIP software or the open source dfu-programmer project, and - * the CDC class (AVR109 protocol) is compatible with such open source software as AVRDUDE and AVR-OSP. + * Also included with the library are three fully functional bootloaders, located in the /Bootloaders/ subdirectory. + * The DFU class bootloader is compatible with Atmel's FLIP software or the open source dfu-programmer project, the + * CDC class (AVR109 protocol) is compatible with such open source software as AVRDUDE and AVR-OSP, and the TeensyLoader + * HID class bootloader is compatible with the software from PJRC (http://www.pjrc.com/teensy/index.html). * * * \section Sec_Donations Donate