Loading a USB personality

This document tells you how to use the USB Manager library to start USB services with a particular personality specified.

Purpose

A USB personality is a data structure whose purpose is to provide the configuration of USB peripheral services on a Symbian platform phone. In particular, it determines the class or classes of peripheral device that the Symbian platform phone can present itself as to a USB host.

For information about how to create a USB personality, see Using USB personalities.

For information about how to start USB services, see Starting USB services.

Intended Audience

This document is for Symbian licensees who are implementing USB peripheral services on a Symbian platform phone.

Required Background

To follow this tutorial, you will find it helpful to have a general understanding of the USB 2.0 specification and a particular understanding of Chapter 9 of that specification (which concerns the USB protocol stack).

The USB 2.0 specification is available from the following location on the website of the USB Implementers Forum:

http://www.usb.org/developers/docs/

Information about USB classes is available from the following location on the same website:

http://www.usb.org/developers/devclass_docs#approved

Setup and Configuration Requirements

The device you are designing needs to have Symbian's USB peripheral stack included in the ROM. It also needs to have a personality configured for it in which all the USB device classes it supports are specified. Note that the USB personality specifies the classes of device that the Symbian platform phone can present itself as to USB hosts. It does not provide any host configuration information for when the phone is itself a USB host (in a phone that supports USB host/OTG role-swapping).

Using the USB Manager to load a personality

The following tasks will be covered in this tutorial:

  • Starting USB services with a personality specified

Note: There is no method of loading a new personality while USB services is running.

Starting USB services with a personality specified

To start USB services with a personality specified, call the function RUsb::TryStart(), passing a personality ID as a parameter:

...

TRequestStatus status;
TInt personalityId;
personalityId = 2;
RUsb::TryStart(personalityId, status)
User::WaitForRequest(status);
         if ( status != KErrNone )
            {
            // Handle an error
            }
...

In the example above, USB services are started (as long as they are not already running) with the peripheral stack configuration provided by a personality whose id is 2.

Note: You cannot start USB services with a personality specified if you use the RUsb::Start() function instead of the RUsb::TryStart() function.

For information about stopping USB services, see Stopping USB services.