From 4a3b70e72710abc5232915d07b0e0691d29aaef4 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Sun, 27 Feb 2011 15:23:09 +0000 Subject: Fix USB Host mode compile errors for the UC3B architecture. --- LUFA/Common/Common.h | 1 + LUFA/Drivers/USB/Core/UC3B/Host_UC3B.h | 42 +++++++++---------- LUFA/Drivers/USB/Core/UC3B/Pipe_UC3B.h | 55 ++++++++++++++----------- LUFA/Drivers/USB/Core/UC3B/USBController_UC3B.c | 2 +- 4 files changed, 53 insertions(+), 47 deletions(-) diff --git a/LUFA/Common/Common.h b/LUFA/Common/Common.h index fc2185058..355391b2a 100644 --- a/LUFA/Common/Common.h +++ b/LUFA/Common/Common.h @@ -102,6 +102,7 @@ #define eeprom_read_byte(x) *x #define eeprom_update_byte(x, y) *x = y #define eeprom_write_byte(x, y) *x = y + #define _delay_ms(x) #define memcmp_P(...) memcmp(__VA_ARGS__) #define memcpy_P(...) memcpy(__VA_ARGS__) diff --git a/LUFA/Drivers/USB/Core/UC3B/Host_UC3B.h b/LUFA/Drivers/USB/Core/UC3B/Host_UC3B.h index 0a055ed95..816b19831 100644 --- a/LUFA/Drivers/USB/Core/UC3B/Host_UC3B.h +++ b/LUFA/Drivers/USB/Core/UC3B/Host_UC3B.h @@ -180,7 +180,7 @@ static inline void USB_Host_ResetBus(void) ATTR_ALWAYS_INLINE; static inline void USB_Host_ResetBus(void) { - AVR32_USBB_UHCON.reset = true; + AVR32_USBB.UHCON.reset = true; } /** Determines if a previously issued bus reset (via the \ref USB_Host_ResetBus() macro) has @@ -191,7 +191,7 @@ static inline bool USB_Host_IsBusResetComplete(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline bool USB_Host_IsBusResetComplete(void) { - return AVR32_USBB_UHCON.reset; + return AVR32_USBB.UHCON.reset; } /** Resumes USB communications with an attached and enumerated device, by resuming the transmission @@ -201,7 +201,7 @@ static inline void USB_Host_ResumeBus(void) ATTR_ALWAYS_INLINE; static inline void USB_Host_ResumeBus(void) { - AVR32_USBB_UHCON.sofe = true; + AVR32_USBB.UHCON.sofe = true; } /** Suspends the USB bus, preventing any communications from occurring between the host and attached @@ -211,7 +211,7 @@ static inline void USB_Host_SuspendBus(void) ATTR_ALWAYS_INLINE; static inline void USB_Host_SuspendBus(void) { - AVR32_USBB_UHCON.sofe = false; + AVR32_USBB.UHCON.sofe = false; } /** Determines if the USB bus has been suspended via the use of the \ref USB_Host_SuspendBus() macro, @@ -223,7 +223,7 @@ static inline bool USB_Host_IsBusSuspended(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline bool USB_Host_IsBusSuspended(void) { - return AVR32_USBB_UHCON.sofe; + return AVR32_USBB.UHCON.sofe; } /** Determines if the attached device is currently enumerated in Full Speed mode (12Mb/s), or @@ -234,7 +234,7 @@ static inline bool USB_Host_IsDeviceFullSpeed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline bool USB_Host_IsDeviceFullSpeed(void) { - return (AVR32_USBB_USBSTA.speed == AVR32_USBB_SPEED_FULL); + return (AVR32_USBB.USBSTA.speed == AVR32_USBB_SPEED_FULL); } /** Determines if the attached device is currently issuing a Remote Wakeup request, requesting @@ -245,14 +245,14 @@ static inline bool USB_Host_IsRemoteWakeupSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline bool USB_Host_IsRemoteWakeupSent(void) { - return AVR32_USBB_UHINT.rxrsmi; + return AVR32_USBB.UHINT.rxrsmi; } /** Clears the flag indicating that a Remote Wakeup request has been issued by an attached device. */ static inline void USB_Host_ClearRemoteWakeupSent(void) ATTR_ALWAYS_INLINE; static inline void USB_Host_ClearRemoteWakeupSent(void) { - AVR32_USBB_UHINTCLR.rxrsmic = true; + AVR32_USBB.UHINTCLR.rxrsmic = true; } /** Accepts a Remote Wakeup request from an attached device. This must be issued in response to @@ -262,7 +262,7 @@ static inline void USB_Host_ResumeFromWakeupRequest(void) ATTR_ALWAYS_INLINE; static inline void USB_Host_ResumeFromWakeupRequest(void) { - AVR32_USBB_UHCON.resume = true; + AVR32_USBB.UHCON.resume = true; } /** Determines if a resume from Remote Wakeup request is currently being sent to an attached @@ -273,7 +273,7 @@ static inline bool USB_Host_IsResumeFromWakeupRequestSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline bool USB_Host_IsResumeFromWakeupRequestSent(void) { - return AVR32_USBB_UHCON.resume; + return AVR32_USBB.UHCON.resume; } /* Function Prototypes: */ @@ -348,13 +348,13 @@ static inline void USB_Host_VBUS_Auto_Enable(void) ATTR_ALWAYS_INLINE; static inline void USB_Host_VBUS_Auto_Enable(void) { - AVR32_USBB_USBCON.vbushwc = false; + AVR32_USBB.USBCON.vbushwc = false; } static inline void USB_Host_VBUS_Manual_Enable(void) ATTR_ALWAYS_INLINE; static inline void USB_Host_VBUS_Manual_Enable(void) { - AVR32_USBB_USBCON.vbushwc = true; + AVR32_USBB.USBCON.vbushwc = true; // TODO: Manual VBUS pin output setup } @@ -362,7 +362,7 @@ static inline void USB_Host_VBUS_Auto_On(void) ATTR_ALWAYS_INLINE; static inline void USB_Host_VBUS_Auto_On(void) { - AVR32_USBB_USBSTASET.vbusreqs = true; + AVR32_USBB.USBSTASET.vbusrqs = true; } static inline void USB_Host_VBUS_Manual_On(void) ATTR_ALWAYS_INLINE; @@ -374,7 +374,7 @@ static inline void USB_Host_VBUS_Auto_Off(void) ATTR_ALWAYS_INLINE; static inline void USB_Host_VBUS_Auto_Off(void) { - AVR32_USBB_USBSTACLR.vbusreqc = true; + AVR32_USBB.USBSTACLR.vbusrqc = true; } static inline void USB_Host_VBUS_Manual_Off(void) ATTR_ALWAYS_INLINE; @@ -386,13 +386,13 @@ static inline void USB_Host_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE; static inline void USB_Host_SetDeviceAddress(const uint8_t Address) { - AVR32_USBB_UHADDR1.uhaddrp0 = Address; - AVR32_USBB_UHADDR1.uhaddrp1 = Address; - AVR32_USBB_UHADDR1.uhaddrp2 = Address; - AVR32_USBB_UHADDR1.uhaddrp3 = Address; - AVR32_USBB_UHADDR2.uhaddrp4 = Address; - AVR32_USBB_UHADDR2.uhaddrp5 = Address; - AVR32_USBB_UHADDR2.uhaddrp6 = Address; + AVR32_USBB.UHADDR1.uhaddr_p0 = Address; + AVR32_USBB.UHADDR1.uhaddr_p1 = Address; + AVR32_USBB.UHADDR1.uhaddr_p2 = Address; + AVR32_USBB.UHADDR1.uhaddr_p3 = Address; + AVR32_USBB.UHADDR2.uhaddr_p4 = Address; + AVR32_USBB.UHADDR2.uhaddr_p5 = Address; + AVR32_USBB.UHADDR2.uhaddr_p6 = Address; } /* Enums: */ diff --git a/LUFA/Drivers/USB/Core/UC3B/Pipe_UC3B.h b/LUFA/Drivers/USB/Core/UC3B/Pipe_UC3B.h index 21b2583de..1d7a002e4 100644 --- a/LUFA/Drivers/USB/Core/UC3B/Pipe_UC3B.h +++ b/LUFA/Drivers/USB/Core/UC3B/Pipe_UC3B.h @@ -96,30 +96,33 @@ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. #endif + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* External Variables: */ + extern uint8_t USB_SelectedPipe; + #endif + /* Public Interface - May be used in end-application: */ /* Macros: */ /** \name Pipe Error Flag Masks */ //@{ /** Mask for \ref Pipe_GetErrorFlags(), indicating that an overflow error occurred in the pipe on the received data. */ - #define PIPE_ERRORFLAG_OVERFLOW ((1 << AVR32_USBB_UPSTA0_OVERFI_OFFSET) << 8) - - /** Mask for \ref Pipe_GetErrorFlags(), indicating that an underflow error occurred in the pipe on the received data. */ - #define PIPE_ERRORFLAG_UNDERFLOW ((1 << AVR32_USBB_UPSTA0_UNDERFI_OFFSET) << 8) + #define PIPE_ERRORFLAG_OVERFLOW (AVR32_USBB_UPSTA0_OVERFI_MASK << 8) /** Mask for \ref Pipe_GetErrorFlags(), indicating that a CRC error occurred in the pipe on the received data. */ - #define PIPE_ERRORFLAG_CRC16 (1 << AVR32_USBB_UPERR0_CRC16_OFFSET) + #define PIPE_ERRORFLAG_CRC16 AVR32_USBB_UPERR0_CRC16_MASK /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware timeout error occurred in the pipe. */ - #define PIPE_ERRORFLAG_TIMEOUT (1 << AVR32_USBB_UPERR0_TIMEOUT_OFFSET) + #define PIPE_ERRORFLAG_TIMEOUT AVR32_USBB_UPERR0_TIMEOUT_MASK /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware PID error occurred in the pipe. */ - #define PIPE_ERRORFLAG_PID (1 << AVR32_USBB_UPERR0_PID_OFFSET) + #define PIPE_ERRORFLAG_PID AVR32_USBB_UPERR0_PID_MASK /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware data PID error occurred in the pipe. */ - #define PIPE_ERRORFLAG_DATAPID (1 << AVR32_USBB_UPERR0_DATAPID_OFFSET) + #define PIPE_ERRORFLAG_DATAPID AVR32_USBB_UPERR0_DATAPID_MASK /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware data toggle error occurred in the pipe. */ - #define PIPE_ERRORFLAG_DATATGL (1 << AVR32_USBB_UPERR0_DATATGL_OFFSET) + #define PIPE_ERRORFLAG_DATATGL AVR32_USBB_UPERR0_DATATGL_MASK //@} /** \name Pipe Token Masks */ @@ -254,7 +257,7 @@ static inline void Pipe_EnablePipe(void) ATTR_ALWAYS_INLINE; static inline void Pipe_EnablePipe(void) { - AVR32_USBB.uprst |= (AVR32_USBB_PEN0_MASK << PipeNumber); + AVR32_USBB.uprst |= (AVR32_USBB_PEN0_MASK << USB_SelectedPipe); } /** Disables the currently selected pipe so that data cannot be sent and received through it to and @@ -263,7 +266,7 @@ static inline void Pipe_DisablePipe(void) ATTR_ALWAYS_INLINE; static inline void Pipe_DisablePipe(void) { - AVR32_USBB.uprst &= ~(AVR32_USBB_PEN0_MASK << PipeNumber); + AVR32_USBB.uprst &= ~(AVR32_USBB_PEN0_MASK << USB_SelectedPipe); } /** Determines if the currently selected pipe is enabled, but not necessarily configured. @@ -273,7 +276,7 @@ static inline bool Pipe_IsEnabled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline bool Pipe_IsEnabled(void) { - return ((AVR32_USBB.uprst & (AVR32_USBB_PEN0_MASK << PipeNumber)) ? true : false); + return ((AVR32_USBB.uprst & (AVR32_USBB_PEN0_MASK << USB_SelectedPipe)) ? true : false); } /** Gets the current pipe token, indicating the pipe's data direction and type. @@ -405,6 +408,7 @@ static inline void Pipe_ClearError(void) { ((uint32_t*)AVR32_USBB_UPERR0)[USB_SelectedPipe] = 0; + ((avr32_usbb_upsta0clr_t*)AVR32_USBB_UPSTA0CLR)[USB_SelectedPipe].overfic = true; } /** Determines if the master pipe error flag is set for the currently selected pipe, indicating that @@ -417,7 +421,8 @@ static inline bool Pipe_IsError(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline bool Pipe_IsError(void) { - return ((((avr32_usbb_upsta0_t*)AVR32_USBB_UPSTA0)[USB_SelectedPipe].perri) ? true : false); + return ((((uint32_t*)AVR32_USBB_UPSTA0)[USB_SelectedPipe] & + (AVR32_USBB_PERRI_MASK | AVR32_USBB_OVERFI_MASK)) ? true : false); } /** Gets a mask of the hardware error flags which have occurred on the currently selected pipe. This @@ -428,10 +433,13 @@ static inline uint8_t Pipe_GetErrorFlags(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline uint8_t Pipe_GetErrorFlags(void) { - return ((UPERRX & (PIPE_ERRORFLAG_CRC16 | PIPE_ERRORFLAG_TIMEOUT | - PIPE_ERRORFLAG_PID | PIPE_ERRORFLAG_DATAPID | - PIPE_ERRORFLAG_DATATGL)) | - (UPSTAX & (PIPE_ERRORFLAG_OVERFLOW | PIPE_ERRORFLAG_UNDERFLOW))); + + return ((((uint32_t*)AVR32_USBB_UPERR0)[USB_SelectedPipe] & + (PIPE_ERRORFLAG_CRC16 | PIPE_ERRORFLAG_TIMEOUT | + PIPE_ERRORFLAG_PID | PIPE_ERRORFLAG_DATAPID | + PIPE_ERRORFLAG_DATATGL)) | + ((((uint32_t*)AVR32_USBB_UPSTA0)[USB_SelectedPipe] << 8) & + PIPE_ERRORFLAG_OVERFLOW)); } /** Retrieves the number of busy banks in the currently selected pipe, which have been queued for @@ -487,7 +495,7 @@ static inline bool Pipe_IsOUTReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline bool Pipe_IsOUTReady(void) { - return ((avr32_usbb_upsta0_t*)AVR32_USBB_UPSTA0)[USB_SelectedPipe].rxouti; + return ((avr32_usbb_upsta0_t*)AVR32_USBB_UPSTA0)[USB_SelectedPipe].txouti; } /** Determines if no SETUP request is currently being sent to the attached device on the selected @@ -522,7 +530,7 @@ static inline void Pipe_ClearIN(void) { ((avr32_usbb_upsta0clr_t*)AVR32_USBB_UPSTA0CLR)[USB_SelectedPipe].rxinic = true; - ((avr32_usbb_upsta0clr_t*)AVR32_USBB_UPSTA0CLR)[USB_SelectedPipe].fifoconc = true; + ((avr32_usbb_upcon0clr_t*)AVR32_USBB_UPCON0CLR)[USB_SelectedPipe].fifoconc = true; } /** Sends the currently selected pipe's contents to the device as an OUT packet on the selected pipe, freeing @@ -534,7 +542,7 @@ static inline void Pipe_ClearOUT(void) { ((avr32_usbb_upsta0clr_t*)AVR32_USBB_UPSTA0CLR)[USB_SelectedPipe].txoutic = true; - ((avr32_usbb_upsta0clr_t*)AVR32_USBB_UPSTA0CLR)[USB_SelectedPipe].fifoconc = true; + ((avr32_usbb_upcon0clr_t*)AVR32_USBB_UPCON0CLR)[USB_SelectedPipe].fifoconc = true; } /** Determines if the device sent a NAK (Negative Acknowledge) in response to the last sent packet on @@ -574,7 +582,7 @@ static inline bool Pipe_IsStalled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline bool Pipe_IsStalled(void) { - return ((avr32_usbb_upsta0_t*)AVR32_USBB_UPSTA0)[USB_SelectedPipe].rxstalledi; + return ((avr32_usbb_upsta0_t*)AVR32_USBB_UPSTA0)[USB_SelectedPipe].rxstalldi; } /** Clears the STALL condition detection flag on the currently selected pipe, but does not clear the @@ -585,7 +593,7 @@ static inline void Pipe_ClearStall(void) ATTR_ALWAYS_INLINE; static inline void Pipe_ClearStall(void) { - ((avr32_usbb_upsta0clr_t*)AVR32_USBB_UPSTA0CLR)[USB_SelectedPipe].rxstalledic = true; + ((avr32_usbb_upsta0clr_t*)AVR32_USBB_UPSTA0CLR)[USB_SelectedPipe].rxstalldic = true; } /** Reads one byte from the currently selected pipe's bank, for OUT direction pipes. @@ -913,9 +921,6 @@ /* Function Prototypes: */ void Pipe_ClearPipes(void); - - /* External Variables: */ - extern uint8_t USB_SelectedPipe; #endif /* Disable C linkage for C++ Compilers: */ diff --git a/LUFA/Drivers/USB/Core/UC3B/USBController_UC3B.c b/LUFA/Drivers/USB/Core/UC3B/USBController_UC3B.c index 8e18add47..68092fbf6 100644 --- a/LUFA/Drivers/USB/Core/UC3B/USBController_UC3B.c +++ b/LUFA/Drivers/USB/Core/UC3B/USBController_UC3B.c @@ -98,7 +98,7 @@ void USB_Disable(void) void USB_ResetInterface(void) { #if defined(USB_CAN_BE_BOTH) - bool UIDModeSelectEnabled = ((UHWCON & (1 << UIDE)) != 0); + bool UIDModeSelectEnabled = AVR32_USBB.USBCON.uide; #endif USB_INT_DisableAllInterrupts(); -- cgit v1.2.3