Add start of a SDP service table, which will be linked to the Bluetooth SDP code.
[pub/USBasp.git] / LUFA / Drivers / USB / LowLevel / Endpoint.h
index cf6fbc6..b18ff45 100644 (file)
   this software.\r
 */\r
 \r
   this software.\r
 */\r
 \r
+/** \file\r
+ *  \brief USB device endpoint management definitions.\r
+ *\r
+ *  This file contains structures, function prototypes and macros related to the management of the device's\r
+ *  data endpoints when the library is initialized in USB device mode.\r
+ *\r
+ *  \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ *        dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
 /** \ingroup Group_USB\r
  *  @defgroup Group_EndpointManagement Endpoint Management\r
  *\r
 /** \ingroup Group_USB\r
  *  @defgroup Group_EndpointManagement Endpoint Management\r
  *\r
 #define __ENDPOINT_H__\r
 \r
        /* Includes: */\r
 #define __ENDPOINT_H__\r
 \r
        /* Includes: */\r
-               #if defined(__AVR32__)\r
-                       #include <avr32/io.h>\r
-                       #include <stdint.h>\r
-                       #include <stdbool.h>\r
-               #elif defined(__AVR__)\r
-                       #include <avr/io.h>\r
-                       #include <avr/pgmspace.h>\r
-                       #include <avr/eeprom.h>\r
-                       #include <stdbool.h>\r
-               #endif\r
-               \r
+               #include <avr/io.h>\r
+               #include <avr/pgmspace.h>\r
+               #include <avr/eeprom.h>\r
+               #include <stdbool.h>\r
+\r
                #include "../../../Common/Common.h"\r
                #include "../HighLevel/USBTask.h"\r
 \r
                #include "../../../Common/Common.h"\r
                #include "../HighLevel/USBTask.h"\r
 \r
@@ -91,7 +95,7 @@
 \r
        /* Preprocessor Checks: */\r
                #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
 \r
        /* Preprocessor Checks: */\r
                #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
-                       #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+                       #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
                #endif\r
                \r
        /* Public Interface - May be used in end-application: */\r
                #endif\r
                \r
        /* Public Interface - May be used in end-application: */\r
                                #define Endpoint_ClearSETUP()                 MACROS{ UEINTX &= ~(1 << RXSTPI); }MACROE\r
 \r
                                #if !defined(CONTROL_ONLY_DEVICE)\r
                                #define Endpoint_ClearSETUP()                 MACROS{ UEINTX &= ~(1 << RXSTPI); }MACROE\r
 \r
                                #if !defined(CONTROL_ONLY_DEVICE)\r
-                                       #define Endpoint_ClearIN()                MACROS{ uint8_t Temp = UEINTX; UEINTX = (Temp & ~(1 << TXINI)); \\r
-                                                                                         UEINTX = (Temp & ~(1 << FIFOCON)); }MACROE\r
+                                       #define Endpoint_ClearIN()                MACROS{ UEINTX &= ~((1 << TXINI) | (1 << FIFOCON)); }MACROE\r
                                #else\r
                                        #define Endpoint_ClearIN()                MACROS{ UEINTX &= ~(1 << TXINI); }MACROE\r
                                #endif\r
 \r
                                #if !defined(CONTROL_ONLY_DEVICE)\r
                                #else\r
                                        #define Endpoint_ClearIN()                MACROS{ UEINTX &= ~(1 << TXINI); }MACROE\r
                                #endif\r
 \r
                                #if !defined(CONTROL_ONLY_DEVICE)\r
