Synergy Software Package User's Manual
Azure RTOS USBX Overview

Azure RTOS USBX Interface Overview

The Azure RTOS USBX USB stack (ux) is integrated into the SSP.  This document provides an overview and summary of the Azure RTOS USBX Interface for SSP. Specific USBX modules in SSP each have their own module overview section. Refer to the appropriate module overview sections in the SSP User's Manual for details on designing with specific modules.

What Does the Azure RTOS USBX Module Do?

USBX supports the two existing USB specifications: 1.1 and 2.0. It is designed to be scalable and will accommodate simple USB topologies with only one connected device, as well as complex topologies with multiple devices and cascading hubs. USBX supports both the host and device sides.

Supported USB Classes in Azure RTOS USBX

The USBX class modules listed below are fully supported in the Synergy Configuration tool. To use these USBX class modules, go to the Threads tab of the Synergy Configuration tool (configuration.xml), and select any of the USB class modules:

  • ux_device_class_cdc_acm
  • ux_device_class_hid
  • ux_device_class_storage
  • ux_host_class_cdc_acm
  • ux_host_class_hid
  • ux_host_class_printer
  • ux_host_class_storage
  • ux_host_class_video
  • ux_host_class_hub
Note
Refer to the USBX Device Class User Guide, USBX Host Class User Guide or USBX Host Stack UVC User Guide for more information about the USBX Class specification. Each of the modules listed above also has an associated module overview section in the SSP User's Manual. Additionally, Module Guides for each of these modules are available from the Renesas Synergy web site.

The USBX class modules listed below are experimental modules for Synergy parts. The experimental modules are not currently supported in Synergy Configuration. To experiment with these USBX class modules, go to the Components tab of the Synergy Configuration tool (configuration.xml) and select any of the USB class modules:

  • ux_device_class_cdc_ecm
  • ux_device_class_rndis
  • ux_host_class_audio
  • ux_host_class_gser
  • ux_host_class_prolific
  • ux_host_class_swar
  • ux_network_driver
  • ux_device_class_pima
  • ux_host_class_pima
  • ux_pictbridge
Note
Any of the USB classes shown above are experimental and not yet tested for Synergy parts; it is not recommended to use them for product developments.

When the components above are added, a prebuilt library of the application code is also added.  For each component listed above, there is an analogous component ending in '_src' that contains protected source files.  The '_src' component can be added in addition to the prebuilt library module.

Writing an Application with USBX Modules

Refer to the associated module overview section in the SSP User's Manual for details on how to write an application with USBX modules. Additionally, each of the associated Module Guides have a working application project that illustrates how to use the module in a typical application. Module Guides are available from the Renesas Synergy web site.

Writing an Application with Deprecated Modules

In the SSP version 1.2.0 or later, the USBX stack configuration is supported in the Synergy Configuration tool and the few USBX relevant components, which were defined in previous SSP versions, are now treated as [DEPRECATED] components. They are kept in the SSP version today to provide you with backward compatibility. Anyone using a new version of SSP and wanting to keep their existing application code compatible to an existing SSP version, can use [DEPRECATED] components.

In e2 studio, create and configure a project and add the drivers:

  1. Create the project: Creating a Project.
  2. Configure the project: Configuring a Project.
  3. Add the following components, if required, the same way as was done when using an existing version of SSP: Adding Drivers to a Thread and Configuring the Drivers.
Azure RTOS USBX Device Class CDC-ACM(option) Threads Framework > USB > [DEPRECATED] USBX Device Class CDC-ACM on ux_device_class_cdc_acm
Azure RTOS USBX (option) Threads Framework > USB > [DEPRECATED] USBX on ux
Note
Do not use components marked as [DEPRECATED] for new development. Only use these components for existing user applications which were developed with previous SSP releases.

USB Class Stack Configuration Overview

USBX Device Class Stack Configuration

The following figure shows the interface diagram of the USBX Device Class stack. The stack consists of one USBX device class component (ux_device_class_xxx) on the top, the USBX (ux) in the middle and the USBX Port driver (sf_el_ux Device Controller Driver (DCD)) on the bottom of the device class stack. As a recommended option, the SSP Transfer module (r_dmac) supports data transfer between memory and hardware FIFO in Synergy USB peripherals (USBHS or USBFS). To support the USB device stack configuration, there are components named USBX Device Configuration and USBX Interface Configuration. These two components do not represent actual software modules in SSP; they are virtual modules to handle the code generation.

