Driver_USB.h 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* -----------------------------------------------------------------------------
  2. * Copyright (c) 2013-2014 ARM Ltd.
  3. *
  4. * This software is provided 'as-is', without any express or implied warranty.
  5. * In no event will the authors be held liable for any damages arising from
  6. * the use of this software. Permission is granted to anyone to use this
  7. * software for any purpose, including commercial applications, and to alter
  8. * it and redistribute it freely, subject to the following restrictions:
  9. *
  10. * 1. The origin of this software must not be misrepresented; you must not
  11. * claim that you wrote the original software. If you use this software in
  12. * a product, an acknowledgment in the product documentation would be
  13. * appreciated but is not required.
  14. *
  15. * 2. Altered source versions must be plainly marked as such, and must not be
  16. * misrepresented as being the original software.
  17. *
  18. * 3. This notice may not be removed or altered from any source distribution.
  19. *
  20. *
  21. * $Date: 20. May 2014
  22. * $Revision: V2.00
  23. *
  24. * Project: USB Driver common definitions
  25. * -------------------------------------------------------------------------- */
  26. /* History:
  27. * Version 2.00
  28. * Version 1.10
  29. * Namespace prefix ARM_ added
  30. * Version 1.01
  31. * Added PID Types
  32. * Version 1.00
  33. * Initial release
  34. */
  35. #ifndef __DRIVER_USB_H
  36. #define __DRIVER_USB_H
  37. #include "Driver_Common.h"
  38. /* USB Role */
  39. #define ARM_USB_ROLE_NONE 0
  40. #define ARM_USB_ROLE_HOST 1
  41. #define ARM_USB_ROLE_DEVICE 2
  42. /* USB Pins */
  43. #define ARM_USB_PIN_DP (1 << 0) ///< USB D+ pin
  44. #define ARM_USB_PIN_DM (1 << 1) ///< USB D- pin
  45. #define ARM_USB_PIN_VBUS (1 << 2) ///< USB VBUS pin
  46. #define ARM_USB_PIN_OC (1 << 3) ///< USB OverCurrent pin
  47. #define ARM_USB_PIN_ID (1 << 4) ///< USB ID pin
  48. /* USB Speed */
  49. #define ARM_USB_SPEED_LOW 0 ///< Low-speed USB
  50. #define ARM_USB_SPEED_FULL 1 ///< Full-speed USB
  51. #define ARM_USB_SPEED_HIGH 2 ///< High-speed USB
  52. /* USB PID Types */
  53. #define ARM_USB_PID_OUT 1
  54. #define ARM_USB_PID_IN 9
  55. #define ARM_USB_PID_SOF 5
  56. #define ARM_USB_PID_SETUP 13
  57. #define ARM_USB_PID_DATA0 3
  58. #define ARM_USB_PID_DATA1 11
  59. #define ARM_USB_PID_DATA2 7
  60. #define ARM_USB_PID_MDATA 15
  61. #define ARM_USB_PID_ACK 2
  62. #define ARM_USB_PID_NAK 10
  63. #define ARM_USB_PID_STALL 14
  64. #define ARM_USB_PID_NYET 6
  65. #define ARM_USB_PID_PRE 12
  66. #define ARM_USB_PID_ERR 12
  67. #define ARM_USB_PID_SPLIT 8
  68. #define ARM_USB_PID_PING 4
  69. #define ARM_USB_PID_RESERVED 0
  70. /* USB Endpoint Address (bEndpointAddress) */
  71. #define ARM_USB_ENDPOINT_NUMBER_MASK 0x0F
  72. #define ARM_USB_ENDPOINT_DIRECTION_MASK 0x80
  73. /* USB Endpoint Type */
  74. #define ARM_USB_ENDPOINT_CONTROL 0 ///< Control Endpoint
  75. #define ARM_USB_ENDPOINT_ISOCHRONOUS 1 ///< Isochronous Endpoint
  76. #define ARM_USB_ENDPOINT_BULK 2 ///< Bulk Endpoint
  77. #define ARM_USB_ENDPOINT_INTERRUPT 3 ///< Interrupt Endpoint
  78. /* USB Endpoint Maximum Packet Size (wMaxPacketSize) */
  79. #define ARM_USB_ENDPOINT_MAX_PACKET_SIZE_MASK 0x07FF
  80. #define ARM_USB_ENDPOINT_MICROFRAME_TRANSACTIONS_MASK 0x1800
  81. #define ARM_USB_ENDPOINT_MICROFRAME_TRANSACTIONS_1 0x0000
  82. #define ARM_USB_ENDPOINT_MICROFRAME_TRANSACTIONS_2 0x0800
  83. #define ARM_USB_ENDPOINT_MICROFRAME_TRANSACTIONS_3 0x1000
  84. #endif /* __DRIVER_USB_H */