Removed Pipe_ClearErrorFlags(), pipe error flags are now automatically cleared when...
[pub/USBasp.git] / LUFA / Drivers / USB / Core / UC3B / Pipe_UC3B.h
index e904518..5663a76 100644 (file)
                        /** \name Pipe Error Flag Masks */\r
                        //@{\r
                        /** Mask for \ref Pipe_GetErrorFlags(), indicating that an overflow error occurred in the pipe on the received data. */\r
-                       #define PIPE_ERRORFLAG_OVERFLOW         (1 << 6)\r
+                       #define PIPE_ERRORFLAG_OVERFLOW         ((1 << AVR32_USBB_UPSTA0_OVERFI_OFFSET) << 8)\r
 \r
                        /** Mask for \ref Pipe_GetErrorFlags(), indicating that an underflow error occurred in the pipe on the received data. */\r
-                       #define PIPE_ERRORFLAG_UNDERFLOW        (1 << 5)\r
+                       #define PIPE_ERRORFLAG_UNDERFLOW        ((1 << AVR32_USBB_UPSTA0_UNDERFI_OFFSET) << 8)\r
 \r
                        /** Mask for \ref Pipe_GetErrorFlags(), indicating that a CRC error occurred in the pipe on the received data. */\r
-                       #define PIPE_ERRORFLAG_CRC16            (1 << 4)\r
+                       #define PIPE_ERRORFLAG_CRC16            (1 << AVR32_USBB_UPERR0_CRC16_OFFSET)\r
 \r
                        /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware timeout error occurred in the pipe. */\r
-                       #define PIPE_ERRORFLAG_TIMEOUT          (1 << 3)\r
+                       #define PIPE_ERRORFLAG_TIMEOUT          (1 << AVR32_USBB_UPERR0_TIMEOUT_OFFSET)\r
 \r
                        /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware PID error occurred in the pipe. */\r
-                       #define PIPE_ERRORFLAG_PID              (1 << 2)\r
+                       #define PIPE_ERRORFLAG_PID              (1 << AVR32_USBB_UPERR0_PID_OFFSET)\r
 \r
                        /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware data PID error occurred in the pipe. */\r
-                       #define PIPE_ERRORFLAG_DATAPID          (1 << 1)\r
+                       #define PIPE_ERRORFLAG_DATAPID          (1 << AVR32_USBB_UPERR0_DATAPID_OFFSET)\r
 \r
                        /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware data toggle error occurred in the pipe. */\r
-                       #define PIPE_ERRORFLAG_DATATGL          (1 << 0)\r
+                       #define PIPE_ERRORFLAG_DATATGL          (1 << AVR32_USBB_UPERR0_DATATGL_OFFSET)\r
                        //@}\r
 \r
                        /** \name Pipe Token Masks */\r
                        /** Token mask for \ref Pipe_ConfigurePipe(). This sets the pipe as a SETUP token (for CONTROL type pipes),\r
                         *  which will trigger a control request on the attached device when data is written to the pipe.\r
                         */\r
-                       #define PIPE_TOKEN_SETUP                (0 << PTOKEN0)\r
+                       #define PIPE_TOKEN_SETUP                AVR32_USBB_UPCFG0_PTOKEN_SETUP\r
 \r
                        /** Token mask for \ref Pipe_ConfigurePipe(). This sets the pipe as a IN token (for non-CONTROL type pipes),\r
                         *  indicating that the pipe data will flow from device to host.\r
                         */\r
-                       #define PIPE_TOKEN_IN                   (1 << PTOKEN0)\r
+                       #define PIPE_TOKEN_IN                   AVR32_USBB_UPCFG0_PTOKEN_IN\r
 \r
                        /** Token mask for \ref Pipe_ConfigurePipe(). This sets the pipe as a OUT token (for non-CONTROL type pipes),\r
                         *  indicating that the pipe data will flow from host to device.\r
                         */\r
