This topic describes how to design the USB client controller for different types of USB hardware.
On most hardware platforms, the Variant is split into a common, or ASSP, layer and a device specific, or Variant, layer; for example, the Symbian port for the template board is split into a core layer for the ASSP (in ...\template_assp\...) and code specific to the template board (in ...\template_variant\...).
On some hardware configurations, the USB platform-specific layer functionality is not only dependent on the USB device controller (in the ASSP) but also on the Variant. As an example, the USB cable connection/disconnection notification mechanism is not defined in the USB specification. This means that some USB device controllers have a mechanism for detecting the status of a cable connection that is internal to the ASSP, while for other controllers the mechanism is Variant specific, and requires software support in the Variant layer.
In the template example port, the ASSP layer is implemented by the TemplateAssp class defined in ...\template_assp\template_assp_priv.h. This class defines a number of pure virtual functions that act as the interface to the cable connection status mechanism.
class TemplateAssp : public Asic { ... /** * USB client controller - Some example functions for the case that USB cable detection and * UDC connect/disconnect functionality are part of the Variant. * Pure virtual functions called by the USB PSL, to be implemented by the Variant (derived class). * If this functionality is part of the ASSP then these functions can be removed and calls to them * in the PSL (./pa_usbc.cpp) replaced by the appropriate internal operations. */ virtual TBool UsbClientConnectorDetectable()=0; virtual TBool UsbClientConnectorInserted()=0; virtual TInt RegisterUsbClientConnectorCallback(TInt (*aCallback)(TAny*), TAny* aPtr)=0; virtual void UnregisterUsbClientConnectorCallback()=0; virtual TBool UsbSoftwareConnectable()=0; virtual TInt UsbConnect()=0; virtual TInt UsbDisconnect()=0;
In the template example port, the Variant layer is implemented by the Template class defined in ...\template_variant\inc\variant.h. The Variant layer provides the implementation for these USB pure virtual functions.
NONSHARABLE_CLASS(Template) : public TemplateAssp { ... /** * USB client controller - Some example functions for the case that USB cable detection and * UDC connect/disconnect functionality are part of the Variant. * These virtual functions are called by the USB PSL (pa_usbc.cpp). * If this functionality is part of the ASSP then these functions can be removed as calls to them * in the PSL will have been replaced by the appropriate internal operations. */ virtual TBool UsbClientConnectorDetectable(); virtual TBool UsbClientConnectorInserted(); virtual TInt RegisterUsbClientConnectorCallback(TInt (*aCallback)(TAny*), TAny* aPtr); virtual void UnregisterUsbClientConnectorCallback(); virtual TBool UsbSoftwareConnectable(); virtual TInt UsbConnect(); virtual TInt UsbDisconnect();
The implementation for these functions can be found in ...\template_variant\specific\variant.cpp.
The USB port also needs interrupt handling code to deal with USB external interrupts. See the Interrupt Dispatcher Tutorial for details about how to do this. Note: This may be done by others as a specialist porting activity.