Removed Pipe_ClearErrorFlags(), pipe error flags are now automatically cleared when...
[pub/USBasp.git] / LUFA / Drivers / USB / Core / UC3B / Endpoint_UC3B.h
index bc347b4..b95415c 100644 (file)
                        #endif\r
 \r
                /* Inline Functions: */\r
-                       static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST\r
+                       static inline uint32_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST\r
                                                                                               ATTR_ALWAYS_INLINE;\r
-                       static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes)\r
+                       static inline uint32_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes)\r
                        {\r
                                uint8_t  MaskVal    = 0;\r
                                uint16_t CheckBytes = 8;\r
                        /** Endpoint data direction mask for \ref Endpoint_ConfigureEndpoint(). This indicates that the endpoint\r
                         *  should be initialized in the OUT direction - i.e. data flows from host to device.\r
                         */\r
-                       #define ENDPOINT_DIR_OUT                        (0 << AVR32_USBB_UECFG0_EPDIR_OFFSET)\r
+                       #define ENDPOINT_DIR_OUT                        AVR32_USBB_UECFG0_EPDIR_OUT\r
 \r
                        /** Endpoint data direction mask for \ref Endpoint_ConfigureEndpoint(). This indicates that the endpoint\r
                         *  should be initialized in the IN direction - i.e. data flows from device to host.\r
                         */\r
-                       #define ENDPOINT_DIR_IN                         (1 << AVR32_USBB_UECFG0_EPDIR_OFFSET)\r
+                       #define ENDPOINT_DIR_IN                         AVR32_USBB_UECFG0_EPDIR_IN\r
                        //@}\r
                        \r
                        /** \name Endpoint Bank Mode Masks */\r
                         *  in slower transfers as only one USB device (the AVR or the host) can access the endpoint's\r
                         *  bank at the one time.\r
                         */\r
-                       #define ENDPOINT_BANK_SINGLE                    (0 << AVR32_USBB_UECFG0_EPBK0_OFFSET)\r
+                       #define ENDPOINT_BANK_SINGLE                    AVR32_USBB_UECFG0_EPBK0_SINGLE\r
 \r
                        /** Mask for the bank mode selection for the \ref Endpoint_ConfigureEndpoint() macro. This indicates\r
                         *  that the endpoint should have two banks, which requires more USB FIFO memory but results\r
                         *  in faster transfers as one USB device (the AVR or the host) can access one bank while the other\r
                         *  accesses the second bank.\r
                         */\r
-                       #define ENDPOINT_BANK_DOUBLE                    (1 << AVR32_USBB_UECFG0_EPBK0_OFFSET)\r
+                       #define ENDPOINT_BANK_DOUBLE                    AVR32_USBB_UECFG0_EPBK0_DOUBLE\r
 \r
                        /** Mask for the bank mode selection for the \ref Endpoint_ConfigureEndpoint() macro. This indicates\r
                         *  that the endpoint should have three banks, which requires more USB FIFO memory but results\r
                         *  in faster transfers as one USB device (the AVR or the host) can access one bank while the other\r
                         *  accesses the remaining banks.\r
                         */\r
-                       #define ENDPOINT_BANK_TRIPLE                    (2 << AVR32_USBB_UECFG0_EPBK0_OFFSET)\r
+                       #define ENDPOINT_BANK_TRIPLE                    AVR32_USBB_UECFG0_TRIPLE\r
                        //@}\r
                        \r
                        /** Endpoint address for the default control endpoint, which always resides in address 0. This is\r
                                                                      const uint16_t Size,\r
                                                                      const uint8_t Banks)\r
                        {\r
-                               return Endpoint_ConfigureEndpoint_Prv(Number, ((Type << AVR32_USBB_EPTYPE_OFFSET) | AVR32_USBB_ALLOC |\r
-                                                                              (Direction << AVR32_USBB_EPDIR_OFFSET) |\r
-                                                                              (Banks     << AVR32_USBB_EPBK_OFFSET) |\r
+                               return Endpoint_ConfigureEndpoint_Prv(Number, (AVR32_USBB_ALLOC_MASK |\r
+                                                                              ((uint32_t)Type      << AVR32_USBB_EPTYPE_OFFSET) | \r
+                                                                              ((uint32_t)Direction << AVR32_USBB_EPDIR_OFFSET)  |\r
+                                                                              ((uint32_t)Banks     << AVR32_USBB_EPBK_OFFSET)   |\r
                                                                               Endpoint_BytesToEPSizeMask(Size)));\r
                        }\r
 \r
                        static inline void Endpoint_ResetFIFO(const uint8_t EndpointNumber) ATTR_ALWAYS_INLINE;\r
                        static inline void Endpoint_ResetFIFO(const uint8_t EndpointNumber)\r
                        {\r
-                               AVR32_USBB.uerst |=  (AVR32_USBB_EPRST0_OFFSET << EndpointNumber);\r
-                               AVR32_USBB.uerst &= ~(AVR32_USBB_EPRST0_OFFSET << EndpointNumber);\r
+                               AVR32_USBB.uerst |=  (AVR32_USBB_EPRST0_MASK << EndpointNumber);\r
+                               AVR32_USBB.uerst &= ~(AVR32_USBB_EPRST0_MASK << EndpointNumber);\r
                        }\r
 \r
                        /** Enables the currently selected endpoint so that data can be sent and received through it to\r
                        static inline void Endpoint_EnableEndpoint(void) ATTR_ALWAYS_INLINE;\r
                        static inline void Endpoint_EnableEndpoint(void)\r
                        {\r
-                               AVR32_USBB.uerst |=  (AVR32_USBB_EPEN0 << USB_SelectedEndpoint);\r
+                               AVR32_USBB.uerst |=  (AVR32_USBB_EPEN0_MASK << USB_SelectedEndpoint);\r
                        }\r
 \r
                        /** Disables the currently selected endpoint so that data cannot be sent and received through it\r
                        static inline void Endpoint_DisableEndpoint(void) ATTR_ALWAYS_INLINE;\r
                        static inline void Endpoint_DisableEndpoint(void)\r
                        {\r
-                               AVR32_USBB.uerst &= ~(AVR32_USBB_EPEN0_OFFSET << USB_SelectedEndpoint);\r
+                               AVR32_USBB.uerst &= ~(AVR32_USBB_EPEN0_MASK << USB_SelectedEndpoint);\r
                        }\r
 \r
                        /** Determines if the currently selected endpoint is enabled, but not necessarily configured.\r
                        static inline bool Endpoint_IsEnabled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
                        static inline bool Endpoint_IsEnabled(void)\r
                        {\r
-                               return ((AVR32_USBB.uerst & (AVR32_USBB_EPEN0_OFFSET << USB_SelectedEndpoint)) ? true : false);\r
+                               return ((AVR32_USBB.uerst & (AVR32_USBB_EPEN0_MASK << USB_SelectedEndpoint)) ? true : false);\r
                        }\r
 \r
                        /** Retrieves the number of busy banks in the currently selected endpoint, which have been queued for\r
                        static inline uint8_t Endpoint_GetEndpointInterrupts(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
                        static inline uint8_t Endpoint_GetEndpointInterrupts(void)\r
                        {\r
-                               return ((AVR32_USBB.udint & (AVR32_USBB_EP6INTES_MASK | AVR32_USBB_EP5INTES_MASK |\r
-                                                            AVR32_USBB_EP4INTES_MASK | AVR32_USBB_EP3INTES_MASK |\r
-                                                            AVR32_USBB_EP2INTES_MASK | AVR32_USBB_EP1INTES_MASK |\r
-                                                            AVR32_USBB_EP0INTES_MASK)) >> AVR32_USBB_EP0INT_OFFSET);\r
+                               return ((AVR32_USBB.udint & (AVR32_USBB_EP6INT_MASK | AVR32_USBB_EP5INT_MASK |\r
+                                                            AVR32_USBB_EP4INT_MASK | AVR32_USBB_EP3INT_MASK |\r
+                                                            AVR32_USBB_EP2INT_MASK | AVR32_USBB_EP1INT_MASK |\r
+                                                            AVR32_USBB_EP0INT_MASK)) >> AVR32_USBB_EP0INT_OFFSET);\r
                        }\r
 \r
                        /** Determines if the specified endpoint number has interrupted (valid only for INTERRUPT type\r
                        static inline bool Endpoint_HasEndpointInterrupted(const uint8_t EndpointNumber) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
                        static inline bool Endpoint_HasEndpointInterrupted(const uint8_t EndpointNumber)\r
                        {\r
-                               return ((Endpoint_GetEndpointInterrupts() & (1 << EndpointNumber)) ? true : false);\r
+                               return ((Endpoint_GetEndpointInterrupts() & (AVR32_USBB_EP0INT_MASK << EndpointNumber)) ? true : false);\r
                        }\r
 \r
                        /** Determines if the selected IN endpoint is ready for a new packet to be sent to the host.\r
                        static inline void Endpoint_ClearSETUP(void) ATTR_ALWAYS_INLINE;\r
                        static inline void Endpoint_ClearSETUP(void)\r
                        {\r
-                               ((avr32_usbb_uesta0_t*)AVR32_USBB_UESTA0CLR)[USB_SelectedEndpoint].rxstpi = true;\r
+                               ((avr32_usbb_uesta0clr_t*)AVR32_USBB_UESTA0CLR)[USB_SelectedEndpoint].rxstpic = true;\r
                        }\r
 \r
                        /** Sends an IN packet to the host on the currently selected endpoint, freeing up the endpoint for the\r
                        static inline void Endpoint_ClearIN(void) ATTR_ALWAYS_INLINE;\r
                        static inline void Endpoint_ClearIN(void)\r
                        {\r
-                               ((avr32_usbb_uesta0_t*)AVR32_USBB_UESTA0CLR)[USB_SelectedEndpoint].txini   = true;\r
-                               ((avr32_usbb_uecon0_t*)AVR32_USBB_UECON0CLR)[USB_SelectedEndpoint].fifocon = true;\r
+                               ((avr32_usbb_uesta0clr_t*)AVR32_USBB_UESTA0CLR)[USB_SelectedEndpoint].txinic   = true;\r
+                               ((avr32_usbb_uecon0clr_t*)AVR32_USBB_UECON0CLR)[USB_SelectedEndpoint].fifoconc = true;\r
                        }\r
 \r
                        /** Acknowledges an OUT packet to the host on the currently selected endpoint, freeing up the endpoint\r
                        static inline void Endpoint_ClearOUT(void) ATTR_ALWAYS_INLINE;\r
                        static inline void Endpoint_ClearOUT(void)\r
                        {\r
-                               ((avr32_usbb_uesta0_t*)AVR32_USBB_UESTA0CLR)[USB_SelectedEndpoint].rxouti  = true;\r
-                               ((avr32_usbb_uecon0_t*)AVR32_USBB_UECON0CLR)[USB_SelectedEndpoint].fifocon = true;\r
+                               ((avr32_usbb_uesta0clr_t*)AVR32_USBB_UESTA0CLR)[USB_SelectedEndpoint].rxoutic  = true;\r
+                               ((avr32_usbb_uecon0clr_t*)AVR32_USBB_UECON0CLR)[USB_SelectedEndpoint].fifoconc = true;\r
                        }\r
 \r
                        /** Stalls the current endpoint, indicating to the host that a logical problem occurred with the\r
                        static inline void Endpoint_StallTransaction(void) ATTR_ALWAYS_INLINE;\r
                        static inline void Endpoint_StallTransaction(void)\r
                        {\r
-                               ((avr32_usbb_uecon0_t*)AVR32_USBB_UECON0SET)[USB_SelectedEndpoint].stallrq = true;\r
+                               ((avr32_usbb_uecon0set_t*)AVR32_USBB_UECON0SET)[USB_SelectedEndpoint].stallrqs = true;\r
                        }\r
 \r
                        /** Clears the STALL condition on the currently selected endpoint.\r
                        static inline void Endpoint_ClearStall(void) ATTR_ALWAYS_INLINE;\r
                        static inline void Endpoint_ClearStall(void)\r
                        {\r
-                               ((avr32_usbb_uecon0_t*)AVR32_USBB_UECON0CLR)[USB_SelectedEndpoint].stallrq = true;\r
+                               ((avr32_usbb_uecon0clr_t*)AVR32_USBB_UECON0CLR)[USB_SelectedEndpoint].stallrqc = true;\r
                        }\r
 \r
                        /** Determines if the currently selected endpoint is stalled, false otherwise.\r
                        static inline void Endpoint_ResetDataToggle(void) ATTR_ALWAYS_INLINE;\r
                        static inline void Endpoint_ResetDataToggle(void)\r
                        {\r
-                               ((avr32_usbb_uecon0_t*)AVR32_USBB_UECON0SET)[USB_SelectedEndpoint].rstdt = true;\r
+                               ((avr32_usbb_uecon0set_t*)AVR32_USBB_UECON0SET)[USB_SelectedEndpoint].rstdts = true;\r
                        }\r
 \r
                        /** Determines the currently selected endpoint's direction.\r