Keyboard firmwares for Atmel AVR and Cortex-M
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

USBController.h 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /*
  2. LUFA Library
  3. Copyright (C) Dean Camera, 2014.
  4. dean [at] fourwalledcubicle [dot] com
  5. www.lufa-lib.org
  6. */
  7. /*
  8. Copyright 2014 Dean Camera (dean [at] fourwalledcubicle [dot] com)
  9. Permission to use, copy, modify, distribute, and sell this
  10. software and its documentation for any purpose is hereby granted
  11. without fee, provided that the above copyright notice appear in
  12. all copies and that both that the copyright notice and this
  13. permission notice and warranty disclaimer appear in supporting
  14. documentation, and that the name of the author not be used in
  15. advertising or publicity pertaining to distribution of the
  16. software without specific, written prior permission.
  17. The author disclaims all warranties with regard to this
  18. software, including all implied warranties of merchantability
  19. and fitness. In no event shall the author be liable for any
  20. special, indirect or consequential damages or any damages
  21. whatsoever resulting from loss of use, data or profits, whether
  22. in an action of contract, negligence or other tortious action,
  23. arising out of or in connection with the use or performance of
  24. this software.
  25. */
  26. /** \file
  27. * \brief Common USB Controller definitions for all architectures.
  28. * \copydetails Group_USBManagement
  29. *
  30. * \note This file should not be included directly. It is automatically included as needed by the USB driver
  31. * dispatch header located in LUFA/Drivers/USB/USB.h.
  32. */
  33. /** \ingroup Group_USB
  34. * \defgroup Group_USBManagement USB Interface Management
  35. * \brief USB Controller definitions for general USB controller management.
  36. *
  37. * Functions, macros, variables, enums and types related to the setup and management of the USB interface.
  38. *
  39. * @{
  40. */
  41. #ifndef __USBCONTROLLER_H__
  42. #define __USBCONTROLLER_H__
  43. /* Includes: */
  44. #include "../../../Common/Common.h"
  45. #include "USBMode.h"
  46. /* Enable C linkage for C++ Compilers: */
  47. #if defined(__cplusplus)
  48. extern "C" {
  49. #endif
  50. /* Preprocessor Checks and Defines: */
  51. #if !defined(__INCLUDE_FROM_USB_DRIVER)
  52. #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
  53. #endif
  54. /* Defines: */
  55. /** \name Endpoint Direction Masks */
  56. //@{
  57. /** Endpoint direction mask, for masking against endpoint addresses to retrieve the endpoint's
  58. * direction for comparing with the \c ENDPOINT_DIR_* masks.
  59. */
  60. #define ENDPOINT_DIR_MASK 0x80
  61. /** Endpoint address direction mask for an OUT direction (Host to Device) endpoint. This may be ORed with
  62. * the index of the address within a device to obtain the full endpoint address.
  63. */
  64. #define ENDPOINT_DIR_OUT 0x00
  65. /** Endpoint address direction mask for an IN direction (Device to Host) endpoint. This may be ORed with
  66. * the index of the address within a device to obtain the full endpoint address.
  67. */
  68. #define ENDPOINT_DIR_IN 0x80
  69. //@}
  70. /** \name Pipe Direction Masks */
  71. //@{
  72. /** Pipe direction mask, for masking against pipe addresses to retrieve the pipe's
  73. * direction for comparing with the \c PIPE_DIR_* masks.
  74. */
  75. #define PIPE_DIR_MASK 0x80
  76. /** Endpoint address direction mask for an OUT direction (Host to Device) endpoint. This may be ORed with
  77. * the index of the address within a device to obtain the full endpoint address.
  78. */
  79. #define PIPE_DIR_OUT 0x00
  80. /** Endpoint address direction mask for an IN direction (Device to Host) endpoint. This may be ORed with
  81. * the index of the address within a device to obtain the full endpoint address.
  82. */
  83. #define PIPE_DIR_IN 0x80
  84. //@}
  85. /** \name Endpoint/Pipe Type Masks */
  86. //@{
  87. /** Mask for determining the type of an endpoint from an endpoint descriptor. This should then be compared
  88. * with the \c EP_TYPE_* masks to determine the exact type of the endpoint.
  89. */
  90. #define EP_TYPE_MASK 0x03
  91. /** Mask for a CONTROL type endpoint or pipe.
  92. *
  93. * \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.
  94. */
  95. #define EP_TYPE_CONTROL 0x00
  96. /** Mask for an ISOCHRONOUS type endpoint or pipe.
  97. *
  98. * \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.
  99. */
  100. #define EP_TYPE_ISOCHRONOUS 0x01
  101. /** Mask for a BULK type endpoint or pipe.
  102. *
  103. * \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.
  104. */
  105. #define EP_TYPE_BULK 0x02
  106. /** Mask for an INTERRUPT type endpoint or pipe.
  107. *
  108. * \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.
  109. */
  110. #define EP_TYPE_INTERRUPT 0x03
  111. //@}
  112. /* Enums: */
  113. /** Enum for the possible USB controller modes, for initialization via \ref USB_Init() and indication back to the
  114. * user application via \ref USB_CurrentMode.
  115. */
  116. enum USB_Modes_t
  117. {
  118. USB_MODE_None = 0, /**< Indicates that the controller is currently not initialized in any specific USB mode. */
  119. USB_MODE_Device = 1, /**< Indicates that the controller is currently initialized in USB Device mode. */
  120. USB_MODE_Host = 2, /**< Indicates that the controller is currently initialized in USB Host mode. */
  121. USB_MODE_UID = 3, /**< Indicates that the controller should determine the USB mode from the UID pin of the
  122. * USB connector.
  123. */
  124. };
  125. /* Architecture Includes: */
  126. #if (ARCH == ARCH_AVR8)
  127. #include "AVR8/USBController_AVR8.h"
  128. #elif (ARCH == ARCH_UC3)
  129. #include "UC3/USBController_UC3.h"
  130. #elif (ARCH == ARCH_XMEGA)
  131. #include "XMEGA/USBController_XMEGA.h"
  132. #endif
  133. /* Disable C linkage for C++ Compilers: */
  134. #if defined(__cplusplus)
  135. }
  136. #endif
  137. #endif
  138. /** @} */