USB Host Interface (UHI) for Vendor Class Device provides an interface for the configuration and management of USB Vendor host.
The outline of this documentation is as follows:
For more details for Atmel® Software Framework (ASF) USB Host Stack, refer to following application note:
Interface with USB Host Core (UHC) | |
#define | UHI_VENDOR |
Global definition which contains standard UHI API for UHC It must be added in USB_HOST_UHI definition from conf_usb_host.h file. More... | |
Functions Required by UHC | |
uhc_enum_status_t | uhi_vendor_install (uhc_device_t *dev) |
Install interface. More... | |
void | uhi_vendor_enable (uhc_device_t *dev) |
Enable the interface. More... | |
void | uhi_vendor_uninstall (uhc_device_t *dev) |
Uninstall the interface (if installed). More... | |
UHI for Vendor Class | |
Common APIs used by high level application to use this USB host class. This Vendor Class implementation supports one endpoint for all endpoint types on all directions: Control IN, control OUT, interrupt IN, interrupt OUT, bulk IN, bulk OUT, isochronous IN, isochronous OUT. This implementation is an example and can be a base to create another Vendor Class which supports more endpoint as two bulk IN endpoints. | |
bool | uhi_vendor_control_in_run (uint8_t *buf, iram_size_t buf_size, uhd_callback_setup_end_t callback) |
Start a transfer on control IN. More... | |
bool | uhi_vendor_control_out_run (uint8_t *buf, iram_size_t buf_size, uhd_callback_setup_end_t callback) |
Start a transfer on control OUT. More... | |
bool | uhi_vendor_bulk_in_run (uint8_t *buf, iram_size_t buf_size, uhd_callback_trans_t callback) |
Start a transfer on bulk IN. More... | |
bool | uhi_vendor_bulk_out_run (uint8_t *buf, iram_size_t buf_size, uhd_callback_trans_t callback) |
Start a transfer on bulk OUT. More... | |
bool | uhi_vendor_int_in_run (uint8_t *buf, iram_size_t buf_size, uhd_callback_trans_t callback) |
Start a transfer on interrupt IN. More... | |
bool | uhi_vendor_int_out_run (uint8_t *buf, iram_size_t buf_size, uhd_callback_trans_t callback) |
Start a transfer on interrupt OUT. More... | |
bool | uhi_vendor_iso_in_run (uint8_t *buf, iram_size_t buf_size, uhd_callback_trans_t callback) |
Start a transfer on ISO IN. More... | |
bool | uhi_vendor_iso_out_run (uint8_t *buf, iram_size_t buf_size, uhd_callback_trans_t callback) |
Start a transfer on ISO OUT. More... | |
bool | uhi_vendor_bulk_is_available (void) |
Check if a transfer on BULK is possible. More... | |
bool | uhi_vendor_int_is_available (void) |
Check if a transfer on INTERRUPT is possible. More... | |
bool | uhi_vendor_iso_is_available (void) |
Check if a transfer on ISO is possible. More... | |
#define UHI_VENDOR |
Global definition which contains standard UHI API for UHC It must be added in USB_HOST_UHI definition from conf_usb_host.h file.
bool uhi_vendor_bulk_in_run | ( | uint8_t * | buf, |
iram_size_t | buf_size, | ||
uhd_callback_trans_t | callback | ||
) |
Start a transfer on bulk IN.
When the transfer is finished or aborted (stall, reset, ...), the callback is called. The callback returns the transfer status and eventually the number of byte transferred.
[out] | buf | Buffer on Internal RAM to send or fill. It must be align, then use COMPILER_WORD_ALIGNED. |
[in] | buf_size | Buffer size to send or fill |
[in] | callback | NULL or function to call at the end of transfer |
1
if function was successfully done, otherwise 0
.When the transfer is finished or aborted (stall, reset, ...), the callback is called. The callback returns the transfer status and eventually the number of byte transfered.
buf | Buffer on Internal RAM to send or fill. It must be align, then use COMPILER_WORD_ALIGNED. |
buf_size | Buffer size to send or fill |
callback | NULL or function to call at the end of transfer |
1
if function was successfully done, otherwise 0
. References uhc_device_t::address, uhi_vendor_dev_t::dev, uhi_vendor_dev_t::ep_bulk_in, uhd_ep_run(), uhi_vendor_bulk_is_available(), and UHI_VENDOR_TIMEOUT.
Referenced by main_loop_back_bulk().
bool uhi_vendor_bulk_is_available | ( | void | ) |
Check if a transfer on BULK is possible.
1
if possible, otherwise 0
. References uhi_vendor_dev_t::dev, uhi_vendor_dev_t::ep_bulk_in, uhi_vendor_dev_t::ep_bulk_out, and NULL.
Referenced by uhi_vendor_bulk_in_run(), and uhi_vendor_bulk_out_run().
bool uhi_vendor_bulk_out_run | ( | uint8_t * | buf, |
iram_size_t | buf_size, | ||
uhd_callback_trans_t | callback | ||
) |
Start a transfer on bulk OUT.
When the transfer is finished or aborted (stall, reset, ...), the callback is called. The callback returns the transfer status and eventually the number of byte transferred.
[in] | buf | Buffer on Internal RAM to send or fill. It must be align, then use COMPILER_WORD_ALIGNED. |
[in] | buf_size | Buffer size to send or fill |
[in] | callback | NULL or function to call at the end of transfer |
1
if function was successfully done, otherwise 0
.When the transfer is finished or aborted (stall, reset, ...), the callback is called. The callback returns the transfer status and eventually the number of byte transfered.
buf | Buffer on Internal RAM to send or fill. It must be align, then use COMPILER_WORD_ALIGNED. |
buf_size | Buffer size to send or fill |
callback | NULL or function to call at the end of transfer |
1
if function was successfully done, otherwise 0
. References uhc_device_t::address, uhi_vendor_dev_t::dev, uhi_vendor_dev_t::ep_bulk_out, uhd_ep_run(), uhi_vendor_bulk_is_available(), and UHI_VENDOR_TIMEOUT.
Referenced by main_loop_back_bulk().
bool uhi_vendor_control_in_run | ( | uint8_t * | buf, |
iram_size_t | buf_size, | ||
uhd_callback_setup_end_t | callback | ||
) |
Start a transfer on control IN.
When the transfer is finished or aborted (stall, reset, ...), the callback is called. The callback returns the transfer status and eventually the number of bytes transferred.
[out] | buf | Buffer on Internal RAM to send or fill. It must be align, then use COMPILER_WORD_ALIGNED. |
[in] | buf_size | Buffer size to send or fill |
[in] | callback | NULL or function to call at the end of transfer |
1
if function was successfully done, otherwise 0
.When the transfer is finished or aborted (stall, reset, ...), the callback is called. The callback returns the transfer status and eventually the number of byte transfered.
buf | Buffer on Internal RAM to send or fill. It must be align, then use COMPILER_WORD_ALIGNED. |
buf_size | Buffer size to send or fill |
callback | NULL or function to call at the end of transfer |
1
if function was successfully done, otherwise 0
. References uhc_device_t::address, usb_setup_req_t::bmRequestType, usb_setup_req_t::bRequest, uhi_vendor_dev_t::dev, NULL, uhd_setup_request(), USB_REQ_DIR_IN, USB_REQ_RECIP_INTERFACE, USB_REQ_TYPE_VENDOR, usb_setup_req_t::wIndex, usb_setup_req_t::wLength, and usb_setup_req_t::wValue.
Referenced by main_loop_back_control().
bool uhi_vendor_control_out_run | ( | uint8_t * | buf, |
iram_size_t | buf_size, | ||
uhd_callback_setup_end_t | callback | ||
) |
Start a transfer on control OUT.
When the transfer is finished or aborted (stall, reset, ...), the callback is called. The callback returns the transfer status and eventually the number of byte transferred.
[in] | buf | Buffer on Internal RAM to send or fill. It must be align, then use COMPILER_WORD_ALIGNED. |
[in] | buf_size | Buffer size to send or fill |
[in] | callback | NULL or function to call at the end of transfer |
1
if function was successfully done, otherwise 0
.When the transfer is finished or aborted (stall, reset, ...), the callback is called. The callback returns the transfer status and eventually the number of byte transfered.
buf | Buffer on Internal RAM to send or fill. It must be align, then use COMPILER_WORD_ALIGNED. |
buf_size | Buffer size to send or fill |
callback | NULL or function to call at the end of transfer |
1
if function was successfully done, otherwise 0
. References uhc_device_t::address, usb_setup_req_t::bmRequestType, usb_setup_req_t::bRequest, uhi_vendor_dev_t::dev, NULL, uhd_setup_request(), USB_REQ_RECIP_INTERFACE, USB_REQ_TYPE_VENDOR, usb_setup_req_t::wIndex, usb_setup_req_t::wLength, and usb_setup_req_t::wValue.
Referenced by main_loop_back_control().
void uhi_vendor_enable | ( | uhc_device_t * | dev | ) |
Enable the interface.
Enable a USB interface corresponding to UHI.
[in] | uhc_device_t | Device to request |
References uhc_device_t::address, uhi_vendor_dev_t::bInterfaceNumber, usb_setup_req_t::bmRequestType, usb_setup_req_t::bRequest, uhi_vendor_dev_t::dev, NULL, uhd_setup_request(), UHI_VENDOR_CHANGE, USB_REQ_RECIP_INTERFACE, USB_REQ_SET_INTERFACE, usb_setup_req_t::wIndex, usb_setup_req_t::wLength, and usb_setup_req_t::wValue.
uhc_enum_status_t uhi_vendor_install | ( | uhc_device_t * | dev | ) |
Install interface.
Allocate interface endpoints if supported.
[in] | uhc_device_t | Device to request |
References uhc_device_t::address, Assert, usb_iface_desc_t::bAlternateSetting, usb_iface_desc_t::bDescriptorType, usb_iface_desc_t::bInterfaceClass, uhi_vendor_dev_t::bInterfaceNumber, usb_iface_desc_t::bInterfaceNumber, usb_iface_desc_t::bInterfaceProtocol, usb_iface_desc_t::bInterfaceSubClass, usb_iface_desc_t::bLength, uhc_device_t::conf_desc, uhi_vendor_dev_t::dev, dev, uhc_device_t::dev_desc, uhi_vendor_dev_t::ep_bulk_in, uhi_vendor_dev_t::ep_bulk_out, uhi_vendor_dev_t::ep_int_in, uhi_vendor_dev_t::ep_int_out, uhi_vendor_dev_t::ep_iso_in, uhi_vendor_dev_t::ep_iso_out, i, usb_dev_desc_t::idProduct, usb_dev_desc_t::idVendor, le16_to_cpu, NULL, uhc_device_t::speed, UHC_ENUM_HARDWARE_LIMIT, UHC_ENUM_SOFTWARE_LIMIT, UHC_ENUM_SUCCESS, UHC_ENUM_UNSUPPORTED, uhd_ep_alloc(), UHI_VENDOR_VID_PID_LIST, USB_DT_ENDPOINT, USB_DT_INTERFACE, USB_EP_DIR_IN, USB_EP_TYPE_BULK, USB_EP_TYPE_INTERRUPT, USB_EP_TYPE_ISOCHRONOUS, USB_EP_TYPE_MASK, VENDOR_CLASS, VENDOR_PROTOCOL, VENDOR_SUBCLASS, and usb_conf_desc_t::wTotalLength.
bool uhi_vendor_int_in_run | ( | uint8_t * | buf, |
iram_size_t | buf_size, | ||
uhd_callback_trans_t | callback | ||
) |
Start a transfer on interrupt IN.
When the transfer is finished or aborted (stall, reset, ...), the callback is called. The callback returns the transfer status and eventually the number of byte transferred.
[out] | buf | Buffer on Internal RAM to send or fill. It must be align, then use COMPILER_WORD_ALIGNED. |
[in] | buf_size | Buffer size to send or fill |
[in] | callback | NULL or function to call at the end of transfer |
1
if function was successfully done, otherwise 0
.When the transfer is finished or aborted (stall, reset, ...), the callback is called. The callback returns the transfer status and eventually the number of byte transfered.
buf | Buffer on Internal RAM to send or fill. It must be align, then use COMPILER_WORD_ALIGNED. |
buf_size | Buffer size to send or fill |
callback | NULL or function to call at the end of transfer |
1
if function was successfully done, otherwise 0
. References uhc_device_t::address, uhi_vendor_dev_t::dev, uhi_vendor_dev_t::ep_int_in, uhd_ep_run(), uhi_vendor_int_is_available(), and UHI_VENDOR_TIMEOUT.
Referenced by main_loop_back_int().
bool uhi_vendor_int_is_available | ( | void | ) |
Check if a transfer on INTERRUPT is possible.
1
if possible, otherwise 0
. References uhi_vendor_dev_t::dev, uhi_vendor_dev_t::ep_int_in, uhi_vendor_dev_t::ep_int_out, and NULL.
Referenced by uhi_vendor_int_in_run(), and uhi_vendor_int_out_run().
bool uhi_vendor_int_out_run | ( | uint8_t * | buf, |
iram_size_t | buf_size, | ||
uhd_callback_trans_t | callback | ||
) |
Start a transfer on interrupt OUT.
When the transfer is finished or aborted (stall, reset, ...), the callback is called. The callback returns the transfer status and eventually the number of byte transferred.
[in] | buf | Buffer on Internal RAM to send or fill. It must be align, then use COMPILER_WORD_ALIGNED. |
[in] | buf_size | Buffer size to send or fill |
[in] | callback | NULL or function to call at the end of transfer |
1
if function was successfully done, otherwise 0
.When the transfer is finished or aborted (stall, reset, ...), the callback is called. The callback returns the transfer status and eventually the number of byte transfered.
buf | Buffer on Internal RAM to send or fill. It must be align, then use COMPILER_WORD_ALIGNED. |
buf_size | Buffer size to send or fill |
callback | NULL or function to call at the end of transfer |
1
if function was successfully done, otherwise 0
. References uhc_device_t::address, uhi_vendor_dev_t::dev, uhi_vendor_dev_t::ep_int_out, uhd_ep_run(), uhi_vendor_int_is_available(), and UHI_VENDOR_TIMEOUT.
Referenced by main_loop_back_int().
bool uhi_vendor_iso_in_run | ( | uint8_t * | buf, |
iram_size_t | buf_size, | ||
uhd_callback_trans_t | callback | ||
) |
Start a transfer on ISO IN.
When the transfer is finished or aborted (stall, reset, ...), the callback is called. The callback returns the transfer status and eventually the number of byte transferred.
[out] | buf | Buffer on Internal RAM to send or fill. It must be align, then use COMPILER_WORD_ALIGNED. |
[in] | buf_size | Buffer size to send or fill |
[in] | callback | NULL or function to call at the end of transfer |
1
if function was successfully done, otherwise 0
.When the transfer is finished or aborted (stall, reset, ...), the callback is called. The callback returns the transfer status and eventually the number of byte transfered.
buf | Buffer on Internal RAM to send or fill. It must be align, then use COMPILER_WORD_ALIGNED. |
buf_size | Buffer size to send or fill |
callback | NULL or function to call at the end of transfer |
1
if function was successfully done, otherwise 0
. References uhc_device_t::address, uhi_vendor_dev_t::dev, uhi_vendor_dev_t::ep_iso_in, uhd_ep_run(), uhi_vendor_iso_is_available(), and UHI_VENDOR_TIMEOUT.
Referenced by main_iso_in_done(), and main_loop_back_iso().
bool uhi_vendor_iso_is_available | ( | void | ) |
Check if a transfer on ISO is possible.
1
if possible, otherwise 0
. References uhi_vendor_dev_t::dev, uhi_vendor_dev_t::ep_iso_in, uhi_vendor_dev_t::ep_iso_out, and NULL.
Referenced by uhi_vendor_iso_in_run(), and uhi_vendor_iso_out_run().
bool uhi_vendor_iso_out_run | ( | uint8_t * | buf, |
iram_size_t | buf_size, | ||
uhd_callback_trans_t | callback | ||
) |
Start a transfer on ISO OUT.
When the transfer is finished or aborted (stall, reset, ...), the callback is called. The callback returns the transfer status and eventually the number of byte transferred.
[in] | buf | Buffer on Internal RAM to send or fill. It must be align, then use COMPILER_WORD_ALIGNED. |
[in] | buf_size | Buffer size to send or fill |
[in] | callback | NULL or function to call at the end of transfer |
1
if function was successfully done, otherwise 0
.When the transfer is finished or aborted (stall, reset, ...), the callback is called. The callback returns the transfer status and eventually the number of byte transfered.
buf | Buffer on Internal RAM to send or fill. It must be align, then use COMPILER_WORD_ALIGNED. |
buf_size | Buffer size to send or fill |
callback | NULL or function to call at the end of transfer |
1
if function was successfully done, otherwise 0
. References uhc_device_t::address, uhi_vendor_dev_t::dev, uhi_vendor_dev_t::ep_iso_out, uhd_ep_run(), uhi_vendor_iso_is_available(), and UHI_VENDOR_TIMEOUT.
Referenced by main_iso_out_done(), and main_loop_back_iso().
void uhi_vendor_uninstall | ( | uhc_device_t * | dev | ) |
Uninstall the interface (if installed).
[in] | uhc_device_t | Device to request |
References uhi_vendor_dev_t::dev, NULL, and UHI_VENDOR_CHANGE.