Tizen Native API  5.0
USB Host

This module provides an API for raw access to USB devices.

Required Header

#include <usb_host.h>

Overview

USB host API provides direct access to USB devices. Before using it, become familiar with USB protocol specification. Note, that this API is created for *host* mode USB, i.e. communication with connected devices.

Before using any of usb_host API functions you must initialize API context. Also you must cleanup context after using USB host API.

Related Features

This API is related with the following features:

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_create (usb_host_context_h *ctx)
 Initializes usb_host context.
int usb_host_destroy (usb_host_context_h ctx)
 Deinitializes usb_host context.

Typedefs

typedef struct usb_host_context_s * usb_host_context_h
 Context handle to USB host.

Typedef Documentation

typedef struct usb_host_context_s* usb_host_context_h

Context handle to USB host.

This structure represents usb_host session. Using own session allows to use this API independently. For example calling usb_host_destroy() will not destroy resources that are being used by another user of the library.

To create session there is need to call usb_host_create(), to destroy call usb_host_destroy(). Each session created by usb_host_create() has to be destroyed using usb_host_destroy()

Since :
3.0

Enumeration Type Documentation

Enumeration of error codes reported by USB host API.

Since :
3.0
Enumerator:
USB_HOST_ERROR_NONE 

Successful

USB_HOST_ERROR_IO_ERROR 

I/O error

USB_HOST_ERROR_INVALID_PARAMETER 

Invalid parameter

USB_HOST_ERROR_PERMISSION_DENIED 

Permission denied

USB_HOST_ERROR_NO_SUCH_DEVICE 

No device

USB_HOST_ERROR_NOT_FOUND 

Entity not found

USB_HOST_ERROR_RESOURCE_BUSY 

Resource busy

USB_HOST_ERROR_TIMED_OUT 

Operation timed out

USB_HOST_ERROR_OVERFLOW 

Overflow

USB_HOST_ERROR_DEVICE_NOT_OPENED 

Device is not opened

USB_HOST_ERROR_BROKEN_PIPE 

Pipe error

USB_HOST_ERROR_INTERRUPTED_SYS_CALL 

System call interrupted

USB_HOST_ERROR_OUT_OF_MEMORY 

Insufficient memory

USB_HOST_ERROR_NOT_SUPPORTED 

Operation not supported

USB_HOST_ERROR_UNKNOWN 

Other error


Function Documentation

Initializes usb_host context.

This function must be called before any other function from this module.

Since :
3.0
Remarks:
ctx should be destroyed by calling usb_host_destroy() when no longer needed.
Parameters:
[out]ctxContext pointer
Returns:
0 on success, otherwise a negative error value
Return values:
USB_HOST_ERROR_OUT_OF_MEMORYOut of memory
USB_HOST_ERROR_INVALID_PARAMETERInvalid parameter was passed
USB_HOST_ERROR_NONESuccessful
Postcondition:
usb_host_destroy() should be called to free resources allocated for ctx by this function.

Deinitializes usb_host context.

This function must be called after closing all devices and before application close. It has to be called to clean the memory used by library.

Since :
3.0
Parameters:
[in]ctxContext to deinitialize
Returns:
0 on success, otherwise a negative error value
Return values:
USB_HOST_ERROR_NONESuccess
USB_HOST_ERROR_INVALID_PARAMETERInvalid parameter was passed
Precondition:
Context must be initialized by usb_host_create().