usbhhid.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. //*****************************************************************************
  2. //
  3. // usbhhid.h - This hold the host driver for hid class.
  4. //
  5. // Copyright (c) 2008-2010 Texas Instruments Incorporated. All rights reserved.
  6. // Software License Agreement
  7. //
  8. // Texas Instruments (TI) is supplying this software for use solely and
  9. // exclusively on TI's microcontroller products. The software is owned by
  10. // TI and/or its suppliers, and is protected under applicable copyright
  11. // laws. You may not combine this software with "viral" open-source
  12. // software in order to form a larger program.
  13. //
  14. // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
  15. // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
  16. // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  17. // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
  18. // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
  19. // DAMAGES, FOR ANY REASON WHATSOEVER.
  20. //
  21. // This is part of AM1808 StarterWare USB Library, resused from revision 6288 of the
  22. // stellaris USB Library
  23. //
  24. //*****************************************************************************
  25. #ifndef __USBHHID_H__
  26. #define __USBHHID_H__
  27. //*****************************************************************************
  28. //
  29. // If building with a C++ compiler, make all of the definitions in this header
  30. // have a C binding.
  31. //
  32. //*****************************************************************************
  33. #ifdef __cplusplus
  34. extern "C"
  35. {
  36. #endif
  37. //*****************************************************************************
  38. //
  39. //! \addtogroup usblib_host_class
  40. //! @{
  41. //
  42. //*****************************************************************************
  43. //*****************************************************************************
  44. //
  45. // These defines are the the events that will be passed in the ulEvent
  46. // parameter of the callback from the driver.
  47. //
  48. //*****************************************************************************
  49. #define USBH_EVENT_HID_SETRPT USBH_HID_EVENT_BASE + 0
  50. #define USBH_EVENT_HID_REPORT USBH_HID_EVENT_BASE + 1
  51. //
  52. //! The HID keyboard detected a key being pressed.
  53. //
  54. #define USBH_EVENT_HID_KB_PRESS USBH_HID_EVENT_BASE + 16
  55. //
  56. //! The HID keyboard detected a key being released.
  57. //
  58. #define USBH_EVENT_HID_KB_REL USBH_HID_EVENT_BASE + 17
  59. //
  60. //! The HID keyboard detected one of the keyboard modifiers being pressed.
  61. //
  62. #define USBH_EVENT_HID_KB_MOD USBH_HID_EVENT_BASE + 18
  63. //
  64. //! A button was pressed on a HID mouse.
  65. //
  66. #define USBH_EVENT_HID_MS_PRESS USBH_HID_EVENT_BASE + 32
  67. //
  68. //! A button was released on a HID mouse.
  69. //
  70. #define USBH_EVENT_HID_MS_REL USBH_HID_EVENT_BASE + 33
  71. //
  72. //! The HID mouse detected movement in the X direction.
  73. //
  74. #define USBH_EVENT_HID_MS_X USBH_HID_EVENT_BASE + 34
  75. //
  76. //! The HID mouse detected movement in the Y direction.
  77. //
  78. #define USBH_EVENT_HID_MS_Y USBH_HID_EVENT_BASE + 35
  79. //*****************************************************************************
  80. //
  81. //! The following values are used to register callbacks to the USB HOST HID
  82. //! device class layer.
  83. //
  84. //*****************************************************************************
  85. typedef enum
  86. {
  87. //
  88. //! No device should be used. This value should not be used by
  89. //! applications.
  90. //
  91. USBH_HID_DEV_NONE = 0,
  92. //
  93. //! This is a keyboard device.
  94. //
  95. USBH_HID_DEV_KEYBOARD,
  96. //
  97. //! This is a mouse device.
  98. //
  99. USBH_HID_DEV_MOUSE,
  100. //
  101. //! This is a vendor specific device.
  102. //
  103. USBH_HID_DEV_VENDOR
  104. }
  105. tHIDSubClassProtocol;
  106. //*****************************************************************************
  107. //
  108. // This is the structure that holds all of the data for a given instance of
  109. // a HID device.
  110. //
  111. //*****************************************************************************
  112. typedef struct
  113. {
  114. //
  115. // Save the device instance.
  116. //
  117. tUSBHostDevice *pDevice;
  118. //
  119. // Used to save the callback.
  120. //
  121. tUSBCallback pfnCallback;
  122. //
  123. // Callback data provided by caller.
  124. //
  125. unsigned int ulCBData;
  126. //
  127. // Used to remember what type of device was registered.
  128. //
  129. tHIDSubClassProtocol eDeviceType;
  130. //
  131. // Interrupt IN pipe.
  132. //
  133. unsigned int ulIntInPipe;
  134. unsigned int ulIndex;
  135. }
  136. tHIDInstance;
  137. //*****************************************************************************
  138. //
  139. // Close the Doxygen group.
  140. //! @}
  141. //
  142. //*****************************************************************************
  143. //*****************************************************************************
  144. //
  145. // Prototypes.
  146. //
  147. //*****************************************************************************
  148. extern unsigned int USBHHIDOpen(unsigned int ulIndex,
  149. tHIDSubClassProtocol eDeviceType,
  150. tUSBCallback pfnCallback,
  151. unsigned int ulCBData);
  152. extern void USBHHIDClose(unsigned int ulInstance);
  153. extern unsigned int USBHHIDGetReportDescriptor(unsigned int ulInstance,
  154. unsigned char *pucBuffer,
  155. unsigned int ulSize);
  156. extern unsigned int USBHHIDSetIdle(unsigned int ulInstance,
  157. unsigned char ucDuration,
  158. unsigned char ucReportID);
  159. extern unsigned int USBHHIDSetProtocol(unsigned int ulInstance,
  160. unsigned int ulBootProtocol);
  161. extern unsigned int USBHHIDSetReport(unsigned int ulInstance,
  162. unsigned int ulInterface,
  163. unsigned char *pucData,
  164. unsigned int ulSize);
  165. extern unsigned int USBHHIDGetReport(unsigned int ulInstance,
  166. unsigned int ulInterface,
  167. unsigned char *pucData,
  168. unsigned int ulSize);
  169. extern const tUSBHostClassDriver g_USBHIDClassDriver;
  170. //*****************************************************************************
  171. //
  172. // Mark the end of the C bindings section for C++ compilers.
  173. //
  174. //*****************************************************************************
  175. #ifdef __cplusplus
  176. }
  177. #endif
  178. #endif // __USBHHID_H__