Using the PHDC Demo Application

Micrium provides a demo application that lets you test and evaluate the class implementation. Source files are provided for the device (for μC/OS-II and μC/OS-III only). Executable and source files are provided for the host (Windows only).

Note that the demo application provided by Micriµm is only an example and is intended to be used as a starting point to develop your own application.

Set Up the PHDC Demo Application

On the target side, you should compile the application file, app_usbd_phdc.c , with your project. This file is located in the following folder:

\Micrium\Software\uC-USB-Device-V4\App\Device\

The demo application allows you to send and receive different QoS levels for data transfers. All transfers sent by the host application is received using a single receive task. While all transfers sent by the device are handled using one or several transmit tasks assuming one QoS level per transmit task. You can have several tasks transmitting data with the same QoS. When several transmit tasks are used, you may enable the RTOS QoS-based scheduler to prioritize the transfers by their QoS latency. 

Several constants are available to customize the demo application on both device and host (Windows) side. Table - Device Side Demo Application’s Configuration Constants describe device side constants that are located in the app_cfg.h or  app_usbd_cfg.h file. Table - Host Side (Windows) Demo Application’s Configuration Constants describe host side constants that are located in the app_phdc.c file.

Table - Device Side Demo Application’s Configuration Constants
ConstantDescriptionFile
APP_CFG_USBD_PHDC_ENSet to DEF_ENABLED to enable the demo application. app_usbd_cfg.h
APP_CFG_USBD_PHDC_ITEM_DATA_LEN_MAXSet this constant to the maximum number of bytes that can be transferred as data. Must be >= 5. app_usbd_cfg.h
APP_CFG_USBD_PHDC_ITEM_NBR_MAXSet this constant to the maximum number of items that the application should support. Must be >= 1. app_usbd_cfg.h
APP_CFG_USBD_PHDC_MAX_NBR_TASKSSet this constant to the number of transmit tasks needed to handle all the QoS levels. Must be >= 1.

Each created task will send data attached to one specific QoS level. If this constant is greater than one, usually USBD_PHDC_OS_CFG_SCHED_EN is set to DEF_ENABLED.

Otherwise, USBD_PHDC_OS_CFG_SCHED_EN can be set to DEF_DISABLED.
app_usbd_cfg.h
APP_CFG_USBD_PHDC_TX_COMM_TASK_PRIOPriority of the write task. app_cfg.h
APP_CFG_USBD_PHDC_RX_COMM_TASK_PRIOPriority of the read task. app_cfg.h
APP_CFG_USBD_PHDC_TASK_STK_SIZEStack size of both read and write tasks. Default value is 512. app_cfg.h

Table - Host Side (Windows) Demo Application’s Configuration Constants
ConstantDescription
APP_ITEM_DATA_LEN_MAXSet this constant to the maximum number of bytes that can be transferred as data. Must be >= 5.
APP_ITEM_DATA_OPAQUE_LEN_MAXSet this constant to the maximum number of bytes that can be transferred as opaque data. Must be <= (MaxPacketSize - 21).
APP_ITEM_NBR_MAXSet this constant to the maximum number of items that the application should support. Must be >= 1.
APP_STAT_COMP_PERIODSet this constant to the period (in ms) on which the statistic of each transfer (mean and standard deviation) should be computed.
APP_ITEM_PERIOD_MINSet this constant to the minimum period (in ms) that a user can specify for an item.
APP_ITEM_PERIOD_MAXSet this constant to the maximum period (in ms) that a user can specify for an item.
APP_ITEM_PERIOD_MULTIPLESet this constant to a multiple (in ms) that periodicity of items specified by the user must comply.


Since Microsoft does not provide any specific driver for PHDC, you will have to indicate to windows which driver to load using an INF file. The INF file will ask Windows to load the WinUSB generic driver (provided by Microsoft). The application uses the USBDev_API, which is a wrapper of the WinUSB driver (refer to the USBDev_API page).

Windows will ask for the INF file (refer to the About INF Files section) the first time the device will be plugged-in. It is located in the following folder:

\Micrium\Software\uC-USB-Device-V4\App\Host\OS\Windows\PHDC\INF

Once the driver is successfully loaded, the Windows host application is ready to be launched. The executable is located in the following folder:

\Micrium\Software\uC-USB-Device-V4\App\Host\OS\Windows\PHDC\Visual Studio 2010\exe

Running the PHDC Demo Application

In this demo application, you can ask the device to continuously send data of different QoS level and using a given periodicity. Each requested transfer is called an “item”. Using the monitor, you can see each transfer’s average periodicity and standard deviation. The monitor will also show the data and opaque data that you specified. At startup, the application will always send a default item with a periodicity of 100 ms. This item will send the device CPU usage and the value of a counter that is incremented each time the item is sent. The default item uses low latency / good reliability as QoS. Figure - Demo Application at Startup shows the demo application at startup.

Figure - Demo Application at Startup

Demo Application at Startup


At this point, you have the possibility to add a new item by pressing 1. You will be prompted to specify the following values:

  • Periodicity of the transfer: the period at which the transfer will attempt to occur.
  • QoS (Latency / reliability) of the transfer: the type of QoS desired for this transfer.
  • Opaque data (if QoS is not low latency / good reliability): the opaque data that will be included in this transfer.
  • Data: the actual data that will be transferred.

Figure - Demo Application with Five Items Added shows the demo application with a few items added.

Figure - Demo Application with Five Items Added

Demo Application with Five Items Added


Once an item has been added, the application provides statistics about every transfer. From left to right, there is the item’s number, the type of QoS, the ideal period, the mean period value, the standard deviation value and the opaque data/data. The mean and standard deviation values are calculated by the host application, based on a sampling of the actual period value obtained for every single transfer.