Tizen Native API  6.5
USB Interface

USB interface-related API.

Overview

Data structures and operations described here are related to USB interface. Each interface has number of endpoints used for performing transfer operations.

Related Features

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_claim_interface (usb_host_interface_h interface, bool force)
 Claims interface.
int usb_host_release_interface (usb_host_interface_h interface)
 Releases interface.
int usb_host_interface_get_number (usb_host_interface_h interface, int *number)
 Gets number of given interface.
int usb_host_interface_get_num_endpoints (usb_host_interface_h interface, int *num_endpoints)
 Gets number of endpoints in given interface.
int usb_host_interface_get_endpoint (usb_host_interface_h interface, int ep_index, usb_host_endpoint_h *ep)
 Gets an endpoint from interface.
int usb_host_interface_set_altsetting (usb_host_interface_h interface, int altsetting)
 Sets alternative setting for interface.
int usb_host_interface_get_altsetting (usb_host_interface_h interface, int *altsetting)
 Gets current alternative setting from an interface.
int usb_host_interface_get_str (usb_host_interface_h interface, int *length, unsigned char *data)
 Gets string describing an interface.

Typedefs

typedef struct
usb_host_interface_s * 
usb_host_interface_h
 USB interface handle.

Typedef Documentation

typedef struct usb_host_interface_s* usb_host_interface_h

USB interface handle.

This type represents USB interface. An interface is a part of configuration and can have multiple endpoints. This handle can be obtained by usb_host_config_get_interface().

Since :
3.0

Function Documentation

int usb_host_claim_interface ( usb_host_interface_h  interface,
bool  force 
)

Claims interface.

Claims interface on a device. To perform I/O operations on interface user has to claim it. Remember to call usb_host_release_interface() when communication with the device is finished.

Since :
3.0
Parameters:
[in]interfaceThe bInterfaceNumber of interface to claim
[in]forceSet to true to auto detach kernel driver, set to false to not detach it
Returns:
0 on success, otherwise a negative error value
Return values:
USB_HOST_ERROR_NONESuccessful
USB_HOST_ERROR_NOT_FOUNDRequested interface does not exist
USB_HOST_ERROR_RESOURCE_BUSYAnother program or driver has claimed the interface
USB_HOST_ERROR_NO_SUCH_DEVICEDevice has been disconnected
USB_HOST_ERROR_INVALID_PARAMETERInvalid parameter was passed
USB_HOST_ERROR_DEVICE_NOT_OPENEDThe device was not opened
int usb_host_interface_get_altsetting ( usb_host_interface_h  interface,
int *  altsetting 
)

Gets current alternative setting from an interface.

Since :
4.0
Parameters:
[in]interfaceInterface handle
[out]altsettingIndex of alternative setting set for the given interface
Returns:
0 on success, otherwise a negative error value
Return values:
USB_HOST_ERROR_NONESuccessful
USB_HOST_ERROR_NOT_SUPPORTEDNot supported
USB_HOST_ERROR_INVALID_PARAMETERInvalid parameter was passed
int usb_host_interface_get_endpoint ( usb_host_interface_h  interface,
int  ep_index,
usb_host_endpoint_h ep 
)

Gets an endpoint from interface.

Get a USB endpoint from interface by its index.

Since :
3.0
Parameters:
[in]interfaceInterface handle
[in]ep_indexindex of endpoint to retrieve (counting from 0)
[out]epEndpoint handle
Remarks:
ep handle is no longer valid when config will be destroyed. There is no need to destroy it, it is done automatically when the configuration is destroyed.
Returns:
0 on success, otherwise a negative error value
Return values:
USB_HOST_ERROR_NONESuccessful
USB_HOST_ERROR_INVALID_PARAMETERInvalid parameter was passed
int usb_host_interface_get_num_endpoints ( usb_host_interface_h  interface,
int *  num_endpoints 
)

Gets number of endpoints in given interface.

Since :
3.0
Parameters:
[in]interfaceAn interface
[out]num_endpointsNumber of endpoints in interface
Returns:
0 on success, otherwise a negative error value
Return values:
USB_HOST_ERROR_NONESuccessful
USB_HOST_ERROR_NOT_SUPPORTEDNot supported
USB_HOST_ERROR_INVALID_PARAMETERInvalid parameter was passed
int usb_host_interface_get_number ( usb_host_interface_h  interface,
int *  number 
)

Gets number of given interface.

Since :
3.0
Parameters:
[in]interfaceAn interface
[out]numberNumber of given interface
Returns:
0 on success, otherwise a negative error value
Return values:
USB_HOST_ERROR_NONESuccessful
USB_HOST_ERROR_NOT_SUPPORTEDNot supported
USB_HOST_ERROR_INVALID_PARAMETERInvalid parameter was passed
int usb_host_interface_get_str ( usb_host_interface_h  interface,
int *  length,
unsigned char *  data 
)

Gets string describing an interface.

Since :
3.0
Parameters:
[in]interfaceAn interface
[in,out]lengthData buffer size/how much was actually used
[out]dataBuffer to store string
Returns:
0 on success, otherwise a negative error value
Return values:
USB_HOST_ERROR_NONESuccessful
USB_HOST_ERROR_NOT_SUPPORTEDNot supported
USB_HOST_ERROR_OVERFLOWThere was no space in buffer
USB_HOST_ERROR_INVALID_PARAMETERInvalid parameter was passed
Precondition:
device which interface is part of must be opened by usb_host_device_open() or usb_host_device_open_with_vid_pid()
int usb_host_interface_set_altsetting ( usb_host_interface_h  interface,
int  altsetting 
)

Sets alternative setting for interface.

Since :
3.0
Parameters:
[in]interfaceInterface handle
[in]altsettingIndex of new alternative setting for given interface
Returns:
0 on success, otherwise a negative error value
Return values:
USB_HOST_ERROR_NONESuccessful
USB_HOST_ERROR_INVALID_PARAMETERInvalid parameter was passed

Releases interface.

Releases interface previously claimed by usb_host_claim_interface(). This is a blocking function.

Since :
3.0
Parameters:
[in]interfaceThe bInterfaceNumber of interface to release
Returns:
0 on success, otherwise a negative error value
Return values:
USB_HOST_ERROR_NONESuccessful
USB_HOST_ERROR_NOT_FOUNDInterface was not claimed
USB_HOST_ERROR_NO_SUCH_DEVICEDevice has been disconnected
USB_HOST_ERROR_INVALID_PARAMETERInvalid parameter was passed
USB_HOST_ERROR_DEVICE_NOT_OPENEDThe device was not opened
USB_HOST_ERROR_NOT_SUPPORTEDNot supported