aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers/USB/Core
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2011-02-26 15:54:11 +0000
committerDean Camera <dean@fourwalledcubicle.com>2011-02-26 15:54:11 +0000
commit6f01b6afd5a4fbd0a618f790e0afaa5eb2531e12 (patch)
tree53ece1aef3409d4dc0f26ec113af110cc809d866 /LUFA/Drivers/USB/Core
parenta318f32b310eac95a4a208a0f25fb1c39afa22f5 (diff)
downloadlufa-6f01b6afd5a4fbd0a618f790e0afaa5eb2531e12.tar.gz
lufa-6f01b6afd5a4fbd0a618f790e0afaa5eb2531e12.tar.bz2
lufa-6f01b6afd5a4fbd0a618f790e0afaa5eb2531e12.zip
More UC3B architecture port updates.
Diffstat (limited to 'LUFA/Drivers/USB/Core')
-rw-r--r--LUFA/Drivers/USB/Core/AVR8/Device_AVR8.c2
-rw-r--r--LUFA/Drivers/USB/Core/UC3B/Device_UC3B.c4
-rw-r--r--LUFA/Drivers/USB/Core/UC3B/Device_UC3B.h6
-rw-r--r--LUFA/Drivers/USB/Core/UC3B/Endpoint_UC3B.c42
-rw-r--r--LUFA/Drivers/USB/Core/UC3B/USBController_UC3B.c36
-rw-r--r--LUFA/Drivers/USB/Core/UC3B/USBController_UC3B.h126
-rw-r--r--LUFA/Drivers/USB/Core/UC3B/USBInterrupt_UC3B.c24
7 files changed, 21 insertions, 219 deletions
diff --git a/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.c b/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.c
index 2473327b3..4bf339308 100644
--- a/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.c
+++ b/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.c
@@ -46,7 +46,7 @@ void USB_Device_SendRemoteWakeup(void)
USB_CLK_Unfreeze();
UDCON |= (1 << RMWKUP);
- while (!(UDCON & (1 << RMWKUP)));
+ while (UDCON & (1 << RMWKUP));
}
#endif
diff --git a/LUFA/Drivers/USB/Core/UC3B/Device_UC3B.c b/LUFA/Drivers/USB/Core/UC3B/Device_UC3B.c
index fc6abc891..8ea9bd7aa 100644
--- a/LUFA/Drivers/USB/Core/UC3B/Device_UC3B.c
+++ b/LUFA/Drivers/USB/Core/UC3B/Device_UC3B.c
@@ -45,8 +45,8 @@ void USB_Device_SendRemoteWakeup(void)
USB_CLK_Unfreeze();
- AVR32_USBB.UDCON |= (1 << RMWKUP);
- while (!(AVR32_USBB.UDCON & (1 << RMWKUP)));
+ AVR32_USBB.UDCON.rmwakeup = true;
+ while (AVR32_USBB.UDCON.rmwakeup);
}
#endif
diff --git a/LUFA/Drivers/USB/Core/UC3B/Device_UC3B.h b/LUFA/Drivers/USB/Core/UC3B/Device_UC3B.h
index d68b6e893..7d4802722 100644
--- a/LUFA/Drivers/USB/Core/UC3B/Device_UC3B.h
+++ b/LUFA/Drivers/USB/Core/UC3B/Device_UC3B.h
@@ -59,10 +59,6 @@
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
#endif
- #if (defined(USE_RAM_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS))
- #error USE_RAM_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive.
- #endif
-
/* Public Interface - May be used in end-application: */
/* Macros: */
/** \name USB Device Mode Option Masks */
@@ -209,7 +205,7 @@
static inline void USB_Device_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE;
static inline void USB_Device_SetDeviceAddress(const uint8_t Address)
{
- AVR32_USBB.UDCON = (AVR32_USBB_UDCON & ~AVR32_USBB_UDADDR) | Address;
+ AVR32_USBB.udcon = (AVR32_USBB.udcon & ~AVR32_USBB_UADD_MASK) | Address;
AVR32_USBB.UDCON.adden = true;
}
diff --git a/LUFA/Drivers/USB/Core/UC3B/Endpoint_UC3B.c b/LUFA/Drivers/USB/Core/UC3B/Endpoint_UC3B.c
index a212543e0..05a81f273 100644
--- a/LUFA/Drivers/USB/Core/UC3B/Endpoint_UC3B.c
+++ b/LUFA/Drivers/USB/Core/UC3B/Endpoint_UC3B.c
@@ -41,10 +41,10 @@ uint8_t USB_ControlEndpointSize = ENDPOINT_CONTROLEP_DEFAULT_SIZE;
uint8_t USB_SelectedEndpoint = ENDPOINT_CONTROLEP;
+
bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number,
const uint32_t UECFGXData)
{
-#if defined(CONTROL_ONLY_DEVICE) || defined(ORDERED_EP_CONFIG)
Endpoint_SelectEndpoint(Number);
Endpoint_EnableEndpoint();
@@ -52,42 +52,6 @@ bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number,
*((uint32_t*)AVR32_USBB_UECFG0)[USB_SelectedEndpoint] = UECFGXData;
return Endpoint_IsConfigured();
-#else
- for (uint8_t EPNum = Number; EPNum < ENDPOINT_TOTAL_ENDPOINTS; EPNum++)
- {
- uint32_t UECFGXTemp;
- uint32_t UEIENXTemp;
-
- Endpoint_SelectEndpoint(EPNum);
-
- if (EPNum == Number)
- {
- UECFGXTemp = UECFGXData;
- UEIENXTemp = 0;
- }
- else
- {
- UECFGXTemp = *((uint32_t*)AVR32_USBB_UECFG0)[EPNum];
- UEIENXTemp = *((uint32_t*)AVR32_USBB_UEINT0)[EPNum];
- }
-
- if (!(UECFGXTemp & AVR32_USBB_ALLOC))
- continue;
-
- Endpoint_DisableEndpoint();
- *((uint32_t*)AVR32_USBB_UECFG0)[USB_SelectedEndpoint] &= ~AVR32_USBB_ALLOC;
-
- Endpoint_EnableEndpoint();
- *((uint32_t*)AVR32_USBB_UECFG0)[EPNum] = UECFGXTemp;
- *((uint32_t*)AVR32_USBB_UEINT0)[EPNum] = UEINTXTemp;
-
- if (!(Endpoint_IsConfigured()))
- return false;
- }
-
- Endpoint_SelectEndpoint(Number);
- return true;
-#endif
}
void Endpoint_ClearEndpoints(void)
@@ -97,9 +61,7 @@ void Endpoint_ClearEndpoints(void)
for (uint8_t EPNum = 0; EPNum < ENDPOINT_TOTAL_ENDPOINTS; EPNum++)
{
Endpoint_SelectEndpoint(EPNum);
- UEIENX = 0;
- UEINTX = 0;
- UECFG1X = 0;
+ *((uint32_t*)AVR32_USBB_UECFG0)[USB_SelectedEndpoint] = 0;
Endpoint_DisableEndpoint();
}
}
diff --git a/LUFA/Drivers/USB/Core/UC3B/USBController_UC3B.c b/LUFA/Drivers/USB/Core/UC3B/USBController_UC3B.c
index 1a80c5b05..8e18add47 100644
--- a/LUFA/Drivers/USB/Core/UC3B/USBController_UC3B.c
+++ b/LUFA/Drivers/USB/Core/UC3B/USBController_UC3B.c
@@ -60,15 +60,10 @@ void USB_Init(
USB_Options = Options;
#endif
- if (!(USB_Options & USB_OPT_REG_DISABLED))
- USB_REG_On();
- else
- USB_REG_Off();
-
#if defined(USB_CAN_BE_BOTH)
if (Mode == USB_MODE_UID)
{
- UHWCON |= (1 << UIDE);
+ AVR32_USBB.USBCON.uide = true;
USB_INT_Enable(USB_INT_IDTI);
USB_CurrentMode = USB_GetUSBModeFromUID();
}
@@ -91,14 +86,7 @@ void USB_Disable(void)
USB_Detach();
USB_Controller_Disable();
- if (!(USB_Options & USB_OPT_MANUAL_PLL))
- USB_PLL_Off();
-
- USB_REG_Off();
-
- #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
USB_OTGPAD_Off();
- #endif
#if defined(USB_CAN_BE_BOTH)
USB_CurrentMode = USB_MODE_None;
@@ -118,20 +106,10 @@ void USB_ResetInterface(void)
USB_Controller_Reset();
- if (!(USB_Options & USB_OPT_MANUAL_PLL))
- {
- #if defined(USB_SERIES_4_AVR)
- PLLFRQ = ((1 << PLLUSB) | (1 << PDIV3) | (1 << PDIV1));
- #endif
-
- USB_PLL_On();
- while (!(USB_PLL_IsReady()));
- }
-
#if defined(USB_CAN_BE_BOTH)
if (UIDModeSelectEnabled)
{
- UHWCON |= (1 << UIDE);
+ AVR32_USBB.USBCON.uide = true;
USB_INT_Enable(USB_INT_IDTI);
}
#endif
@@ -141,25 +119,19 @@ void USB_ResetInterface(void)
if (USB_CurrentMode == USB_MODE_Device)
{
#if defined(USB_CAN_BE_DEVICE)
- #if (defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))
- UHWCON |= (1 << UIMOD);
- #endif
-
+ AVR32_USBB.USBCON.uimod = true;
USB_Init_Device();
#endif
}
else if (USB_CurrentMode == USB_MODE_Host)
{
#if defined(USB_CAN_BE_HOST)
- UHWCON &= ~(1 << UIMOD);
-
+ AVR32_USBB.USBCON.uimod = false;
USB_Init_Host();
#endif
}
- #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))
USB_OTGPAD_On();
- #endif
}
#if defined(USB_CAN_BE_DEVICE)
diff --git a/LUFA/Drivers/USB/Core/UC3B/USBController_UC3B.h b/LUFA/Drivers/USB/Core/UC3B/USBController_UC3B.h
index 4c903621a..f528c6b1c 100644
--- a/LUFA/Drivers/USB/Core/UC3B/USBController_UC3B.h
+++ b/LUFA/Drivers/USB/Core/UC3B/USBController_UC3B.h
@@ -80,71 +80,8 @@
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
#endif
- #if !defined(F_CLOCK)
- #error F_CLOCK is not defined. You must define F_CLOCK to the frequency of the unprescaled USB controller clock in your project makefile.
- #endif
-
- #if (F_CLOCK == 8000000)
- #if (defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__) || \
- defined(__AVR_ATmega8U2__) || defined(__AVR_ATmega16U2__) || \
- defined(__AVR_ATmega32U2__))
- #define USB_PLL_PSC 0
- #elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))
- #define USB_PLL_PSC 0
- #elif (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_ATmega32U6__))
- #define USB_PLL_PSC ((1 << PLLP1) | (1 << PLLP0))
- #elif (defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__))
- #define USB_PLL_PSC ((1 << PLLP1) | (1 << PLLP0))
- #endif
- #elif (F_CLOCK == 16000000)
- #if (defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__) || \
- defined(__AVR_ATmega8U2__) || defined(__AVR_ATmega16U2__) || \
- defined(__AVR_ATmega32U2__))
- #define USB_PLL_PSC (1 << PLLP0)
- #elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))
- #define USB_PLL_PSC (1 << PINDIV)
- #elif (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_ATmega32U6__))
- #define USB_PLL_PSC ((1 << PLLP2) | (1 << PLLP1))
- #elif (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__))
- #define USB_PLL_PSC ((1 << PLLP2) | (1 << PLLP0))
- #endif
- #endif
-
- #if !defined(USB_PLL_PSC)
- #error No PLL prescale value available for chosen F_CLOCK value and AVR model.
- #endif
-
/* Public Interface - May be used in end-application: */
/* Macros: */
- /** \name USB Controller Option Masks */
- //@{
- /** Regulator disable option mask for \ref USB_Init(). This indicates that the internal 3.3V USB data pad
- * regulator should be enabled to regulate the data pin voltages to within the USB standard.
- *
- * \note See USB AVR data sheet for more information on the internal pad regulator.
- */
- #define USB_OPT_REG_DISABLED (1 << 1)
-
- /** Regulator enable option mask for \ref USB_Init(). This indicates that the internal 3.3V USB data pad
- * regulator should be disabled and the AVR's VCC level used for the data pads.
- *
- * \note See USB AVR data sheet for more information on the internal pad regulator.
- */
- #define USB_OPT_REG_ENABLED (0 << 1)
-
- /** Manual PLL control option mask for \ref USB_Init(). This indicates to the library that the user application
- * will take full responsibility for controlling the AVR's PLL (used to generate the high frequency clock
- * that the USB controller requires) and ensuring that it is locked at the correct frequency for USB operations.
- */
- #define USB_OPT_MANUAL_PLL (1 << 2)
-
- /** Automatic PLL control option mask for \ref USB_Init(). This indicates to the library that the library should
- * take full responsibility for controlling the AVR's PLL (used to generate the high frequency clock
- * that the USB controller requires) and ensuring that it is locked at the correct frequency for USB operations.
- */
- #define USB_OPT_AUTO_PLL (0 << 2)
- //@}
-
/** \name Endpoint/Pipe Type Masks */
//@{
/** Mask for a CONTROL type endpoint or pipe.
@@ -191,7 +128,7 @@
static inline void USB_Detach(void) ATTR_ALWAYS_INLINE;
static inline void USB_Detach(void)
{
- UDCON |= (1 << DETACH);
+ AVR32_USBB.UDCON.detach = true;
}
/** Attaches the device to the USB bus. This announces the device's presence to any attached
@@ -205,7 +142,7 @@
static inline void USB_Attach(void) ATTR_ALWAYS_INLINE;
static inline void USB_Attach(void)
{
- UDCON &= ~(1 << DETACH);
+ AVR32_USBB.UDCON.detach = false;
}
/* Function Prototypes: */
@@ -341,97 +278,56 @@
#endif
/* Inline Functions: */
- static inline void USB_PLL_On(void) ATTR_ALWAYS_INLINE;
- static inline void USB_PLL_On(void)
- {
- PLLCSR = USB_PLL_PSC;
- PLLCSR |= (1 << PLLE);
- }
-
- static inline void USB_PLL_Off(void) ATTR_ALWAYS_INLINE;
- static inline void USB_PLL_Off(void)
- {
- PLLCSR = 0;
- }
-
- static inline bool USB_PLL_IsReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline bool USB_PLL_IsReady(void)
- {
- return ((PLLCSR & (1 << PLOCK)) ? true : false);
- }
-
- static inline void USB_REG_On(void) ATTR_ALWAYS_INLINE;
- static inline void USB_REG_On(void)
- {
- #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
- UHWCON |= (1 << UVREGE);
- #else
- REGCR &= ~(1 << REGDIS);
- #endif
- }
-
- static inline void USB_REG_Off(void) ATTR_ALWAYS_INLINE;
- static inline void USB_REG_Off(void)
- {
- #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
- UHWCON &= ~(1 << UVREGE);
- #else
- REGCR |= (1 << REGDIS);
- #endif
- }
-
#if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
static inline void USB_OTGPAD_On(void) ATTR_ALWAYS_INLINE;
static inline void USB_OTGPAD_On(void)
{
- USBCON |= (1 << OTGPADE);
+ AVR32_USBB.USBCON.otgpade = true;
}
static inline void USB_OTGPAD_Off(void) ATTR_ALWAYS_INLINE;
static inline void USB_OTGPAD_Off(void)
{
- USBCON &= ~(1 << OTGPADE);
+ AVR32_USBB.USBCON.otgpade = false;
}
#endif
static inline void USB_CLK_Freeze(void) ATTR_ALWAYS_INLINE;
static inline void USB_CLK_Freeze(void)
{
- USBCON |= (1 << FRZCLK);
+ AVR32_USBB.USBCON.frzclk = true;
}
static inline void USB_CLK_Unfreeze(void) ATTR_ALWAYS_INLINE;
static inline void USB_CLK_Unfreeze(void)
{
- USBCON &= ~(1 << FRZCLK);
+ AVR32_USBB.USBCON.frzclk = false;
}
static inline void USB_Controller_Enable(void) ATTR_ALWAYS_INLINE;
static inline void USB_Controller_Enable(void)
{
- USBCON |= (1 << USBE);
+ AVR32_USBB.USBCON.usbe = true;
}
static inline void USB_Controller_Disable(void) ATTR_ALWAYS_INLINE;
static inline void USB_Controller_Disable(void)
{
- USBCON &= ~(1 << USBE);
+ AVR32_USBB.USBCON.usbe = false;
}
static inline void USB_Controller_Reset(void) ATTR_ALWAYS_INLINE;
static inline void USB_Controller_Reset(void)
{
- const uint8_t Temp = USBCON;
-
- USBCON = (Temp & ~(1 << USBE));
- USBCON = (Temp | (1 << USBE));
+ AVR32_USBB.USBCON.usbe = false;
+ AVR32_USBB.USBCON.usbe = true;
}
#if defined(USB_CAN_BE_BOTH)
static inline uint8_t USB_GetUSBModeFromUID(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline uint8_t USB_GetUSBModeFromUID(void)
{
- if (USBSTA & (1 << ID))
+ if (AVR32_USBB.USBSTA.id)
return USB_MODE_Device;
else
return USB_MODE_Host;
diff --git a/LUFA/Drivers/USB/Core/UC3B/USBInterrupt_UC3B.c b/LUFA/Drivers/USB/Core/UC3B/USBInterrupt_UC3B.c
index a079e4c90..9324acfe9 100644
--- a/LUFA/Drivers/USB/Core/UC3B/USBInterrupt_UC3B.c
+++ b/LUFA/Drivers/USB/Core/UC3B/USBInterrupt_UC3B.c
@@ -164,10 +164,6 @@ ISR(USB_GEN_vect, ISR_BLOCK)
ENDPOINT_DIR_OUT, USB_ControlEndpointSize,
ENDPOINT_BANK_SINGLE);
- #if defined(INTERRUPT_CONTROL_ENDPOINT)
- USB_INT_Enable(USB_INT_RXSTPI);
- #endif
-
EVENT_USB_Device_Reset();
}
#endif
@@ -247,23 +243,3 @@ ISR(USB_GEN_vect, ISR_BLOCK)
}
#endif
}
-
-#if defined(INTERRUPT_CONTROL_ENDPOINT) && defined(USB_CAN_BE_DEVICE)
-ISR(USB_COM_vect, ISR_BLOCK)
-{
- uint8_t PrevSelectedEndpoint = Endpoint_GetCurrentEndpoint();
-
- Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);
- USB_INT_Disable(USB_INT_RXSTPI);
-
- NONATOMIC_BLOCK(NONATOMIC_FORCEOFF)
- {
- USB_Device_ProcessControlRequest();
- }
-
- Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);
- USB_INT_Enable(USB_INT_RXSTPI);
- Endpoint_SelectEndpoint(PrevSelectedEndpoint);
-}
-#endif
-