diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2009-06-14 07:44:02 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2009-06-14 07:44:02 +0000 |
commit | 4d3a594f3e26447ba223ac58292c9a77480ceed3 (patch) | |
tree | 1bf9da2a2290ccdb594dffd8af29cfafae231900 /LUFA/Drivers | |
parent | 9798440ca4f694e7cd8312a51b82e59589f1ebeb (diff) | |
download | lufa-4d3a594f3e26447ba223ac58292c9a77480ceed3.tar.gz lufa-4d3a594f3e26447ba223ac58292c9a77480ceed3.tar.bz2 lufa-4d3a594f3e26447ba223ac58292c9a77480ceed3.zip |
Changed per-device controller preprocessor checks over to per-device series for better device control.
Fixed error in Endpoint.c using HSOFI rather than SOFI for counting elapsed milliseconds.
Diffstat (limited to 'LUFA/Drivers')
-rw-r--r-- | LUFA/Drivers/USB/HighLevel/Events.h | 2 | ||||
-rw-r--r-- | LUFA/Drivers/USB/HighLevel/USBInterrupt.c | 12 | ||||
-rw-r--r-- | LUFA/Drivers/USB/HighLevel/USBMode.h | 18 | ||||
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/DevChapter9.c | 6 | ||||
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/Device.h | 7 | ||||
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/Endpoint.c | 4 | ||||
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/Endpoint.h | 6 | ||||
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/LowLevel.c | 10 | ||||
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/LowLevel.h | 34 | ||||
-rw-r--r-- | LUFA/Drivers/USB/USB.h | 6 |
10 files changed, 54 insertions, 51 deletions
diff --git a/LUFA/Drivers/USB/HighLevel/Events.h b/LUFA/Drivers/USB/HighLevel/Events.h index 80ace8720..7f369bc63 100644 --- a/LUFA/Drivers/USB/HighLevel/Events.h +++ b/LUFA/Drivers/USB/HighLevel/Events.h @@ -275,7 +275,7 @@ #if defined(INCLUDE_FROM_EVENTS_C)
void USB_Event_Stub(void) ATTR_CONST;
- #if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER)
+ #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);
diff --git a/LUFA/Drivers/USB/HighLevel/USBInterrupt.c b/LUFA/Drivers/USB/HighLevel/USBInterrupt.c index 0b9d08223..43bc53220 100644 --- a/LUFA/Drivers/USB/HighLevel/USBInterrupt.c +++ b/LUFA/Drivers/USB/HighLevel/USBInterrupt.c @@ -32,9 +32,9 @@ void USB_INT_DisableAllInterrupts(void)
{
- #if defined(USB_FULL_CONTROLLER)
+ #if defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
USBCON &= ~((1 << VBUSTE) | (1 << IDTE));
- #elif defined(USB_MODIFIED_FULL_CONTROLLER)
+ #elif defined(USB_SERIES_4_AVR)
USBCON &= ~(1 << VBUSTE);
#endif
@@ -50,7 +50,7 @@ void USB_INT_DisableAllInterrupts(void) void USB_INT_ClearAllInterrupts(void)
{
- #if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER)
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
USBINT = 0;
#endif
@@ -67,7 +67,7 @@ void USB_INT_ClearAllInterrupts(void) ISR(USB_GEN_vect, ISR_BLOCK)
{
#if defined(USB_CAN_BE_DEVICE)
- #if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER)
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
if (USB_INT_HasOccurred(USB_INT_VBUS) && USB_INT_IsEnabled(USB_INT_VBUS))
{
USB_INT_Clear(USB_INT_VBUS);
@@ -121,7 +121,7 @@ ISR(USB_GEN_vect, ISR_BLOCK) EVENT_USB_Suspend();
- #if defined(USB_LIMITED_CONTROLLER) && !defined(NO_LIMITED_CONTROLLER_CONNECT)
+ #if defined(USB_SERIES_2_AVR) && !defined(NO_LIMITED_CONTROLLER_CONNECT)
if (USB_IsConnected)
{
USB_IsConnected = false;
@@ -145,7 +145,7 @@ ISR(USB_GEN_vect, ISR_BLOCK) USB_INT_Disable(USB_INT_WAKEUP);
USB_INT_Enable(USB_INT_SUSPEND);
- #if defined(USB_LIMITED_CONTROLLER) && !defined(NO_LIMITED_CONTROLLER_CONNECT)
+ #if defined(USB_SERIES_2_AVR) && !defined(NO_LIMITED_CONTROLLER_CONNECT)
if (!(USB_IsConnected))
{
USB_IsConnected = true;
diff --git a/LUFA/Drivers/USB/HighLevel/USBMode.h b/LUFA/Drivers/USB/HighLevel/USBMode.h index 138af9ed0..471f307e7 100644 --- a/LUFA/Drivers/USB/HighLevel/USBMode.h +++ b/LUFA/Drivers/USB/HighLevel/USBMode.h @@ -42,11 +42,13 @@ #endif
#if (defined(__AVR_AT90USB162__) || defined(__AVR_AT90USB82__))
- #define USB_LIMITED_CONTROLLER
+ #define USB_SERIES_2_AVR
#elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))
- #define USB_MODIFIED_FULL_CONTROLLER
- #else
- #define USB_FULL_CONTROLLER
+ #define USB_SERIES_4_AVR
+ #elif (defined(__AVR_ATmega32U6__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__))
+ #define USB_SERIES_6_AVR
+ #elif (defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__))
+ #define USB_SERIES_7_AVR
#endif
#if (!defined(USB_DEVICE_ONLY) && !defined(USB_HOST_ONLY))
@@ -61,14 +63,12 @@ #define USB_CurrentMode USB_MODE_DEVICE
#endif
- #if (defined(USB_HOST_ONLY) && defined(USB_DEVICE_ONLY))
+ #if (!(defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__)) && defined(USB_HOST_ONLY))
+ #error USB_HOST_ONLY is not available for the currently selected USB AVR model.
+ #elif (defined(USB_HOST_ONLY) && defined(USB_DEVICE_ONLY))
#error USB_HOST_ONLY and USB_DEVICE_ONLY are mutually exclusive.
#endif
- #if (defined(USE_RAM_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS))
- #error USE_RAM_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive.
- #endif
-
#if defined(USE_STATIC_OPTIONS)
#define USB_Options USE_STATIC_OPTIONS
#endif
diff --git a/LUFA/Drivers/USB/LowLevel/DevChapter9.c b/LUFA/Drivers/USB/LowLevel/DevChapter9.c index 9bba23495..829bd13e8 100644 --- a/LUFA/Drivers/USB/LowLevel/DevChapter9.c +++ b/LUFA/Drivers/USB/LowLevel/DevChapter9.c @@ -179,8 +179,8 @@ static void USB_Device_GetDescriptor(void) void* DescriptorPointer;
uint16_t DescriptorSize;
- if ((DescriptorSize = CALLBACK_USB_GetDescriptor(USB_ControlRequest.wValue,
- USB_ControlRequest.wIndex, &DescriptorPointer)) == NO_DESCRIPTOR)
+ if ((DescriptorSize = CALLBACK_USB_GetDescriptor(USB_ControlRequest.wValue, USB_ControlRequest.wIndex,
+ &DescriptorPointer)) == NO_DESCRIPTOR)
{
return;
}
@@ -209,7 +209,7 @@ static void USB_Device_GetDescriptor(void) while (USB_ControlRequest.wLength && (Endpoint_BytesInEndpoint() < USB_ControlEndpointSize))
{
#if defined (USE_EEPROM_DESCRIPTORS)
- Endpoint_Write_Byte(eeprom_read_byte(DescriptorPointer++));
+ Endpoint_Write_Byte(eeprom_read_byte(DescriptorPointer++));
#else
Endpoint_Write_Byte(pgm_read_byte(DescriptorPointer++));
#endif
diff --git a/LUFA/Drivers/USB/LowLevel/Device.h b/LUFA/Drivers/USB/LowLevel/Device.h index 31d612c0a..6661b9e0c 100644 --- a/LUFA/Drivers/USB/LowLevel/Device.h +++ b/LUFA/Drivers/USB/LowLevel/Device.h @@ -48,9 +48,14 @@ #include "../HighLevel/StdDescriptors.h"
#include "Endpoint.h"
+ /* Preprocessor Checks: */
+ #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: */
- #if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER) || defined(__DOXYGEN__)
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__)
/** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the
* USB interface should be initialized in low speed (1.5Mb/s) mode.
*
diff --git a/LUFA/Drivers/USB/LowLevel/Endpoint.c b/LUFA/Drivers/USB/LowLevel/Endpoint.c index fd97b75c1..dca755497 100644 --- a/LUFA/Drivers/USB/LowLevel/Endpoint.c +++ b/LUFA/Drivers/USB/LowLevel/Endpoint.c @@ -98,9 +98,9 @@ uint8_t Endpoint_WaitUntilReady(void) else if (Endpoint_IsStalled())
return ENDPOINT_READYWAIT_EndpointStalled;
- if (USB_INT_HasOccurred(USB_INT_HSOFI))
+ if (USB_INT_HasOccurred(USB_INT_SOFI))
{
- USB_INT_Clear(USB_INT_HSOFI);
+ USB_INT_Clear(USB_INT_SOFI);
if (!(TimeoutMSRem--))
return ENDPOINT_READYWAIT_Timeout;
diff --git a/LUFA/Drivers/USB/LowLevel/Endpoint.h b/LUFA/Drivers/USB/LowLevel/Endpoint.h index 323559320..2c7a064e5 100644 --- a/LUFA/Drivers/USB/LowLevel/Endpoint.h +++ b/LUFA/Drivers/USB/LowLevel/Endpoint.h @@ -128,7 +128,7 @@ #define ENDPOINT_DOUBLEBANK_SUPPORTED(n) _ENDPOINT_GET_DOUBLEBANK(n)
#if !defined(CONTROL_ONLY_DEVICE)
- #if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER) || defined(__DOXYGEN__)
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__)
/** Total number of endpoints (including the default control endpoint at address 0) which may
* be used in the device. Different USB AVR models support different amounts of endpoints,
* this value reflects the maximum number of endpoints for the currently selected AVR model.
@@ -316,7 +316,7 @@ */
static inline uint8_t Endpoint_GetEndpointDirection(void);
#else
- #if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER) || defined(__DOXYGEN__)
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__)
#define Endpoint_BytesInEndpoint() UEBCX
#else
#define Endpoint_BytesInEndpoint() UEBCLX
@@ -933,7 +933,7 @@ #define _ENDPOINT_GET_DOUBLEBANK2(details) _ENDPOINT_GET_DOUBLEBANK3(details)
#define _ENDPOINT_GET_DOUBLEBANK3(maxsize, db) db
- #if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER)
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
#define ENDPOINT_DETAILS_EP0 64, true
#define ENDPOINT_DETAILS_EP1 256, true
#define ENDPOINT_DETAILS_EP2 64, true
diff --git a/LUFA/Drivers/USB/LowLevel/LowLevel.c b/LUFA/Drivers/USB/LowLevel/LowLevel.c index 16a50ac8f..865a57d57 100644 --- a/LUFA/Drivers/USB/LowLevel/LowLevel.c +++ b/LUFA/Drivers/USB/LowLevel/LowLevel.c @@ -68,7 +68,7 @@ void USB_Init( USB_ControlPipeSize = PIPE_CONTROLPIPE_DEFAULT_SIZE;
#endif
- #if defined(USB_DEVICE_ONLY) && defined(USB_FULL_CONTROLLER)
+ #if defined(USB_DEVICE_ONLY) && (defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))
UHWCON |= (1 << UIMOD);
#elif defined(USB_HOST_ONLY)
UHWCON &= ~(1 << UIMOD);
@@ -99,7 +99,7 @@ void USB_Init( USB_ResetInterface();
- #if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER)
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
USB_OTGPAD_On();
#endif
@@ -136,7 +136,7 @@ void USB_ShutDown(void) USB_Interface_Disable();
USB_PLL_Off();
- #if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER)
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
USB_OTGPAD_Off();
#endif
@@ -165,7 +165,7 @@ void USB_ResetInterface(void) if (!(USB_Options & USB_OPT_MANUAL_PLL))
{
- #if defined(USB_MODIFIED_FULL_CONTROLLER)
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
PLLFRQ = ((1 << PLLUSB) | (1 << PDIV3) | (1 << PDIV1));
#endif
@@ -189,7 +189,7 @@ void USB_ResetInterface(void) USB_CLK_Unfreeze();
- #if (defined(USB_CAN_BE_DEVICE) && (defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER)))
+ #if (defined(USB_CAN_BE_DEVICE) && (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)))
if (USB_CurrentMode == USB_MODE_DEVICE)
{
if (USB_Options & USB_DEVICE_OPT_LOWSPEED)
diff --git a/LUFA/Drivers/USB/LowLevel/LowLevel.h b/LUFA/Drivers/USB/LowLevel/LowLevel.h index 41b0ff5f6..f22a751f0 100644 --- a/LUFA/Drivers/USB/LowLevel/LowLevel.h +++ b/LUFA/Drivers/USB/LowLevel/LowLevel.h @@ -77,22 +77,22 @@ #if (F_CLOCK == 8000000)
#if (defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__))
#define USB_PLL_PSC 0
- #elif (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || \
- defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) || \
- defined(__AVR_ATmega32U6__))
- #define USB_PLL_PSC ((1 << PLLP1) | (1 << PLLP0))
#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_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))
- #elif (defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__))
+ #if (defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__))
#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
@@ -107,11 +107,13 @@ */
#define USB_MODE_NONE 0
- /** Mode mask for the \ref USB_CurrentMode global and the \ref USB_Init() function. This indicates that the
- * USB interface is or should be initialized in the USB device mode.
- */
- #define USB_MODE_DEVICE 1
-
+ #if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__)
+ /** Mode mask for the \ref USB_CurrentMode global and the \ref USB_Init() function. This indicates that the
+ * USB interface is or should be initialized in the USB device mode.
+ */
+ #define USB_MODE_DEVICE 1
+ #endif
+
#if defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__)
/** Mode mask for the \ref USB_CurrentMode global and the \ref USB_Init() function. This indicates that the
* USB interface is or should be initialized in the USB host mode.
@@ -181,7 +183,7 @@ */
#define EP_TYPE_INTERRUPT 0x03
- #if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER) || defined(__DOXYGEN__)
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__)
/** Returns boolean true if the VBUS line is currently high (i.e. the USB host is supplying power),
* otherwise returns false.
*
@@ -320,7 +322,7 @@ #define USB_PLL_Off() MACROS{ PLLCSR = 0; }MACROE
#define USB_PLL_IsReady() ((PLLCSR & (1 << PLOCK)) ? true : false)
- #if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER)
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
#define USB_REG_On() MACROS{ UHWCON |= (1 << UVREGE); }MACROE
#define USB_REG_Off() MACROS{ UHWCON &= ~(1 << UVREGE); }MACROE
#else
diff --git a/LUFA/Drivers/USB/USB.h b/LUFA/Drivers/USB/USB.h index d0837a844..c2d9339ac 100644 --- a/LUFA/Drivers/USB/USB.h +++ b/LUFA/Drivers/USB/USB.h @@ -84,11 +84,7 @@ #ifndef __USB_H__
#define __USB_H__
- /* Preprocessor Checks: */
- #if (!(defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__)) && defined(USB_HOST_ONLY))
- #error USB_HOST_ONLY is not available for the currently selected USB AVR model.
- #endif
-
+ /* Preprocessor Checks: */
#if (!(defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \
defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \
defined(__AVR_AT90USB162__) || defined(__AVR_AT90USB82__) || \
|