-                       #define PIPE_TOKEN_OUT                  (2 << PTOKEN0)\r
+                       #define PIPE_TOKEN_OUT                  AVR32_USBB_UPCFG0_PTOKEN_OUT\r
                        //@}\r
                        \r
                        /** \name Pipe Bank Mode Masks */\r
                         *  should have one single bank, which requires less USB FIFO memory but results in slower transfers as\r
                         *  only one USB device (the AVR or the attached device) can access the pipe's bank at the one time.\r
                         */\r
-                       #define PIPE_BANK_SINGLE                (0 << EPBK0)\r
+                       #define PIPE_BANK_SINGLE                AVR32_USBB_UPCFG0_PBK_SINGLE\r
 \r
                        /** Mask for the bank mode selection for the \ref Pipe_ConfigurePipe() macro. This indicates that the pipe\r
                         *  should have two banks, which requires more USB FIFO memory but results in faster transfers as one\r
                         *  USB device (the AVR or the attached device) can access one bank while the other accesses the second\r
                         *  bank.\r
                         */\r
-                       #define PIPE_BANK_DOUBLE                (1 << EPBK0)\r
+                       #define PIPE_BANK_DOUBLE                AVR32_USBB_UPCFG0_PBK_DOUBLE\r
+\r
+                       /** Mask for the bank mode selection for the \ref Pipe_ConfigurePipe() macro. This indicates that the pipe\r
+                        *  should have three banks, which requires more USB FIFO memory but results in faster transfers as one\r
+                        *  USB device (the AVR or the attached device) can access one bank while the other accesses the remaining\r
+                        *  banks.\r
+                        */\r
+                       #define PIPE_BANK_TRIPLE                AVR32_USBB_UPCFG0_PBK_TRIPLE\r
                        //@}\r
                        \r
                        /** Pipe address for the default control pipe, which always resides in address 0. This is\r
                        static inline uint16_t Pipe_BytesInPipe(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
                        static inline uint16_t Pipe_BytesInPipe(void)\r
                        {\r
-                               return UPBCX;\r
+                               return ((avr32_usbb_upsta0_t*)AVR32_USBB_UPSTA0)[USB_SelectedPipe].pbyct;\r
                        }\r
 \r
                        /** Returns the pipe address of the currently selected pipe. This is typically used to save the\r
                        static inline uint8_t Pipe_GetCurrentPipe(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
                        static inline uint8_t Pipe_GetCurrentPipe(void)\r
                        {\r
-                               return (UPNUM & PIPE_PIPENUM_MASK);\r
+                               return USB_SelectedPipe;\r
                        }\r
 \r
                        /** Selects the given pipe number. Any pipe operations which do not require the pipe number to be\r
                        static inline void Pipe_SelectPipe(const uint8_t PipeNumber) ATTR_ALWAYS_INLINE;\r
                        static inline void Pipe_SelectPipe(const uint8_t PipeNumber)\r
                        {\r
-                               UPNUM = PipeNumber;\r
+                               USB_SelectedPipe = PipeNumber;\r
                        }\r
 \r
                        /** Resets the desired pipe, including the pipe banks and flags.\r
                        static inline void Pipe_ResetPipe(const uint8_t PipeNumber) ATTR_ALWAYS_INLINE;\r
                        static inline void Pipe_ResetPipe(const uint8_t PipeNumber)\r
                        {\r
-                               UPRST = (1 << PipeNumber);\r
-                               UPRST = 0;\r
+                               AVR32_USBB.uprst |=  (AVR32_USBB_PRST0_MASK << PipeNumber);\r
+                               AVR32_USBB.uprst &= ~(AVR32_USBB_PRST0_MASK << PipeNumber);\r
                        }\r
 \r
                        /** Enables the currently selected pipe so that data can be sent and received through it to and from\r
                        static inline void Pipe_EnablePipe(void) ATTR_ALWAYS_INLINE;\r
                        static inline void Pipe_EnablePipe(void)\r
                        {\r
-                               UPCONX |= (1 << PEN);\r
+                               AVR32_USBB.uprst |=  (AVR32_USBB_PEN0_MASK << PipeNumber);\r
                        }\r
 \r
                        /** Disables the currently selected pipe so that data cannot be sent and received through it to and\r
                        static inline void Pipe_DisablePipe(void) ATTR_ALWAYS_INLINE;\r
                        static inline void Pipe_DisablePipe(void)\r
                        {\r
-                               UPCONX &= ~(1 << PEN);\r
+                               AVR32_USBB.uprst &= ~(AVR32_USBB_PEN0_MASK << PipeNumber);\r
                        }\r
 \r
                        /** Determines if the currently selected pipe is enabled, but not necessarily configured.\r
                        static inline bool Pipe_IsEnabled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
                        static inline bool Pipe_IsEnabled(void)\r
                        {\r
-                               return ((UPCONX & (1 << PEN)) ? true : false);\r
+                               return ((AVR32_USBB.uprst & (AVR32_USBB_PEN0_MASK << PipeNumber)) ? true : false);\r
                        }\r
 \r
                        /** Gets the current pipe token, indicating the pipe's data direction and type.\r
                        static inline uint8_t Pipe_GetPipeToken(void) ATTR_ALWAYS_INLINE;\r
                        static inline uint8_t Pipe_GetPipeToken(void)\r
                        {\r
-                               return (UPCFG0X & (0x03 << PTOKEN0));\r
+                               return ((avr32_usbb_upcfg0_t*)AVR32_USBB_UPCFG0)[USB_SelectedPipe].ptoken;\r
                        }\r
 \r
                        /** Sets the token for the currently selected pipe to one of the tokens specified by the \c PIPE_TOKEN_*\r
                        static inline void Pipe_SetPipeToken(const uint8_t Token) ATTR_ALWAYS_INLINE;\r
                        static inline void Pipe_SetPipeToken(const uint8_t Token)\r
                        {\r
-                               UPCFG0X = ((UPCFG0X & ~(0x03 << PTOKEN0)) | Token);\r
+                               ((avr32_usbb_upcfg0_t*)AVR32_USBB_UPCFG0)[USB_SelectedPipe].ptoken = Token;\r
                        }\r
 \r
                        /** Configures the currently selected pipe to allow for an unlimited number of IN requests. */\r
                        static inline void Pipe_SetInfiniteINRequests(void) ATTR_ALWAYS_INLINE;\r
                        static inline void Pipe_SetInfiniteINRequests(void)\r
                        {\r
-                               UPCONX |= (1 << INMODE);\r
+                               ((avr32_usbb_upinrq0_t*)AVR32_USBB_UPINRQ0)[USB_SelectedPipe].inmode = true;\r
                        }\r
 \r
                        /** Configures the currently selected pipe to only allow the specified number of IN requests to be\r
                        static inline void Pipe_SetFiniteINRequests(const uint8_t TotalINRequests) ATTR_ALWAYS_INLINE;\r
                        static inline void Pipe_SetFiniteINRequests(const uint8_t TotalINRequests)\r
                        {\r
-                               UPCONX &= ~(1 << INMODE);\r
-                               UPINRQX = TotalINRequests;\r
+                               ((avr32_usbb_upinrq0_t*)AVR32_USBB_UPINRQ0)[USB_SelectedPipe].inmode = false;\r
+                               ((avr32_usbb_upinrq0_t*)AVR32_USBB_UPINRQ0)[USB_SelectedPipe].inrq   = TotalINRequests;\r
                        }\r
 \r
                        /** Determines if the currently selected pipe is configured.\r
                        static inline bool Pipe_IsConfigured(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
                        static inline bool Pipe_IsConfigured(void)\r
                        {\r
-                               return ((UPSTAX & (1 << CFGOK)) ? true : false);\r
+                               return ((avr32_usbb_upsta0_t*)AVR32_USBB_UPSTA0)[USB_SelectedPipe].cfgok;\r
                        }\r
 \r
                        /** Retrieves the endpoint number of the endpoint within the attached device that the currently selected\r
                        static inline uint8_t Pipe_BoundEndpointNumber(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
                        static inline uint8_t Pipe_BoundEndpointNumber(void)\r
                        {\r
-                               return ((UPCFG0X >> PEPNUM0) & PIPE_EPNUM_MASK);\r
+                               return ((avr32_usbb_upcfg0_t*)AVR32_USBB_UPCFG0)[USB_SelectedPipe].pepnum;\r
                        }\r
 \r
                        /** Sets the period between interrupts for an INTERRUPT type pipe to a specified number of milliseconds.\r
                        static inline void Pipe_SetInterruptPeriod(const uint8_t Milliseconds) ATTR_ALWAYS_INLINE;\r
                        static inline void Pipe_SetInterruptPeriod(const uint8_t Milliseconds)\r
                        {\r
-                               UPCFG2X = Milliseconds;\r
+                               ((avr32_usbb_upcfg0_t*)AVR32_USBB_UPCFG0)[USB_SelectedPipe].intfrq = Milliseconds;\r
                        }\r
 \r
                        /** Returns a mask indicating which pipe's interrupt periods have elapsed, indicating that the pipe should\r
                        static inline uint8_t Pipe_GetPipeInterrupts(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
                        static inline uint8_t Pipe_GetPipeInterrupts(void)\r
                        {\r
-                               return UPINT;\r
+                               return ((AVR32_USBB.uhint & (AVR32_USBB_P6INT_MASK | AVR32_USBB_P5INT_MASK |\r
+                                                            AVR32_USBB_P4INT_MASK | AVR32_USBB_P3INT_MASK |\r
+                                                            AVR32_USBB_P2INT_MASK | AVR32_USBB_P1INT_MASK |\r
+                                                            AVR32_USBB_P0INT_MASK)) >> AVR32_USBB_P0INT_OFFSET);\r
                        }\r
 \r
                        /** Determines if the specified pipe number has interrupted (valid only for INTERRUPT type\r
                        static inline bool Pipe_HasPipeInterrupted(const uint8_t PipeNumber) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
                        static inline bool Pipe_HasPipeInterrupted(const uint8_t PipeNumber)\r
                        {\r
-                               return ((UPINT & (1 << PipeNumber)) ? true : false);\r
+                               return ((AVR32_USBB.uhint & (AVR32_USBB_P0INTES_MASK << USB_SelectedPipe)) ? true : false);\r
                        }\r
 \r
                        /** Unfreezes the selected pipe, allowing it to communicate with an attached device. */\r
                        static inline void Pipe_Unfreeze(void) ATTR_ALWAYS_INLINE;\r
                        static inline void Pipe_Unfreeze(void)\r
                        {\r
-                               UPCONX &= ~(1 << PFREEZE);\r
+                               ((avr32_usbb_upcon0clr_t*)AVR32_USBB_UPCON0CLR)[USB_SelectedPipe].pfreezec = true;\r
                        }\r
 \r
                        /** Freezes the selected pipe, preventing it from communicating with an attached device. */\r
                        static inline void Pipe_Freeze(void) ATTR_ALWAYS_INLINE;\r
                        static inline void Pipe_Freeze(void)\r
                        {\r
-                               UPCONX |= (1 << PFREEZE);\r
+                               ((avr32_usbb_upcon0set_t*)AVR32_USBB_UPCON0SET)[USB_SelectedPipe].pfreezes = true;\r
                        }\r
 \r
                        /** Determines if the currently selected pipe is frozen, and not able to accept data.\r
                        static inline bool Pipe_IsFrozen(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
                        static inline bool Pipe_IsFrozen(void)\r
                        {\r
-                               return ((UPCONX & (1 << PFREEZE)) ? true : false);\r
+                               return ((((avr32_usbb_upcon0_t*)AVR32_USBB_UPCON0)[USB_SelectedPipe].pfreeze) ? true : false);\r
                        }\r
 \r
-                       /** Clears the master pipe error flag. */\r
+                       /** Clears the error flags for the currently selected pipe. */\r
                        static inline void Pipe_ClearError(void) ATTR_ALWAYS_INLINE;\r
                        static inline void Pipe_ClearError(void)\r
                        {\r
-                               UPINTX &= ~(1 << PERRI);\r
+                               ((uint32_t*)AVR32_USBB_UPERR0)[USB_SelectedPipe] = 0;\r
                        }\r
 \r
                        /** Determines if the master pipe error flag is set for the currently selected pipe, indicating that\r
                        static inline bool Pipe_IsError(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
                        static inline bool Pipe_IsError(void)\r
                        {\r
-                               return ((UPINTX & (1 << PERRI)) ? true : false);\r
-                       }\r
-\r
-                       /** Clears all the currently selected pipe's hardware error flags, but does not clear the master error\r
-                        *  flag for the pipe.\r
-                        */\r
-                       static inline void Pipe_ClearErrorFlags(void) ATTR_ALWAYS_INLINE;\r
-                       static inline void Pipe_ClearErrorFlags(void)\r
-                       {\r
-                               UPERRX = 0;\r
+                               return ((((avr32_usbb_upsta0_t*)AVR32_USBB_UPSTA0)[USB_SelectedPipe].perri) ? true : false);\r
                        }\r
 \r
                        /** Gets a mask of the hardware error flags which have occurred on the currently selected pipe. This\r
                         */\r
                        static inline uint8_t Pipe_GetBusyBanks(void)\r
                        {\r
-                               return (UPSTAX & (0x03 << NBUSYBK0));\r
+                               return ((avr32_usbb_upsta0_t*)AVR32_USBB_UPSTA0)[USB_SelectedPipe].nbusybk;\r
                        }\r
 \r
                        /** Determines if the currently selected pipe may be read from (if data is waiting in the pipe\r
                        static inline bool Pipe_IsReadWriteAllowed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
                        static inline bool Pipe_IsReadWriteAllowed(void)\r
                        {\r
-                               return ((UPINTX & (1 << RWAL)) ? true : false);\r
+                               return ((avr32_usbb_upsta0_t*)AVR32_USBB_UPSTA0)[USB_SelectedPipe].rwall;\r
                        }\r
 \r
                        /** Determines if a packet has been received on the currently selected IN pipe from the attached device.\r
                        static inline bool Pipe_IsINReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
                        static inline bool Pipe_IsINReceived(void)\r
                        {\r
-                               return ((UPINTX & (1 << RXINI)) ? true : false);\r
+                               return ((avr32_usbb_upsta0_t*)AVR32_USBB_UPSTA0)[USB_SelectedPipe].rxini;\r
                        }\r
 \r
                        /** Determines if the currently selected OUT pipe is ready to send an OUT packet to the attached device.\r
                        static inline bool Pipe_IsOUTReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
                        static inline bool Pipe_IsOUTReady(void)\r
                        {\r
-                               return ((UPINTX & (1 << TXOUTI)) ? true : false);\r
+                               return ((avr32_usbb_upsta0_t*)AVR32_USBB_UPSTA0)[USB_SelectedPipe].rxouti;\r
                        }\r
 \r
                        /** Determines if no SETUP request is currently being sent to the attached device on the selected\r
                        static inline bool Pipe_IsSETUPSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
                        static inline bool Pipe_IsSETUPSent(void)\r
                        {\r
-                               return ((UPINTX & (1 << TXSTPI)) ? true : false);\r
+                               return ((avr32_usbb_upsta0_t*)AVR32_USBB_UPSTA0)[USB_SelectedPipe].txstpi;\r
                        }\r
 \r
                        /** Sends the currently selected CONTROL type pipe's contents to the device as a SETUP packet.\r
                        static inline void Pipe_ClearSETUP(void) ATTR_ALWAYS_INLINE;\r
                        static inline void Pipe_ClearSETUP(void)\r
                        {\r
-                               UPINTX &= ~((1 << TXSTPI) | (1 << FIFOCON));\r
+                               ((avr32_usbb_upsta0clr_t*)AVR32_USBB_UPSTA0CLR)[USB_SelectedPipe].txstpic = true;\r
                        }\r
 \r
                        /** Acknowledges the reception of a setup IN request from the attached device on the currently selected\r
                        static inline void Pipe_ClearIN(void) ATTR_ALWAYS_INLINE;\r
                        static inline void Pipe_ClearIN(void)\r
                        {\r
-                               UPINTX &= ~((1 << RXINI) | (1 << FIFOCON));\r
+                               ((avr32_usbb_upsta0clr_t*)AVR32_USBB_UPSTA0CLR)[USB_SelectedPipe].rxinic   = true;\r
+                               ((avr32_usbb_upsta0clr_t*)AVR32_USBB_UPSTA0CLR)[USB_SelectedPipe].fifoconc = true;\r
                        }\r
 \r
                        /** Sends the currently selected pipe's contents to the device as an OUT packet on the selected pipe, freeing\r
                        static inline void Pipe_ClearOUT(void) ATTR_ALWAYS_INLINE;\r
                        static inline void Pipe_ClearOUT(void)\r
                        {\r
-                               UPINTX &= ~((1 << TXOUTI) | (1 << FIFOCON));\r
+                               ((avr32_usbb_upsta0clr_t*)AVR32_USBB_UPSTA0CLR)[USB_SelectedPipe].txoutic  = true;\r
+                               ((avr32_usbb_upsta0clr_t*)AVR32_USBB_UPSTA0CLR)[USB_SelectedPipe].fifoconc = true;\r
                        }\r
 \r
                        /** Determines if the device sent a NAK (Negative Acknowledge) in response to the last sent packet on\r
                        static inline bool Pipe_IsNAKReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
                        static inline bool Pipe_IsNAKReceived(void)\r
                        {\r
-                               return ((UPINTX & (1 << NAKEDI)) ? true : false);\r
+                               return ((avr32_usbb_upsta0_t*)AVR32_USBB_UPSTA0)[USB_SelectedPipe].nakedi;\r
                        }\r
 \r
                        /** Clears the NAK condition on the currently selected pipe.\r
                        static inline void Pipe_ClearNAKReceived(void) ATTR_ALWAYS_INLINE;\r
                        static inline void Pipe_ClearNAKReceived(void)\r
                        {\r
-                               UPINTX &= ~(1 << NAKEDI);\r
+                               ((avr32_usbb_upsta0clr_t*)AVR32_USBB_UPSTA0CLR)[USB_SelectedPipe].nakedic = true;\r
                        }\r
 \r
                        /** Determines if the currently selected pipe has had the STALL condition set by the attached device.\r
                        static inline bool Pipe_IsStalled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
                        static inline bool Pipe_IsStalled(void)\r
                        {\r
-                               return ((UPINTX & (1 << RXSTALLI)) ? true : false);\r
+                               return ((avr32_usbb_upsta0_t*)AVR32_USBB_UPSTA0)[USB_SelectedPipe].rxstalledi;\r
                        }\r
 \r
                        /** Clears the STALL condition detection flag on the currently selected pipe, but does not clear the\r
                        static inline void Pipe_ClearStall(void) ATTR_ALWAYS_INLINE;\r
                        static inline void Pipe_ClearStall(void)\r
                        {\r
-                               UPINTX &= ~(1 << RXSTALLI);\r
+                               ((avr32_usbb_upsta0clr_t*)AVR32_USBB_UPSTA0CLR)[USB_SelectedPipe].rxstalledic = true;\r
                        }\r
 \r
                        /** Reads one byte from the currently selected pipe's bank, for OUT direction pipes.\r
                        static inline uint8_t Pipe_Read_Byte(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
                        static inline uint8_t Pipe_Read_Byte(void)\r
                        {\r
-                               return UPDATX;\r
+                               return *((uint8_t*)AVR32_USBB_EP_DATA);\r
                        }\r
 \r
                        /** Writes one byte from the currently selected pipe's bank, for IN direction pipes.\r
                        static inline void Pipe_Write_Byte(const uint8_t Byte) ATTR_ALWAYS_INLINE;\r
                        static inline void Pipe_Write_Byte(const uint8_t Byte)\r
                        {\r
-                               UPDATX = Byte;\r
+                               *((uint8_t*)AVR32_USBB_EP_DATA) = Byte;\r
                        }\r
 \r
                        /** Discards one byte from the currently selected pipe's bank, for OUT direction pipes.\r
                        {\r
                                uint8_t Dummy;\r
 \r
-                               Dummy = UPDATX;\r
+                               Dummy = *((uint8_t*)AVR32_USBB_EP_DATA);\r
                        }\r
 \r
                        /** Reads two bytes from the currently selected pipe's bank in little endian format, for OUT\r
                                        uint8_t  Bytes[2];\r
                                } Data;\r
 \r
-                               Data.Bytes[0] = UPDATX;\r
-                               Data.Bytes[1] = UPDATX;\r
+                               Data.Bytes[0] = *((uint8_t*)AVR32_USBB_EP_DATA);\r
+                               Data.Bytes[1] = *((uint8_t*)AVR32_USBB_EP_DATA);\r
 \r
                                return Data.Word;\r
                        }\r
                                        uint8_t  Bytes[2];\r
                                } Data;\r
 \r
-                               Data.Bytes[1] = UPDATX;\r
-                               Data.Bytes[0] = UPDATX;\r
+                               Data.Bytes[1] = *((uint8_t*)AVR32_USBB_EP_DATA);\r
+                               Data.Bytes[0] = *((uint8_t*)AVR32_USBB_EP_DATA);\r
 \r
                                return Data.Word;\r
                        }\r
                        static inline void Pipe_Write_Word_LE(const uint16_t Word) ATTR_ALWAYS_INLINE;\r
                        static inline void Pipe_Write_Word_LE(const uint16_t Word)\r
                        {\r
-                               UPDATX = (Word & 0xFF);\r
-                               UPDATX = (Word >> 8);\r
+                               *((uint8_t*)AVR32_USBB_EP_DATA) = (Word & 0xFF);\r
+                               *((uint8_t*)AVR32_USBB_EP_DATA) = (Word >> 8);\r
                        }\r
 \r
                        /** Writes two bytes to the currently selected pipe's bank in big endian format, for IN\r
                        static inline void Pipe_Write_Word_BE(const uint16_t Word) ATTR_ALWAYS_INLINE;\r
                        static inline void Pipe_Write_Word_BE(const uint16_t Word)\r
                        {\r
-                               UPDATX = (Word >> 8);\r
-                               UPDATX = (Word & 0xFF);\r
+                               *((uint8_t*)AVR32_USBB_EP_DATA) = (Word >> 8);\r
+                               *((uint8_t*)AVR32_USBB_EP_DATA) = (Word & 0xFF);\r
                        }\r
 \r
                        /** Discards two bytes from the currently selected pipe's bank, for OUT direction pipes.\r
                        {\r
                                uint8_t Dummy;\r
 \r
-                               Dummy = UPDATX;\r
-                               Dummy = UPDATX;\r
+                               Dummy = *((uint8_t*)AVR32_USBB_EP_DATA);\r
+                               Dummy = *((uint8_t*)AVR32_USBB_EP_DATA);\r
                        }\r
 \r
                        /** Reads four bytes from the currently selected pipe's bank in little endian format, for OUT\r
                                        uint8_t  Bytes[4];\r
                                } Data;\r
 \r
-                               Data.Bytes[0] = UPDATX;\r
-                               Data.Bytes[1] = UPDATX;\r
-                               Data.Bytes[2] = UPDATX;\r
-                               Data.Bytes[3] = UPDATX;\r
+                               Data.Bytes[0] = *((uint8_t*)AVR32_USBB_EP_DATA);\r
+                               Data.Bytes[1] = *((uint8_t*)AVR32_USBB_EP_DATA);\r
+                               Data.Bytes[2] = *((uint8_t*)AVR32_USBB_EP_DATA);\r
+                               Data.Bytes[3] = *((uint8_t*)AVR32_USBB_EP_DATA);\r
 \r
                                return Data.DWord;\r
                        }\r
                                        uint8_t  Bytes[4];\r
                                } Data;\r
 \r
-                               Data.Bytes[3] = UPDATX;\r
-                               Data.Bytes[2] = UPDATX;\r
-                               Data.Bytes[1] = UPDATX;\r
-                               Data.Bytes[0] = UPDATX;\r
+                               Data.Bytes[3] = *((uint8_t*)AVR32_USBB_EP_DATA);\r
+                               Data.Bytes[2] = *((uint8_t*)AVR32_USBB_EP_DATA);\r
+                               Data.Bytes[1] = *((uint8_t*)AVR32_USBB_EP_DATA);\r
+                               Data.Bytes[0] = *((uint8_t*)AVR32_USBB_EP_DATA);\r
 \r
                                return Data.DWord;\r
                        }\r
                        static inline void Pipe_Write_DWord_LE(const uint32_t DWord) ATTR_ALWAYS_INLINE;\r
                        static inline void Pipe_Write_DWord_LE(const uint32_t DWord)\r
                        {\r
-                               UPDATX = (DWord &  0xFF);\r
-                               UPDATX = (DWord >> 8);\r
-                               UPDATX = (DWord >> 16);\r
-                               UPDATX = (DWord >> 24);\r
+                               *((uint8_t*)AVR32_USBB_EP_DATA) = (DWord &  0xFF);\r
+                               *((uint8_t*)AVR32_USBB_EP_DATA) = (DWord >> 8);\r
+                               *((uint8_t*)AVR32_USBB_EP_DATA) = (DWord >> 16);\r
+                               *((uint8_t*)AVR32_USBB_EP_DATA) = (DWord >> 24);\r
                        }\r
 \r
                        /** Writes four bytes to the currently selected pipe's bank in big endian format, for IN\r
                        static inline void Pipe_Write_DWord_BE(const uint32_t DWord) ATTR_ALWAYS_INLINE;\r
                        static inline void Pipe_Write_DWord_BE(const uint32_t DWord)\r
                        {\r
-                               UPDATX = (DWord >> 24);\r
-                               UPDATX = (DWord >> 16);\r
-                               UPDATX = (DWord >> 8);\r
-                               UPDATX = (DWord &  0xFF);\r
+                               *((uint8_t*)AVR32_USBB_EP_DATA) = (DWord >> 24);\r
+                               *((uint8_t*)AVR32_USBB_EP_DATA) = (DWord >> 16);\r
+                               *((uint8_t*)AVR32_USBB_EP_DATA) = (DWord >> 8);\r
+                               *((uint8_t*)AVR32_USBB_EP_DATA) = (DWord &  0xFF);\r
                        }\r
 \r
                        /** Discards four bytes from the currently selected pipe's bank, for OUT direction pipes.\r
                        {\r
                                uint8_t Dummy;\r
 \r
-                               Dummy = UPDATX;\r
-                               Dummy = UPDATX;\r
-                               Dummy = UPDATX;\r
-                               Dummy = UPDATX;\r
+                               Dummy = *((uint8_t*)AVR32_USBB_EP_DATA);\r
+                               Dummy = *((uint8_t*)AVR32_USBB_EP_DATA);\r
+                               Dummy = *((uint8_t*)AVR32_USBB_EP_DATA);\r
+                               Dummy = *((uint8_t*)AVR32_USBB_EP_DATA);\r
                        }\r
 \r
                /* External Variables: */\r
                        #if !defined(ENDPOINT_CONTROLEP)\r
                                #define ENDPOINT_CONTROLEP          0\r
                        #endif\r
-\r
+                       \r
                /* Inline Functions: */\r
                        static inline uint8_t Pipe_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST ATTR_ALWAYS_INLINE;\r
                        static inline uint8_t Pipe_BytesToEPSizeMask(const uint16_t Bytes)\r
                                        CheckBytes <<= 1;\r
                                }\r
 \r
-                               return (MaskVal << EPSIZE0);\r
+                               return (MaskVal << AVR32_USBB_PSIZE_OFFSET);\r
                        }\r
 \r
                /* Function Prototypes: */\r
                        void Pipe_ClearPipes(void);\r
+\r
+               /* External Variables: */\r
+                       extern uint8_t USB_SelectedPipe;\r
        #endif\r
 \r
        /* Disable C linkage for C++ Compilers: */\r