You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

148 lines
6.5 KiB

  1. # group `udc_group` {#group__udc__group}
  2. The UDC provides a high-level abstraction of the usb device. You can use these functions to control the main device state (start/attach/wakeup).
  3. USB Device Custom configurationThe following USB Device configuration must be included in the [conf_usb.h](.build/docs/internals_undefined.md#conf__usb_8h) file of the application.
  4. USB_DEVICE_VENDOR_ID (Word)
  5. Vendor ID provided by USB org (ATMEL 0x03EB).
  6. USB_DEVICE_PRODUCT_ID (Word)
  7. Product ID (Referenced in [usb_atmel.h](.build/docs/internals_undefined.md#usb__atmel_8h)).
  8. USB_DEVICE_MAJOR_VERSION (Byte)
  9. Major version of the device
  10. USB_DEVICE_MINOR_VERSION (Byte)
  11. Minor version of the device
  12. USB_DEVICE_MANUFACTURE_NAME (string)
  13. ASCII name for the manufacture
  14. USB_DEVICE_PRODUCT_NAME (string)
  15. ASCII name for the product
  16. USB_DEVICE_SERIAL_NAME (string)
  17. ASCII name to enable and set a serial number
  18. USB_DEVICE_POWER (Numeric)
  19. (unit mA) Maximum device power
  20. USB_DEVICE_ATTR (Byte)
  21. USB attributes available:
  22. * USB_CONFIG_ATTR_SELF_POWERED
  23. * USB_CONFIG_ATTR_REMOTE_WAKEUP Note: if remote wake enabled then defines remotewakeup callbacks, see Table 5-2. External API from UDC - Callback
  24. USB_DEVICE_LOW_SPEED (Only defined)
  25. Force the USB Device to run in low speed
  26. USB_DEVICE_HS_SUPPORT (Only defined)
  27. Authorize the USB Device to run in high speed
  28. USB_DEVICE_MAX_EP (Byte)
  29. Define the maximum endpoint number used by the USB Device.
  30. This one is already defined in UDI default configuration. Ex:
  31. * When endpoint control 0x00, endpoint 0x01 and endpoint 0x82 is used then USB_DEVICE_MAX_EP=2
  32. * When only endpoint control 0x00 is used then USB_DEVICE_MAX_EP=0
  33. * When endpoint 0x01 and endpoint 0x81 is used then USB_DEVICE_MAX_EP=1
  34. (configuration not possible on USBB interface)
  35. ## Summary
  36. Members | Descriptions
  37. --------------------------------|---------------------------------------------
  38. `public inline static bool `[`udc_include_vbus_monitoring`](#group__udc__group_1ga70d88509bac27ef9c25f693dd21d91ca)`(void)` | Authorizes the VBUS event.
  39. `public void `[`udc_start`](#group__udc__group_1gadf4e193509cd03ab6333d62629ea51e7)`(void)` | Start the USB Device stack.
  40. `public void `[`udc_stop`](#group__udc__group_1gae2264dd91b24db9d4bb23fb1a2014972)`(void)` | Stop the USB Device stack.
  41. `public inline static void `[`udc_attach`](#group__udc__group_1ga2e71c4c6090543bc3bab06e710e2ee6b)`(void)` | Attach device to the bus when possible.
  42. `public inline static void `[`udc_detach`](#group__udc__group_1ga702d387f5ebfc2e0ab41667eb7644dda)`(void)` | Detaches the device from the bus.
  43. `public inline void `[`udc_remotewakeup`](#group__udc__group_1ga52c0439e5f6e471a9570471f00476260)`(void)` | The USB driver sends a resume signal called *"Upstream Resume"* This is authorized only when the remote wakeup feature is enabled by host.
  44. `public `[`usb_iface_desc_t](.build/docs/internals_usb_protocol_group.md#structusb__iface__desc__t)[UDC_DESC_STORAGE`](.build/docs/internals_undefined.md#group__udc__desc__group_1gae086959cec07a2e71ab069e25a51764f)` * `[`udc_get_interface_desc`](#group__udc__group_1gadb2a0f5ad1e834d4d7e7777f901d64d2)`(void)` | Returns a pointer on the current interface descriptor.
  45. ## Members
  46. #### `public inline static bool `[`udc_include_vbus_monitoring`](#group__udc__group_1ga70d88509bac27ef9c25f693dd21d91ca)`(void)` {#group__udc__group_1ga70d88509bac27ef9c25f693dd21d91ca}
  47. Authorizes the VBUS event.
  48. #### Returns
  49. true, if the VBUS monitoring is possible.
  50. VBus monitoring used casesThe VBus monitoring is used only for USB SELF Power application.
  51. * By default the USB device is automatically attached when Vbus is high or when USB is start for devices without internal Vbus monitoring. [conf_usb.h](.build/docs/internals_undefined.md#conf__usb_8h) file does not contains define USB_DEVICE_ATTACH_AUTO_DISABLE.
  52. ```cpp
  53. //#define USB_DEVICE_ATTACH_AUTO_DISABLE
  54. ```
  55. * Add custom VBUS monitoring. [conf_usb.h](.build/docs/internals_undefined.md#conf__usb_8h) file contains define USB_DEVICE_ATTACH_AUTO_DISABLE:
  56. ```cpp
  57. #define USB_DEVICE_ATTACH_AUTO_DISABLE
  58. ```
  59. User C file contains:
  60. ```cpp
  61. // Authorize VBUS monitoring
  62. if (!udc_include_vbus_monitoring()) {
  63. // Implement custom VBUS monitoring via GPIO or other
  64. }
  65. Event_VBUS_present() // VBUS interrupt or GPIO interrupt or other
  66. {
  67. // Attach USB Device
  68. udc_attach();
  69. }
  70. ```
  71. * Case of battery charging. [conf_usb.h](.build/docs/internals_undefined.md#conf__usb_8h) file contains define USB_DEVICE_ATTACH_AUTO_DISABLE:
  72. ```cpp
  73. #define USB_DEVICE_ATTACH_AUTO_DISABLE
  74. ```
  75. User C file contains:
  76. ```cpp
  77. Event VBUS present() // VBUS interrupt or GPIO interrupt or ..
  78. {
  79. // Authorize battery charging, but wait key press to start USB.
  80. }
  81. Event Key press()
  82. {
  83. // Stop batteries charging
  84. // Start USB
  85. udc_attach();
  86. }
  87. ```
  88. #### `public void `[`udc_start`](#group__udc__group_1gadf4e193509cd03ab6333d62629ea51e7)`(void)` {#group__udc__group_1gadf4e193509cd03ab6333d62629ea51e7}
  89. Start the USB Device stack.
  90. #### `public void `[`udc_stop`](#group__udc__group_1gae2264dd91b24db9d4bb23fb1a2014972)`(void)` {#group__udc__group_1gae2264dd91b24db9d4bb23fb1a2014972}
  91. Stop the USB Device stack.
  92. #### `public inline static void `[`udc_attach`](#group__udc__group_1ga2e71c4c6090543bc3bab06e710e2ee6b)`(void)` {#group__udc__group_1ga2e71c4c6090543bc3bab06e710e2ee6b}
  93. Attach device to the bus when possible.
  94. If a VBus control is included in driver, then it will attach device when an acceptable Vbus level from the host is detected.
  95. #### `public inline static void `[`udc_detach`](#group__udc__group_1ga702d387f5ebfc2e0ab41667eb7644dda)`(void)` {#group__udc__group_1ga702d387f5ebfc2e0ab41667eb7644dda}
  96. Detaches the device from the bus.
  97. The driver must remove pull-up on USB line D- or D+.
  98. #### `public inline void `[`udc_remotewakeup`](#group__udc__group_1ga52c0439e5f6e471a9570471f00476260)`(void)` {#group__udc__group_1ga52c0439e5f6e471a9570471f00476260}
  99. The USB driver sends a resume signal called *"Upstream Resume"* This is authorized only when the remote wakeup feature is enabled by host.
  100. #### `public `[`usb_iface_desc_t](.build/docs/internals_usb_protocol_group.md#structusb__iface__desc__t)[UDC_DESC_STORAGE`](.build/docs/internals_undefined.md#group__udc__desc__group_1gae086959cec07a2e71ab069e25a51764f)` * `[`udc_get_interface_desc`](#group__udc__group_1gadb2a0f5ad1e834d4d7e7777f901d64d2)`(void)` {#group__udc__group_1gadb2a0f5ad1e834d4d7e7777f901d64d2}
  101. Returns a pointer on the current interface descriptor.
  102. #### Returns
  103. pointer on the current interface descriptor.