-                                       #define Endpoint_ClearOUT()               MACROS{ uint8_t Temp = UEINTX; UEINTX = (Temp & ~(1 << RXOUTI)); \\r
-                                                                                         UEINTX = (Temp & ~(1 << FIFOCON)); }MACROE\r
+                                       #define Endpoint_ClearOUT()               MACROS{ UEINTX &= ~((1 << RXOUTI) | (1 << FIFOCON)); }MACROE\r
                                #else\r
                                        #define Endpoint_ClearOUT()               MACROS{ UEINTX &= ~(1 << RXOUTI); }MACROE                     \r
                                #endif\r
                                #else\r
                                        #define Endpoint_ClearOUT()               MACROS{ UEINTX &= ~(1 << RXOUTI); }MACROE                     \r
                                #endif\r
                        static inline uint8_t Endpoint_Read_Byte(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
                        static inline uint8_t Endpoint_Read_Byte(void)\r
                        {\r
                        static inline uint8_t Endpoint_Read_Byte(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
                        static inline uint8_t Endpoint_Read_Byte(void)\r
                        {\r
-                               #if defined(__AVR32__)\r
-                               return 0; // TODO\r
-                               #elif defined(__AVR__)\r
                                return UEDATX;\r
                                return UEDATX;\r
-                               #endif\r
                        }\r
 \r
                        /** Writes one byte from the currently selected endpoint's bank, for IN direction endpoints.\r
                        }\r
 \r
                        /** Writes one byte from the currently selected endpoint's bank, for IN direction endpoints.\r
                        static inline void Endpoint_Write_Byte(const uint8_t Byte) ATTR_ALWAYS_INLINE;\r
                        static inline void Endpoint_Write_Byte(const uint8_t Byte)\r
                        {\r
                        static inline void Endpoint_Write_Byte(const uint8_t Byte) ATTR_ALWAYS_INLINE;\r
                        static inline void Endpoint_Write_Byte(const uint8_t Byte)\r
                        {\r
-                               #if defined(__AVR32__)\r
-                               // TODO\r
-                               #elif defined(__AVR__)\r
                                UEDATX = Byte;\r
                                UEDATX = Byte;\r
-                               #endif\r
                        }\r
 \r
                        /** Discards one byte from the currently selected endpoint's bank, for OUT direction endpoints.\r
                        }\r
 \r
                        /** Discards one byte from the currently selected endpoint's bank, for OUT direction endpoints.\r
                        {\r
                                uint8_t Dummy;\r
                                \r
                        {\r
                                uint8_t Dummy;\r
                                \r
-                               #if defined(__AVR32__)\r
-                               // TODO\r
-                               #elif defined(__AVR__)\r
                                Dummy = UEDATX;\r
                                Dummy = UEDATX;\r
-                               #endif\r
                        }\r
                        \r
                        /** Reads two bytes from the currently selected endpoint's bank in little endian format, for OUT\r
                        }\r
                        \r
                        /** Reads two bytes from the currently selected endpoint's bank in little endian format, for OUT\r
                                        uint8_t  Bytes[2];\r
                                } Data;\r
                                \r
                                        uint8_t  Bytes[2];\r
                                } Data;\r
                                \r
-                               #if defined(__AVR32__)\r
-                               // TODO\r
-                               #elif defined(__AVR__)\r
                                Data.Bytes[0] = UEDATX;\r
                                Data.Bytes[1] = UEDATX;\r
                                Data.Bytes[0] = UEDATX;\r
                                Data.Bytes[1] = UEDATX;\r
-                               #endif\r
                        \r
                                return Data.Word;\r
                        }\r
                        \r
                                return Data.Word;\r
                        }\r
                                        uint8_t  Bytes[2];\r
                                } Data;\r
                                \r
                                        uint8_t  Bytes[2];\r
                                } Data;\r
                                \r
-                               #if defined(__AVR32__)\r
-                               // TODO\r
-                               #elif defined(__AVR__)\r
                                Data.Bytes[1] = UEDATX;\r
                                Data.Bytes[0] = UEDATX;\r
                                Data.Bytes[1] = UEDATX;\r
                                Data.Bytes[0] = UEDATX;\r
-                               #endif\r
                        \r
                                return Data.Word;\r
                        }\r
                        \r
                                return Data.Word;\r
                        }\r
                        static inline void Endpoint_Write_Word_LE(const uint16_t Word) ATTR_ALWAYS_INLINE;\r
                        static inline void Endpoint_Write_Word_LE(const uint16_t Word)\r
                        {\r
                        static inline void Endpoint_Write_Word_LE(const uint16_t Word) ATTR_ALWAYS_INLINE;\r
                        static inline void Endpoint_Write_Word_LE(const uint16_t Word)\r
                        {\r
-                               #if defined(__AVR32__)\r
-                               // TODO\r
-                               #elif defined(__AVR__)\r
                                UEDATX = (Word & 0xFF);\r
                                UEDATX = (Word >> 8);\r
                                UEDATX = (Word & 0xFF);\r
                                UEDATX = (Word >> 8);\r
-                               #endif\r
                        }\r
                        \r
                        /** Writes two bytes to the currently selected endpoint's bank in big endian format, for IN\r
                        }\r
                        \r
                        /** Writes two bytes to the currently selected endpoint's bank in big endian format, for IN\r
                        static inline void Endpoint_Write_Word_BE(const uint16_t Word) ATTR_ALWAYS_INLINE;\r
                        static inline void Endpoint_Write_Word_BE(const uint16_t Word)\r
                        {\r
                        static inline void Endpoint_Write_Word_BE(const uint16_t Word) ATTR_ALWAYS_INLINE;\r
                        static inline void Endpoint_Write_Word_BE(const uint16_t Word)\r
                        {\r
-                               #if defined(__AVR32__)\r
-                               // TODO\r
-                               #elif defined(__AVR__)\r
                                UEDATX = (Word >> 8);\r
                                UEDATX = (Word & 0xFF);\r
                                UEDATX = (Word >> 8);\r
                                UEDATX = (Word & 0xFF);\r
-                               #endif\r
                        }\r
 \r
                        /** Discards two bytes from the currently selected endpoint's bank, for OUT direction endpoints.\r
                        }\r
 \r
                        /** Discards two bytes from the currently selected endpoint's bank, for OUT direction endpoints.\r
                        {\r
                                uint8_t Dummy;\r
                                \r
                        {\r
                                uint8_t Dummy;\r
                                \r
-                               #if defined(__AVR32__)\r
-                               // TODO\r
-                               #elif defined(__AVR__)\r
                                Dummy = UEDATX;\r
                                Dummy = UEDATX;\r
                                Dummy = UEDATX;\r
                                Dummy = UEDATX;\r
-                               #endif\r
                        }\r
 \r
                        /** Reads four bytes from the currently selected endpoint's bank in little endian format, for OUT\r
                        }\r
 \r
                        /** Reads four bytes from the currently selected endpoint's bank in little endian format, for OUT\r
                                        uint8_t  Bytes[4];\r
                                } Data;\r
                                \r
                                        uint8_t  Bytes[4];\r
                                } Data;\r
                                \r
-                               #if defined(__AVR32__)\r
-                               // TODO\r
-                               #elif defined(__AVR__)\r
                                Data.Bytes[0] = UEDATX;\r
                                Data.Bytes[1] = UEDATX;\r
                                Data.Bytes[2] = UEDATX;\r
                                Data.Bytes[3] = UEDATX;\r
                                Data.Bytes[0] = UEDATX;\r
                                Data.Bytes[1] = UEDATX;\r
                                Data.Bytes[2] = UEDATX;\r
                                Data.Bytes[3] = UEDATX;\r
-                               #endif\r
                        \r
                                return Data.DWord;\r
                        }\r
                        \r
                                return Data.DWord;\r
                        }\r
                                        uint8_t  Bytes[4];\r
                                } Data;\r
                                \r
                                        uint8_t  Bytes[4];\r
                                } Data;\r
                                \r
-                               #if defined(__AVR32__)\r
-                               // TODO\r
-                               #elif defined(__AVR__)\r
                                Data.Bytes[3] = UEDATX;\r
                                Data.Bytes[2] = UEDATX;\r
                                Data.Bytes[1] = UEDATX;\r
                                Data.Bytes[0] = UEDATX;\r
                                Data.Bytes[3] = UEDATX;\r
                                Data.Bytes[2] = UEDATX;\r
                                Data.Bytes[1] = UEDATX;\r
                                Data.Bytes[0] = UEDATX;\r
-                               #endif\r
                        \r
                                return Data.DWord;\r
                        }\r
                        \r
                                return Data.DWord;\r
                        }\r
                        static inline void Endpoint_Write_DWord_LE(const uint32_t DWord) ATTR_ALWAYS_INLINE;\r
                        static inline void Endpoint_Write_DWord_LE(const uint32_t DWord)\r
                        {\r
                        static inline void Endpoint_Write_DWord_LE(const uint32_t DWord) ATTR_ALWAYS_INLINE;\r
                        static inline void Endpoint_Write_DWord_LE(const uint32_t DWord)\r
                        {\r
-                               #if defined(__AVR32__)\r
-                               // TODO\r
-                               #elif defined(__AVR__)\r
                                UEDATX = (DWord &  0xFF);\r
                                UEDATX = (DWord >> 8);\r
                                UEDATX = (DWord >> 16);\r
                                UEDATX = (DWord >> 24);\r
                                UEDATX = (DWord &  0xFF);\r
                                UEDATX = (DWord >> 8);\r
                                UEDATX = (DWord >> 16);\r
                                UEDATX = (DWord >> 24);\r
-                               #endif\r
                        }\r
                        \r
                        /** Writes four bytes to the currently selected endpoint's bank in big endian format, for IN\r
                        }\r
                        \r
                        /** Writes four bytes to the currently selected endpoint's bank in big endian format, for IN\r
                        static inline void Endpoint_Write_DWord_BE(const uint32_t DWord) ATTR_ALWAYS_INLINE;\r
                        static inline void Endpoint_Write_DWord_BE(const uint32_t DWord)\r
                        {\r
                        static inline void Endpoint_Write_DWord_BE(const uint32_t DWord) ATTR_ALWAYS_INLINE;\r
                        static inline void Endpoint_Write_DWord_BE(const uint32_t DWord)\r
                        {\r
-                               #if defined(__AVR32__)\r
-                               // TODO\r
-                               #elif defined(__AVR__)\r
                                UEDATX = (DWord >> 24);\r
                                UEDATX = (DWord >> 16);\r
                                UEDATX = (DWord >> 8);\r
                                UEDATX = (DWord &  0xFF);\r
                                UEDATX = (DWord >> 24);\r
                                UEDATX = (DWord >> 16);\r
                                UEDATX = (DWord >> 8);\r
                                UEDATX = (DWord &  0xFF);\r
-                               #endif\r
                        }\r
 \r
                        /** Discards four bytes from the currently selected endpoint's bank, for OUT direction endpoints.       \r
                        }\r
 \r
                        /** Discards four bytes from the currently selected endpoint's bank, for OUT direction endpoints.       \r
                        {\r
                                uint8_t Dummy;\r
                                \r
                        {\r
                                uint8_t Dummy;\r
                                \r
-                               #if defined(__AVR32__)\r
-                               // TODO\r
-                               #elif defined(__AVR__)\r
                                Dummy = UEDATX;\r
                                Dummy = UEDATX;\r
                                Dummy = UEDATX;\r
                                Dummy = UEDATX;\r
                                Dummy = UEDATX;\r
                                Dummy = UEDATX;\r
                                Dummy = UEDATX;\r
                                Dummy = UEDATX;\r
-                               #endif\r
                        }\r
 \r
                /* External Variables: */\r
                        }\r
 \r
                /* External Variables: */\r
                         *  The banking mode may be either \ref ENDPOINT_BANK_SINGLE or \ref ENDPOINT_BANK_DOUBLE.\r
                         *\r
                         *  \note The default control endpoint does not have to be manually configured, as it is automatically\r
                         *  The banking mode may be either \ref ENDPOINT_BANK_SINGLE or \ref ENDPOINT_BANK_DOUBLE.\r
                         *\r
                         *  \note The default control endpoint does not have to be manually configured, as it is automatically\r
-                        *  configured by the library internally.\r
+                        *        configured by the library internally.\r
+                        *        \n\n\r
                         *\r
                         *  \note This routine will select the specified endpoint, and the endpoint will remain selected\r
                         *        once the routine completes regardless of if the endpoint configuration succeeds.\r
                         *\r
                         *  \note This routine will select the specified endpoint, and the endpoint will remain selected\r
                         *        once the routine completes regardless of if the endpoint configuration succeeds.\r
                         *\r
                         *  \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
                         *        to clear the status stage when using this routine in a control transaction.\r
                         *\r
                         *  \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
                         *        to clear the status stage when using this routine in a control transaction.\r
+                        *        \n\n\r
                         *\r
                         *  \note This routine should only be used on CONTROL type endpoints.\r
                         *\r
                         *\r
                         *  \note This routine should only be used on CONTROL type endpoints.\r
                         *\r
                         *\r
                         *  \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
                         *        to clear the status stage when using this routine in a control transaction.\r
                         *\r
                         *  \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
                         *        to clear the status stage when using this routine in a control transaction.\r
+                        *        \n\n\r
                         *\r
                         *  \note This routine should only be used on CONTROL type endpoints.\r
                         *\r
                         *\r
                         *  \note This routine should only be used on CONTROL type endpoints.\r
                         *\r
                         *\r
                         *  \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
                         *        to clear the status stage when using this routine in a control transaction.\r
                         *\r
                         *  \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
                         *        to clear the status stage when using this routine in a control transaction.\r
+                        *        \n\n\r
                         *\r
                         *  \note The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.\r
                         *\r
                         *  \note The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.\r
+                        *        \n\n\r
                         *\r
                         *  \note This routine should only be used on CONTROL type endpoints.\r
                         *\r
                         *\r
                         *  \note This routine should only be used on CONTROL type endpoints.\r
                         *\r
                         *\r
                         *  \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
                         *        to clear the status stage when using this routine in a control transaction.\r
                         *\r
                         *  \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
                         *        to clear the status stage when using this routine in a control transaction.\r
+                        *        \n\n\r
                         *\r
                         *  \note This routine should only be used on CONTROL type endpoints.\r
                         *\r
                         *\r
                         *  \note This routine should only be used on CONTROL type endpoints.\r
                         *\r
                         *\r
                         *  \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
                         *        to clear the status stage when using this routine in a control transaction.\r
                         *\r
                         *  \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
                         *        to clear the status stage when using this routine in a control transaction.\r
+                        *        \n\n\r
                         *\r
                         *  \note This routine should only be used on CONTROL type endpoints.\r
                         *\r
                         *\r
                         *  \note This routine should only be used on CONTROL type endpoints.\r
                         *\r
                         *\r
                         *  \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
                         *        to clear the status stage when using this routine in a control transaction.\r
                         *\r
                         *  \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
                         *        to clear the status stage when using this routine in a control transaction.\r
+                        *        \n\n\r
                         *\r
                         *  \note The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.\r
                         *\r
                         *  \note The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.\r
+                        *        \n\n\r
                         *\r
                         *  \note This routine should only be used on CONTROL type endpoints.\r
                         *\r
                         *\r
                         *  \note This routine should only be used on CONTROL type endpoints.\r
                         *\r
                         *\r
                         *  \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
                         *        to clear the status stage when using this routine in a control transaction.\r
                         *\r
                         *  \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
                         *        to clear the status stage when using this routine in a control transaction.\r
+                        *        \n\n\r
                         *\r
                         *  \note This routine should only be used on CONTROL type endpoints.\r
                         *\r
                         *\r
                         *  \note This routine should only be used on CONTROL type endpoints.\r
                         *\r
                         *\r
                         *  \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
                         *        to clear the status stage when using this routine in a control transaction.\r
                         *\r
                         *  \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
                         *        to clear the status stage when using this routine in a control transaction.\r
+                        *        \n\n\r
                         *\r
                         *  \note This routine should only be used on CONTROL type endpoints.\r
                         *\r
                         *\r
                         *  \note This routine should only be used on CONTROL type endpoints.\r
                         *\r
                         *\r
                         *  \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
                         *        to clear the status stage when using this routine in a control transaction.\r
                         *\r
                         *  \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
                         *        to clear the status stage when using this routine in a control transaction.\r
+                        *        \n\n\r
                         *\r
                         *  \note This routine should only be used on CONTROL type endpoints.\r
                         *\r
                         *\r
                         *  \note This routine should only be used on CONTROL type endpoints.\r
                         *\r
                         *\r
                         *  \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
                         *        to clear the status stage when using this routine in a control transaction.\r
                         *\r
                         *  \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
                         *        to clear the status stage when using this routine in a control transaction.\r
+                        *        \n\n\r
                         *\r
                         *  \note This routine should only be used on CONTROL type endpoints.\r
                         *\r
                         *\r
                         *  \note This routine should only be used on CONTROL type endpoints.\r
                         *\r