usbdbulk.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. //*****************************************************************************
  2. //
  3. // usbdcdc.h - USBLib support for a generic bulk device.
  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 revision 6288 of the Stellaris USB Library.
  22. //
  23. //*****************************************************************************
  24. #ifndef __USBDBULK_H__
  25. #define __USBDBULK_H__
  26. //*****************************************************************************
  27. //
  28. // If building with a C++ compiler, make all of the definitions in this header
  29. // have a C binding.
  30. //
  31. //*****************************************************************************
  32. #ifdef __cplusplus
  33. extern "C"
  34. {
  35. #endif
  36. //*****************************************************************************
  37. //
  38. //! \addtogroup bulk_device_class_api
  39. //! @{
  40. //
  41. //*****************************************************************************
  42. //*****************************************************************************
  43. //
  44. // PRIVATE
  45. //
  46. // The first few sections of this header are private defines that are used by
  47. // the USB Bulk example code and are here only to help with the application
  48. // allocating the correct amount of memory for the Bulk example device code.
  49. //
  50. //*****************************************************************************
  51. //*****************************************************************************
  52. //
  53. // PRIVATE
  54. //
  55. // This enumeration holds the various states that the device can be in during
  56. // normal operation.
  57. //
  58. //*****************************************************************************
  59. typedef enum
  60. {
  61. //
  62. // Unconfigured.
  63. //
  64. BULK_STATE_UNCONFIGURED,
  65. //
  66. // No outstanding transaction remains to be completed.
  67. //
  68. BULK_STATE_IDLE,
  69. //
  70. // Waiting on completion of a send or receive transaction.
  71. //
  72. BULK_STATE_WAIT_DATA,
  73. //
  74. // Waiting for client to process data.
  75. //
  76. BULK_STATE_WAIT_CLIENT
  77. } tBulkState;
  78. //*****************************************************************************
  79. //
  80. // PRIVATE
  81. //
  82. // This structure defines the private instance data and state variables for the
  83. // Bulk only example device. The memory for this structure is pointed to by
  84. // the psPrivateBulkData field in the tUSBDBulkDevice structure passed on
  85. // USBDBulkInit().
  86. //
  87. //*****************************************************************************
  88. typedef struct
  89. {
  90. unsigned int ulUSBBase;
  91. tDeviceInfo *psDevInfo;
  92. tConfigDescriptor *psConfDescriptor;
  93. volatile tBulkState eBulkRxState;
  94. volatile tBulkState eBulkTxState;
  95. volatile unsigned short usDeferredOpFlags;
  96. unsigned short usLastTxSize;
  97. volatile tBoolean bConnected;
  98. unsigned char ucINEndpoint;
  99. unsigned char ucOUTEndpoint;
  100. unsigned char ucInterface;
  101. }
  102. tBulkInstance;
  103. #ifndef DEPRECATED
  104. //*****************************************************************************
  105. //
  106. // The number of bytes of workspace required by the bulk device class driver.
  107. // The client must provide a block of RAM of at least this size in the
  108. // tBulkInstance field of the tUSBBulkDevice structure passed on USBDBulkInit.
  109. //
  110. // This value is deprecated and should not be used, any new code should just
  111. // pass in a tBulkInstance structure in the psPrivateBulkData field.
  112. //
  113. //*****************************************************************************
  114. #define USB_BULK_WORKSPACE_SIZE (sizeof(tBulkInstance))
  115. #endif
  116. //*****************************************************************************
  117. //
  118. //! The size of the memory that should be allocated to create a configuration
  119. //! descriptor for a single instance of the USB Bulk Device.
  120. //! This does not include the configuration descriptor which is automatically
  121. //! ignored by the composite device class.
  122. //
  123. // For reference this is sizeof(g_sCDCSerIfaceHeaderSectionNOINT) +
  124. // sizeof(g_sCDCSerInterfaceSection) + sizeof(g_sCDCSerIfaceEndpointsNOINT)
  125. //
  126. //*****************************************************************************
  127. #define COMPOSITE_DBULK_SIZE (23)
  128. //*****************************************************************************
  129. //
  130. //! The structure used by the application to define operating parameters for
  131. //! the bulk device.
  132. //
  133. //*****************************************************************************
  134. typedef struct
  135. {
  136. //
  137. //! The vendor ID that this device is to present in the device descriptor.
  138. //
  139. unsigned short usVID;
  140. //
  141. //! The product ID that this device is to present in the device descriptor.
  142. //
  143. unsigned short usPID;
  144. //
  145. //! The maximum power consumption of the device, expressed in milliamps.
  146. //
  147. unsigned short usMaxPowermA;
  148. //
  149. //! Indicates whether the device is self- or bus-powered and whether or not
  150. //! it supports remote wakeup. Valid values are USB_CONF_ATTR_SELF_PWR or
  151. //! USB_CONF_ATTR_BUS_PWR, optionally ORed with USB_CONF_ATTR_RWAKE.
  152. //
  153. unsigned char ucPwrAttributes;
  154. //
  155. //! A pointer to the callback function which will be called to notify
  156. //! the application of events related to the device's data receive channel.
  157. //
  158. tUSBCallback pfnRxCallback;
  159. //
  160. //! A client-supplied pointer which will be sent as the first
  161. //! parameter in all calls made to the receive channel callback,
  162. //! pfnRxCallback.
  163. //
  164. void *pvRxCBData;
  165. //
  166. //! A pointer to the callback function which will be called to notify
  167. //! the application of events related to the device's data transmit
  168. //! channel.
  169. //
  170. tUSBCallback pfnTxCallback;
  171. //
  172. //! A client-supplied pointer which will be sent as the first
  173. //! parameter in all calls made to the transmit channel callback,
  174. //! pfnTxCallback.
  175. //
  176. void *pvTxCBData;
  177. //
  178. //! A pointer to the string descriptor array for this device. This array
  179. //! must contain pointers to the following string descriptors in this
  180. //! order. Language descriptor, Manufacturer name string (language 1),
  181. //! Product name string (language 1), Serial number string (language 1),
  182. //! Interface description string (language 1) and Configuration description
  183. //! string (language 1).
  184. //!
  185. //! If supporting more than 1 language, the strings for indices 1 through 5
  186. //! must be repeated for each of the other languages defined in the
  187. //! language descriptor.
  188. //
  189. const unsigned char * const *ppStringDescriptors;
  190. //
  191. //! The number of descriptors provided in the ppStringDescriptors array.
  192. //! This must be 1 + (5 * number of supported languages).
  193. //
  194. unsigned int ulNumStringDescriptors;
  195. //
  196. //! A pointer to private instance data for this device. This memory must
  197. //! remain accessible for as int as the bulk device is in use and must not
  198. //! be modified by any code outside the bulk class driver.
  199. //
  200. tBulkInstance *psPrivateBulkData;
  201. }
  202. tUSBDBulkDevice;
  203. extern tDeviceInfo g_sBulkDeviceInfo;
  204. //*****************************************************************************
  205. //
  206. // API Function Prototypes
  207. //
  208. //*****************************************************************************
  209. extern void *USBDBulkInit(unsigned int ulIndex,
  210. const tUSBDBulkDevice *psDevice);
  211. extern void *USBDBulkCompositeInit(unsigned int ulIndex,
  212. const tUSBDBulkDevice *psDevice);
  213. extern void USBDBulkTerm(void *pvInstance);
  214. extern void *USBDBulkSetRxCBData(void *pvInstance, void *pvCBData);
  215. extern void *USBDBulkSetTxCBData(void *pvInstance, void *pvCBData);
  216. extern unsigned int USBDBulkPacketWrite(void *pvInstance,
  217. unsigned char *pcData,
  218. unsigned int ulLength,
  219. tBoolean bLast);
  220. extern unsigned int USBDBulkPacketRead(void *pvInstance,
  221. unsigned char *pcData,
  222. unsigned int ulLength,
  223. tBoolean bLast);
  224. extern unsigned int USBDBulkTxPacketAvailable(void *pvInstance);
  225. extern unsigned int USBDBulkRxPacketAvailable(void *pvInstance);
  226. extern void USBDBulkPowerStatusSet(void *pvInstance, unsigned char ucPower);
  227. extern tBoolean USBDBulkRemoteWakeupRequest(void *pvInstance);
  228. //*****************************************************************************
  229. //
  230. // Close the Doxygen group.
  231. //! @}
  232. //
  233. //*****************************************************************************
  234. //*****************************************************************************
  235. //
  236. // Mark the end of the C bindings section for C++ compilers.
  237. //
  238. //*****************************************************************************
  239. #ifdef __cplusplus
  240. }
  241. #endif
  242. #endif // __USBDBULK_H__