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.

StillImageClassCommon.h 6.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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 definitions and declarations for the library USB Still Image Class driver.
  28. *
  29. * Common definitions and declarations for the library USB Still Image Class driver.
  30. *
  31. * \note This file should not be included directly. It is automatically included as needed by the USB module driver
  32. * dispatch header located in LUFA/Drivers/USB.h.
  33. */
  34. /** \ingroup Group_USBClassSI
  35. * \defgroup Group_USBClassSICommon Common Class Definitions
  36. *
  37. * \section Sec_USBClassSICommon_ModDescription Module Description
  38. * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB
  39. * Still Image Class.
  40. *
  41. * @{
  42. */
  43. #ifndef _SI_CLASS_COMMON_H_
  44. #define _SI_CLASS_COMMON_H_
  45. /* Includes: */
  46. #include "../../Core/StdDescriptors.h"
  47. /* Enable C linkage for C++ Compilers: */
  48. #if defined(__cplusplus)
  49. extern "C" {
  50. #endif
  51. /* Preprocessor Checks: */
  52. #if !defined(__INCLUDE_FROM_SI_DRIVER)
  53. #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.
  54. #endif
  55. /* Macros: */
  56. /** Length in bytes of a given Unicode string's character length.
  57. *
  58. * \param[in] Chars Total number of Unicode characters in the string.
  59. *
  60. * \return Number of bytes of the given unicode string.
  61. */
  62. #define UNICODE_STRING_LENGTH(Chars) ((Chars) << 1)
  63. /** Used in the DataLength field of a PIMA container, to give the total container size in bytes for
  64. * a command container.
  65. *
  66. * \param[in] Params Number of parameters which are to be sent in the \c Param field of the container.
  67. */
  68. #define PIMA_COMMAND_SIZE(Params) ((sizeof(PIMA_Container_t) - 12) + ((Params) * sizeof(uint32_t)))
  69. /** Used in the DataLength field of a PIMA container, to give the total container size in bytes for
  70. * a data container.
  71. *
  72. * \param[in] DataLen Length in bytes of the data in the container.
  73. */
  74. #define PIMA_DATA_SIZE(DataLen) ((sizeof(PIMA_Container_t) - 12) + (DataLen))
  75. /* Enums: */
  76. /** Enum for the possible PIMA contains types. */
  77. enum PIMA_Container_Types_t
  78. {
  79. PIMA_CONTAINER_Undefined = 0, /**< Undefined container type. */
  80. PIMA_CONTAINER_CommandBlock = 1, /**< Command Block container type. */
  81. PIMA_CONTAINER_DataBlock = 2, /**< Data Block container type. */
  82. PIMA_CONTAINER_ResponseBlock = 3, /**< Response container type. */
  83. PIMA_CONTAINER_EventBlock = 4, /**< Event Block container type. */
  84. };
  85. /* Enums: */
  86. /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors relating to the
  87. * Still Image device class.
  88. */
  89. enum SI_Descriptor_ClassSubclassProtocol_t
  90. {
  91. SI_CSCP_StillImageClass = 0x06, /**< Descriptor Class value indicating that the device or interface
  92. * belongs to the Still Image class.
  93. */
  94. SI_CSCP_StillImageSubclass = 0x01, /**< Descriptor Subclass value indicating that the device or interface
  95. * belongs to the Still Image subclass.
  96. */
  97. SI_CSCP_BulkOnlyProtocol = 0x01, /**< Descriptor Protocol value indicating that the device or interface
  98. * belongs to the Bulk Only Transport protocol of the Still Image class.
  99. */
  100. };
  101. /** Enums for the possible status codes of a returned Response Block from an attached PIMA compliant Still Image device. */
  102. enum PIMA_ResponseCodes_t
  103. {
  104. PIMA_RESPONSE_OK = 1, /**< Response code indicating no error in the issued command. */
  105. PIMA_RESPONSE_GeneralError = 2, /**< Response code indicating a general error while processing the
  106. * issued command.
  107. */
  108. PIMA_RESPONSE_SessionNotOpen = 3, /**< Response code indicating that the sent command requires an open
  109. * session before being issued.
  110. */
  111. PIMA_RESPONSE_InvalidTransaction = 4, /**< Response code indicating an invalid transaction occurred. */
  112. PIMA_RESPONSE_OperationNotSupported = 5, /**< Response code indicating that the issued command is not supported
  113. * by the attached device.
  114. */
  115. PIMA_RESPONSE_ParameterNotSupported = 6, /**< Response code indicating that one or more of the issued command's
  116. * parameters are not supported by the device.
  117. */
  118. };
  119. /* Type Defines: */
  120. /** \brief PIMA Still Image Device Command/Response Container.
  121. *
  122. * Type define for a PIMA container, use to send commands and receive responses to and from an
  123. * attached Still Image device.
  124. *
  125. * \note Regardless of CPU architecture, these values should be stored as little endian.
  126. */
  127. typedef struct
  128. {
  129. uint32_t DataLength; /**< Length of the container and data, in bytes. */
  130. uint16_t Type; /**< Container type, a value from the \ref PIMA_Container_Types_t enum. */
  131. uint16_t Code; /**< Command, event or response code of the container. */
  132. uint32_t TransactionID; /**< Unique container ID to link blocks together. */
  133. uint32_t Params[3]; /**< Block parameters to be issued along with the block code (command blocks only). */
  134. } ATTR_PACKED PIMA_Container_t;
  135. /* Disable C linkage for C++ Compilers: */
  136. #if defined(__cplusplus)
  137. }
  138. #endif
  139. #endif
  140. /** @} */