Tizen Native API  9.0
USB Interface

This API is used to handle tasks related to USB interfaces.

This API is used to handle tasks related to USB interfaces

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 a USB interface on a device for further I/O.
int usb_host_release_interface (usb_host_interface_h interface)
 Releases a previously claimed interface on a device.
int usb_host_interface_get_number (usb_host_interface_h interface, int *number)
 Gets the "number" of the given USB interface handle.
int usb_host_interface_get_num_endpoints (usb_host_interface_h interface, int *num_endpoints)
 Gets the number of endpoints in given USB interface.
int usb_host_interface_get_endpoint (usb_host_interface_h interface, int ep_index, usb_host_endpoint_h *ep)
 Gets an endpoint via index from given USB interface.
int usb_host_interface_set_altsetting (usb_host_interface_h interface, int altsetting)
 Sets an alternative setting for given USB 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 a string describing the given USB interface into a buffer.

Typedefs

typedef struct
usb_host_interface_s * 
usb_host_interface_h
 An opaque handle representing a USB configuration interface.

Typedef Documentation

typedef struct usb_host_interface_s* usb_host_interface_h

An opaque handle representing a USB configuration interface.

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 a USB interface on a device for further I/O.

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.

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 via index from given USB interface.

Gets an endpoint via index from given USB interface.

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 the number of endpoints in given USB interface.

Gets the number of endpoints in given USB 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 the "number" of the given USB interface handle.

Gets the "number" of the given USB interface handle.

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 a string describing the given USB interface into a buffer.

Gets a string describing the given USB interface into a buffer.

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 an alternative setting for given USB interface.

Sets an alternative setting for given USB 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 a previously claimed interface on a device.

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