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.

DeviceStandardReq.h 6.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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 USB device standard request management.
  28. *
  29. * This file contains the function prototypes necessary for the processing of incoming standard control requests
  30. * when the library is in USB device mode.
  31. *
  32. * \note This file should not be included directly. It is automatically included as needed by the USB driver
  33. * dispatch header located in LUFA/Drivers/USB/USB.h.
  34. */
  35. #ifndef __DEVICESTDREQ_H__
  36. #define __DEVICESTDREQ_H__
  37. /* Includes: */
  38. #include "../../../Common/Common.h"
  39. #include "USBMode.h"
  40. #include "StdDescriptors.h"
  41. #include "Events.h"
  42. #include "StdRequestType.h"
  43. #include "USBTask.h"
  44. #include "USBController.h"
  45. /* Enable C linkage for C++ Compilers: */
  46. #if defined(__cplusplus)
  47. extern "C" {
  48. #endif
  49. /* Preprocessor Checks: */
  50. #if !defined(__INCLUDE_FROM_USB_DRIVER)
  51. #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
  52. #endif
  53. /* Public Interface - May be used in end-application: */
  54. /* Enums: */
  55. #if defined(ARCH_HAS_MULTI_ADDRESS_SPACE) || defined(__DOXYGEN__)
  56. /** Enum for the possible descriptor memory spaces, for the \c MemoryAddressSpace parameter of the
  57. * \ref CALLBACK_USB_GetDescriptor() function. This can be used when none of the \c USE_*_DESCRIPTORS
  58. * compile time options are used, to indicate in which memory space the descriptor is stored.
  59. *
  60. * \ingroup Group_Device
  61. */
  62. enum USB_DescriptorMemorySpaces_t
  63. {
  64. #if defined(ARCH_HAS_FLASH_ADDRESS_SPACE) || defined(__DOXYGEN__)
  65. MEMSPACE_FLASH = 0, /**< Indicates the requested descriptor is located in FLASH memory. */
  66. #endif
  67. #if defined(ARCH_HAS_EEPROM_ADDRESS_SPACE) || defined(__DOXYGEN__)
  68. MEMSPACE_EEPROM = 1, /**< Indicates the requested descriptor is located in EEPROM memory. */
  69. #endif
  70. MEMSPACE_RAM = 2, /**< Indicates the requested descriptor is located in RAM memory. */
  71. };
  72. #endif
  73. /* Global Variables: */
  74. /** Indicates the currently set configuration number of the device. USB devices may have several
  75. * different configurations which the host can select between; this indicates the currently selected
  76. * value, or 0 if no configuration has been selected.
  77. *
  78. * \attention This variable should be treated as read-only in the user application, and never manually
  79. * changed in value.
  80. *
  81. * \ingroup Group_Device
  82. */
  83. extern uint8_t USB_Device_ConfigurationNumber;
  84. #if !defined(NO_DEVICE_REMOTE_WAKEUP)
  85. /** Indicates if the host is currently allowing the device to issue remote wakeup events. If this
  86. * flag is cleared, the device should not issue remote wakeup events to the host.
  87. *
  88. * \attention This variable should be treated as read-only in the user application, and never manually
  89. * changed in value.
  90. *
  91. * \note To reduce FLASH usage of the compiled applications where Remote Wakeup is not supported,
  92. * this global and the underlying management code can be disabled by defining the
  93. * \c NO_DEVICE_REMOTE_WAKEUP token in the project makefile and passing it to the compiler via
  94. * the -D switch.
  95. *
  96. * \ingroup Group_Device
  97. */
  98. extern bool USB_Device_RemoteWakeupEnabled;
  99. #endif
  100. #if !defined(NO_DEVICE_SELF_POWER)
  101. /** Indicates if the device is currently being powered by its own power supply, rather than being
  102. * powered by the host's USB supply. This flag should remain cleared if the device does not
  103. * support self powered mode, as indicated in the device descriptors.
  104. *
  105. * \ingroup Group_Device
  106. */
  107. extern bool USB_Device_CurrentlySelfPowered;
  108. #endif
  109. /* Private Interface - For use in library only: */
  110. #if !defined(__DOXYGEN__)
  111. #if defined(USE_RAM_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS)
  112. #error USE_RAM_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive.
  113. #elif defined(USE_RAM_DESCRIPTORS) && defined(USE_FLASH_DESCRIPTORS)
  114. #error USE_RAM_DESCRIPTORS and USE_FLASH_DESCRIPTORS are mutually exclusive.
  115. #elif defined(USE_FLASH_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS)
  116. #error USE_FLASH_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive.
  117. #elif defined(USE_FLASH_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS) && defined(USE_RAM_DESCRIPTORS)
  118. #error Only one of the USE_*_DESCRIPTORS modes should be selected.
  119. #endif
  120. /* Function Prototypes: */
  121. void USB_Device_ProcessControlRequest(void);
  122. #if defined(__INCLUDE_FROM_DEVICESTDREQ_C)
  123. static void USB_Device_SetAddress(void);
  124. static void USB_Device_SetConfiguration(void);
  125. static void USB_Device_GetConfiguration(void);
  126. static void USB_Device_GetDescriptor(void);
  127. static void USB_Device_GetStatus(void);
  128. static void USB_Device_ClearSetFeature(void);
  129. #if !defined(NO_INTERNAL_SERIAL) && (USE_INTERNAL_SERIAL != NO_DESCRIPTOR)
  130. static void USB_Device_GetInternalSerialDescriptor(void);
  131. #endif
  132. #endif
  133. #endif
  134. /* Disable C linkage for C++ Compilers: */
  135. #if defined(__cplusplus)
  136. }
  137. #endif
  138. #endif