express_logic_ux_usbx_device_stack.png
USBX Device Class Stack Configuration

Note: Currently, the r_dtc is not supported for the device side driver (only r_dmac is supported).

USBX Host Class Stack Configuration

The following figure shows the interface diagram of the USBX Host Class stack. The stack consists of one of the USBX Host Class components (ux_host_class_xxx) on the top, the USBX (ux) in the middle and the USBX Port driver component (sf_el_ux Host Controller Driver (HCD)) on the bottom of the host class stack. As a recommended option, the SSP Transfer module (r_dmac) supports data transfer between memory and hardware FIFO in Synergy USB peripherals (USBHS or USBFS). To support the USB host stack configuration, there is a virtual component (USBX Host Configuration) to handle the code generation:

express_logic_usbx_host.png
USBX Host Class Stack Configuration
Note
Currently, the r_dtc is not supported for the host side driver (only r_dmac is supported).

USB Device Descriptor Configuration

USBX Device Configuration

The USBX Device Configuration component has configurations, as shown in below table, to auto-generate the USB Device Descriptor and USB Configuration Descriptor. Refer to http://www.usb.org and download USB 2.0 Specification for more information about the specification of USB Device Descriptor and or Configuration Descriptor.

USBX Device Configuration

Configuration Settings Description
Composite Device     Enable or Disable (Default)  Enable this configuration only if composite device support is required in the application.
Vendor ID 16-bit arbitrary number (Default: 0x045B) Specify Vendor ID assigned by USB-IF. This configuration is a part of the USB Device Descriptor (idVendor).
Product ID 16-bit arbitrary number (Default: 0x0000) Specify Product ID assigned by manufacturer. This configuration is a part of the Device Descriptor (idProduct).
Device Release Number 16-bit arbitrary number (Default: 0x0000) Specify Device Release Number in binary-coded decimal. This configuration is a part of the USB Device Descriptor (bcdDevice).
Index of Manufacturer String Descriptor Arbitrary number from 0 to 255 (Default: 0x00) Specify the Index of Manufacturer String Descriptor defined in the USBX String Framework. This configuration is a part of the USB Device Descriptor (iManufacturer). Set zero if String Descriptor is not used. See section USBX-String-Framework-Configuration for more information.
Index of Product String Descriptor Arbitrary number from 0 to 255 (Default: 0x00) Specify the Index of Product String Descriptor defined in the USBX String Framework. This configuration is a part of the USB Device Descriptor (iProduct). Set zero if String Descriptor is not used. See section "USBX String Framework Configuration" for more information.
Index of Serial Number String Descriptor Arbitrary number from 0 to 255 (Default: 0x00) Specify the Index of Serial Number String Descriptor defined in the USBX String Framework. This configuration is a part of the USB Device Descriptor (iSerialNumber). Set zero if the String Descriptor is not used. See section "USBX String Framework Configuration" for more information.
Class Code Device(0x00), Communications(CDC) (0x02, Default), HID (0x03), Mass Storage (0x08), Miscellaneous (0xEF), Vendor Specific (0xFF) Select the USB Device Class Code. This configuration is a part of the USB Configuration Descriptor (bDeviceClass).
Index of String Descriptor describing this configuration Arbitrary number from 0 to 255 (Default: 0x00) Specify the Index of String Descriptor describing this configuration. This configuration is a part of the USB Configuration Descriptor (iConfiguration). Set zero if String Descriptor is not used. See section "USBX String Framework Configuration" for more information.
Size of USB Descriptor in bytes for this configuration 0x00 (Default) or value to be set to wTotalLength (calculated by user) Specify the size of USB Descriptor in bytes. Modify the value for Vendor-specific Class, otherwise you can set zero to calculate the size automatically in the auto-generated code from Synergy Configuration tool. This configuration is a part of the USB Configuration Descriptor (wTotalLength).
Number of Interfaces 0x00 (Default) or value to be set to bNumInterfaces (calculated by user). Specify the Number of interfaces supported by this configuration. Modify the value for Vendor-specific Class, otherwise you can set zero to calculate the value automatically in the auto-generated code from Synergy Configuration tool. This configuration is a part of the USB Configuration Descriptor (bNumInterfaces).
Self-Powered Enable (Default) or Disable Enable this configuration if your USB Device is a self- powered device. This configuration is a part of the USB Configuration Descriptor (bmAttributes bit6)
Remote Wakeup Enable or Disable (Default) Enable this configuration if your USB Device supports remote wakeup. This configuration is a part of the USB Configuration Descriptor (bmAttributes bit5)
Maximum Power Consumption in 2mA units(0-250) 50 (Default), Integer value from 0 to 250. Set the maximum power consumption of your device to indicate the amount of bus power required. This configuration is 2mA units, thus, the maximum 500 mA can be specified. This configuration is a part of the USB Configuration Descriptor (bMaxPower).
Supported Language Code 16-bit number assigned by Manufacturer (Default: 0x0409) Specify the Language ID Code.  For example, 0x0409 English - United States. This configuration is used for Language ID Framework code generation. See section "USBX Language Framework Configuration" for more information.
Name of USBX String Framework Arbitrary C language symbol (Default:  NULL) Specify the name of user defined USBX String Framework. This must be a valid C symbol. Set NULL if the String Descriptor is not used. See section "USBX String Framework Configuration" for more information.
Total index number in USB String Descriptor in USBX String Framework Arbitrary integer number (Default: 0) Specify the total number of index for String Descriptor. See section "USBX String Framework Configuration" for more information.
Name of USB Language Descriptor Arbitrary C language symbol (Default:  NULL) Specify the name of user defined USBX Language Framework. This must be a valid C symbol. If '0' is set to the property "Total Number of Language Support", this configuration is ignored. See section "USBX Language Framework Configuration" for more information.
Total Number of Language Support Arbitrary integer number (Default: 0) Specify the total number of languages to support. See section "USBX String Framework Configuration" for more information. If '0' is set here, US English (0x0409) is applied as the default language.

 

