aboutsummaryrefslogtreecommitdiff
path: root/LUFA/Drivers/USB
diff options
context:
space:
mode:
authorDean Camera <[email protected]>2009-08-05 06:36:31 +0000
committerDean Camera <[email protected]>2009-08-05 06:36:31 +0000
commitc5038f1bf44aea75f1ae1ed035cb7d523ccfdacb (patch)
tree5cf62e8642cc53c49eb28f973db843df5f047ba3 /LUFA/Drivers/USB
parent357ccc577bc6f8710ff942019e16cfa6a08466b7 (diff)
downloadqmk_firmware-c5038f1bf44aea75f1ae1ed035cb7d523ccfdacb.tar.gz
qmk_firmware-c5038f1bf44aea75f1ae1ed035cb7d523ccfdacb.zip
Renamed all library events to properly seperate out Device and Host mode events. Changed the firing conditions for some events to ensure that events are fired by their own USB mode only.
Remove VBUS events - not needed as the library takes care of VBUS detection and feedback on supported AVRs via the USB_Device_Connected and USB_Device_Disconnected events. Fixed incorrect Host state assignment in the incomplete BluetoothHost demo.
Diffstat (limited to 'LUFA/Drivers/USB')
-rw-r--r--LUFA/Drivers/USB/Class/Device/Audio.c2
-rw-r--r--LUFA/Drivers/USB/Class/Device/Audio.h6
-rw-r--r--LUFA/Drivers/USB/Class/Device/CDC.c2
-rw-r--r--LUFA/Drivers/USB/Class/Device/CDC.h8
-rw-r--r--LUFA/Drivers/USB/Class/Device/HID.c2
-rw-r--r--LUFA/Drivers/USB/Class/Device/HID.h6
-rw-r--r--LUFA/Drivers/USB/Class/Device/MIDI.c2
-rw-r--r--LUFA/Drivers/USB/Class/Device/MIDI.h6
-rw-r--r--LUFA/Drivers/USB/Class/Device/MassStorage.c2
-rw-r--r--LUFA/Drivers/USB/Class/Device/MassStorage.h6
-rw-r--r--LUFA/Drivers/USB/Class/Device/RNDIS.c2
-rw-r--r--LUFA/Drivers/USB/Class/Device/RNDIS.h6
-rw-r--r--LUFA/Drivers/USB/HighLevel/Events.h158
-rw-r--r--LUFA/Drivers/USB/HighLevel/StdRequestType.h20
-rw-r--r--LUFA/Drivers/USB/HighLevel/USBInterrupt.c67
-rw-r--r--LUFA/Drivers/USB/HighLevel/USBTask.c2
-rw-r--r--LUFA/Drivers/USB/HighLevel/USBTask.h14
-rw-r--r--LUFA/Drivers/USB/LowLevel/DevChapter9.c19
-rw-r--r--LUFA/Drivers/USB/LowLevel/DevChapter9.h2
-rw-r--r--LUFA/Drivers/USB/LowLevel/Host.c9
-rw-r--r--LUFA/Drivers/USB/LowLevel/Host.h6
-rw-r--r--LUFA/Drivers/USB/LowLevel/LowLevel.c40
-rw-r--r--LUFA/Drivers/USB/LowLevel/LowLevel.h4
23 files changed, 156 insertions, 235 deletions
diff --git a/LUFA/Drivers/USB/Class/Device/Audio.c b/LUFA/Drivers/USB/Class/Device/Audio.c
index 210a3c8001..c4fbc3d9c9 100644
--- a/LUFA/Drivers/USB/Class/Device/Audio.c
+++ b/LUFA/Drivers/USB/Class/Device/Audio.c
@@ -33,7 +33,7 @@
#include "Audio.h"
-void Audio_Device_ProcessControlPacket(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo)
+void Audio_Device_ProcessControlRequest(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo)
{
if (!(Endpoint_IsSETUPReceived()))
return;
diff --git a/LUFA/Drivers/USB/Class/Device/Audio.h b/LUFA/Drivers/USB/Class/Device/Audio.h
index 2c91dae7c5..b1c5046c6c 100644
--- a/LUFA/Drivers/USB/Class/Device/Audio.h
+++ b/LUFA/Drivers/USB/Class/Device/Audio.h
@@ -97,7 +97,7 @@
/* Function Prototypes: */
/** Configures the endpoints of a given Audio interface, ready for use. This should be linked to the library
- * \ref EVENT_USB_ConfigurationChanged() event so that the endpoints are configured when the configuration containing the
+ * \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration containing the
* given Audio interface is selected.
*
* \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.
@@ -107,11 +107,11 @@
bool Audio_Device_ConfigureEndpoints(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo);
/** Processes incomming control requests from the host, that are directed to the given Audio class interface. This should be
- * linked to the library \ref EVENT_USB_UnhandledControlPacket() event.
+ * linked to the library \ref EVENT_USB_Device_UnhandledControlRequest() event.
*
* \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.
*/
- void Audio_Device_ProcessControlPacket(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo);
+ void Audio_Device_ProcessControlRequest(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo);
/** General management task for a given Audio class interface, required for the correct operation of the interface. This should
* be called frequently in the main program loop, before the master USB management task \ref USB_USBTask().
diff --git a/LUFA/Drivers/USB/Class/Device/CDC.c b/LUFA/Drivers/USB/Class/Device/CDC.c
index 9ed20e4846..9da0ed1ebf 100644
--- a/LUFA/Drivers/USB/Class/Device/CDC.c
+++ b/LUFA/Drivers/USB/Class/Device/CDC.c
@@ -39,7 +39,7 @@ void CDC_Device_Event_Stub(void)
}
-void CDC_Device_ProcessControlPacket(USB_ClassInfo_CDC_Device_t* CDCInterfaceInfo)
+void CDC_Device_ProcessControlRequest(USB_ClassInfo_CDC_Device_t* CDCInterfaceInfo)
{
if (!(Endpoint_IsSETUPReceived()))
return;
diff --git a/LUFA/Drivers/USB/Class/Device/CDC.h b/LUFA/Drivers/USB/Class/Device/CDC.h
index 2a8f1ecd8f..7332f56cc6 100644
--- a/LUFA/Drivers/USB/Class/Device/CDC.h
+++ b/LUFA/Drivers/USB/Class/Device/CDC.h
@@ -108,8 +108,8 @@
/* Function Prototypes: */
/** Configures the endpoints of a given CDC interface, ready for use. This should be linked to the library
- * \ref EVENT_USB_ConfigurationChanged() event so that the endpoints are configured when the configuration containing the
- * given CDC interface is selected.
+ * \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration containing
+ * the given CDC interface is selected.
*
* \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
*
@@ -118,11 +118,11 @@
bool CDC_Device_ConfigureEndpoints(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo);
/** Processes incomming control requests from the host, that are directed to the given CDC class interface. This should be
- * linked to the library \ref EVENT_USB_UnhandledControlPacket() event.
+ * linked to the library \ref EVENT_USB_Device_UnhandledControlRequest() event.
*
* \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
*/
- void CDC_Device_ProcessControlPacket(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo);
+ void CDC_Device_ProcessControlRequest(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo);
/** General management task for a given CDC class interface, required for the correct operation of the interface. This should
* be called frequently in the main program loop, before the master USB management task \ref USB_USBTask().
diff --git a/LUFA/Drivers/USB/Class/Device/HID.c b/LUFA/Drivers/USB/Class/Device/HID.c
index 40f7d2f498..937214b946 100644
--- a/LUFA/Drivers/USB/Class/Device/HID.c
+++ b/LUFA/Drivers/USB/Class/Device/HID.c
@@ -33,7 +33,7 @@
#include "HID.h"
-void HID_Device_ProcessControlPacket(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo)
+void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo)
{
if (!(Endpoint_IsSETUPReceived()))
return;
diff --git a/LUFA/Drivers/USB/Class/Device/HID.h b/LUFA/Drivers/USB/Class/Device/HID.h
index b8ca47980a..0c141e62c9 100644
--- a/LUFA/Drivers/USB/Class/Device/HID.h
+++ b/LUFA/Drivers/USB/Class/Device/HID.h
@@ -95,7 +95,7 @@
/* Function Prototypes: */
/** Configures the endpoints of a given HID interface, ready for use. This should be linked to the library
- * \ref EVENT_USB_ConfigurationChanged() event so that the endpoints are configured when the configuration
+ * \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration
* containing the given HID interface is selected.
*
* \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state.
@@ -105,11 +105,11 @@
bool HID_Device_ConfigureEndpoints(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo);
/** Processes incomming control requests from the host, that are directed to the given HID class interface. This should be
- * linked to the library \ref EVENT_USB_UnhandledControlPacket() event.
+ * linked to the library \ref EVENT_USB_Device_UnhandledControlRequest() event.
*
* \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state.
*/
- void HID_Device_ProcessControlPacket(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo);
+ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo);
/** General management task for a given HID class interface, required for the correct operation of the interface. This should
* be called frequently in the main program loop, before the master USB management task \ref USB_USBTask().
diff --git a/LUFA/Drivers/USB/Class/Device/MIDI.c b/LUFA/Drivers/USB/Class/Device/MIDI.c
index ed3aaa7231..a74e7a6192 100644
--- a/LUFA/Drivers/USB/Class/Device/MIDI.c
+++ b/LUFA/Drivers/USB/Class/Device/MIDI.c
@@ -33,7 +33,7 @@
#include "MIDI.h"
-void MIDI_Device_ProcessControlPacket(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo)
+void MIDI_Device_ProcessControlRequest(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo)
{
}
diff --git a/LUFA/Drivers/USB/Class/Device/MIDI.h b/LUFA/Drivers/USB/Class/Device/MIDI.h
index 980ddc5bf2..c7e46ba97f 100644
--- a/LUFA/Drivers/USB/Class/Device/MIDI.h
+++ b/LUFA/Drivers/USB/Class/Device/MIDI.h
@@ -86,7 +86,7 @@
/* Function Prototypes: */
/** Configures the endpoints of a given MIDI interface, ready for use. This should be linked to the library
- * \ref EVENT_USB_ConfigurationChanged() event so that the endpoints are configured when the configuration
+ * \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration
* containing the given MIDI interface is selected.
*
* \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state.
@@ -96,11 +96,11 @@
bool MIDI_Device_ConfigureEndpoints(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo);
/** Processes incomming control requests from the host, that are directed to the given MIDI class interface. This should be
- * linked to the library \ref EVENT_USB_UnhandledControlPacket() event.
+ * linked to the library \ref EVENT_USB_Device_UnhandledControlRequest() event.
*
* \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state.
*/
- void MIDI_Device_ProcessControlPacket(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo);
+ void MIDI_Device_ProcessControlRequest(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo);
/** General management task for a given MIDI class interface, required for the correct operation of the interface. This should
* be called frequently in the main program loop, before the master USB management task \ref USB_USBTask().
diff --git a/LUFA/Drivers/USB/Class/Device/MassStorage.c b/LUFA/Drivers/USB/Class/Device/MassStorage.c
index 6160641bf0..04c63fca73 100644
--- a/LUFA/Drivers/USB/Class/Device/MassStorage.c
+++ b/LUFA/Drivers/USB/Class/Device/MassStorage.c
@@ -36,7 +36,7 @@
static USB_ClassInfo_MS_Device_t* CallbackMSInterfaceInfo;
-void MS_Device_ProcessControlPacket(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
+void MS_Device_ProcessControlRequest(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
{
if (!(Endpoint_IsSETUPReceived()))
return;
diff --git a/LUFA/Drivers/USB/Class/Device/MassStorage.h b/LUFA/Drivers/USB/Class/Device/MassStorage.h
index cd7a8ef1d7..b207c237e2 100644
--- a/LUFA/Drivers/USB/Class/Device/MassStorage.h
+++ b/LUFA/Drivers/USB/Class/Device/MassStorage.h
@@ -95,7 +95,7 @@
/* Function Prototypes: */
/** Configures the endpoints of a given Mass Storage interface, ready for use. This should be linked to the library
- * \ref EVENT_USB_ConfigurationChanged() event so that the endpoints are configured when the configuration
+ * \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration
* containing the given Mass Storage interface is selected.
*
* \param[in,out] MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state.
@@ -105,11 +105,11 @@
bool MS_Device_ConfigureEndpoints(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
/** Processes incomming control requests from the host, that are directed to the given Mass Storage class interface. This should be
- * linked to the library \ref EVENT_USB_UnhandledControlPacket() event.
+ * linked to the library \ref EVENT_USB_Device_UnhandledControlRequest() event.
*
* \param[in,out] MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state.
*/
- void MS_Device_ProcessControlPacket(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
+ void MS_Device_ProcessControlRequest(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
/** General management task for a given Mass Storage class interface, required for the correct operation of the interface. This should
* be called frequently in the main program loop, before the master USB management task \ref USB_USBTask().
diff --git a/LUFA/Drivers/USB/Class/Device/RNDIS.c b/LUFA/Drivers/USB/Class/Device/RNDIS.c
index 8131d87576..13d82a5bf4 100644
--- a/LUFA/Drivers/USB/Class/Device/RNDIS.c
+++ b/LUFA/Drivers/USB/Class/Device/RNDIS.c
@@ -65,7 +65,7 @@ static const uint32_t PROGMEM AdapterSupportedOIDList[] =
OID_802_3_XMIT_MORE_COLLISIONS,
};
-void RNDIS_Device_ProcessControlPacket(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo)
+void RNDIS_Device_ProcessControlRequest(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo)
{
if (!(Endpoint_IsSETUPReceived()))
return;
diff --git a/LUFA/Drivers/USB/Class/Device/RNDIS.h b/LUFA/Drivers/USB/Class/Device/RNDIS.h
index 8855aac175..d9a5d7f0be 100644
--- a/LUFA/Drivers/USB/Class/Device/RNDIS.h
+++ b/LUFA/Drivers/USB/Class/Device/RNDIS.h
@@ -103,7 +103,7 @@
/* Function Prototypes: */
/** Configures the endpoints of a given RNDIS interface, ready for use. This should be linked to the library
- * \ref EVENT_USB_ConfigurationChanged() event so that the endpoints are configured when the configuration
+ * \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration
* containing the given HID interface is selected.
*
* \param[in,out] RNDISInterfaceInfo Pointer to a structure containing a RNDIS Class configuration and state.
@@ -113,11 +113,11 @@
bool RNDIS_Device_ConfigureEndpoints(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo);
/** Processes incomming control requests from the host, that are directed to the given RNDIS class interface. This should be
- * linked to the library \ref EVENT_USB_UnhandledControlPacket() event.
+ * linked to the library \ref EVENT_USB_Device_UnhandledControlRequest() event.
*
* \param[in,out] RNDISInterfaceInfo Pointer to a structure containing a RNDIS Class configuration and state.
*/
- void RNDIS_Device_ProcessControlPacket(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo);
+ void RNDIS_Device_ProcessControlRequest(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo);
/** General management task for a given HID class interface, required for the correct operation of the interface. This should
* be called frequently in the main program loop, before the master USB management task \ref USB_USBTask().
diff --git a/LUFA/Drivers/USB/HighLevel/Events.h b/LUFA/Drivers/USB/HighLevel/Events.h
index 4042d46703..1e638314cf 100644
--- a/LUFA/Drivers/USB/HighLevel/Events.h
+++ b/LUFA/Drivers/USB/HighLevel/Events.h
@@ -62,67 +62,7 @@
/* Public Interface - May be used in end-application: */
/* 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, 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. 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 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.
- */
- void EVENT_USB_VBUSDisconnect(void);
-
- /** Event for USB device connection. This event fires when the AVR is in USB host mode and a device
- * has been attached (but not yet fully enumerated), or when in device mode and the device is connected
- * to a host, beginning the enumeration process.
- *
- * When in device mode, this can be used to programmatically start the USB management task to reduce
- * CPU usage.
- *
- * \note For the smaller USB AVRs (AT90USBXX2) with limited USB controllers, VBUS is not available to the USB controller.
- * this means that the current connection state is derived from the bus suspension and wake up events by default,
- * which is not always accurate (host may suspend the bus while still connected). If the actual connection state
- * needs to be determined, VBUS should be routed to an external pin, and the auto-detect behaviour turned off by
- * passing the NO_LIMITED_CONTROLLER_CONNECT token to the compiler via the -D switch at compile time. The connection
- * and disconnection events may be manually fired, and the \ref USB_DeviceState global changed manually.
- *
- * \see USBTask.h for more information on the USB management task and reducing CPU usage.
- */
- void EVENT_USB_Connect(void);
-
- /** Event for USB device disconnection. This event fires when the AVR is in USB host mode and an
- * attached and enumerated device has been disconnected, or when in device mode and the device is
- * disconnected from the host.
- *
- * When in device mode, this can be used to programmatically stop the USB management task to reduce
- * CPU usage.
- *
- * \note For the smaller USB AVRs (AT90USBXX2) with limited USB controllers, VBUS is not available to the USB controller.
- * this means that the current connection state is derived from the bus suspension and wake up events by default,
- * which is not always accurate (host may suspend the bus while still connected). If the actual connection state
- * needs to be determined, VBUS should be routed to an external pin, and the auto-detect behaviour turned off by
- * passing the NO_LIMITED_CONTROLLER_CONNECT token to the compiler via the -D switch at compile time. The connection
- * and disconnection events may be manually fired, and the \ref USB_DeviceState global changed manually.
- *
- * \see USBTask.h for more information on the USB management task and reducing CPU usage.
- */
- void EVENT_USB_Disconnect(void);
-
- /** Event for USB initialization failure. This event fires when the USB interface fails to
+ /** Event for USB stack initialization failure. This event fires when the USB interface fails to
* initialize correctly due to a hardware or software fault.
*
* \note This event only exists on USB AVR models which support dual role modes.
@@ -133,8 +73,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 but after the \ref EVENT_USB_Disconnect event
- * has fired (if connected before the role change).
+ * before the mode is switched to the newly indicated mode but after the \ref EVENT_USB_Device_Disconnect
+ * event has fired (if connected before the role change).
*
* \note This event only exists on USB AVR models which support dual role modes.
*
@@ -153,12 +93,12 @@
* \note This event does not exist if the USB_DEVICE_ONLY token is supplied to the compiler (see
* \ref Group_USBManagement documentation).
*/
- void EVENT_USB_HostError(const uint8_t ErrorCode);
+ void EVENT_USB_Host_HostError(const uint8_t ErrorCode);
/** Event for USB device attachment. This event fires when a the USB interface is in host mode, and
* a USB device has been connected to the USB interface. This is interrupt driven, thus fires before
- * the standard \ref EVENT_USB_Connect event and so can be used to programmatically start the USB management
- * task to reduce CPU consumption.
+ * the standard \ref EVENT_USB_Device_Connect event and so can be used to programmatically start the USB
+ * management task to reduce CPU consumption.
*
* \note This event only exists on USB AVR models which supports host mode.
*
@@ -167,7 +107,7 @@
*
* \see \ref USB_USBTask() for more information on the USB management task and reducing CPU usage.
*/
- void EVENT_USB_DeviceAttached(void);
+ void EVENT_USB_Host_DeviceAttached(void);
/** Event for USB device removal. This event fires when a the USB interface is in host mode, and
* a USB device has been removed the USB interface whether or not it has been enumerated. This
@@ -180,7 +120,7 @@
*
* \see \ref USB_USBTask() for more information on the USB management task and reducing CPU usage.
*/
- void EVENT_USB_DeviceUnattached(void);
+ void EVENT_USB_Host_DeviceUnattached(void);
/** Event for USB device enumeration failure. This event fires when a the USB interface is
* in host mode, and an attached USB device has failed to enumerate completely.
@@ -197,14 +137,41 @@
* \note This event does not exist if the USB_DEVICE_ONLY token is supplied to the compiler (see
* \ref Group_USBManagement documentation).
*/
- void EVENT_USB_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode);
+ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode);
/** Event for USB device enumeration completion. This event fires when a the USB interface is
* in host mode and an attached USB device has been completely enumerated and is ready to be
- * controlled by the user application, or when the library is in device mode, and the Host
- * has finished enumerating the device.
+ * controlled by the user application.
*/
- void EVENT_USB_DeviceEnumerationComplete(void);
+ void EVENT_USB_Host_DeviceEnumerationComplete(void);
+
+ /** Event for USB device connection. This event fires when the AVR in device mode and the device is connected
+ * to a host, beginning the enumeration process, measured by a rising level on the AVR's VBUS pin.
+ *
+ * \note For the smaller USB AVRs (AT90USBXX2) with limited USB controllers, VBUS is not available to the USB controller.
+ * this means that the current connection state is derived from the bus suspension and wake up events by default,
+ * which is not always accurate (host may suspend the bus while still connected). If the actual connection state
+ * needs to be determined, VBUS should be routed to an external pin, and the auto-detect behaviour turned off by
+ * passing the NO_LIMITED_CONTROLLER_CONNECT token to the compiler via the -D switch at compile time. The connection
+ * and disconnection events may be manually fired, and the \ref USB_DeviceState global changed manually.
+ *
+ * \see USBTask.h for more information on the USB management task and reducing CPU usage.
+ */
+ void EVENT_USB_Device_Connect(void);
+
+ /** Event for USB device disconnection. This event fires when the AVR in device mode and the device is disconnected
+ * from a host, measured by a falling level on the AVR's VBUS pin.
+ *
+ * \note For the smaller USB AVRs (AT90USBXX2) with limited USB controllers, VBUS is not available to the USB controller.
+ * this means that the current connection state is derived from the bus suspension and wake up events by default,
+ * which is not always accurate (host may suspend the bus while still connected). If the actual connection state
+ * needs to be determined, VBUS should be routed to an external pin, and the auto-detect behaviour turned off by
+ * passing the NO_LIMITED_CONTROLLER_CONNECT token to the compiler via the -D switch at compile time. The connection
+ * and disconnection events may be manually fired, and the \ref USB_DeviceState global changed manually.
+ *
+ * \see USBTask.h for more information on the USB management task and reducing CPU usage.
+ */
+ void EVENT_USB_Device_Disconnect(void);
/** Event for unhandled control requests. This event fires when a the USB host issues a control
* request to the control endpoint (address 0) that the library does not handle. This may either
@@ -220,7 +187,7 @@
* request SETUP parameters into the \ref USB_ControlRequest structure which should then be used
* by the application to determine how to handle the issued request.
*/
- void EVENT_USB_UnhandledControlPacket(void);
+ void EVENT_USB_Device_UnhandledControlRequest(void);
/** Event for USB configuration number changed. This event fires when a the USB host changes the
* selected configuration number while in device mode. This event should be hooked in device
@@ -231,7 +198,7 @@
* \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see
* \ref Group_USBManagement documentation).
*/
- void EVENT_USB_ConfigurationChanged(void);
+ void EVENT_USB_Device_ConfigurationChanged(void);
/** 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
@@ -242,9 +209,9 @@
* \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see
* \ref Group_USBManagement documentation).
*
- * \see \ref EVENT_USB_WakeUp() event for accompanying Wake Up event.
+ * \see \ref EVENT_USB_Device_WakeUp() event for accompanying Wake Up event.
*/
- void EVENT_USB_Suspend(void);
+ void EVENT_USB_Device_Suspend(void);
/** 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
@@ -255,9 +222,9 @@
* \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see
* \ref Group_USBManagement documentation).
*
- * \see \ref EVENT_USB_Suspend() event for accompanying Suspend event.
+ * \see \ref EVENT_USB_Device_Suspend() event for accompanying Suspend event.
*/
- void EVENT_USB_WakeUp(void);
+ void EVENT_USB_Device_WakeUp(void);
/** 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
@@ -266,7 +233,7 @@
* \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see
* \ref Group_USBManagement documentation).
*/
- void EVENT_USB_Reset(void);
+ void EVENT_USB_Device_Reset(void);
#endif
/* Private Interface - For use in library only: */
@@ -274,35 +241,30 @@
/* Function Prototypes: */
#if defined(INCLUDE_FROM_EVENTS_C)
void USB_Event_Stub(void) ATTR_CONST;
-
- #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))
- void EVENT_USB_VBUSChange(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
- void EVENT_USB_VBUSConnect(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
- void EVENT_USB_VBUSDisconnect(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
- #endif
- void EVENT_USB_Connect(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
- void EVENT_USB_Disconnect(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
- void EVENT_USB_DeviceEnumerationComplete(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
-
#if defined(USB_CAN_BE_BOTH)
void EVENT_USB_InitFailure(const uint8_t ErrorCode) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
void EVENT_USB_UIDChange(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
#endif
#if defined(USB_CAN_BE_HOST)
- void EVENT_USB_HostError(const uint8_t ErrorCode) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
- void EVENT_USB_DeviceAttached(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
- void EVENT_USB_DeviceUnattached(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
- void EVENT_USB_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode)
+ void EVENT_USB_Host_HostError(const uint8_t ErrorCode) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
+ void EVENT_USB_Host_DeviceAttached(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
+ void EVENT_USB_Host_DeviceUnattached(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
+ void EVENT_USB_Host_DeviceEnumerationComplete(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
+ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode)
ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
#endif
- void EVENT_USB_UnhandledControlPacket(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
- void EVENT_USB_ConfigurationChanged(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
- void EVENT_USB_Suspend(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
- void EVENT_USB_WakeUp(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
- void EVENT_USB_Reset(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
+ #if defined(USB_CAN_BE_DEVICE)
+ void EVENT_USB_Device_Connect(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
+ void EVENT_USB_Device_Disconnect(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
+ void EVENT_USB_Device_UnhandledControlRequest(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
+ void EVENT_USB_Device_ConfigurationChanged(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
+ void EVENT_USB_Device_Suspend(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
+ void EVENT_USB_Device_WakeUp(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
+ void EVENT_USB_Device_Reset(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
+ #endif
#endif
#endif
diff --git a/LUFA/Drivers/USB/HighLevel/StdRequestType.h b/LUFA/Drivers/USB/HighLevel/StdRequestType.h
index b9ae04598b..c5be544b97 100644
--- a/LUFA/Drivers/USB/HighLevel/StdRequestType.h
+++ b/LUFA/Drivers/USB/HighLevel/StdRequestType.h
@@ -160,41 +160,41 @@
{
REQ_GetStatus = 0, /**< Implemented in the library for device, endpoint and interface
* recipients. Passed to the user application for other recipients
- * via the \ref EVENT_USB_UnhandledControlPacket() event when received in
+ * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
* device mode. */
REQ_ClearFeature = 1, /**< Implemented in the library for device, endpoint and interface
* recipients. Passed to the user application for other recipients
- * via the \ref EVENT_USB_UnhandledControlPacket() event when received in
+ * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
* device mode. */
REQ_SetFeature = 3, /**< Implemented in the library for device, endpoint and interface
* recipients. Passed to the user application for other recipients
- * via the \ref EVENT_USB_UnhandledControlPacket() event when received in
+ * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
* device mode. */
REQ_SetAddress = 5, /**< Implemented in the library for the device recipient. Passed
* to the user application for other recipients via the
- * \ref EVENT_USB_UnhandledControlPacket() event when received in
+ * \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
* device mode. */
REQ_GetDescriptor = 6, /**< Implemented in the library for all recipients and all request
* types. */
REQ_SetDescriptor = 7, /**< Not implemented in the library, passed to the user application
- * via the \ref EVENT_USB_UnhandledControlPacket() event when received in
+ * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
* device mode. */
REQ_GetConfiguration = 8, /**< Implemented in the library for the device recipient. Passed
* to the user application for other recipients via the
- * \ref EVENT_USB_UnhandledControlPacket() event when received in
+ * \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
* device mode. */
REQ_SetConfiguration = 9, /**< Implemented in the library for the device recipient. Passed
* to the user application for other recipients via the
- * \ref EVENT_USB_UnhandledControlPacket() event when received in
+ * \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
* device mode. */
REQ_GetInterface = 10, /**< Not implemented in the library, passed to the user application
- * via the \ref EVENT_USB_UnhandledControlPacket() event when received in
+ * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
* device mode. */
REQ_SetInterface = 11, /**< Not implemented in the library, passed to the user application
- * via the \ref EVENT_USB_UnhandledControlPacket() event when received in
+ * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
* device mode. */
REQ_SynchFrame = 12, /**< Not implemented in the library, passed to the user application
- * via the \ref EVENT_USB_UnhandledControlPacket() event when received in
+ * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
* device mode. */
};
diff --git a/LUFA/Drivers/USB/HighLevel/USBInterrupt.c b/LUFA/Drivers/USB/HighLevel/USBInterrupt.c
index 51a761ae7f..56e54f25ac 100644
--- a/LUFA/Drivers/USB/HighLevel/USBInterrupt.c
+++ b/LUFA/Drivers/USB/HighLevel/USBInterrupt.c
@@ -72,36 +72,15 @@ ISR(USB_GEN_vect, ISR_BLOCK)
{
USB_INT_Clear(USB_INT_VBUS);
- EVENT_USB_VBUSChange();
-
if (USB_VBUS_GetStatus())
{
- EVENT_USB_VBUSConnect();
-
- if (USB_DeviceState != DEVICE_STATE_Unattached)
- EVENT_USB_Disconnect();
-
- USB_ResetInterface();
-
USB_DeviceState = DEVICE_STATE_Powered;
- EVENT_USB_Connect();
+ EVENT_USB_Device_Connect();
}
else
{
- USB_DeviceState = DEVICE_STATE_Unattached;
- EVENT_USB_Disconnect();
-
- USB_Detach();
- USB_CLK_Freeze();
-
- if (!(USB_Options & USB_OPT_MANUAL_PLL))
- USB_PLL_Off();
-
- USB_REG_Off();
-
- EVENT_USB_VBUSDisconnect();
-
- USB_INT_Clear(USB_INT_VBUS);
+ USB_DeviceState = DEVICE_STATE_Unattached;
+ EVENT_USB_Device_Disconnect();
}
}
#endif
@@ -120,10 +99,10 @@ ISR(USB_GEN_vect, ISR_BLOCK)
#if defined(USB_SERIES_2_AVR) && !defined(NO_LIMITED_CONTROLLER_CONNECT)
USB_DeviceState = DEVICE_STATE_Unattached;
- EVENT_USB_Disconnect();
+ EVENT_USB_Device_Disconnect();
#else
USB_DeviceState = DEVICE_STATE_Suspended;
- EVENT_USB_Suspend();
+ EVENT_USB_Device_Suspend();
#endif
}
@@ -143,11 +122,11 @@ ISR(USB_GEN_vect, ISR_BLOCK)
USB_INT_Enable(USB_INT_SUSPEND);
#if defined(USB_SERIES_2_AVR) && !defined(NO_LIMITED_CONTROLLER_CONNECT)
- USB_DeviceState = DEVICE_STATE_Powered;
- EVENT_USB_Connect();
+ USB_DeviceState = (USB_ConfigurationNumber) ? DEVICE_STATE_Configured : DEVICE_STATE_Powered;
+ EVENT_USB_Device_Connect();
#else
USB_DeviceState = (USB_ConfigurationNumber) ? DEVICE_STATE_Configured : DEVICE_STATE_Addressed;
- EVENT_USB_WakeUp();
+ EVENT_USB_Device_WakeUp();
#endif
}
@@ -172,7 +151,7 @@ ISR(USB_GEN_vect, ISR_BLOCK)
USB_INT_Enable(USB_INT_ENDPOINT_SETUP);
#endif
- EVENT_USB_Reset();
+ EVENT_USB_Device_Reset();
}
#endif
@@ -183,8 +162,7 @@ ISR(USB_GEN_vect, ISR_BLOCK)
USB_INT_Clear(USB_INT_DCONNI);
USB_INT_Disable(USB_INT_DDISCI);
- EVENT_USB_DeviceUnattached();
- EVENT_USB_Disconnect();
+ EVENT_USB_Host_DeviceUnattached();
USB_ResetInterface();
}
@@ -196,8 +174,8 @@ ISR(USB_GEN_vect, ISR_BLOCK)
USB_Host_VBUS_Manual_Off();
USB_Host_VBUS_Auto_Off();
- EVENT_USB_HostError(HOST_ERROR_VBusVoltageDip);
- EVENT_USB_DeviceUnattached();
+ EVENT_USB_Host_HostError(HOST_ERROR_VBusVoltageDip);
+ EVENT_USB_Host_DeviceUnattached();
USB_HostState = HOST_STATE_Unattached;
}
@@ -207,7 +185,7 @@ ISR(USB_GEN_vect, ISR_BLOCK)
USB_INT_Clear(USB_INT_SRPI);
USB_INT_Disable(USB_INT_SRPI);
- EVENT_USB_DeviceAttached();
+ EVENT_USB_Host_DeviceAttached();
USB_INT_Enable(USB_INT_DDISCI);
@@ -218,11 +196,8 @@ ISR(USB_GEN_vect, ISR_BLOCK)
{
USB_INT_Clear(USB_INT_BCERRI);
- EVENT_USB_DeviceEnumerationFailed(HOST_ENUMERROR_NoDeviceDetected, 0);
- EVENT_USB_DeviceUnattached();
-
- if (USB_HostState != HOST_STATE_Unattached)
- EVENT_USB_Disconnect();
+ EVENT_USB_Host_DeviceEnumerationFailed(HOST_ENUMERROR_NoDeviceDetected, 0);
+ EVENT_USB_Host_DeviceUnattached();
USB_ResetInterface();
}
@@ -237,15 +212,11 @@ ISR(USB_GEN_vect, ISR_BLOCK)
EVENT_USB_Disconnect();
if (USB_HostState != HOST_STATE_Unattached)
- {
- EVENT_USB_Disconnect();
- EVENT_USB_DeviceUnattached();
- }
-
- EVENT_USB_Disconnect();
-
- EVENT_USB_UIDChange();
+ EVENT_USB_Host_DeviceUnattached();
+ USB_CurrentMode = USB_GetUSBModeFromUID();
+ EVENT_USB_UIDChange();
+
USB_ResetInterface();
}
#endif
diff --git a/LUFA/Drivers/USB/HighLevel/USBTask.c b/LUFA/Drivers/USB/HighLevel/USBTask.c
index c02a38bf6c..f1277b9a7a 100644
--- a/LUFA/Drivers/USB/HighLevel/USBTask.c
+++ b/LUFA/Drivers/USB/HighLevel/USBTask.c
@@ -68,7 +68,7 @@ static void USB_DeviceTask(void)
Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);
if (Endpoint_IsSETUPReceived())
- USB_Device_ProcessControlPacket();
+ USB_Device_ProcessControlRequest();
Endpoint_SelectEndpoint(PrevEndpoint);
}
diff --git a/LUFA/Drivers/USB/HighLevel/USBTask.h b/LUFA/Drivers/USB/HighLevel/USBTask.h
index 9138e687f3..08accc1ef3 100644
--- a/LUFA/Drivers/USB/HighLevel/USBTask.h
+++ b/LUFA/Drivers/USB/HighLevel/USBTask.h
@@ -65,7 +65,7 @@
extern volatile bool USB_IsInitialized;
/** Structure containing the last received Control request when in Device mode (for use in user-applications
- * inside of the \ref EVENT_USB_UnhandledControlPacket() event, or for filling up with a control request to issue when
+ * inside of the \ref EVENT_USB_Device_UnhandledControlRequest() event, or for filling up with a control request to issue when
* in Host mode before calling \ref USB_Host_SendControlRequest().
*
* \ingroup Group_USBManagement
@@ -108,7 +108,7 @@
*
* This value should not be altered by the user application as it is handled automatically by the
* library. The only exception to this rule is if the NO_LIMITED_CONTROLLER_CONNECT token is used
- * (see \ref EVENT_USB_Connect() and \ref EVENT_USB_Disconnect() events).
+ * (see \ref EVENT_USB_Device_Connect() and \ref EVENT_USB_Device_Disconnect() events).
*
* To reduce program size and speed up checks of this global, it can be placed into one of the AVR's
* GPIOR hardware registers instead of RAM by defining the DEVICE_STATE_AS_GPIOR token to a value
@@ -142,12 +142,12 @@
* The USB task must be serviced within 30ms while in device mode, or within 1ms while in host mode.
* The task may be serviced at all times, or (for minimum CPU consumption):
*
- * - In device mode, it may be disabled at start-up, enabled on the firing of the \ref EVENT_USB_Connect() event
- * and disabled again on the firing of the \ref EVENT_USB_Disconnect() event.
+ * - In device mode, it may be disabled at start-up, enabled on the firing of the \ref EVENT_USB_Device_Connect()
+ * event and disabled again on the firing of the \ref EVENT_USB_Device_Disconnect() event.
*
- * - In host mode, it may be disabled at start-up, enabled on the firing of the \ref EVENT_USB_DeviceAttached()
- * event and disabled again on the firing of the \ref EVENT_USB_DeviceEnumerationComplete() or
- * \ref EVENT_USB_DeviceEnumerationFailed() events.
+ * - In host mode, it may be disabled at start-up, enabled on the firing of the \ref EVENT_USB_Host_DeviceAttached()
+ * event and disabled again on the firing of the \ref EVENT_USB_Host_DeviceEnumerationComplete() or
+ * \ref EVENT_USB_Host_DeviceEnumerationFailed() events.
*
* If in device mode (only), the control endpoint can instead be managed via interrupts entirely by the library
* by defining the INTERRUPT_CONTROL_ENDPOINT token and passing it to the compiler via the -D switch.
diff --git a/LUFA/Drivers/USB/LowLevel/DevChapter9.c b/LUFA/Drivers/USB/LowLevel/DevChapter9.c
index f9c52e666a..033db094ea 100644
--- a/LUFA/Drivers/USB/LowLevel/DevChapter9.c
+++ b/LUFA/Drivers/USB/LowLevel/DevChapter9.c
@@ -39,7 +39,7 @@ uint8_t USB_ConfigurationNumber;
bool USB_RemoteWakeupEnabled;
bool USB_CurrentlySelfPowered;
-void USB_Device_ProcessControlPacket(void)
+void USB_Device_ProcessControlRequest(void)
{
bool RequestHandled = false;
uint8_t* RequestHeader = (uint8_t*)&USB_ControlRequest;
@@ -106,7 +106,7 @@ void USB_Device_ProcessControlPacket(void)
}
if (!(RequestHandled))
- EVENT_USB_UnhandledControlPacket();
+ EVENT_USB_Device_UnhandledControlRequest();
if (Endpoint_IsSETUPReceived())
{
@@ -139,8 +139,6 @@ static void USB_Device_SetAddress(void)
static void USB_Device_SetConfiguration(void)
{
- bool AlreadyConfigured = (USB_ConfigurationNumber != 0);
-
#if defined(FIXED_NUM_CONFIGURATIONS)
if ((uint8_t)USB_ControlRequest.wValue > FIXED_NUM_CONFIGURATIONS)
return;
@@ -195,18 +193,11 @@ static void USB_Device_SetConfiguration(void)
Endpoint_ClearIN();
if (USB_ConfigurationNumber)
- {
- USB_DeviceState = DEVICE_STATE_Configured;
-
- if (!(AlreadyConfigured))
- EVENT_USB_DeviceEnumerationComplete();
- }
+ USB_DeviceState = DEVICE_STATE_Configured;
else
- {
- USB_DeviceState = DEVICE_STATE_Addressed;
- }
+ USB_DeviceState = DEVICE_STATE_Addressed;
- EVENT_USB_ConfigurationChanged();
+ EVENT_USB_Device_ConfigurationChanged();
}
void USB_Device_GetConfiguration(void)
diff --git a/LUFA/Drivers/USB/LowLevel/DevChapter9.h b/LUFA/Drivers/USB/LowLevel/DevChapter9.h
index a70dd066e3..e6baca2be0 100644
--- a/LUFA/Drivers/USB/LowLevel/DevChapter9.h
+++ b/LUFA/Drivers/USB/LowLevel/DevChapter9.h
@@ -113,7 +113,7 @@
#endif
/* Function Prototypes: */
- void USB_Device_ProcessControlPacket(void);
+ void USB_Device_ProcessControlRequest(void);
#if defined(INCLUDE_FROM_DEVCHAPTER9_C)
static void USB_Device_SetAddress(void);
diff --git a/LUFA/Drivers/USB/LowLevel/Host.c b/LUFA/Drivers/USB/LowLevel/Host.c
index 3d99b25947..8a51ae5bfc 100644
--- a/LUFA/Drivers/USB/LowLevel/Host.c
+++ b/LUFA/Drivers/USB/LowLevel/Host.c
@@ -92,8 +92,6 @@ void USB_Host_ProcessNextHostState(void)
USB_INT_Clear(USB_INT_VBERRI);
USB_INT_Enable(USB_INT_VBERRI);
-
- EVENT_USB_Connect();
USB_Host_ResumeBus();
Pipe_ClearPipes();
@@ -185,19 +183,18 @@ void USB_Host_ProcessNextHostState(void)
case HOST_STATE_Default_PostAddressSet:
USB_Host_SetDeviceAddress(USB_HOST_DEVICEADDRESS);
- EVENT_USB_DeviceEnumerationComplete();
+ EVENT_USB_Host_DeviceEnumerationComplete();
USB_HostState = HOST_STATE_Addressed;
break;
}
if ((ErrorCode != HOST_ENUMERROR_NoError) && (USB_HostState != HOST_STATE_Unattached))
{
- EVENT_USB_DeviceEnumerationFailed(ErrorCode, SubErrorCode);
+ EVENT_USB_Host_DeviceEnumerationFailed(ErrorCode, SubErrorCode);
USB_Host_VBUS_Auto_Off();
- EVENT_USB_DeviceUnattached();
- EVENT_USB_Disconnect();
+ EVENT_USB_Host_DeviceUnattached();
USB_ResetInterface();
}
diff --git a/LUFA/Drivers/USB/LowLevel/Host.h b/LUFA/Drivers/USB/LowLevel/Host.h
index a602cee771..50912ad7dc 100644
--- a/LUFA/Drivers/USB/LowLevel/Host.h
+++ b/LUFA/Drivers/USB/LowLevel/Host.h
@@ -312,7 +312,7 @@
*/
};
- /** Enum for the error codes for the \ref EVENT_USB_HostError() event.
+ /** Enum for the error codes for the \ref EVENT_USB_Host_HostError() event.
*
* \see \ref Group_Events for more information on this event.
*/
@@ -326,14 +326,14 @@
*/
};
- /** Enum for the error codes for the \ref EVENT_USB_DeviceEnumerationFailed() event.
+ /** Enum for the error codes for the \ref EVENT_USB_Host_DeviceEnumerationFailed() event.
*
* \see \ref Group_Events for more information on this event.
*/
enum USB_Host_EnumerationErrorCodes_t
{
HOST_ENUMERROR_NoError = 0, /**< No error occurred. Used internally, this is not a valid
- * ErrorCode parameter value for the \ref EVENT_USB_DeviceEnumerationFailed()
+ * ErrorCode parameter value for the \ref EVENT_USB_Host_DeviceEnumerationFailed()
* event.
*/
HOST_ENUMERROR_WaitStage = 1, /**< One of the delays between enumeration steps failed
diff --git a/LUFA/Drivers/USB/LowLevel/LowLevel.c b/LUFA/Drivers/USB/LowLevel/LowLevel.c
index 3ad1e98309..e6791098a1 100644
--- a/LUFA/Drivers/USB/LowLevel/LowLevel.c
+++ b/LUFA/Drivers/USB/LowLevel/LowLevel.c
@@ -108,16 +108,6 @@ void USB_Init(
void USB_ShutDown(void)
{
- #if defined(USB_CAN_BE_DEVICE)
- if (USB_DeviceState != DEVICE_STATE_Unattached)
- EVENT_USB_Disconnect();
- #endif
-
- #if defined(USB_CAN_BE_HOST)
- if (USB_HostState != HOST_STATE_Unattached)
- EVENT_USB_Disconnect();
- #endif
-
USB_ResetInterface();
USB_Detach();
USB_Controller_Disable();
@@ -191,8 +181,6 @@ void USB_ResetInterface(void)
USB_Device_SetLowSpeed();
else
USB_Device_SetFullSpeed();
-
- USB_INT_Enable(USB_INT_VBUS);
}
#endif
@@ -204,11 +192,11 @@ void USB_ResetInterface(void)
if (CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DeviceDescriptorPtr) != NO_DESCRIPTOR)
{
#if defined(USE_RAM_DESCRIPTORS)
- USB_ControlEndpointSize = DeviceDescriptorPtr->Endpoint0Size;
+ USB_ControlEndpointSize = DeviceDescriptorPtr->Endpoint0Size;
#elif defined(USE_EEPROM_DESCRIPTORS)
- USB_ControlEndpointSize = eeprom_read_byte(&DeviceDescriptorPtr->Endpoint0Size);
+ USB_ControlEndpointSize = eeprom_read_byte(&DeviceDescriptorPtr->Endpoint0Size);
#else
- USB_ControlEndpointSize = pgm_read_byte(&DeviceDescriptorPtr->Endpoint0Size);
+ USB_ControlEndpointSize = pgm_read_byte(&DeviceDescriptorPtr->Endpoint0Size);
#endif
}
}
@@ -216,13 +204,19 @@ void USB_ResetInterface(void)
USB_Attach();
- #if defined(USB_DEVICE_ONLY)
+ #if defined(USB_DEVICE_ONLY)
+ USB_INT_Clear(USB_INT_SUSPEND);
USB_INT_Enable(USB_INT_SUSPEND);
+ USB_INT_Clear(USB_INT_EORSTI);
USB_INT_Enable(USB_INT_EORSTI);
- #if defined(CONTROL_ONLY_DEVICE)
- UENUM = ENDPOINT_CONTROLEP;
- #endif
-
+
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
+ USB_INT_Enable(USB_INT_VBUS);
+ #endif
+
+ #if defined(CONTROL_ONLY_DEVICE)
+ UENUM = ENDPOINT_CONTROLEP;
+ #endif
#elif defined(USB_HOST_ONLY)
USB_Host_HostMode_On();
@@ -237,9 +231,15 @@ void USB_ResetInterface(void)
#else
if (USB_CurrentMode == USB_MODE_DEVICE)
{
+ USB_INT_Clear(USB_INT_SUSPEND);
USB_INT_Enable(USB_INT_SUSPEND);
+ USB_INT_Clear(USB_INT_EORSTI);
USB_INT_Enable(USB_INT_EORSTI);
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
+ USB_INT_Enable(USB_INT_VBUS);
+ #endif
+
#if defined(CONTROL_ONLY_DEVICE)
UENUM = ENDPOINT_CONTROLEP;
#endif
diff --git a/LUFA/Drivers/USB/LowLevel/LowLevel.h b/LUFA/Drivers/USB/LowLevel/LowLevel.h
index 1ca54ed9d4..b8f7b9de12 100644
--- a/LUFA/Drivers/USB/LowLevel/LowLevel.h
+++ b/LUFA/Drivers/USB/LowLevel/LowLevel.h
@@ -191,7 +191,7 @@
#endif
/** Detaches the device from the USB bus. This has the effect of removing the device from any
- * host if, ceasing USB communications. If no host is present, this prevents any host from
+ * attached host, ceasing USB communications. If no host is present, this prevents any host from
* enumerating the device once attached until \ref USB_Attach() is called.
*/
#define USB_Detach() MACROS{ UDCON |= (1 << DETACH); }MACROE
@@ -342,7 +342,7 @@
#define USB_Controller_Enable() MACROS{ USBCON |= (1 << USBE); }MACROE
#define USB_Controller_Disable() MACROS{ USBCON &= ~(1 << USBE); }MACROE
- #define USB_Controller_Reset() MACROS{ uint8_t Temp = USBCON; USBCON = (Temp & ~(1 << USBE)); \
+ #define USB_Controller_Reset() MACROS{ const uint8_t Temp = USBCON; USBCON = (Temp & ~(1 << USBE)); \
USBCON = (Temp | (1 << USBE)); }MACROE
/* Inline Functions: */