usbdevice.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. //*****************************************************************************
  2. //
  3. // usbdevice.h - types and definitions used during USB enumeration.
  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. //
  22. //*****************************************************************************
  23. #ifndef __USBDEVICE_H__
  24. #define __USBDEVICE_H__
  25. //*****************************************************************************
  26. //
  27. // If building with a C++ compiler, make all of the definitions in this header
  28. // have a C binding.
  29. //
  30. //*****************************************************************************
  31. #ifdef __cplusplus
  32. extern "C"
  33. {
  34. #endif
  35. //*****************************************************************************
  36. //
  37. //! \addtogroup device_api
  38. //! @{
  39. //
  40. //*****************************************************************************
  41. //*****************************************************************************
  42. //
  43. //! The maximum number of independent interfaces that any single device
  44. //! implementation can support. Independent interfaces means interface
  45. //! descriptors with different bInterfaceNumber values - several interface
  46. //! descriptors offering different alternative settings but the same interface
  47. //! number count as a single interface.
  48. //
  49. //*****************************************************************************
  50. #define USB_MAX_INTERFACES_PER_DEVICE 8
  51. //*****************************************************************************
  52. //
  53. // Close the Doxygen group.
  54. //! @}
  55. //
  56. //*****************************************************************************
  57. //*****************************************************************************
  58. //
  59. // The default USB endpoint FIFO configuration structure. This structure
  60. // contains definitions to set all USB FIFOs into single buffered mode with
  61. // no DMA use. Each endpoint's FIFO is sized to hold the largest maximum
  62. // packet size for any interface alternate setting in the current config
  63. // descriptor. A pointer to this structure may be passed in the psFIFOConfig
  64. // field of the tDeviceInfo structure passed to USBCDCInit if the application
  65. // does not require any special handling of the USB controller FIFO.
  66. //
  67. //*****************************************************************************
  68. extern const tFIFOConfig g_sUSBDefaultFIFOConfig;
  69. //*****************************************************************************
  70. //
  71. // Public APIs offered by the USB library device control driver.
  72. //
  73. //*****************************************************************************
  74. extern void USBDCDInit(uint32 ulIndex, tDeviceInfo *psDevice);
  75. extern void USBDCDTerm(uint32 ulIndex);
  76. extern void USBDCDStallEP0(uint32 ulIndex);
  77. extern void USBDCDRequestDataEP0(uint32 ulIndex, uint8 *pucData,
  78. uint32 ulSize);
  79. extern void USBDCDSendDataEP0(uint32 ulIndex, uint8 *pucData,
  80. uint32 ulSize);
  81. extern void USBDCDSetDefaultConfiguration(uint32 ulIndex,
  82. uint32 ulDefaultConfig);
  83. extern uint32 USBDCDConfigDescGetSize(const tConfigHeader *psConfig);
  84. extern uint32 USBDCDConfigDescGetNum(const tConfigHeader *psConfig,
  85. uint32 ulType);
  86. extern tDescriptorHeader *USBDCDConfigDescGet(const tConfigHeader *psConfig,
  87. uint32 ulType,
  88. uint32 ulIndex,
  89. uint32 *pulSection);
  90. extern uint32
  91. USBDCDConfigGetNumAlternateInterfaces(const tConfigHeader *psConfig,
  92. uint8 ucInterfaceNumber);
  93. extern tInterfaceDescriptor *
  94. USBDCDConfigGetInterface(const tConfigHeader *psConfig,
  95. uint32 ulIndex, uint32 ulAltCfg,
  96. uint32 *pulSection);
  97. extern tEndpointDescriptor *
  98. USBDCDConfigGetInterfaceEndpoint(const tConfigHeader *psConfig,
  99. uint32 ulInterfaceNumber,
  100. uint32 ulAltCfg,
  101. uint32 ulIndex);
  102. extern void USBDCDPowerStatusSet(uint32 ulIndex, uint8 ucPower);
  103. extern tBoolean USBDCDRemoteWakeupRequest(uint32 ulIndex);
  104. //*****************************************************************************
  105. //
  106. // Early releases of the USB library had the following function named
  107. // incorrectly. This macro ensures that any code which used the previous name
  108. // will still operate as expected.
  109. //
  110. //*****************************************************************************
  111. #ifndef DEPRECATED
  112. #define USBCDCConfigGetInterfaceEndpoint(a, b, c, d) \
  113. USBDCDConfigGetInterfaceEndpoint((a), (b), (c), (d))
  114. #endif
  115. //*****************************************************************************
  116. //
  117. // Device mode interrupt handler for controller index 0.
  118. //
  119. //*****************************************************************************
  120. extern void USB0DeviceIntHandler(void);
  121. //*****************************************************************************
  122. //
  123. // Mark the end of the C bindings section for C++ compilers.
  124. //
  125. //*****************************************************************************
  126. #ifdef __cplusplus
  127. }
  128. #endif
  129. #endif // __USBENUM_H__