USBX Device String Framework Configuration

The USBX String Framework is byte stream data to provide USB device information with human readable strings to the USB Host device. Users need to define the byte stream data in their application code if required.  See the USBX Device Class User Guide section Definition of the Strings of the Device Framework for more information about the USBX String Framework. Here is an example of USBX String Framework, which consists of three indexes String descriptors.

const UCHAR g_usb_string_framework[] =
{
    /* Index #1 (this example shows manufacturer information) */
    (uint8_t) (0x0409), /* Byte0 Language Code, US English */
    (uint8_t) (0x0409 >> 8), /* Byte1 Language Code */
    0x01, /* Byte2 Index */
    7, /* Byte3 Length */
    'R', 'E', 'N', 'E', 'S', 'A', 'S',
    /* Index #2 (this example shows product information) */
    (uint8_t) (0x0409), /* Byte0 Language Code, US English */
    (uint8_t) (0x0409 >> 8), /* Byte1 Language Code */
    0x02, /* Byte2 Index */
    10, /* Byte3 Length */
    'C', 'O', 'M', ' ', 'D', 'E', 'V', 'I', 'C', 'E',
    /* Index #3 (this example shows Device Serial Number information) */
    (uint8_t) (0x0409), /* Byte0 Language Code, US English */
    (uint8_t) (0x0409 >> 8), /* Byte1 Language Code */
    0x03, /* Byte2 Index */
    4, /* Byte3 Length */
    '0', '1', '0', '0'
};

You can configure the properties of the USBX Device Configuration component as shown in the following table. Refer to USBX Device Configuration for more information about each configuration in the table.

Example of the USBX String Framework Configuration

