|
Tizen Native API
10.0
|
This API is used to handle tasks related to USB endpoints.
This module can be used to operate on one of the endpoints of the device.
Overview
Data structures and operations described here are related to USB endpoint. Endpoints are used to perform USB transfers.
Overview
This API is related with the following features:
- http://tizen.org/feature/usb.host
It is recommended to design feature related codes in your application for reliability.
You can check if a device supports the related features for this API by using System Information, thereby controlling the procedure of your application.
To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.
More details on featuring your application can be found from Feature List.
Functions | |
| int | usb_host_endpoint_get_number (usb_host_endpoint_h ep, int *number) |
| Gets the "number" of the given USB endpoint handle. | |
| int | usb_host_endpoint_get_direction (usb_host_endpoint_h ep, usb_host_endpoint_direction_e *direction) |
| Gets the direction of the given USB endpoint handle. | |
| int | usb_host_endpoint_get_transfer_type (usb_host_endpoint_h ep, usb_host_transfer_type_e *transfer_type) |
| Gets transfer type of the given USB endpoint handle. | |
| int | usb_host_endpoint_get_synch_type (usb_host_endpoint_h ep, usb_host_iso_sync_type_e *synch_type) |
| Gets synchronization type of given USB endpoint handle. | |
| int | usb_host_endpoint_get_usage_type (usb_host_endpoint_h ep, usb_host_usage_type_e *usage_type) |
| Gets the usage type of the given USB endpoint handle. | |
| int | usb_host_endpoint_get_max_packet_size (usb_host_endpoint_h ep, int *max_packet_size) |
| Gets max packet size from given USB endpoint handle. | |
| int | usb_host_endpoint_get_interval (usb_host_endpoint_h ep, int *interval) |
| Gets interval for polling endpoint for data transfers. | |
| int | usb_host_transfer_get_type (usb_host_transfer_h transfer, usb_host_transfer_type_e *transfer_type) |
| Gets type of a transfer from a given transfer handle. | |
Typedefs | |
| typedef struct usb_host_endpoint_s * | usb_host_endpoint_h |
| An opaque handle representing a USB interface endpoint. | |
Typedef Documentation
| typedef struct usb_host_endpoint_s* usb_host_endpoint_h |
An opaque handle representing a USB interface endpoint.
This type represents USB endpoint. This handle can be obtained by usb_host_interface_get_endpoint().
- Since :
- 3.0
Enumeration Type Documentation
Enumeration of isochronous endpoint's synchronization type.
Used to control how a data transfer request is going to be synchronized.
- Since :
- 3.0
An enumeration representing USB endpoint transfer type.
Used to control how a data transfer request is going to operate.
- Since :
- 3.0
Function Documentation
| int usb_host_endpoint_get_direction | ( | usb_host_endpoint_h | ep, |
| usb_host_endpoint_direction_e * | direction | ||
| ) |
Gets the direction of the given USB endpoint handle.
Returns the direction of the provided USB endpoint handle.
- Since :
- 3.0
- Parameters:
-
[in] ep An endpoint [out] direction Direction of endpoint (a value from enum usb_host_endpoint_direction_e)
- Returns:
- 0 on success, otherwise a negative error value
- Return values:
-
USB_HOST_ERROR_NONE Successful USB_HOST_ERROR_NOT_SUPPORTED Not supported USB_HOST_ERROR_INVALID_PARAMETER Invalid parameter was passed
#include <usb_host.h> #include <stdio.h> void print_endpoint_direction(usb_host_endpoint_h ep) { int ret; usb_host_endpoint_direction_e direction; ret = usb_host_endpoint_get_direction(ep, &direction); if (ret != USB_HOST_ERROR_NONE) handle_error(ret); switch (direction) { case USB_HOST_DIRECTION_IN: printf("Input endpoint\n"); break; case USB_HOST_DIRECTION_OUT: printf("Output endpoint\n"); break; } }
| int usb_host_endpoint_get_interval | ( | usb_host_endpoint_h | ep, |
| int * | interval | ||
| ) |
Gets interval for polling endpoint for data transfers.
Returns the interval for polling endpoint for data transfers.
- Since :
- 3.0
- Parameters:
-
[in] ep An endpoint [out] interval Interval for polling, in frame counts (refer to USB protocol specification)
- Returns:
- 0 on success, otherwise a negative error value
- Return values:
-
USB_HOST_ERROR_NONE Successful USB_HOST_ERROR_INVALID_PARAMETER Invalid parameter was passed
#include <usb_host.h> #include <stdio.h> void print_endpoint_interval(usb_host_endpoint_h ep) { int ret, interval; ret = usb_host_endpoint_get_interval(dev, &interval); if (ret != USB_HOST_ERROR_NONE) handle_error(ret); printf("Polling interval: %d frames\n", interval); }
| int usb_host_endpoint_get_max_packet_size | ( | usb_host_endpoint_h | ep, |
| int * | max_packet_size | ||
| ) |
Gets max packet size from given USB endpoint handle.
Gets max packet size from given USB endpoint handle.
- Since :
- 3.0
- Parameters:
-
[in] ep An endpoint [out] max_packet_size Max packet size, in bytes
- Returns:
- 0 on success, otherwise a negative error value
- Return values:
-
USB_HOST_ERROR_NONE Successful USB_HOST_ERROR_INVALID_PARAMETER Invalid parameter was passed
#include <usb_host.h> #include <stdio.h> void print_endpoint_max_packet_size(usb_host_endpoint_h ep) { int ret, max_packet_size; ret = usb_host_endpoint_get_max_packet_size(dev, &max_packet_size); if (ret != USB_HOST_ERROR_NONE) handle_error(ret); printf("Maximum packet size: %d bytes\n", max_packet_size); }
| int usb_host_endpoint_get_number | ( | usb_host_endpoint_h | ep, |
| int * | number | ||
| ) |
Gets the "number" of the given USB endpoint handle.
Gets the index of the endpoint handle, as passed to usb_host_interface_get_endpoint().
- Since :
- 3.0
- Parameters:
-
[in] ep An endpoint [out] number Number of given endpoint
- Returns:
- 0 on success, otherwise a negative error value
- Return values:
-
USB_HOST_ERROR_NONE Successful USB_HOST_ERROR_NOT_SUPPORTED Not supported USB_HOST_ERROR_INVALID_PARAMETER Invalid parameter was passed
#include <usb_host.h> #include <stdio.h> void print_endpoint_index(usb_host_endpoint_h ep) { int ret, number; ret = usb_host_endpoint_get_number(ep, &number); if (ret != USB_HOST_ERROR_NONE) handle_error(ret); printf("Endpoint index: %d\n", number); }
| int usb_host_endpoint_get_synch_type | ( | usb_host_endpoint_h | ep, |
| usb_host_iso_sync_type_e * | synch_type | ||
| ) |
Gets synchronization type of given USB endpoint handle.
Returns the synchronization type of provided USB endpoint handle.
- Since :
- 3.0
- Parameters:
-
[in] ep An endpoint [out] synch_type Synch type (a value from enum usb_host_iso_sync_type_e)
- Returns:
- 0 on success, otherwise a negative error value
- Return values:
-
USB_HOST_ERROR_NONE Successful USB_HOST_ERROR_NOT_SUPPORTED Not supported USB_HOST_ERROR_INVALID_PARAMETER Invalid parameter was passed
#include <usb_host.h> #include <stdio.h> void print_endpoint_synch_type(usb_host_endpoint_h ep) { int ret; usb_host_iso_sync_type_e synch_type; ret = usb_host_endpoint_get_synch_type(ep, &synch_type); if (ret != USB_HOST_ERROR_NONE) handle_error(ret); switch (synch_type) { case USB_HOST_ISO_SYNC_TYPE_NONE: printf("No synchronization\n"); break; case USB_HOST_ISO_SYNC_TYPE_ASYNC: printf("Asynchronous synchronization\n"); break; case USB_HOST_ISO_SYNC_TYPE_ADAPTIVE: printf("Adaptive synchronization\n"); break; case USB_HOST_ISO_SYNC_TYPE_SYNC: printf("Synchronous synchronization\n"); break; } }
| int usb_host_endpoint_get_transfer_type | ( | usb_host_endpoint_h | ep, |
| usb_host_transfer_type_e * | transfer_type | ||
| ) |
Gets transfer type of the given USB endpoint handle.
Returns the transfer type of the provided USB endpoint handle.
- Since :
- 3.0
- Parameters:
-
[in] ep An endpoint [out] transfer_type Transfer type (a value from enum usb_host_transfer_type_e)
- Returns:
- 0 on success, otherwise a negative error value
- Return values:
-
USB_HOST_ERROR_NONE Successful USB_HOST_ERROR_NOT_SUPPORTED Not supported USB_HOST_ERROR_INVALID_PARAMETER Invalid parameter was passed
#include <usb_host.h> #include <stdio.h> void print_endpoint_transfer_type(usb_host_endpoint_h ep) { int ret; usb_host_transfer_type_e transport_type; ret = usb_host_endpoint_get_transfer_type(ep, &transport_type); if (ret != USB_HOST_ERROR_NONE) handle_error(ret); switch (transfer_type) { case USB_HOST_TRANSFER_TYPE_CONTROL: printf("Control endpoint\n"); break; case USB_HOST_TRANSFER_TYPE_ISOCHRONOUS: printf("Isochronous endpoint\n"); break; case USB_HOST_TRANSFER_TYPE_BULK: printf("Bulk endpoint\n"); break; case USB_HOST_TRANSFER_TYPE_INTERRUPT: printf("Interrupt endpoint\n"); break; } }
| int usb_host_endpoint_get_usage_type | ( | usb_host_endpoint_h | ep, |
| usb_host_usage_type_e * | usage_type | ||
| ) |
Gets the usage type of the given USB endpoint handle.
Returns the usage type of the provided USB endpoint handle.
- Since :
- 3.0
- Parameters:
-
[in] ep An endpoint [out] usage_type Usage type (a value from enum usb_host_usage_type_e)
- Returns:
- 0 on success, otherwise a negative error value
- Return values:
-
USB_HOST_ERROR_NONE Successful USB_HOST_ERROR_NOT_SUPPORTED Not supported USB_HOST_ERROR_INVALID_PARAMETER Invalid parameter was passed
#include <usb_host.h> #include <stdio.h> void print_endpoint_usage_type(usb_host_endpoint_h ep) { int ret; usb_host_usage_type_e usage_type; ret = usb_host_endpoint_get_usage_type(ep, &usage_type); if (ret != USB_HOST_ERROR_NONE) handle_error(ret); switch (usage_type) { case USB_HOST_USAGE_TYPE_DATA: printf("Data endpoint\n"); break; case USB_HOST_USAGE_TYPE_FEEDBACK: printf("Feedback endpoint\n"); break; case USB_HOST_USAGE_TYPE_IMPLICIT: printf("Implicit feedback data endpoint\n"); break; } }
| int usb_host_transfer_get_type | ( | usb_host_transfer_h | transfer, |
| usb_host_transfer_type_e * | transfer_type | ||
| ) |
Gets type of a transfer from a given transfer handle.
Gets the type of the transfer provided by its handle.
- Since :
- 5.0
- Parameters:
-
[in] transfer Transfer handle [out] transfer_type Transfer type (a value from enum usb_host_transfer_type_e)
- Returns:
- 0 on success, otherwise a negative error value
- Return values:
-
USB_HOST_ERROR_NONE Successful USB_HOST_ERROR_NOT_SUPPORTED Not supported USB_HOST_ERROR_INVALID_PARAMETER Invalid parameter was passed
#include <usb_host.h> #include <stdio.h> void print_transfer_type(usb_host_transfer_h transfer) { int ret; usb_host_transfer_type_e transport_type; ret = usb_host_transfer_get_type(transfer, &transport_type); if (ret != USB_HOST_ERROR_NONE) handle_error(ret); switch (transfer_type) { case USB_HOST_TRANSFER_TYPE_CONTROL: printf("Control transfer\n"); break; case USB_HOST_TRANSFER_TYPE_ISOCHRONOUS: printf("Isochronous transfer\n"); break; case USB_HOST_TRANSFER_TYPE_BULK: printf("Bulk transfer\n"); break; case USB_HOST_TRANSFER_TYPE_INTERRUPT: printf("Interrupt transfer\n"); break; } }