Driver_USB.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /**
  2. \defgroup usb_interface_gr USB Interface
  3. \brief USB common definitions (%Driver_USB.h)
  4. \details
  5. The <b>Universal Serial Bus</b> (USB) implements a serial bus for data exchange. It is a host controlled, plug-and-play interface
  6. between a USB host and USB devices using a tiered star topology.
  7. In microcontroller (MCU) applications, the interface is often used to connect a device to a host for data exchange or control purposes.
  8. - Wikipedia offers more information about the <a href="http://en.wikipedia.org/wiki/Universal_Serial_Bus" target="_blank"><b>Universal Serial Bus</b></a>.
  9. - The USB Implementers Forum provides detailed documentation under <a href="http://www.usb.org"><b>www.usb.org</b></a>.
  10. <b>Block Diagram</b>
  11. Typically only one USB Device is connected to a USB Host. If several USB devices must be connected to the same USB host, then
  12. the connection must be done via a USB hub.
  13. <p>
  14. \image html USB_Schematics.png "Simplified USB Schema"
  15. </p>
  16. <b>USB API</b>
  17. The following header files define the Application Programming Interface (API) for the USB interface:
  18. - \b %Driver_USB.h : Common definitions of the USBD and USBH interface
  19. - \b %Driver_USBD.h : Driver API for USB Device Peripheral
  20. - \b %Driver_USBH.h : Driver API for USB Host Peripheral
  21. The driver implementation is a typical part of the Device Family Pack (DFP) that supports the
  22. peripherals of the microcontroller family.
  23. <b>Driver Functions</b>
  24. The driver functions are published in the access struct as explained in \ref DriverFunctions
  25. - \ref ARM_DRIVER_USBD : access struct for USBD driver functions
  26. - \ref ARM_DRIVER_USBH : access struct for USBH driver functions
  27. <hr>
  28. */
  29. /**
  30. \addtogroup usbd_interface_gr
  31. \ingroup usb_interface_gr
  32. \details
  33. <b>USB Device API</b>
  34. The header file \b Driver_USBD.h defines the API for the <b>USB Device Driver</b> interface used by middleware components.
  35. The driver implementation itself is a typical part of the Device Family Pack, which provides entry points to the interface
  36. as function pointers in the struct \ref ARM_DRIVER_USBD. This structure can be available several times in each interface to control multiple USBD interfaces.
  37. Header file \b Driver_USBD.h also defines callback routines that can be categorized as
  38. <b>device event callbacks</b> and <b>endpoint event callbacks</b>.
  39. Callbacks are called by the driver, in interrupt context when an appropriate event occurs, to signal device related events (\ref USBD_dev_events)
  40. and endpoint related events (\ref USBD_ep_events).
  41. <b>USB Device Function Call Sequence</b>
  42. To use the USBD driver invoke the API functions in the following order:
  43. \msc
  44. a [label="", textcolor="indigo", linecolor="indigo", arclinecolor="red"],
  45. b [label="", textcolor="blue", linecolor="blue", arclinecolor="blue"];
  46. a rbox a [label="Middleware", linecolor="indigo"],
  47. b rbox b [label="USBD Driver", linecolor="blue"];
  48. a=>b [label="ARM_USBD_Initialize", URL="\ref ARM_USBD_Initialize"];
  49. a=>b [label="ARM_USBD_PowerControl (ARM_POWER_FULL)", URL="\ref ARM_USBD_Initialize"];
  50. a=>b [label="ARM_USBD_DeviceConnect", URL="\ref ARM_USBD_DeviceConnect"];
  51. a<=b [label="ARM_USBD_SignalDeviceEvent (ARM_USBD_EVENT_RESET)", URL="\ref ARM_USBD_SignalDeviceEvent", linecolor="orange"];
  52. a=>b [label="ARM_USBD_DeviceGetState", URL="\ref ARM_USBD_DeviceGetState"];
  53. a=>b [label="ARM_USBD_EndpointConfigure", URL="\ref ARM_USBD_EndpointConfigure", linecolor="green"];
  54. --- [label="Repeat and use as needed"];
  55. a=>b [label="ARM_USBD_EndpointTransfer", URL="\ref ARM_USBD_EndpointTransfer", linecolor="green"];
  56. a<=b [label="ARM_USBD_SignalEndpointEvent", URL="\ref ARM_USBD_SignalEndpointEvent", linecolor="orange"];
  57. a=>b [label="ARM_USBD_EndpointTransferGetResult", URL="\ref ARM_USBD_EndpointTransferGetResult", linecolor="green"];
  58. --- [label="Repeat End"];
  59. a=>b [label="ARM_USBD_DeviceDisconnect", URL="\ref ARM_USBD_DeviceDisconnect"];
  60. a=>b [label="ARM_USBD_PowerControl (ARM_POWER_OFF)", URL="\ref ARM_USBD_Initialize"];
  61. a=>b [label="ARM_USBD_Uninitialize", URL="\ref ARM_USBD_Uninitialize"];
  62. \endmsc
  63. */
  64. /**
  65. \addtogroup usbh_interface_gr
  66. \ingroup usb_interface_gr
  67. \details
  68. <b>USB Host API</b>
  69. The header file \b Driver_USBH.h defines the API for the <b>USB Host Driver</b> interface used by middleware components.
  70. The driver implementation itself is a typical part of the Device Family Pack, which provides entry points to the interface
  71. as function pointers in the struct \ref ARM_DRIVER_USBH. This structure can be available several times in each interface to control multiple USBH interfaces.
  72. \b Driver_USBH.h also defines callback routines, which are categorized in
  73. <b>port event callbacks</b> and <b>pipe event callbacks</b>.
  74. Callbacks are called by the driver, in interrupt context when an appropriate event occurs, to signal port related events (\ref ARM_USBH_SignalPortEvent)
  75. and pipe related events (\ref ARM_USBH_SignalPipeEvent).
  76. \cond
  77. <b>USB Host Function Call Sequence</b>
  78. To use the USBH driver invoke the API functions in the following order:
  79. \msc
  80. a [label="", textcolor="indigo", linecolor="indigo", arclinecolor="red"],
  81. b [label="", textcolor="blue", linecolor="blue", arclinecolor="blue"];
  82. a rbox a [label="Middleware", linecolor="indigo"],
  83. b rbox b [label="USBH Driver", linecolor="blue"];
  84. a=>b [label="ARM_USBH_Initialize", URL="\ref ARM_USBD_Initialize"];
  85. --- [label="Repeat and use as needed"];
  86. --- [label="Repeat End"];
  87. a=>b [label="ARM_USBH_Uninitialize", URL="\ref ARM_USBH_Uninitialize"];
  88. \endmsc
  89. <hr>
  90. \endcond
  91. */
  92. /**
  93. \defgroup USB_speed USB Speed
  94. \ingroup usb_interface_gr
  95. \brief USB Speed definitions
  96. \details
  97. The following USB speed values are defined:
  98. @{
  99. \def ARM_USB_SPEED_LOW
  100. \def ARM_USB_SPEED_FULL
  101. \def ARM_USB_SPEED_HIGH
  102. @}
  103. */
  104. /**
  105. \defgroup USB_endpoint_type USB Endpoint Type
  106. \ingroup usb_interface_gr
  107. \brief USB Endpoint Type definitions
  108. \details
  109. The following USB Endpoint Type values are defined:
  110. @{
  111. \def ARM_USB_ENDPOINT_CONTROL
  112. \def ARM_USB_ENDPOINT_ISOCHRONOUS
  113. \def ARM_USB_ENDPOINT_BULK
  114. \def ARM_USB_ENDPOINT_INTERRUPT
  115. @}
  116. */