aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers/USB/Core/XMEGA
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2012-08-28 20:09:14 +0000
committerDean Camera <dean@fourwalledcubicle.com>2012-08-28 20:09:14 +0000
commit44aea22949c40e76b8be6cb56acbd2b155043e6b (patch)
treece9537d7baf57caeb8c871b7d91abd0fa7693f6b /LUFA/Drivers/USB/Core/XMEGA
parente225de8a8372fa2cc5dc1d2d782cf7af0f3c0f08 (diff)
downloadlufa-44aea22949c40e76b8be6cb56acbd2b155043e6b.tar.gz
lufa-44aea22949c40e76b8be6cb56acbd2b155043e6b.tar.bz2
lufa-44aea22949c40e76b8be6cb56acbd2b155043e6b.zip
Fixed logic hole breaking USB operations on a USB controller with only one supported USB mode and no USB_DEVICE_ONLY or USB_HOST_ONLY configuration token set.
Diffstat (limited to 'LUFA/Drivers/USB/Core/XMEGA')
-rw-r--r--LUFA/Drivers/USB/Core/XMEGA/USBController_XMEGA.c12
-rw-r--r--LUFA/Drivers/USB/Core/XMEGA/USBController_XMEGA.h11
2 files changed, 15 insertions, 8 deletions
diff --git a/LUFA/Drivers/USB/Core/XMEGA/USBController_XMEGA.c b/LUFA/Drivers/USB/Core/XMEGA/USBController_XMEGA.c
index 86df5c825..dde984b8b 100644
--- a/LUFA/Drivers/USB/Core/XMEGA/USBController_XMEGA.c
+++ b/LUFA/Drivers/USB/Core/XMEGA/USBController_XMEGA.c
@@ -35,7 +35,7 @@
#define __INCLUDE_FROM_USB_CONTROLLER_C
#include "../USBController.h"
-#if (!defined(USB_HOST_ONLY) && !defined(USB_DEVICE_ONLY))
+#if defined(USB_CAN_BE_BOTH)
volatile uint8_t USB_CurrentMode = USB_MODE_None;
#endif
@@ -43,7 +43,7 @@ volatile uint8_t USB_CurrentMode = USB_MODE_None;
volatile uint8_t USB_Options;
#endif
-/* Ugly workaround to ensure an aligned table, since __BIGGEST_ALIGNMENT__ == 1 for 8-bit AVR-GCC */
+/* Ugly workaround to ensure an aligned table, since __BIGGEST_ALIGNMENT__ == 1 for the 8-bit AVR-GCC toolchain */
uint8_t USB_EndpointTable[sizeof(USB_EndpointTable_t) + 1];
void USB_Init(
@@ -66,8 +66,6 @@ void USB_Init(
USB_Options = Options;
#endif
- USB_IsInitialized = true;
-
uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask();
GlobalInterruptDisable();
@@ -89,6 +87,12 @@ void USB_Init(
SetGlobalInterruptMask(CurrentGlobalInt);
+ #if defined(USB_CAN_BE_BOTH)
+ USB_CurrentMode = Mode;
+ #endif
+
+ USB_IsInitialized = true;
+
USB_ResetInterface();
}
diff --git a/LUFA/Drivers/USB/Core/XMEGA/USBController_XMEGA.h b/LUFA/Drivers/USB/Core/XMEGA/USBController_XMEGA.h
index e1c782db6..8cc9dafc4 100644
--- a/LUFA/Drivers/USB/Core/XMEGA/USBController_XMEGA.h
+++ b/LUFA/Drivers/USB/Core/XMEGA/USBController_XMEGA.h
@@ -70,7 +70,6 @@
/* External Variables: */
extern uint8_t USB_EndpointTable[];
-
#endif
/* Includes: */
@@ -176,8 +175,10 @@
* Calling this function when the USB interface is already initialized will cause a complete USB
* interface reset and re-enumeration.
*
- * \param[in] Mode This is a mask indicating what mode the USB interface is to be initialized to, a value
+ * \param[in] Mode Mask indicating what mode the USB interface is to be initialized to, a value
* from the \ref USB_Modes_t enum.
+ * \note This parameter does not exist on devices with only one supported USB
+ * mode (device or host).
*
* \param[in] Options Mask indicating the options which should be used when initializing the USB
* interface to control the USB interface's behavior. This should be comprised of
@@ -232,7 +233,7 @@
void USB_ResetInterface(void);
/* Global Variables: */
- #if (!defined(USB_HOST_ONLY) && !defined(USB_DEVICE_ONLY)) || defined(__DOXYGEN__)
+ #if defined(USB_CAN_BE_BOTH) || defined(__DOXYGEN__)
/** Indicates the mode that the USB interface is currently initialized to, a value from the
* \ref USB_Modes_t enum.
*
@@ -247,7 +248,9 @@
* USB interface is not initialized.
*/
extern volatile uint8_t USB_CurrentMode;
- #elif defined(USB_DEVICE_ONLY)
+ #elif defined(USB_CAN_BE_HOST)
+ #define USB_CurrentMode USB_MODE_Host
+ #elif defined(USB_CAN_BE_DEVICE)
#define USB_CurrentMode USB_MODE_Device
#endif