Implementation of several key core USB driver functions for the new USB XMEGA devices.
[pub/lufa.git] / LUFA / Drivers / USB / Core / XMEGA / USBController_XMEGA.h
index 8be4ed2..f5adc12 100644 (file)
                #endif\r
 \r
        /* Public Interface - May be used in end-application: */\r
-               /* Macros: */\r
-                       /** \name USB Controller Option Masks */\r
-                       //@{\r
-                       /** Regulator disable option mask for \ref USB_Init(). This indicates that the internal 3.3V USB data pad\r
-                        *  regulator should be disabled and the AVR's VCC level used for the data pads.\r
-                        *\r
-                        *  \note See USB AVR data sheet for more information on the internal pad regulator.\r
-                        */\r
-                       #define USB_OPT_REG_DISABLED               (1 << 1)\r
-\r
-                       /** Regulator enable option mask for \ref USB_Init(). This indicates that the internal 3.3V USB data pad\r
-                        *  regulator should be enabled to regulate the data pin voltages from the VBUS level down to a level within\r
-                        *  the range allowable by the USB standard.\r
-                        *\r
-                        *  \note See USB AVR data sheet for more information on the internal pad regulator.\r
-                        */\r
-                       #define USB_OPT_REG_ENABLED                (0 << 1)\r
-\r
-                       /** Manual PLL control option mask for \ref USB_Init(). This indicates to the library that the user application\r
-                        *  will take full responsibility for controlling the AVR's PLL (used to generate the high frequency clock\r
-                        *  that the USB controller requires) and ensuring that it is locked at the correct frequency for USB operations.\r
-                        */\r
-                       #define USB_OPT_MANUAL_PLL                 (1 << 2)\r
-\r
-                       /** Automatic PLL control option mask for \ref USB_Init(). This indicates to the library that the library should\r
-                        *  take full responsibility for controlling the AVR's PLL (used to generate the high frequency clock\r
-                        *  that the USB controller requires) and ensuring that it is locked at the correct frequency for USB operations.\r
-                        */\r
-                       #define USB_OPT_AUTO_PLL                   (0 << 2)\r
-                       //@}\r
-                       \r
+               /* Macros: */                   \r
                        /** \name Endpoint/Pipe Type Masks */\r
                        //@{\r
                        /** Mask for a CONTROL type endpoint or pipe.\r
                         *\r
                         *  \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.\r
                         */\r
-                       #define EP_TYPE_CONTROL                    0x00\r
+                       #define EP_TYPE_CONTROL                 0x00\r
 \r
                        /** Mask for an ISOCHRONOUS type endpoint or pipe.\r
                         *\r
                         *  \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.\r
                         */\r
-                       #define EP_TYPE_ISOCHRONOUS                0x01\r
+                       #define EP_TYPE_ISOCHRONOUS             0x01\r
 \r
                        /** Mask for a BULK type endpoint or pipe.\r
                         *\r
                         *  \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.\r
                         */\r
-                       #define EP_TYPE_BULK                       0x02\r
+                       #define EP_TYPE_BULK                    0x02\r
 \r
                        /** Mask for an INTERRUPT type endpoint or pipe.\r
                         *\r
                         *  \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.\r
                         */\r
-                       #define EP_TYPE_INTERRUPT                  0x03\r
+                       #define EP_TYPE_INTERRUPT               0x03\r
                        //@}\r
 \r
                        #if !defined(USB_STREAM_TIMEOUT_MS) || defined(__DOXYGEN__)\r
                        #endif\r
 \r
                /* Inline Functions: */\r
-                       /** Determines if the VBUS line is currently high (i.e. the USB host is supplying power).\r
-                        *\r
-                        *  \note This function is not available on some AVR models which do not support hardware VBUS monitoring.\r
-                        *\r
-                        *  \return Boolean \c true if the VBUS line is currently detecting power from a host, \c false otherwise.\r
-                        */\r
-                       static inline bool USB_VBUS_GetStatus(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
-                       static inline bool USB_VBUS_GetStatus(void)\r
-                       {\r
-                               return 0; // TODO\r
-                       }\r
-\r
                        /** Detaches the device from the USB bus. This has the effect of removing the device from any\r
                         *  attached host, ceasing USB communications. If no host is present, this prevents any host from\r
                         *  enumerating the device once attached until \ref USB_Attach() is called.\r
                        static inline void USB_Detach(void) ATTR_ALWAYS_INLINE;\r
                        static inline void USB_Detach(void)\r
                        {\r
-                               // TODO\r
+                               USB.CTRLB &= ~USB_ATTACH_bm;\r
                        }\r
 \r
                        /** Attaches the device to the USB bus. This announces the device's presence to any attached\r
                        static inline void USB_Attach(void) ATTR_ALWAYS_INLINE;\r
                        static inline void USB_Attach(void)\r
                        {\r
-                               // TODO\r
+                               USB.CTRLB |= USB_ATTACH_bm;\r
                        }\r
 \r
                /* Function Prototypes: */\r
                        #endif\r
 \r
                /* Inline Functions: */\r
-                       static inline void USB_REG_On(void) ATTR_ALWAYS_INLINE;\r
-                       static inline void USB_REG_On(void)\r
-                       {\r
-                               // TODO\r
-                       }\r
-\r
-                       static inline void USB_REG_Off(void) ATTR_ALWAYS_INLINE;\r
-                       static inline void USB_REG_Off(void)\r
-                       {\r
-                               // TODO\r
-                       }\r
-\r
-                       static inline void USB_CLK_Freeze(void) ATTR_ALWAYS_INLINE;\r
-                       static inline void USB_CLK_Freeze(void)\r
-                       {\r
-                               // TODO\r
-                       }\r
-\r
-                       static inline void USB_CLK_Unfreeze(void) ATTR_ALWAYS_INLINE;\r
-                       static inline void USB_CLK_Unfreeze(void)\r
-                       {\r
-                               // TODO\r
-                       }\r
-\r
                        static inline void USB_Controller_Enable(void) ATTR_ALWAYS_INLINE;\r
                        static inline void USB_Controller_Enable(void)\r
                        {\r
-                               // TODO\r
+                               USB.CTRLA |= (USB_ENABLE_bm | USB_STFRNUM_bm | USB_MAXEP_gm);\r
                        }\r
 \r
                        static inline void USB_Controller_Disable(void) ATTR_ALWAYS_INLINE;\r
                        static inline void USB_Controller_Disable(void)\r
                        {\r
-                               // TODO\r
+                               USB.CTRLA &= ~USB_ENABLE_bm;\r
                        }\r
 \r
                        static inline void USB_Controller_Reset(void) ATTR_ALWAYS_INLINE;\r
                        static inline void USB_Controller_Reset(void)\r
                        {\r
-                               // TODO\r
+                               USB.CTRLA &= ~USB_ENABLE_bm;\r
+                               USB.CTRLA |=  USB_ENABLE_bm;\r
                        }\r
 \r
        #endif\r