3      Copyright (C) Dean Camera, 2015. 
   5   dean [at] fourwalledcubicle [dot] com 
  10   Copyright 2015  Dean Camera (dean [at] fourwalledcubicle [dot] com) 
  12   Permission to use, copy, modify, distribute, and sell this 
  13   software and its documentation for any purpose is hereby granted 
  14   without fee, provided that the above copyright notice appear in 
  15   all copies and that both that the copyright notice and this 
  16   permission notice and warranty disclaimer appear in supporting 
  17   documentation, and that the name of the author not be used in 
  18   advertising or publicity pertaining to distribution of the 
  19   software without specific, written prior permission. 
  21   The author disclaims all warranties with regard to this 
  22   software, including all implied warranties of merchantability 
  23   and fitness.  In no event shall the author be liable for any 
  24   special, indirect or consequential damages or any damages 
  25   whatsoever resulting from loss of use, data or profits, whether 
  26   in an action of contract, negligence or other tortious action, 
  27   arising out of or in connection with the use or performance of 
  32  *  \brief Common USB Controller definitions for all architectures. 
  33  *  \copydetails Group_USBManagement 
  35  *  \note This file should not be included directly. It is automatically included as needed by the USB driver 
  36  *        dispatch header located in LUFA/Drivers/USB/USB.h. 
  39 /** \ingroup Group_USB 
  40  *  \defgroup Group_USBManagement USB Interface Management 
  41  *  \brief USB Controller definitions for general USB controller management. 
  43  *  Functions, macros, variables, enums and types related to the setup and management of the USB interface. 
  48 #ifndef __USBCONTROLLER_H__ 
  49 #define __USBCONTROLLER_H__ 
  52                 #include "../../../Common/Common.h" 
  55         /* Enable C linkage for C++ Compilers: */ 
  56                 #if defined(__cplusplus) 
  60         /* Preprocessor Checks and Defines: */ 
  61                 #if !defined(__INCLUDE_FROM_USB_DRIVER) 
  62                         #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. 
  66                 /** \name Endpoint Direction Masks */ 
  68                 /** Endpoint direction mask, for masking against endpoint addresses to retrieve the endpoint's 
  69                  *  direction for comparing with the \c ENDPOINT_DIR_* masks. 
  71                 #define ENDPOINT_DIR_MASK                  0x80 
  73                 /** Endpoint address direction mask for an OUT direction (Host to Device) endpoint. This may be ORed with 
  74                  *  the index of the address within a device to obtain the full endpoint address. 
  76                 #define ENDPOINT_DIR_OUT                   0x00 
  78                 /** Endpoint address direction mask for an IN direction (Device to Host) endpoint. This may be ORed with 
  79                  *  the index of the address within a device to obtain the full endpoint address. 
  81                 #define ENDPOINT_DIR_IN                    0x80 
  84                 /** \name Pipe Direction Masks */ 
  86                 /** Pipe direction mask, for masking against pipe addresses to retrieve the pipe's 
  87                  *  direction for comparing with the \c PIPE_DIR_* masks. 
  89                 #define PIPE_DIR_MASK                      0x80 
  91                 /** Endpoint address direction mask for an OUT direction (Host to Device) endpoint. This may be ORed with 
  92                  *  the index of the address within a device to obtain the full endpoint address. 
  94                 #define PIPE_DIR_OUT                       0x00 
  96                 /** Endpoint address direction mask for an IN direction (Device to Host) endpoint. This may be ORed with 
  97                  *  the index of the address within a device to obtain the full endpoint address. 
  99                 #define PIPE_DIR_IN                        0x80 
 102                 /** \name Endpoint/Pipe Type Masks */ 
 104                 /** Mask for determining the type of an endpoint from an endpoint descriptor. This should then be compared 
 105                  *  with the \c EP_TYPE_* masks to determine the exact type of the endpoint. 
 107                 #define EP_TYPE_MASK                       0x03 
 109                 /** Mask for a CONTROL type endpoint or pipe. 
 111                  *  \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions. 
 113                 #define EP_TYPE_CONTROL                    0x00 
 115                 /** Mask for an ISOCHRONOUS type endpoint or pipe. 
 117                  *  \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions. 
 119                 #define EP_TYPE_ISOCHRONOUS                0x01 
 121                 /** Mask for a BULK type endpoint or pipe. 
 123                  *  \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions. 
 125                 #define EP_TYPE_BULK                       0x02 
 127                 /** Mask for an INTERRUPT type endpoint or pipe. 
 129                  *  \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions. 
 131                 #define EP_TYPE_INTERRUPT                  0x03 
 135                 /** Enum for the possible USB controller modes, for initialization via \ref USB_Init() and indication back to the 
 136                  *  user application via \ref USB_CurrentMode. 
 140                         USB_MODE_None   
= 0, /**< Indicates that the controller is currently not initialized in any specific USB mode. */ 
 141                         USB_MODE_Device 
= 1, /**< Indicates that the controller is currently initialized in USB Device mode. */ 
 142                         USB_MODE_Host   
= 2, /**< Indicates that the controller is currently initialized in USB Host mode. */ 
 143                         USB_MODE_UID    
= 3, /**< Indicates that the controller should determine the USB mode from the UID pin of the 
 148         /* Architecture Includes: */ 
 149                 #if (ARCH == ARCH_AVR8) 
 150                         #include "AVR8/USBController_AVR8.h" 
 151                 #elif (ARCH == ARCH_UC3) 
 152                         #include "UC3/USBController_UC3.h" 
 153                 #elif (ARCH == ARCH_XMEGA) 
 154                         #include "XMEGA/USBController_XMEGA.h" 
 157         /* Disable C linkage for C++ Compilers: */ 
 158                 #if defined(__cplusplus)