usbdcomp.h 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. //*****************************************************************************
  2. //
  3. // usbdcomp.h - USB composite device class driver.
  4. //
  5. // Copyright (c) 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 and reused from revision 6288
  22. // of the Stellaris USB Library.
  23. //
  24. //*****************************************************************************
  25. #ifndef __USBDCOMP_H__
  26. #define __USBDCOMP_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. // Return to default packing when using the IAR Embedded Workbench compiler.
  40. //
  41. //*****************************************************************************
  42. #if defined(ewarm) || defined(__IAR_SYSTEMS_ICC__)
  43. #pragma pack()
  44. #endif
  45. //*****************************************************************************
  46. //
  47. //! \addtogroup composite_device_class_api
  48. //! @{
  49. //
  50. //*****************************************************************************
  51. //
  52. // Defines a single entry in a table of device types supported by the composite
  53. // device.
  54. //
  55. typedef struct
  56. {
  57. //
  58. // This is set internally by the composite class so it can be left
  59. // uninitialized by the application.
  60. //
  61. const tDeviceInfo *pDeviceInfo;
  62. //
  63. // This should be the header to the configuration header for a class.
  64. //
  65. const tConfigHeader *psConfigHeader;
  66. //
  67. // The offset to this devices interface, filled in by the composite class.
  68. //
  69. unsigned char ucIfaceOffset;
  70. } tUSBDCompositeEntry;
  71. //*****************************************************************************
  72. //
  73. // PRIVATE
  74. //
  75. // This structure defines the private instance data and state variables for the
  76. // composite device class. The memory for this structure is pointed to by
  77. // the psPrivateData field in the tUSBDCompositeDevice structure passed on
  78. // USBDCompositeInit() and should not be modified by any code outside of the
  79. // composite device code.
  80. //
  81. //*****************************************************************************
  82. typedef struct
  83. {
  84. //
  85. // Saves which USB controller is in use.
  86. //
  87. unsigned int ulUSBBase;
  88. //
  89. // The device information pointer.
  90. //
  91. tDeviceInfo *psDevInfo;
  92. //
  93. // This is the configuration descriptor for this instance.
  94. //
  95. tConfigDescriptor sConfigDescriptor;
  96. //
  97. // This is the device descriptor for this instance.
  98. //
  99. tDeviceDescriptor sDeviceDescriptor;
  100. //
  101. // The configuration header for this instance.
  102. //
  103. tConfigHeader sCompConfigHeader;
  104. //
  105. // These are the configuration sections that will be built from the
  106. // Configuration Descriptor header and the descriptors from the devices
  107. // that are part of this composite device.
  108. //
  109. tConfigSection psCompSections[2];
  110. tConfigSection *ppsCompSections[2];
  111. //
  112. // The size and pointer to the data used by the instance.
  113. //
  114. unsigned int ulDataSize;
  115. unsigned char *pucData;
  116. }
  117. tCompositeInstance;
  118. //*****************************************************************************
  119. //
  120. //! This type is used by an application to describe and instance of a device
  121. //! and an instance data pointer for that class. The psDevice pointer should
  122. //! be a pointer to a valid device class to include in the composite device.
  123. //! The pvInstance pointer should be a pointer to an instance pointer for the
  124. //! device in the psDevice pointer.
  125. //!
  126. //
  127. //*****************************************************************************
  128. typedef struct
  129. {
  130. //
  131. //! This is the top level device information structure.
  132. //
  133. const tDeviceInfo *psDevice;
  134. //
  135. //! This is the instance data for the device structure.
  136. //
  137. void *pvInstance;
  138. }
  139. tCompositeEntry;
  140. //*****************************************************************************
  141. //
  142. //! The structure used by the application to define operating parameters for
  143. //! the composite device class.
  144. //
  145. //*****************************************************************************
  146. typedef struct
  147. {
  148. //
  149. //! The vendor ID that this device is to present in the device descriptor.
  150. //
  151. unsigned short usVID;
  152. //
  153. //! The product ID that this device is to present in the device descriptor.
  154. //
  155. unsigned short usPID;
  156. //
  157. //! The maximum power consumption of the device, expressed in mA.
  158. //
  159. unsigned short usMaxPowermA;
  160. //
  161. //! Indicates whether the device is self or bus-powered and whether or not
  162. //! it supports remote wake up. Valid values are USB_CONF_ATTR_SELF_PWR or
  163. //! USB_CONF_ATTR_BUS_PWR, optionally ORed with USB_CONF_ATTR_RWAKE.
  164. //
  165. unsigned char ucPwrAttributes;
  166. //
  167. //! A pointer to the callback function which will be called to notify
  168. //! the application of events relating to the operation of the composite
  169. //! device.
  170. //
  171. tUSBCallback pfnCallback;
  172. //
  173. //! A pointer to the string descriptor array for this device. This array
  174. //! must contain the following string descriptor pointers in this order.
  175. //! Language descriptor, Manufacturer name string (language 1), Product
  176. //! name string (language 1), Serial number string (language 1), Composite
  177. //! device interface description string (language 1), Configuration
  178. //! description string (language 1).
  179. //!
  180. //! If supporting more than 1 language, the descriptor block (except for
  181. //! string descriptor 0) must be repeated for each language defined in the
  182. //! language descriptor.
  183. //!
  184. //
  185. const unsigned char * const *ppStringDescriptors;
  186. //
  187. //! The number of descriptors provided in the ppStringDescriptors
  188. //! array. This must be 1 + ((5 + (number of strings)) *
  189. //! (number of languages)).
  190. //
  191. unsigned int ulNumStringDescriptors;
  192. //
  193. //! The number of devices in the psDevices array.
  194. //
  195. unsigned int ulNumDevices;
  196. //
  197. //! This application supplied array holds the the top level device class
  198. //! information as well as the Instance data for that class.
  199. //
  200. tCompositeEntry *psDevices;
  201. //
  202. //! A pointer to RAM work space for this device instance. The client
  203. //! must fill in this field with a pointer to at least
  204. //! sizeof(tCompositeInstance) bytes of read/write storage that the
  205. //! library can use for driver work space. This memory must remain
  206. //! accessible for as int as the composite device is in use and must not
  207. //! be modified by any code outside the composite class driver.
  208. //
  209. tCompositeInstance *psPrivateData;
  210. }
  211. tUSBDCompositeDevice;
  212. //*****************************************************************************
  213. //
  214. // Return to default packing when using the IAR Embedded Workbench compiler.
  215. //
  216. //*****************************************************************************
  217. #if defined(ewarm) || defined(__IAR_SYSTEMS_ICC__)
  218. #pragma pack()
  219. #endif
  220. //*****************************************************************************
  221. //
  222. // Composite specific device class driver events
  223. //
  224. //*****************************************************************************
  225. //*****************************************************************************
  226. //
  227. // API Function Prototypes
  228. //
  229. //*****************************************************************************
  230. extern void *USBDCompositeInit(unsigned int ulIndex,
  231. tUSBDCompositeDevice *psCompDevice,
  232. unsigned int ulSize,
  233. unsigned char *pucData);
  234. extern void USBDCompositeTerm(void *pvInstance);
  235. //*****************************************************************************
  236. //
  237. // Close the Doxygen group.
  238. //! @}
  239. //
  240. //*****************************************************************************
  241. //*****************************************************************************
  242. //
  243. // Mark the end of the C bindings section for C++ compilers.
  244. //
  245. //*****************************************************************************
  246. #ifdef __cplusplus
  247. }
  248. #endif
  249. #endif