Configurations for String Descriptor on Synergy Configuration tool Setting Example
Name of USB String Framework g_usb_string_framework
Total index number of USB String Descriptor in USBX String Framework 3 (3 indexes)
Index of Manufacturer String Descriptor 1 (Index #1)
Index of Product String Descriptor 2 (Index #2)
Index of Serial Number String Descriptor 3 (Index #3)
Index of String Descriptor describing this configuration 0 (no string information)
Index of String Descriptor Describing Communications Class interface 0 (no string information)

USBX Device Language Framework Configuration

The USBX Languages Framework is byte stream data to support multiple languages. You need to define the byte stream data in your application code if required. See the USBX Device Class User Guide section Definition of the Languages Supported by the Device for Each String for more information. The following is an example of the USBX Language Framework which supports two Languages:

const UCHAR g_usb_language_framework[] =
{
    /* US English */
    (uint8_t) (0x0409),
    (uint8_t) (0x0409 >> 8),
    /* Japanese */
    (uint8_t) (0x0411),
    (uint8_t) (0x0411 >> 8),
};

You can configure the properties of USBX Device Configuration component as shown in the following table. See section "USBX Device Configuration" for more information.

Example of the USBX Language Framework Configuration

Configurations for String Descriptor on Synergy Configuration tool Setting Example
Name of USB Language Descriptor g_usb_language_framework
Total Number of Language Support 2 (2 languages)

Device-Only Size Optimization

The Azure RTOS USBX module is built in device-only mode to reduce code size for Synergy S1 parts.  The configuration (UX_SYSTEM_DEVICE_ONLY) is applied automatically if the S1 board is selected in the Synergy Configuration tool BSP tab. Note that the following configurations are fixed in the device-only mode.

  • UX_THREAD_STACK_SIZE=512
  • UX_SLAVE_REQUEST_DATA_MAX_LENGTH=512

USBX Hardware support details

  USBX Mass Storage Class USBX HID Class
  Host Device Host Device
  High Speed Full Speed High Speed Full Speed High Speed Full Speed High Speed Full Speed
S1JA N/A N/A N/A N/A N/A N/A
S124 N/A N/A N/A N/A N/A N/A
S128 N/A N/A N/A N/A N/A N/A
S3A1 N/A N/A N/A N/A
S3A3 N/A N/A N/A N/A
S3A6 N/A N/A N/A N/A
S3A7 N/A N/A N/A N/A
S5D5 N/A N/A N/A N/A
S5D3 N/A N/A N/A N/A
S5D9
S7G2
  USBX CDC/ACM USBX Video Class USBX HUB Class
  Host Device Host Host
  High Speed Full Speed High Speed Full Speed High Speed Full Speed High Speed Full Speed
S1JA N/A N/A N/A N/A N/A N/A
S124 N/A N/A N/A N/A N/A N/A
S128 N/A N/A N/A N/A N/A N/A
S3A1 N/A N/A N/A N/A
S3A3 N/A N/A N/A N/A
S3A6 N/A N/A N/A N/A
S3A7 N/A N/A N/A N/A
S5D5 N/A N/A N/A N/A ✓*
S5D3 N/A N/A N/A N/A ✓*
S5D9
S7G2
Symbol Meaning
Available (Tested)
Not Available (Not tested/not functional or both)
N/A Not supported by MCU 

✓ * denotes that the HUB class is tested with self-powered hubs only.

Azure RTOS USBX Auto-generated Code Procedures

Note
Code samples in this section are subject to change. Note any warranty for contents and possible changes.

USBX Device Stack Auto-generated Code Procedures

The following code sample is pseudo code for USBX Device Classes. The function call sequence is auto-generated from the Synergy Configuration tool if one (or multiple) USBX Device Class component(s) is added to the Synergy Configuration tool. Auto-generated code is emitted to common_data.c file and provides the following features:

  • Generates the USB Device Descriptor.
  • Initializes the USBX software contexts in the memory pool.
  • Initializes the USBX Device Stacks added in the Synergy Configuration tool.
  • Initializes Synergy USB controller(s) in device mode. The USBX Device stack supports many-to-one topology between device classes and a device controller. For instance, two USBX Device Classes  which consist of a USB composite device can use a single USB controller.
Note
The USBX Device stack does not support using multiple USB controllers simultaneously. Only one of the USB controllers is used at a time, even if the Synergy part has multiple USB controllers (like S7G2 parts).
SSP_VECTOR_DEFINE_UNIT();
void g_common_init(void)
{
    // Initialize USBX Memory.
    ux_system_initialize ();
    // Initialize USBX Device stack.
    ux_device_stack_initialize ();
    // Register the Device CDC-ACM Class if the class is used.
    ux_device_stack_class_register();
    // Register the Device HID Class if the class is used.
    ux_device_stack_class_register();
    // Register the Device Mass Storage Class if the class is used.
    ux_device_stack_class_register();
    // Initialize the USB Device Controller. This function calls either of
    // _ux_dcd_synergy_initalize() or
    // _ux_dcd_synergy_initalize_transfer_support()
    ux_dcd_initialize ();
}

USBX Host Stack Auto-generated Code Procedures

The following code sample is pseudo code for USBX Host Classes. The function call sequence is auto-generated from the Synergy Configuration tool if one (or multiple) USBX Host Class component(s) is added to the Synergy Configuration tool. Auto-generated code is emitted to the common_data.c file and provides the following features:

  • Initializes the USBX software contexts in the memory pool.
  • Initializes the USBX Host Stacks added in Synergy Configuration tool. Multi-instances of host class stacks are allowed to be built.
  • Initializes the USBX HID Clients if the USBX Host HID Class is added in Synergy Configuration tool.
  • Initializes Synergy USB controller(s) in host mode. The USBX Host stack supports Many-to-one or Many-to-many topology between host classes and host controllers. For instance, Two USBX Host Classes can use single USB controller, or Two USBX Host Classes can use different USB controllers individually if the Synergy part has multiple USB controllers (like S7G2 parts).
  • Gets a USBX Host Class container for user application.
// Interrupt vector registering for USBHS or USBFS controller.
SSP_VECTOR_DEFINE_UNIT();
void g_common_init(void)
{
    // Initialize FileX (ONLY for Mass Storage Class)
    fx_system_initialize ();
    // Initialize USBX Memory.
    ux_system_initialize ();
    // Initialize the USBX Host stack.
    ux_host_stack_initialize ();
    // Register the HUB Class if the class is used.
    ux_host_stack_class_register();
    // Register the Host CDC-ACM Class if the class is used.
    ux_host_stack_class_register();
    // Register the Host HID Class if the class is used.
    ux_host_stack_class_register();
    // Register the Host HID Clents if the HID clients are used.
    ux_host_class_hid_clients_register ();
    // Register the Host Mass Storage Class if the class is used.
    ux_host_stack_class_register();
    // Register and initialize the USB Host Controller.
    ux_host_stack_hcd_register ();
    // Get the USBX Host Class Container for registered classes.
    ux_host_stack_class_get ();
}

Azure RTOS USBX Application Code Examples

Application projects are available in the module guides for each USBX module. Refer to the module guides for application projects showing working code for typical use cases.

Azure RTOS USBX Special Linker Sections

The USBX Device Stack configuration uses the following special memory sections in the linker script files. The order of memory sections in the linker script needs to consist of the USB Device Descriptor byte stream, which is given to _ux_device_stack_initialize() function; the linker script definitions must not be modified.

Memory section for the USBX Device Descriptor

Memory section USB Descriptor to be defined in the section
.usb_device_desc_fs* The USB Device Descriptor for FS mode
.usb_config_desc_fs* The USB Configuration Descriptor for FS mode
.usb_interface_desc_fs* The USB Interface Descriptor for FS mode
.usb_device_desc_hs* The USB Device Descriptor for HS mode
.usb_config_desc_hs* The USB Configuration Descriptor for HS mode
.usb_interface_desc_hs* The USB Interface Descriptor for HS mode
Note
Memory sections for HS mode only exists for Synergy Parts, which has the USBHS controller.

Azure RTOS USBX Memory Requirements

The USBX Device stack and/or USBX Host stack consumes RAM for the control block. The Synergy Configuration tool allocates memory to the USBX memory pool statically in the auto-generated code. The memory consumption is different for each class. Refer to the module overview section in the SSP User's Manual for the USBX memory requirements for a specific module.

Azure RTOS USBX Limitations

  • Support for the USB Device vender-specific class is not available.
  • The module needs the interrupt of a USB Controller enabled. See section "Logic USBX Synergy Port Framework Limitations" for more information.
  • USBX classes (ux_device_class_cdc_ecm, ux_device_class_rndis, ux_host_class_audio, ux_host_class_gser, ux_host_class_prolific, ux_host_class_swar) and USBX network driver (ux_network_driver) are experimental modules and not yet tested for Synergy parts in this version of SSP. It is not recommended to use them for product developments.
  • Composite device class mode is supported only on S3, S5 and S7 series (not on S1 series).
  • Composite device class mode is tested with combination of CDC-CDC as well as CDC-MSC classes on Windows 10 PC acting as Host.
  • In case of USBX composite device with DMA, MSC class will be given highest priority. for eg. 
    • In case of CDC-MSC, MSC class uses DMA for data transfer and CDC class will use CPU for data transfer. 
    • In case of CDC-CDC, one of the CDC class will use DMA for data transfer and other will use CPU for data transfer.
  • In case of Device class CDC-ACM Read, there might be no difference between DMA and CPU performance  (Generally DMA should give better performance over CPU).
  • When using Device class CDC-ACM Read, DMA will be used only when the requested transfer length is greater than the maximum packet size. For the transfer length less than maximum packet size, CPU will be used even if DMA module is added in ISDE configurator.