diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2010-02-24 06:21:46 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2010-02-24 06:21:46 +0000 |
commit | a7aaa45ec4c3f415bf6073a5cc016635d5ecf77d (patch) | |
tree | 19b5e669eb96b428a7d8e002c6dc9af88dbd950d /LUFA/Drivers/USB | |
parent | 3702ba1fb31f265360a0e4cf1736465e44389103 (diff) | |
download | lufa-a7aaa45ec4c3f415bf6073a5cc016635d5ecf77d.tar.gz lufa-a7aaa45ec4c3f415bf6073a5cc016635d5ecf77d.tar.bz2 lufa-a7aaa45ec4c3f415bf6073a5cc016635d5ecf77d.zip |
More AVR32 achitecture ports.
Diffstat (limited to 'LUFA/Drivers/USB')
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/RNDIS.c | 6 | ||||
-rw-r--r-- | LUFA/Drivers/USB/HighLevel/USBInterrupt.c | 29 | ||||
-rw-r--r-- | LUFA/Drivers/USB/HighLevel/USBInterrupt.h | 18 | ||||
-rw-r--r-- | LUFA/Drivers/USB/HighLevel/USBTask.h | 4 | ||||
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/Device.h | 2 | ||||
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/Endpoint.h | 16 | ||||
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/LowLevel.h | 70 | ||||
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/Pipe.h | 4 | ||||
-rw-r--r-- | LUFA/Drivers/USB/USB.h | 4 |
9 files changed, 87 insertions, 66 deletions
diff --git a/LUFA/Drivers/USB/Class/Device/RNDIS.c b/LUFA/Drivers/USB/Class/Device/RNDIS.c index 1961e7e84..197fe6b18 100644 --- a/LUFA/Drivers/USB/Class/Device/RNDIS.c +++ b/LUFA/Drivers/USB/Class/Device/RNDIS.c @@ -345,7 +345,11 @@ static bool RNDIS_Device_ProcessNDISQuery(USB_ClassInfo_RNDIS_Device_t* const RN case OID_GEN_SUPPORTED_LIST:
*ResponseSize = sizeof(AdapterSupportedOIDList);
- memcpy_P(ResponseData, AdapterSupportedOIDList, sizeof(AdapterSupportedOIDList));
+ #if defined(__AVR32__)
+ memcpy(ResponseData, AdapterSupportedOIDList, sizeof(AdapterSupportedOIDList));
+ #elif defined(__AVR__)
+ memcpy_P(ResponseData, AdapterSupportedOIDList, sizeof(AdapterSupportedOIDList));
+ #endif
return true;
case OID_GEN_PHYSICAL_MEDIUM:
diff --git a/LUFA/Drivers/USB/HighLevel/USBInterrupt.c b/LUFA/Drivers/USB/HighLevel/USBInterrupt.c index f8da7e656..f009a0aa5 100644 --- a/LUFA/Drivers/USB/HighLevel/USBInterrupt.c +++ b/LUFA/Drivers/USB/HighLevel/USBInterrupt.c @@ -51,17 +51,24 @@ void USB_INT_DisableAllInterrupts(void) void USB_INT_ClearAllInterrupts(void)
{
- #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
- USBINT = 0;
- #endif
-
- #if defined(USB_CAN_BE_HOST)
- UHINT = 0;
- OTGINT = 0;
- #endif
-
- #if defined(USB_CAN_BE_DEVICE)
- UDINT = 0;
+ #if defined(__AVR32__)
+ AVR32_USBB.USBSTACLR = 0xFFFFFF;
+ AVR32_USBB.UHINTCLR = 0xFFFFFF;
+ AVR32_USBB.UECONX =
+ AVR32_USBB.UDINTCLR = 0xFFFFFF;
+ #elif defined(__AVR__)
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
+ USBINT = 0;
+ #endif
+
+ #if defined(USB_CAN_BE_HOST)
+ UHINT = 0;
+ OTGINT = 0;
+ #endif
+
+ #if defined(USB_CAN_BE_DEVICE)
+ UDINT = 0;
+ #endif
#endif
}
diff --git a/LUFA/Drivers/USB/HighLevel/USBInterrupt.h b/LUFA/Drivers/USB/HighLevel/USBInterrupt.h index 8fb152dd5..482ba0e9e 100644 --- a/LUFA/Drivers/USB/HighLevel/USBInterrupt.h +++ b/LUFA/Drivers/USB/HighLevel/USBInterrupt.h @@ -62,17 +62,19 @@ #if defined(__AVR32__)
#define USB_INT_Enable(int) MACROS{ USB_INT_GET_EN_REG(int) |= USB_INT_GET_EN_MASK(int); }MACROE
#define USB_INT_Disable(int) MACROS{ USB_INT_GET_EN_REG(int) &= ~(USB_INT_GET_EN_MASK(int)); }MACROE
- #define USB_INT_Clear(int) MACROS{ USB_INT_GET_INT_REG(int) ## CLR |= USB_INT_GET_INT_MASK(int) ## C; }MACROE
+ #define USB_INT_Clear(int) MACROS{ USB_INT_GET_INTC_REG(int) |= USB_INT_GET_INTC_MASK(int); }MACROE
#define USB_INT_IsEnabled(int) ((USB_INT_GET_EN_REG(int) & USB_INT_GET_EN_MASK(int)) ? true : false)
#define USB_INT_HasOccurred(int) ((USB_INT_GET_INT_REG(int) & USB_INT_GET_INT_MASK(int)) ? true : false)
- #define USB_INT_GET_EN_REG(a, b, c, d) *((volatile uint32_t*)AVR32_USBB_ ## a)
+ #define USB_INT_GET_EN_REG(a, b, c, d) *( (volatile uint32_t*)AVR32_USBB_ ## a )
#define USB_INT_GET_EN_MASK(a, b, c, d) AVR32_USBB_ ## b
- #define USB_INT_GET_INT_REG(a, b, c, d) *((volatile uint32_t*)AVR32_USBB_ ## c)
+ #define USB_INT_GET_INT_REG(a, b, c, d) *( (volatile uint32_t*)AVR32_USBB_ ## c )
#define USB_INT_GET_INT_MASK(a, b, c, d) AVR32_USBB_ ## d
+ #define USB_INT_GET_INTC_REG(a, b, c, d) *( (volatile uint32_t*)AVR32_USBB_ ## c ## CLR )
+ #define USB_INT_GET_INTC_MASK(a, b, c, d) AVR32_USBB_ ## d ## C
#define USB_INT_VBUS USBCON, USBCON_VBUSTE_MASK, USBSTA, USBSTA_VBUSTI_MASK
- #define USB_INT_IDTI USBCON, USBCON_IDTE_MASK , USBINT, USBCON_IDTI_MASK
+ #define USB_INT_IDTI USBCON, USBCON_IDTE_MASK , USBSTA, USBCON_IDTI_MASK
#define USB_INT_WAKEUP UDIEN , UDIEN_WAKEUPE_MASK, UDINT , UDIEN_WAKEUPI_MASK
#define USB_INT_SUSPEND UDIEN , UDIEN_SUSPE_MASK , UDINT , UDIEN_SUSPI_MASK
#define USB_INT_EORSTI UDIEN , UDIEN_EORSTE_MASK , UDINT , UDIEN_EORSTI_MASK
@@ -81,10 +83,10 @@ #define USB_INT_DDISCI UHIEN , UDIEN_DDISCE_MASK , UHINT , UHIEN_DDISCI_MASK
#define USB_INT_HSOFI UHIEN, UHIEN_HSOFE_MASK , UHINT , UHIEN_HSOFI_MASK
#define USB_INT_RSTI UHIEN , UHIEN_RSTE_MASK , UHINT , UHIEN_RSTI_MASK
- #define USB_INT_RXSTPI UEIENX, UEIENX_RXSTPE_MASK, UEINTX, UEIENX_RXSTPI_MASK
- #define USB_INT_BCERRI OTGIEN, OTGIEN_BCERRE_MASK, OTGINT, OTGIEN_BCERRI_MASK
- #define USB_INT_VBERRI OTGIEN, OTGIEN_VBERRE_MASK, OTGINT, OTGIEN_VBERRI_MASK
- #define USB_INT_SRPI OTGIEN, OTGIEN_SRPE_MASK , OTGINT, OTGIEN_SRPI_MASK
+ #define USB_INT_RXSTPI UECONX, UECONX_RXSTPE_MASK, UESTAX, UESTAX_RXSTPI_MASK
+ #define USB_INT_BCERRI USBCON, USBCON_BCERRE_MASK, USBSTA, USBSTA_BCERRI_MASK
+ #define USB_INT_VBERRI USBCON, USBCON_VBERRE_MASK, USBSTA, USBSTA_VBERRI_MASK
+ #define USB_INT_SRPI USBCON, USBCON_SRPE_MASK , USBSTA, USBSTA_SRPI_MASK
#elif defined(__AVR__)
#define USB_INT_Enable(int) MACROS{ USB_INT_GET_EN_REG(int) |= USB_INT_GET_EN_MASK(int); }MACROE
#define USB_INT_Disable(int) MACROS{ USB_INT_GET_EN_REG(int) &= ~(USB_INT_GET_EN_MASK(int)); }MACROE
diff --git a/LUFA/Drivers/USB/HighLevel/USBTask.h b/LUFA/Drivers/USB/HighLevel/USBTask.h index e65a5dfc9..f2aa03bdb 100644 --- a/LUFA/Drivers/USB/HighLevel/USBTask.h +++ b/LUFA/Drivers/USB/HighLevel/USBTask.h @@ -87,7 +87,7 @@ extern USB_Request_Header_t USB_ControlRequest;
#if defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__)
- #if (!defined(__AVR32__) && !defined(HOST_STATE_AS_GPIOR)) || defined(__DOXYGEN__)
+ #if (!defined(__AVR32__) || !defined(HOST_STATE_AS_GPIOR)) || defined(__DOXYGEN__)
/** Indicates the current host state machine state. When in host mode, this indicates the state
* via one of the values of the \ref USB_Host_States_t enum values.
*
@@ -116,7 +116,7 @@ #endif
#if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__)
- #if (!defined(__AVR32__) && !defined(DEVICE_STATE_AS_GPIOR)) || defined(__DOXYGEN__)
+ #if (defined(__AVR32__) || !defined(DEVICE_STATE_AS_GPIOR)) || defined(__DOXYGEN__)
/** Indicates the current device state machine state. When in device mode, this indicates the state
* via one of the values of the \ref USB_Device_States_t enum values.
*
diff --git a/LUFA/Drivers/USB/LowLevel/Device.h b/LUFA/Drivers/USB/LowLevel/Device.h index 11fb33a97..c1a1d92a4 100644 --- a/LUFA/Drivers/USB/LowLevel/Device.h +++ b/LUFA/Drivers/USB/LowLevel/Device.h @@ -223,7 +223,7 @@ #define USB_Device_SetLowSpeed() MACROS{ AVR32_USBB.UDCON.ls = true; }MACROE
#define USB_Device_SetFullSpeed() MACROS{ AVR32_USBB.UDCON.ls = false; }MACROE
- #define USB_Device_SetDeviceAddress(addr) MACROS{ AVR32_USBB.UDADDR = (AVR32_USBB_UDCON_ADDEN_MASK | DeviceAddress); }MACROE
+ #define USB_Device_SetDeviceAddress(addr) MACROS{ AVR32_USBB.UDCON.uadd = DeviceAddress; AVR32_USBB.UDCON.adden = true; }MACROE
#elif defined(__AVR__)
#define USB_Device_SetLowSpeed() MACROS{ UDCON |= (1 << LSM); }MACROE
#define USB_Device_SetFullSpeed() MACROS{ UDCON &= ~(1 << LSM); }MACROE
diff --git a/LUFA/Drivers/USB/LowLevel/Endpoint.h b/LUFA/Drivers/USB/LowLevel/Endpoint.h index 6b16fd7ac..8431573bf 100644 --- a/LUFA/Drivers/USB/LowLevel/Endpoint.h +++ b/LUFA/Drivers/USB/LowLevel/Endpoint.h @@ -95,6 +95,10 @@ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
#endif
+ #if defined(__AVR32__) && !defined(__AVR32_EPREG_X)
+ #define __AVR32_EPREG_X(x) ((volatile uint32_t*)AVR32_USBB_ ## x)[USB_SelectedEPNumber]
+ #endif
+
/* Public Interface - May be used in end-application: */
/* Macros: */
#if defined(__AVR32__) || defined(__DOXYGEN__)
@@ -377,17 +381,17 @@ #if !defined(CONTROL_ONLY_DEVICE)
#define Endpoint_GetCurrentEndpoint() USB_SelectedEPNumber
#define Endpoint_SelectEndpoint(epnum) MACROS{ USB_SelectedEPNumber = (epnum); }MACROE
- #define Endpoint_IsReadWriteAllowed() (__AVR32_EPREG_X(UESTA0) & AVR32_USBB_RWAL_MASK)
+ #define Endpoint_IsReadWriteAllowed() (__AVR32_EPREG_X(UESTA0) & AVR32_USBB_RWALL_MASK)
#else
#define Endpoint_GetCurrentEndpoint() ENDPOINT_CONTROLEP
#define Endpoint_SelectEndpoint(epnum) (void)(epnum)
#endif
- #define Endpoint_ResetFIFO(epnum) MACROS{ AVR32_USBB.UERST |= (AVR32_USBB_EPRST0_MASK << (epnum)); \
- AVR32_USBB.UERST &= ~(AVR32_USBB_EPRST0_MASK << (epnum)); }MACROE
- #define Endpoint_EnableEndpoint() MACROS{ AVR32_USBB.UERST |= (AVR32_USBB_UERST_EPEN0_MASK << (epen)); }MACROE
- #define Endpoint_DisableEndpoint() MACROS{ AVR32_USBB.UERST &= ~(AVR32_USBB_UERST_EPEN0_MASK << (epen)); }MACROE
- #define Endpoint_IsEnabled() ((AVR32_USBB.UERST & (AVR32_USBB_UERST_EPEN0_MASK << (epen))) ? true : false)
+ #define Endpoint_ResetFIFO(epnum) MACROS{ AVR32_USBB.uerst |= (AVR32_USBB_EPRST0_MASK << (epnum)); \
+ AVR32_USBB.uerst &= ~(AVR32_USBB_EPRST0_MASK << (epnum)); }MACROE
+ #define Endpoint_EnableEndpoint() MACROS{ AVR32_USBB.uerst |= (AVR32_USBB_UERST_EPEN0_MASK << USB_SelectedEPNumber); }MACROE
+ #define Endpoint_DisableEndpoint() MACROS{ AVR32_USBB.uerst &= ~(AVR32_USBB_UERST_EPEN0_MASK << USB_SelectedEPNumber); }MACROE
+ #define Endpoint_IsEnabled() ((AVR32_USBB.uerst & (AVR32_USBB_UERST_EPEN0_MASK << USB_SelectedEPNumber)) ? true : false)
#define Endpoint_IsConfigured() ((__AVR32_EPREG_X(UESTA0) & AVR32_USBB_UESTA0_CFGOK_MASK) ? true : false)
#define Endpoint_GetEndpointInterrupts() (AVR32_USBB.UDINT >> AVR32_USBB_EP0INT)
diff --git a/LUFA/Drivers/USB/LowLevel/LowLevel.h b/LUFA/Drivers/USB/LowLevel/LowLevel.h index 2c8ade7b3..3c98c6df3 100644 --- a/LUFA/Drivers/USB/LowLevel/LowLevel.h +++ b/LUFA/Drivers/USB/LowLevel/LowLevel.h @@ -88,39 +88,43 @@ #if !defined(__INCLUDE_FROM_USB_DRIVER)
#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 input 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))
+
+ #if defined(__AVR32__)
+ #define USB_PLL_PSC 0
+ #elif defined(__AVR__)
+ #if !defined(F_CLOCK)
+ #error F_CLOCK is not defined. You must define F_CLOCK to the frequency of the unprescaled input clock in your project makefile.
#endif
- #endif
- #if !defined(USB_PLL_PSC)
- #error No PLL prescale value available for chosen F_CPU value and AVR model.
+ #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
#endif
/* Public Interface - May be used in end-application: */
@@ -147,7 +151,7 @@ *
* \note This token is not available on AVR models which do not support both host and device modes.
*/
- #define USB_MODE_UID 3
+ #define USB_MODE_UID 3
#endif
/** Regulator disable option mask for \ref USB_Init(). This indicates that the internal 3.3V USB data pad
@@ -206,7 +210,7 @@ *
* \note This token is not available on some AVR models which do not support hardware VBUS monitoring.
*/
- #define USB_VBUS_GetStatus() ((USBSTA & (1 << VBUS)) ? true : false)
+ #define USB_VBUS_GetStatus() ((USBSTA & (1 << VBUS)) ? true : false)
#endif
/** Detaches the device from the USB bus. This has the effect of removing the device from any
diff --git a/LUFA/Drivers/USB/LowLevel/Pipe.h b/LUFA/Drivers/USB/LowLevel/Pipe.h index fca44d866..ab11a5524 100644 --- a/LUFA/Drivers/USB/LowLevel/Pipe.h +++ b/LUFA/Drivers/USB/LowLevel/Pipe.h @@ -103,6 +103,10 @@ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
#endif
+ #if defined(__AVR32__) && !defined(__AVR32_EPREG_X)
+ #define __AVR32_EPREG_X(x) ((volatile uint32_t*)AVR32_USBB_ ## x)[USB_SelectedEPNumber]
+ #endif
+
/* Public Interface - May be used in end-application: */
/* Macros: */
/** Mask for \ref Pipe_GetErrorFlags(), indicating that an overflow error occurred in the pipe on the received data. */
diff --git a/LUFA/Drivers/USB/USB.h b/LUFA/Drivers/USB/USB.h index d648ebe51..406a909f9 100644 --- a/LUFA/Drivers/USB/USB.h +++ b/LUFA/Drivers/USB/USB.h @@ -355,10 +355,6 @@ #define __INCLUDE_FROM_USB_DRIVER
#endif
- #if defined(__AVR32__)
- #define __AVR32_EPREG_X(x) ((volatile uint32_t*)AVR32_USBB_ ## x)[USB_SelectedEPNumber]
- #endif
-
/* Includes: */
#include "HighLevel/USBMode.h"
|