diff --git a/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h b/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h index 454f0b61cf..1168fa2a1d 100644 --- a/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h +++ b/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h @@ -47,7 +47,11 @@ #define __CONFIGDESCRIPTOR_H__ /* Includes: */ - #include + #if defined(__AVR32__) + #include + #elif defined(__AVR__) + #include + #endif #include "../../../Common/Common.h" #include "../HighLevel/USBMode.h" diff --git a/LUFA/Drivers/USB/HighLevel/Events.h b/LUFA/Drivers/USB/HighLevel/Events.h index 12b30b2502..f6d8aaca8b 100644 --- a/LUFA/Drivers/USB/HighLevel/Events.h +++ b/LUFA/Drivers/USB/HighLevel/Events.h @@ -50,7 +50,11 @@ #define __USBEVENTS_H__ /* Includes: */ - #include + #if defined(__AVR32__) + #include + #elif defined(__AVR__) + #include + #endif #include "../../../Common/Common.h" #include "USBMode.h" diff --git a/LUFA/Drivers/USB/HighLevel/StdDescriptors.h b/LUFA/Drivers/USB/HighLevel/StdDescriptors.h index 807eb78f82..f94673d2e1 100644 --- a/LUFA/Drivers/USB/HighLevel/StdDescriptors.h +++ b/LUFA/Drivers/USB/HighLevel/StdDescriptors.h @@ -41,9 +41,16 @@ #define __USBDESCRIPTORS_H__ /* Includes: */ - #include - #include - #include + #if defined(__AVR32__) + #include + #include + #include + #include + #elif defined(__AVR__) + #include + #include + #include + #endif #include "../../../Common/Common.h" #include "USBMode.h" diff --git a/LUFA/Drivers/USB/HighLevel/USBInterrupt.h b/LUFA/Drivers/USB/HighLevel/USBInterrupt.h index 6ff7c70fa3..94f88e278e 100644 --- a/LUFA/Drivers/USB/HighLevel/USBInterrupt.h +++ b/LUFA/Drivers/USB/HighLevel/USBInterrupt.h @@ -32,8 +32,14 @@ #define __USBINTERRUPT_H__ /* Includes: */ - #include - #include + #if defined(__AVR32__) + #include + #include + #include + #elif defined(__AVR__) + #include + #include + #endif #include "../../../Common/Common.h" #include "../LowLevel/LowLevel.h" diff --git a/LUFA/Drivers/USB/HighLevel/USBMode.h b/LUFA/Drivers/USB/HighLevel/USBMode.h index ba2d453947..1ceb981aed 100644 --- a/LUFA/Drivers/USB/HighLevel/USBMode.h +++ b/LUFA/Drivers/USB/HighLevel/USBMode.h @@ -69,6 +69,11 @@ * (i.e. AT90USBXXX7) when defined. */ #define USB_SERIES_7_AVR + + /** Indicates that the target AVR microcontroller belongs to the Series UC3B USB controller + * (i.e. AT32UC3BXXXX) when defined. + */ + #define USB_SERIES_UC3B_AVR /** Indicates that the target AVR microcontroller and compilation settings allow for the * target to be configured in USB Device mode when defined. @@ -95,9 +100,11 @@ #define USB_SERIES_6_AVR #elif (defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__)) #define USB_SERIES_7_AVR + #elif (defined(__AVR32_UC3B0256__)) + #define USB_SERIES_UC3B_AVR #endif - #if !defined(USB_SERIES_7_AVR) + #if !defined(USB_SERIES_7_AVR) && !defined(USB_SERIES_UC3B_AVR) #if defined(USB_HOST_ONLY) #error USB_HOST_ONLY is not available for the currently selected USB AVR model. #endif diff --git a/LUFA/Drivers/USB/HighLevel/USBTask.h b/LUFA/Drivers/USB/HighLevel/USBTask.h index c01b84c37e..350ad5dc54 100644 --- a/LUFA/Drivers/USB/HighLevel/USBTask.h +++ b/LUFA/Drivers/USB/HighLevel/USBTask.h @@ -32,9 +32,15 @@ #define __USBTASK_H__ /* Includes: */ - #include - #include - #include + #if defined(__AVR32__) + #include + #include + #include + #elif defined(__AVR__) + #include + #include + #include + #endif #include "../LowLevel/LowLevel.h" #include "Events.h" diff --git a/LUFA/Drivers/USB/LowLevel/DevChapter9.c b/LUFA/Drivers/USB/LowLevel/DevChapter9.c index 7d9e81502c..0d25e3b12e 100644 --- a/LUFA/Drivers/USB/LowLevel/DevChapter9.c +++ b/LUFA/Drivers/USB/LowLevel/DevChapter9.c @@ -139,7 +139,7 @@ static void USB_Device_SetAddress(void) if (DeviceAddress) USB_DeviceState = DEVICE_STATE_Addressed; - UDADDR = ((1 << ADDEN) | DeviceAddress); + USB_Device_SetDeviceAddress(DeviceAddress); return; } diff --git a/LUFA/Drivers/USB/LowLevel/DevChapter9.h b/LUFA/Drivers/USB/LowLevel/DevChapter9.h index 58a5dc80e4..cb1b44ac5a 100644 --- a/LUFA/Drivers/USB/LowLevel/DevChapter9.h +++ b/LUFA/Drivers/USB/LowLevel/DevChapter9.h @@ -32,10 +32,15 @@ #define __DEVCHAPTER9_H__ /* Includes: */ - #include - #include - #include - #include + #if defined(__AVR32__) + #include + #include + #elif defined(__AVR__) + #include + #include + #include + #include + #endif #include "../HighLevel/StdDescriptors.h" #include "../HighLevel/Events.h" @@ -70,7 +75,11 @@ enum USB_DescriptorMemorySpaces_t { MEMSPACE_FLASH = 0, /**< Indicates the requested descriptor is located in FLASH memory */ + + #if defined(__AVR__) || defined(__DOXYGEN__) MEMSPACE_EEPROM = 1, /**< Indicates the requested descriptor is located in EEPROM memory */ + #endif + MEMSPACE_RAM = 2, /**< Indicates the requested descriptor is located in RAM memory */ }; #endif @@ -125,6 +134,10 @@ #elif defined(USE_FLASH_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS) && defined(USE_RAM_DESCRIPTORS) #error Only one of the USE_*_DESCRIPTORS modes should be selected. #endif + + #if defined(USE_EEPROM_DESCRIPTORS) && defined(USB_SERIES_UC3B_AVR) + #error USE_EEPROM_DESCRIPTORS is not available on the UC3B series AVRs. + #endif /* Function Prototypes: */ void USB_Device_ProcessControlRequest(void); diff --git a/LUFA/Drivers/USB/LowLevel/Device.h b/LUFA/Drivers/USB/LowLevel/Device.h index 1f929bff09..9dff3f9171 100644 --- a/LUFA/Drivers/USB/LowLevel/Device.h +++ b/LUFA/Drivers/USB/LowLevel/Device.h @@ -41,9 +41,11 @@ #define __USBDEVICE_H__ /* Includes: */ - #include - #include - + #if defined(__AVR__) + #include + #include + #endif + #include "../../../Common/Common.h" #include "../HighLevel/StdDescriptors.h" #include "Endpoint.h" @@ -59,7 +61,8 @@ /* Public Interface - May be used in end-application: */ /* Macros: */ - #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__) + #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || \ + defined(USB_SERIES_UC3B_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. * @@ -68,13 +71,13 @@ * \note Restrictions apply on the number, size and type of endpoints which can be used * when running in low speed mode -- refer to the USB 2.0 standard. */ - #define USB_DEVICE_OPT_LOWSPEED (1 << 0) + #define USB_DEVICE_OPT_LOWSPEED (1 << 0) #endif /** Mask for the Options parameter of the USB_Init() function. This indicates that the * USB interface should be initialized in full speed (12Mb/s) mode. */ - #define USB_DEVICE_OPT_FULLSPEED (0 << 0) + #define USB_DEVICE_OPT_FULLSPEED (0 << 0) /* Pseudo-Function Macros: */ #if defined(__DOXYGEN__) @@ -129,16 +132,25 @@ */ static inline bool USB_Device_DisableSOFEvents(void); #else - #if !defined(NO_DEVICE_REMOTE_WAKEUP) - #define USB_Device_SendRemoteWakeup() MACROS{ UDCON |= (1 << RMWKUP); }MACROE + #if defined(__AVR32__) + #if !defined(NO_DEVICE_REMOTE_WAKEUP) + #define USB_Device_SendRemoteWakeup() MACROS{ AVR32_USBB.UDCON.rmwkup = true; }MACROE + + #define USB_Device_IsRemoteWakeupSent() AVR32_USBB.UDCON.rmwkup + #endif + + #define USB_Device_IsUSBSuspended() AVR32_USBB.UDINT.susp + #elif defined(__AVR__) + #if !defined(NO_DEVICE_REMOTE_WAKEUP) + #define USB_Device_SendRemoteWakeup() MACROS{ UDCON |= (1 << RMWKUP); }MACROE - #define USB_Device_IsRemoteWakeupSent() ((UDCON & (1 << RMWKUP)) ? false : true) + #define USB_Device_IsRemoteWakeupSent() ((UDCON & (1 << RMWKUP)) ? false : true) + #endif + + #define USB_Device_IsUSBSuspended() ((UDINT & (1 << SUSPI)) ? true : false) #endif - - #define USB_Device_IsUSBSuspended() ((UDINT & (1 << SUSPI)) ? true : false) - - #define USB_Device_EnableSOFEvents() MACROS{ USB_INT_Enable(USB_INT_SOFI); }MACROE + #define USB_Device_EnableSOFEvents() MACROS{ USB_INT_Enable(USB_INT_SOFI); }MACROE #define USB_Device_DisableSOFEvents() MACROS{ USB_INT_Disable(USB_INT_SOFI); }MACROE #endif @@ -207,8 +219,17 @@ /* Private Interface - For use in library only: */ #if !defined(__DOXYGEN__) /* Macros: */ - #define USB_Device_SetLowSpeed() MACROS{ UDCON |= (1 << LSM); }MACROE - #define USB_Device_SetFullSpeed() MACROS{ UDCON &= ~(1 << LSM); }MACROE + #if defined(__AVR32__) + #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 + #elif defined(__AVR__) + #define USB_Device_SetLowSpeed() MACROS{ UDCON |= (1 << LSM); }MACROE + #define USB_Device_SetFullSpeed() MACROS{ UDCON &= ~(1 << LSM); }MACROE + + #define USB_Device_SetDeviceAddress(addr) MACROS{ UDADDR = ((1 << ADDEN) | DeviceAddress); }MACROE + #endif #endif #endif diff --git a/LUFA/Drivers/USB/LowLevel/Endpoint.c b/LUFA/Drivers/USB/LowLevel/Endpoint.c index 81fef1c2ef..819e3f8125 100644 --- a/LUFA/Drivers/USB/LowLevel/Endpoint.c +++ b/LUFA/Drivers/USB/LowLevel/Endpoint.c @@ -225,12 +225,14 @@ uint8_t Endpoint_Discard_Stream(uint16_t Length #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(pgm_read_byte((uint8_t*)BufferPtr++)) #include "Template/Template_Endpoint_RW.c" -#define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_LE -#define TEMPLATE_BUFFER_TYPE const void* -#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN() -#define TEMPLATE_BUFFER_OFFSET(Length) 0 -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr++)) -#include "Template/Template_Endpoint_RW.c" +#if defined(__AVR__) + #define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_LE + #define TEMPLATE_BUFFER_TYPE const void* + #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN() + #define TEMPLATE_BUFFER_OFFSET(Length) 0 + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr++)) + #include "Template/Template_Endpoint_RW.c" +#endif #define TEMPLATE_FUNC_NAME Endpoint_Write_Stream_BE #define TEMPLATE_BUFFER_TYPE const void* @@ -239,12 +241,14 @@ uint8_t Endpoint_Discard_Stream(uint16_t Length #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(*((uint8_t*)BufferPtr--)) #include "Template/Template_Endpoint_RW.c" -#define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_BE -#define TEMPLATE_BUFFER_TYPE const void* -#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN() -#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr--)) -#include "Template/Template_Endpoint_RW.c" +#if defined(__AVR__) + #define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_BE + #define TEMPLATE_BUFFER_TYPE const void* + #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN() + #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr--)) + #include "Template/Template_Endpoint_RW.c" +#endif #define TEMPLATE_FUNC_NAME Endpoint_Write_PStream_BE #define TEMPLATE_BUFFER_TYPE const void* @@ -260,12 +264,14 @@ uint8_t Endpoint_Discard_Stream(uint16_t Length #define TEMPLATE_TRANSFER_BYTE(BufferPtr) *((uint8_t*)BufferPtr++) = Endpoint_Read_Byte() #include "Template/Template_Endpoint_RW.c" -#define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_LE -#define TEMPLATE_BUFFER_TYPE void* -#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT() -#define TEMPLATE_BUFFER_OFFSET(Length) 0 -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_write_byte((uint8_t*)BufferPtr++, Endpoint_Read_Byte()) -#include "Template/Template_Endpoint_RW.c" +#if defined(__AVR__) + #define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_LE + #define TEMPLATE_BUFFER_TYPE void* + #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT() + #define TEMPLATE_BUFFER_OFFSET(Length) 0 + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_write_byte((uint8_t*)BufferPtr++, Endpoint_Read_Byte()) + #include "Template/Template_Endpoint_RW.c" +#endif #define TEMPLATE_FUNC_NAME Endpoint_Read_Stream_BE #define TEMPLATE_BUFFER_TYPE void* @@ -274,12 +280,14 @@ uint8_t Endpoint_Discard_Stream(uint16_t Length #define TEMPLATE_TRANSFER_BYTE(BufferPtr) *((uint8_t*)BufferPtr--) = Endpoint_Read_Byte() #include "Template/Template_Endpoint_RW.c" -#define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_BE -#define TEMPLATE_BUFFER_TYPE void* -#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT() -#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_write_byte((uint8_t*)BufferPtr--, Endpoint_Read_Byte()) -#include "Template/Template_Endpoint_RW.c" +#if defined(__AVR__) + #define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_BE + #define TEMPLATE_BUFFER_TYPE void* + #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT() + #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_write_byte((uint8_t*)BufferPtr--, Endpoint_Read_Byte()) + #include "Template/Template_Endpoint_RW.c" +#endif #endif @@ -293,10 +301,12 @@ uint8_t Endpoint_Discard_Stream(uint16_t Length #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(pgm_read_byte((uint8_t*)BufferPtr++)) #include "Template/Template_Endpoint_Control_W.c" -#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_EStream_LE -#define TEMPLATE_BUFFER_OFFSET(Length) 0 -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr++)) -#include "Template/Template_Endpoint_Control_W.c" +#if defined(__AVR__) + #define TEMPLATE_FUNC_NAME Endpoint_Write_Control_EStream_LE + #define TEMPLATE_BUFFER_OFFSET(Length) 0 + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr++)) + #include "Template/Template_Endpoint_Control_W.c" +#endif #define TEMPLATE_FUNC_NAME Endpoint_Write_Control_Stream_BE #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) @@ -308,29 +318,35 @@ uint8_t Endpoint_Discard_Stream(uint16_t Length #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(pgm_read_byte((uint8_t*)BufferPtr--)) #include "Template/Template_Endpoint_Control_W.c" -#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_EStream_BE -#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr--)) -#include "Template/Template_Endpoint_Control_W.c" +#if defined(__AVR__) + #define TEMPLATE_FUNC_NAME Endpoint_Write_Control_EStream_BE + #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr--)) + #include "Template/Template_Endpoint_Control_W.c" +#endif #define TEMPLATE_FUNC_NAME Endpoint_Read_Control_Stream_LE #define TEMPLATE_BUFFER_OFFSET(Length) 0 #define TEMPLATE_TRANSFER_BYTE(BufferPtr) *((uint8_t*)BufferPtr++) = Endpoint_Read_Byte() #include "Template/Template_Endpoint_Control_R.c" -#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_EStream_LE -#define TEMPLATE_BUFFER_OFFSET(Length) 0 -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_write_byte((uint8_t*)BufferPtr++, Endpoint_Read_Byte()) -#include "Template/Template_Endpoint_Control_R.c" +#if defined(__AVR__) + #define TEMPLATE_FUNC_NAME Endpoint_Read_Control_EStream_LE + #define TEMPLATE_BUFFER_OFFSET(Length) 0 + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_write_byte((uint8_t*)BufferPtr++, Endpoint_Read_Byte()) + #include "Template/Template_Endpoint_Control_R.c" +#endif #define TEMPLATE_FUNC_NAME Endpoint_Read_Control_Stream_BE #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) #define TEMPLATE_TRANSFER_BYTE(BufferPtr) *((uint8_t*)BufferPtr--) = Endpoint_Read_Byte() #include "Template/Template_Endpoint_Control_R.c" -#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_EStream_BE -#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_write_byte((uint8_t*)BufferPtr--, Endpoint_Read_Byte()) -#include "Template/Template_Endpoint_Control_R.c" +#if defined(__AVR__) + #define TEMPLATE_FUNC_NAME Endpoint_Read_Control_EStream_BE + #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_write_byte((uint8_t*)BufferPtr--, Endpoint_Read_Byte()) + #include "Template/Template_Endpoint_Control_R.c" +#endif #endif diff --git a/LUFA/Drivers/USB/LowLevel/Endpoint.h b/LUFA/Drivers/USB/LowLevel/Endpoint.h index 6d98b78f08..cf6fbc6320 100644 --- a/LUFA/Drivers/USB/LowLevel/Endpoint.h +++ b/LUFA/Drivers/USB/LowLevel/Endpoint.h @@ -66,11 +66,17 @@ #define __ENDPOINT_H__ /* Includes: */ - #include - #include - #include - #include - + #if defined(__AVR32__) + #include + #include + #include + #elif defined(__AVR__) + #include + #include + #include + #include + #endif + #include "../../../Common/Common.h" #include "../HighLevel/USBTask.h" @@ -486,7 +492,11 @@ static inline uint8_t Endpoint_Read_Byte(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline uint8_t Endpoint_Read_Byte(void) { + #if defined(__AVR32__) + return 0; // TODO + #elif defined(__AVR__) return UEDATX; + #endif } /** Writes one byte from the currently selected endpoint's bank, for IN direction endpoints. @@ -498,7 +508,11 @@ static inline void Endpoint_Write_Byte(const uint8_t Byte) ATTR_ALWAYS_INLINE; static inline void Endpoint_Write_Byte(const uint8_t Byte) { + #if defined(__AVR32__) + // TODO + #elif defined(__AVR__) UEDATX = Byte; + #endif } /** Discards one byte from the currently selected endpoint's bank, for OUT direction endpoints. @@ -510,7 +524,11 @@ { uint8_t Dummy; + #if defined(__AVR32__) + // TODO + #elif defined(__AVR__) Dummy = UEDATX; + #endif } /** Reads two bytes from the currently selected endpoint's bank in little endian format, for OUT @@ -529,8 +547,12 @@ uint8_t Bytes[2]; } Data; + #if defined(__AVR32__) + // TODO + #elif defined(__AVR__) Data.Bytes[0] = UEDATX; Data.Bytes[1] = UEDATX; + #endif return Data.Word; } @@ -551,8 +573,12 @@ uint8_t Bytes[2]; } Data; + #if defined(__AVR32__) + // TODO + #elif defined(__AVR__) Data.Bytes[1] = UEDATX; Data.Bytes[0] = UEDATX; + #endif return Data.Word; } @@ -567,8 +593,12 @@ static inline void Endpoint_Write_Word_LE(const uint16_t Word) ATTR_ALWAYS_INLINE; static inline void Endpoint_Write_Word_LE(const uint16_t Word) { + #if defined(__AVR32__) + // TODO + #elif defined(__AVR__) UEDATX = (Word & 0xFF); UEDATX = (Word >> 8); + #endif } /** Writes two bytes to the currently selected endpoint's bank in big endian format, for IN @@ -581,8 +611,12 @@ static inline void Endpoint_Write_Word_BE(const uint16_t Word) ATTR_ALWAYS_INLINE; static inline void Endpoint_Write_Word_BE(const uint16_t Word) { + #if defined(__AVR32__) + // TODO + #elif defined(__AVR__) UEDATX = (Word >> 8); UEDATX = (Word & 0xFF); + #endif } /** Discards two bytes from the currently selected endpoint's bank, for OUT direction endpoints. @@ -594,8 +628,12 @@ { uint8_t Dummy; + #if defined(__AVR32__) + // TODO + #elif defined(__AVR__) Dummy = UEDATX; Dummy = UEDATX; + #endif } /** Reads four bytes from the currently selected endpoint's bank in little endian format, for OUT @@ -614,10 +652,14 @@ uint8_t Bytes[4]; } Data; + #if defined(__AVR32__) + // TODO + #elif defined(__AVR__) Data.Bytes[0] = UEDATX; Data.Bytes[1] = UEDATX; Data.Bytes[2] = UEDATX; Data.Bytes[3] = UEDATX; + #endif return Data.DWord; } @@ -638,10 +680,14 @@ uint8_t Bytes[4]; } Data; + #if defined(__AVR32__) + // TODO + #elif defined(__AVR__) Data.Bytes[3] = UEDATX; Data.Bytes[2] = UEDATX; Data.Bytes[1] = UEDATX; Data.Bytes[0] = UEDATX; + #endif return Data.DWord; } @@ -656,10 +702,14 @@ static inline void Endpoint_Write_DWord_LE(const uint32_t DWord) ATTR_ALWAYS_INLINE; static inline void Endpoint_Write_DWord_LE(const uint32_t DWord) { + #if defined(__AVR32__) + // TODO + #elif defined(__AVR__) UEDATX = (DWord & 0xFF); UEDATX = (DWord >> 8); UEDATX = (DWord >> 16); UEDATX = (DWord >> 24); + #endif } /** Writes four bytes to the currently selected endpoint's bank in big endian format, for IN @@ -672,10 +722,14 @@ static inline void Endpoint_Write_DWord_BE(const uint32_t DWord) ATTR_ALWAYS_INLINE; static inline void Endpoint_Write_DWord_BE(const uint32_t DWord) { + #if defined(__AVR32__) + // TODO + #elif defined(__AVR__) UEDATX = (DWord >> 24); UEDATX = (DWord >> 16); UEDATX = (DWord >> 8); UEDATX = (DWord & 0xFF); + #endif } /** Discards four bytes from the currently selected endpoint's bank, for OUT direction endpoints. @@ -687,10 +741,14 @@ { uint8_t Dummy; + #if defined(__AVR32__) + // TODO + #elif defined(__AVR__) Dummy = UEDATX; Dummy = UEDATX; Dummy = UEDATX; Dummy = UEDATX; + #endif } /* External Variables: */ diff --git a/LUFA/Drivers/USB/LowLevel/Host.h b/LUFA/Drivers/USB/LowLevel/Host.h index 5672dd5319..1e4d3c96d1 100644 --- a/LUFA/Drivers/USB/LowLevel/Host.h +++ b/LUFA/Drivers/USB/LowLevel/Host.h @@ -41,10 +41,16 @@ #define __USBHOST_H__ /* Includes: */ - #include - #include - #include - + #if defined(__AVR32__) + #include + #include + #include + #elif defined(__AVR__) + #include + #include + #include + #endif + #include "../../../Common/Common.h" #include "../HighLevel/USBInterrupt.h" #include "../HighLevel/StdDescriptors.h" diff --git a/LUFA/Drivers/USB/LowLevel/HostChapter9.h b/LUFA/Drivers/USB/LowLevel/HostChapter9.h index 1a85cf6d61..1bd8b6f971 100644 --- a/LUFA/Drivers/USB/LowLevel/HostChapter9.h +++ b/LUFA/Drivers/USB/LowLevel/HostChapter9.h @@ -32,8 +32,14 @@ #define __HOSTCHAPTER9_H__ /* Includes: */ - #include - #include + #if defined(__AVR32__) + #include + #include + #include + #elif defined(__AVR__) + #include + #include + #endif #include "LowLevel.h" #include "../HighLevel/USBMode.h" diff --git a/LUFA/Drivers/USB/LowLevel/LowLevel.h b/LUFA/Drivers/USB/LowLevel/LowLevel.h index 1a92d470b7..581dfd1136 100644 --- a/LUFA/Drivers/USB/LowLevel/LowLevel.h +++ b/LUFA/Drivers/USB/LowLevel/LowLevel.h @@ -40,10 +40,16 @@ #define __USBLOWLEVEL_H__ /* Includes: */ - #include - #include - #include - + #if defined(__AVR32__) + #include + #include + #include + #elif defined(__AVR__) + #include + #include + #include + #endif + #include "../HighLevel/USBMode.h" #include "../../../Common/Common.h" diff --git a/LUFA/Drivers/USB/LowLevel/OTG.h b/LUFA/Drivers/USB/LowLevel/OTG.h index 25cb180a14..acbd47937a 100644 --- a/LUFA/Drivers/USB/LowLevel/OTG.h +++ b/LUFA/Drivers/USB/LowLevel/OTG.h @@ -42,8 +42,14 @@ #define __USBOTG_H__ /* Includes: */ - #include - #include + #if defined(__AVR32__) + #include + #include + #include + #elif defined(__AVR__) + #include + #include + #endif #include "../../../Common/Common.h" diff --git a/LUFA/Drivers/USB/LowLevel/Pipe.c b/LUFA/Drivers/USB/LowLevel/Pipe.c index 78c82e8c47..e6ac0e57c6 100644 --- a/LUFA/Drivers/USB/LowLevel/Pipe.c +++ b/LUFA/Drivers/USB/LowLevel/Pipe.c @@ -226,13 +226,15 @@ uint8_t Pipe_Discard_Stream(uint16_t Length #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_Byte(pgm_read_byte((uint8_t*)BufferPtr++)) #include "Template/Template_Pipe_RW.c" -#define TEMPLATE_FUNC_NAME Pipe_Write_EStream_LE -#define TEMPLATE_BUFFER_TYPE const void* -#define TEMPLATE_TOKEN PIPE_TOKEN_OUT -#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT() -#define TEMPLATE_BUFFER_OFFSET(Length) 0 -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr++)) -#include "Template/Template_Pipe_RW.c" +#if defined(__AVR__) + #define TEMPLATE_FUNC_NAME Pipe_Write_EStream_LE + #define TEMPLATE_BUFFER_TYPE const void* + #define TEMPLATE_TOKEN PIPE_TOKEN_OUT + #define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT() + #define TEMPLATE_BUFFER_OFFSET(Length) 0 + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr++)) + #include "Template/Template_Pipe_RW.c" +#endif #define TEMPLATE_FUNC_NAME Pipe_Write_Stream_BE #define TEMPLATE_BUFFER_TYPE const void* @@ -250,13 +252,15 @@ uint8_t Pipe_Discard_Stream(uint16_t Length #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_Byte(pgm_read_byte((uint8_t*)BufferPtr--)) #include "Template/Template_Pipe_RW.c" -#define TEMPLATE_FUNC_NAME Pipe_Write_EStream_BE -#define TEMPLATE_BUFFER_TYPE const void* -#define TEMPLATE_TOKEN PIPE_TOKEN_OUT -#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT() -#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr--)) -#include "Template/Template_Pipe_RW.c" +#if defined(__AVR__) + #define TEMPLATE_FUNC_NAME Pipe_Write_EStream_BE + #define TEMPLATE_BUFFER_TYPE const void* + #define TEMPLATE_TOKEN PIPE_TOKEN_OUT + #define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT() + #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr--)) + #include "Template/Template_Pipe_RW.c" +#endif #define TEMPLATE_FUNC_NAME Pipe_Read_Stream_LE #define TEMPLATE_BUFFER_TYPE void* @@ -266,13 +270,15 @@ uint8_t Pipe_Discard_Stream(uint16_t Length #define TEMPLATE_TRANSFER_BYTE(BufferPtr) *((uint8_t*)BufferPtr++) = Pipe_Read_Byte() #include "Template/Template_Pipe_RW.c" -#define TEMPLATE_FUNC_NAME Pipe_Read_EStream_LE -#define TEMPLATE_BUFFER_TYPE void* -#define TEMPLATE_TOKEN PIPE_TOKEN_IN -#define TEMPLATE_CLEAR_PIPE() Pipe_ClearIN() -#define TEMPLATE_BUFFER_OFFSET(Length) 0 -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_write_byte((uint8_t*)BufferPtr++, Pipe_Read_Byte()) -#include "Template/Template_Pipe_RW.c" +#if defined(__AVR__) + #define TEMPLATE_FUNC_NAME Pipe_Read_EStream_LE + #define TEMPLATE_BUFFER_TYPE void* + #define TEMPLATE_TOKEN PIPE_TOKEN_IN + #define TEMPLATE_CLEAR_PIPE() Pipe_ClearIN() + #define TEMPLATE_BUFFER_OFFSET(Length) 0 + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_write_byte((uint8_t*)BufferPtr++, Pipe_Read_Byte()) + #include "Template/Template_Pipe_RW.c" +#endif #define TEMPLATE_FUNC_NAME Pipe_Read_Stream_BE #define TEMPLATE_BUFFER_TYPE void* @@ -282,12 +288,14 @@ uint8_t Pipe_Discard_Stream(uint16_t Length #define TEMPLATE_TRANSFER_BYTE(BufferPtr) *((uint8_t*)BufferPtr--) = Pipe_Read_Byte() #include "Template/Template_Pipe_RW.c" -#define TEMPLATE_FUNC_NAME Pipe_Read_EStream_BE -#define TEMPLATE_BUFFER_TYPE void* -#define TEMPLATE_TOKEN PIPE_TOKEN_IN -#define TEMPLATE_CLEAR_PIPE() Pipe_ClearIN() -#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_write_byte((uint8_t*)BufferPtr--, Pipe_Read_Byte()) -#include "Template/Template_Pipe_RW.c" +#if defined(__AVR__) + #define TEMPLATE_FUNC_NAME Pipe_Read_EStream_BE + #define TEMPLATE_BUFFER_TYPE void* + #define TEMPLATE_TOKEN PIPE_TOKEN_IN + #define TEMPLATE_CLEAR_PIPE() Pipe_ClearIN() + #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_write_byte((uint8_t*)BufferPtr--, Pipe_Read_Byte()) + #include "Template/Template_Pipe_RW.c" +#endif #endif diff --git a/LUFA/Drivers/USB/LowLevel/Pipe.h b/LUFA/Drivers/USB/LowLevel/Pipe.h index 3e25d4976b..08935e1f11 100644 --- a/LUFA/Drivers/USB/LowLevel/Pipe.h +++ b/LUFA/Drivers/USB/LowLevel/Pipe.h @@ -74,10 +74,16 @@ #define __PIPE_H__ /* Includes: */ - #include - #include - #include - #include + #if defined(__AVR32__) + #include + #include + #include + #elif defined(__AVR__) + #include + #include + #include + #include + #endif #include "../../../Common/Common.h" #include "../HighLevel/USBTask.h" @@ -547,7 +553,11 @@ static inline uint8_t Pipe_Read_Byte(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline uint8_t Pipe_Read_Byte(void) { + #if defined(__AVR32__) + return 0; // TODO + #elif defined(__AVR__) return UPDATX; + #endif } /** Writes one byte from the currently selected pipe's bank, for IN direction pipes. @@ -559,7 +569,11 @@ static inline void Pipe_Write_Byte(const uint8_t Byte) ATTR_ALWAYS_INLINE; static inline void Pipe_Write_Byte(const uint8_t Byte) { + #if defined(__AVR32__) + // TODO + #elif defined(__AVR__) UPDATX = Byte; + #endif } /** Discards one byte from the currently selected pipe's bank, for OUT direction pipes. @@ -571,7 +585,11 @@ { uint8_t Dummy; + #if defined(__AVR32__) + // TODO + #elif defined(__AVR__) Dummy = UPDATX; + #endif } /** Reads two bytes from the currently selected pipe's bank in little endian format, for OUT @@ -590,8 +608,12 @@ uint8_t Bytes[2]; } Data; + #if defined(__AVR32__) + // TODO + #elif defined(__AVR__) Data.Bytes[0] = UPDATX; Data.Bytes[1] = UPDATX; + #endif return Data.Word; } @@ -612,8 +634,12 @@ uint8_t Bytes[2]; } Data; + #if defined(__AVR32__) + // TODO + #elif defined(__AVR__) Data.Bytes[1] = UPDATX; Data.Bytes[0] = UPDATX; + #endif return Data.Word; } @@ -628,8 +654,12 @@ static inline void Pipe_Write_Word_LE(const uint16_t Word) ATTR_ALWAYS_INLINE; static inline void Pipe_Write_Word_LE(const uint16_t Word) { + #if defined(__AVR32__) + // TODO + #elif defined(__AVR__) UPDATX = (Word & 0xFF); UPDATX = (Word >> 8); + #endif } /** Writes two bytes to the currently selected pipe's bank in big endian format, for IN @@ -642,8 +672,12 @@ static inline void Pipe_Write_Word_BE(const uint16_t Word) ATTR_ALWAYS_INLINE; static inline void Pipe_Write_Word_BE(const uint16_t Word) { + #if defined(__AVR32__) + // TODO + #elif defined(__AVR__) UPDATX = (Word >> 8); UPDATX = (Word & 0xFF); + #endif } /** Discards two bytes from the currently selected pipe's bank, for OUT direction pipes. @@ -655,8 +689,12 @@ { uint8_t Dummy; + #if defined(__AVR32__) + // TODO + #elif defined(__AVR__) Dummy = UPDATX; Dummy = UPDATX; + #endif } /** Reads four bytes from the currently selected pipe's bank in little endian format, for OUT @@ -675,10 +713,14 @@ uint8_t Bytes[4]; } Data; + #if defined(__AVR32__) + // TODO + #elif defined(__AVR__) Data.Bytes[0] = UPDATX; Data.Bytes[1] = UPDATX; Data.Bytes[2] = UPDATX; Data.Bytes[3] = UPDATX; + #endif return Data.DWord; } @@ -699,6 +741,9 @@ uint8_t Bytes[4]; } Data; + #if defined(__AVR32__) + // TODO + #elif defined(__AVR__) Data.Bytes[3] = UPDATX; Data.Bytes[2] = UPDATX; Data.Bytes[1] = UPDATX; @@ -717,10 +762,14 @@ static inline void Pipe_Write_DWord_LE(const uint32_t DWord) ATTR_ALWAYS_INLINE; static inline void Pipe_Write_DWord_LE(const uint32_t DWord) { + #if defined(__AVR32__) + // TODO + #elif defined(__AVR__) UPDATX = (DWord & 0xFF); UPDATX = (DWord >> 8); UPDATX = (DWord >> 16); UPDATX = (DWord >> 24); + #endif } /** Writes four bytes to the currently selected pipe's bank in big endian format, for IN @@ -733,10 +782,14 @@ static inline void Pipe_Write_DWord_BE(const uint32_t DWord) ATTR_ALWAYS_INLINE; static inline void Pipe_Write_DWord_BE(const uint32_t DWord) { + #if defined(__AVR32__) + // TODO + #elif defined(__AVR__) UPDATX = (DWord >> 24); UPDATX = (DWord >> 16); UPDATX = (DWord >> 8); UPDATX = (DWord & 0xFF); + #endif } /** Discards four bytes from the currently selected pipe's bank, for OUT direction pipes. @@ -748,10 +801,14 @@ { uint8_t Dummy; + #if defined(__AVR32__) + // TODO + #elif defined(__AVR__) Dummy = UPDATX; Dummy = UPDATX; Dummy = UPDATX; Dummy = UPDATX; + #endif } /* External Variables: */ diff --git a/LUFA/Drivers/USB/USB.h b/LUFA/Drivers/USB/USB.h index 3bc356d8e7..484978bede 100644 --- a/LUFA/Drivers/USB/USB.h +++ b/LUFA/Drivers/USB/USB.h @@ -360,7 +360,8 @@ /* Preprocessor Checks: */ #if (!defined(USB_SERIES_2_AVR) && !defined(USB_SERIES_4_AVR) && \ - !defined(USB_SERIES_6_AVR) && !defined(USB_SERIES_7_AVR)) + !defined(USB_SERIES_6_AVR) && !defined(USB_SERIES_7_AVR) && \ + !defined(USB_SERIES_UC3B_AVR)) #error The currently selected AVR model is not supported under the USB component of the LUFA library. #endif diff --git a/LUFA/ManPages/FutureChanges.txt b/LUFA/ManPages/FutureChanges.txt index 53c074b012..86114f4345 100644 --- a/LUFA/ManPages/FutureChanges.txt +++ b/LUFA/ManPages/FutureChanges.txt @@ -46,11 +46,11 @@ * * The following drivers have been partially ported: * - SPI Peripheral Driver + * - USB Driver * * The following drivers have not yet been ported: * - Dataflash Board Driver * - Serial Peripheral Driver * - ADC Peripheral Driver * - TWI Peripheral Driver - * - USB Driver */