Home
USBX Device Stack User`s Manual
Contents
1. parameter ux slave class rndis instance activate UX NULL parameter ux slave class rndis instance deactivate UX NULL Define a local NODE ID parameter ux slave class rndis parameter local node id 0 0x00 parameter ux slave class rndis parameter local node id 1 Oxle parameter ux slave class rndis parameter local node id 2 0x58 parameter ux slave class rndis parameter local node id 3 0x41 parameter ux slave class rndis parameter local node id 4 0xb8 parameter ux slave class rndis parameter local node id 5 0x78 Define a remote NODE ID parameter ux slave class rndis parameter remote node id 0 0x00 parameter ux slave class rndis parameter remote node id 1 Dxle parameter ux slave class rndis parameter remote node id 2 0x58 parameter ux slave class rndis parameter remote node id 3 0x41 parameter ux slave class rndis parameter remote node id 4 Dxb8 parameter ux slave class rndis parameter remote node id 5 0x79 x Set extra parameters used by the RNDIS query command with certain OIDs parameter ux slave class rndis parameter vendor id 0x04b4 parameter ux slave class rndis parameter driver version 0x1127 ux utility memory copy parameter ux slave class rndis parameter vendor description ELOGIC RNDIS 12 Initialize the device rndis class This class owns both
2. We have copied the requested data Return OK return UX SUCCESS ux device class pima object data send Host sends the object data Prototype UINT ux device class pima object data send UX SLAVE CLASS PIMA pima ULONG object handle ULONG phase UCHAR object buffer ULONG object offset ULONG object length Description This function is called when the PIMA class needs to receive the object data in the local system for storage Parameters pima Pointer to the pima class instance object handle Handle of the object phase phase of the transfer active or complete object buffer Object buffer address object offset Address of data object length Object data length sent by application Example UINT ux pictbridge dpsclient object data send UX SLAVE CLASS PIMA pima ULONG object handle ULONG phase UCHAR object buffer ULONG object offset ULONG object length UINT status UX PICTBRIDGE pictbridge UX SLAVE CLASS PIMA OBJECT object info ULONG event flag UCHAR pima object buffer Get the pointer to pictbridge UX_PICTB Get the pointer to object info UX SLAV the RIDGI EK D the pima object E CLASS PIMA OBJ Pictbridge instance pima gt ZE ux device class pima application a ECT Is this the corrent handle if pictbridge gt ux pictbridge object host object info ux device class
3. Define a remote NODE ID cdc ecm parameter ux slave class cdc ecm parameter remote node id 0 0x00 cdc ecm parameter ux slave class cdc ecm parameter remote node id 1 Oxle cdc ecm parameter ux slave class cdc ecm parameter remote node id 2 0x58 cdc ecm parameter ux slave class cdc ecm parameter remote node id 3 0x41 cdc ecm parameter ux slave class cdc ecm parameter remote node id 4 Oxb8 cdc ecm parameter ux slave class cdc ecm parameter remote node id 5 0x79 Initialize the device cdc ecm class status ux device stack class register ux system slave class cdc ecm name ux device class cdc ecm entry 1 0 cdc ecm parameter The initialization of this class expects the same function callback for activation and deactivation although here as an exercise they are set to NULL so that no callback is performed The next parameters are for the definition of the node IDs 2 Nodes are necessary for the CDC ECM a local node and a remote node The remote node must be the same one as the one declared in the device framework string descriptor The CDC ECM class has built in APIs for transferring data both ways but they are hidden to the application as the user application will communicate with the USB Ethernet device through NetX The USBX CDC ECM class is closely tied to ExpressLogic NetX Network stack An applic
4. JE devices found From the device list find your device and associate it with the libusb windows driver This will bind the PID VID of the device with the Windows USB library used by the DFU utilities To operate the DEU command simply unpack the zipped dfu utilities into a directory making sure the libusb dll is also present in the same directory The DEU utilities must be run from a DOS box at the command line First type the command dfu util I to determine whether the device is listed If not run Zadig to make sure the device is listed and associated with the USB library You should see a screen as follows C usb specs DFU dfu util 0 6 gt dfu util I dfu util 0 6 Copyright 2005 2008 Weston Schmidt Harald Welte and OpenMoko Inc Copyright 2010 2012 Tormod Volden and Stefan Schmidt This program is Free Software and has ABSOLUTELY NO WARRANTY Found Runtime 0a5c 21bc devnum 0 cfg 1 intf 3 alt 0 name UNDEFINED The next step will be to prepare the file to be downloaded The USBX DFU class does not perform any verification on this file and is agnostic of its internal format This firmware file is very specific to the target but not to DFU nor to USBX Then the dfu util can be instructed to send the file by typing the following command dfu util R t 64 D file to download hex The dfu util should display the file download process until the firmware has been completely downloaded USB D
5. OxFFFFFFFF object info gt ux device class pima object format object handles format code Insert in the array the number of found handles This handle is for the client XML script ux utility long put UCHAR object handles array 1 Adjust the array to point after the number of elements object handles array We have a candicate Store the handle ux utility long put UCHAR object handles array object info ux device class pima object handle id return UX SUCCESS ux device class pima object info get Return the object information Prototype UINT ux device class pima object info get struct UX SLAVE CLASS PIMA STRUCT pima ULONG object handle UX SLAVE CLASS PIMA OBJECT object Description This function is called when the PIMA class needs to retrieve the object handles array in the local system and send it back to the host Parameters pima Pointer to the pima class instance object handles Handle of the object object Object pointer address Example UINT ux pictbridge dpsclient object info get UX SLAVE CLASS PIMA pima ULONG object handle UX SLAVE CLASS PIMA OBJECT object UX PICTBRIDGE pictbridge UX SLAVE CLASS PIMA OBJECT object info Get the pointer to the pictbridge UX_PICTBRIDGE Check the object handle the XML script object If the handle is not 1 or 2 Pictbridge instance
6. ux device stack configuration set Set the current configuration Prototype UINT ux device stack configuration set ULONG configuration value Description This function is used by the host to set the current configuration running in the device Upon reception of this command the USB device stack will activate the alternate setting 0 of each interface connected to this configuration Input Parameter configuration value The configuration value selected by the host Return Value UX SUCCESS 0x00 The data transfer was completed Example ULONG configuration value UINT status The following example illustrates this service status ux device stack configuration set configuration value If status equals UX SUCCESS the operation was successful ux device stack descriptor send Send a descriptor to the host Prototype UINT ux device stack descriptor send ULONG descriptor type ULONG request index ULONG host length Description This function is used by the device side to return a descriptor to the host This descriptor can be a device descriptor a configuration descriptor or a string descriptor Parameters descriptor type The nature of the descriptor UX DEVICE DESCRIPTOR ITEM UX CONFIGURATION DESCRIPTOR ITEM UX STRING DESCRIPTOR ITEM UX DEVICE QUALIFIER DESCRIPTOR ITEM UX OTHER SPEED DESCRIPTOR ITEM request index The index of the descriptor host length The length required
7. Store the instance owner pictbridge ux pictbridge pima parameter ux device class pima parameter application VOID pictbridge x Initialize the device pima class The class is connected with interface 0 status ux device stack class register ux system slave class pima name ux device class pima entry 1 0 VOID amp pictbridge gt ux pictbridge pima parameter Check status if status UX SUCC EI Wei Wei ux device class pima object number get Getting the object number from the application Prototype UINT ux device class pima object number get UX SLAVE CLASS PIMA pima ULONG object numner Description This function is called when the PIMA class needs to retrieve the number of objects in the local system and send it back to the host Parameters pima Pointer to the pima class instance object number Address of the number of objects to be returned Example UINT ux pictbridge dpsclient object number get UX SLAVE CLASS PIMA pima ULONG number objects We force the number of objects to be 1 only here This will be the xml scripts number objects 1 return UX SUCCESS ux device class pima object handles get Return the object handle array Prototype UINT ux device class pima object handles get UX SLAVE CLASS PIMA STRUCT pima ULONG object handles format code Description ULONG object handles ass
8. if object handle UX PICTBRIDGE OBJECT HANDLE HOST RESPONSE object info UX SLAVE CLASS PIMA OBJECT pictbridge gt ux pictbridge object host else object info UX SLAVE CLASS PIMA OBJECT pictbridge gt ux pictbridge object client T Is this the corrent handle if object info gt ux device class pima object handle id object handle Get the pointer to the object buffer pima object buffer object info gt ux device class pima object buffer Copy the demanded object data portion ux utility memory copy object buffer pima object buffer object offset object length requested x Update the length requested for a demo we do not do any checking object actual length object length requested What cycle are we in if pictbridge ux pictbridge host client state machine amp UX PICTBRIDGE STATE MACHINE HOST REQUEST T Check if we are blocking for a client request if pictbridge ux pictbridge host client state machine amp UX PICTBRIDGE STATE MACHINE CLIENT REQUEST PENDING x Yes we are pending send an event to release the pending request ux utility event flags set spictbridge gt ux pictbridge event flags group UX PICTBRIDGE EVENT FLAG STATE MACHINE READY TX OR x Since we are in host request this indicates
9. ux utility unicode to string object info gt ux device class pima object filename string discovery name Now compare it to the HDISCVRY DPS file name Check length first if ux utility string length get ux pictbridge hdiscovery name ux utility string length get string discovery name So far the length of name of the files are the sam Compare names now if ux utility memory compare _ux pictbridge hdiscovery name string discovery name ux utility string length get string discovery name UX SUCCESS x We are done with discovery of the printer We can now send notifications when the camera wants to print an object pictbridge ux pictbridge discovery state UX PICTBRIDGE DPSCLIENT DISCOVERY COMPLE Be 17 H Set an event flag if the application is listening ux utility event flags set amp pictbridge gt ux pictbridge event flags group UX PICTBRIDGE EVENT FLAG DISCOVERY TX OR T There is no object during th discovery cycle return UX SUCCESS x What cycle are we in if pictbridge ux pictbridge host client state machine UX PICTBRIDGE STATE MACHINE IDLE x Since we are in idle state we must have received a request from the host pictbridge ux pictbridge host client state machine UX PICTBRIDGE STATE MACHINE HOST REQUEST
10. PN VA DPS services Discovery Z wf Pictbridge client implementation A DS FS Print Server Storage Client Print Device K Print Data The Pictbridge on the client requires the USBX device stack and the PIMA class to be running first A device framework describes the PIMA class in the following way UCHAR device framework full speed Device descriptor 0x12 Ox01 Ox10 Ox01 OxA9 0x04 OxB6 0x30 0x00 0x01 Configuration descriptor 0x09 0x02 0x27 0x00 Interface descriptor 0x09 0x04 0x00 0x00 0x07 0x05 0x01 0x02 0x00 0x00 Ox01 0x03 Endpoint descriptor Bulk Out 0x40 Endpoint descriptor Bulk In 0x00 0x00 0x01 0x06 ZA 0x00 X 0x00 0x00 0x00 0x01 0x00 0x20 0x00 Oxc0 0x32 0x01 0x00 0x07 0x05 0x82 0x02 0x40 0x00 0x00 Endpoint descriptor Interrupt 0x07 0x05 0x83 0x03 0x08 0x00 0x60 The Pima class is using the ID field 0x06 and has its subclass is 0x01 for Still Image and the protocol is 0x01 for PIMA 15740 3 endpoints are defined in this class 2 bulks for sending receiving data and one interrupt for events Unlike other USBX device implementations the Pictbridge application does not need to define a class itself Rather it invokes the function ux pictbridge dpsclient start An example i
11. storage parameter ux slave class storage parameter lun 0 ux slave class storage media read tx demo thread flash media read storage parameter ux slave class storage parameter lun 0 ux slave class storage media write tx demo thread flash media write storage parameter ux slave class storage parameter lun 0 ux slave class storage media status tx demo thread flash media status x Initialize the device storage class The class is connected with interface 0 status ux device stack class register ux system slave class storage name ux device class storage entry ux device class storage thread 0 VOID amp storage parameter In this example the drive s last block address or LBA is given as well as the logical sector size The LBA is the number of sectors available in the media 1 The block length is set to 512 in regular storage media It can be set to 2048 for optical drives The application needs to pass three callback function pointers to allow the storage class to read write and obtain status for the media The prototypes for the read and write functions are UINT media read UCHAR DIR data pointer ULONG number blocks ULONG lba UINT media write UCHAR PTR data pointer ULONG number blocks ULONG lba Where data pointer is the address of the buffer to be used for reading or writing number blocks is the number of sectors to
12. 0x01 0x01 0x00 0x00 0x00 Configuration descriptor 0x09 0x02 0x20 0x00 0x32 0x01 Interface descriptor 0x09 0x04 0x00 0x00 0x00 0x02 Endpoint 0x07 Bulk Out 0x02 0x40 descriptor 0x05 OxO1 Endpoint 0x07 Bulk In 0x02 0x40 descriptor 0x05 0x82 0x00 0x00 Ox01 0x08 KE 0x00 0x00 define DEVIC E FRAMEWORK LENGTH HIGH SPEE UCHAR device framework high speed Sit Device descriptor 0x12 0x01 0x00 0x0a 0X07 0X25 0x03 0x01 0x02 0x40 0x00 0x01 Device qualifier descriptor 0x0a 0x06 0x00 0x02 0x00 0x01 0x00 Configuration descriptor 0x09 0x02 0x20 0x00 0x32 0x01 Interface descriptor 0x09 0x04 0x00 0x00 0x00 0x02 Endpoint 0x07 Bulk Out 0x02 OxOO descriptor 0x05 O0x01 Endpoint 0x07 Bulk In 0x02 OxOO descriptor 0x05 0x82 0x00 0x00 0x00 Ox01 0x08 0x02 r Ox02 0x00 0x00 0x00 0x06 0x00 0x00 0x00 0x01 0x00 0x00 0x06 0x00 0x00 0x08 0x00 0OxcO 0x50 0x40 0x02 0x40 0OxcO 0x50 x String Device Framework Byte 0 and 1 Byte 2 Byte 3 ef define STRING FRAMEWORK LI UCHAR string framework ENGTH 38 Word containing the language ID Byte co
13. C C C C C C C LC Description This function is called by the application to initialize the USB device stack It does not initialize any classes or any controllers This should be done with separate function calls This call mainly provides the stack with the device framework for the USB function It supports both high and full speeds with the possibility to have completely separate device framework for each speed String framework and multiple languages are supported Parameters device framework high speed Pointer to the high speed framework device framework length high speed Length of the high speed framework device framework full speed Pointer to the full speed framework device framework length full speed Length of the full speed framework string framework Pointer to string framework string framework length Length of string framework language id framework Pointer to string language framework language id framework length Length of the string language framework ux system slave change function Function to be called when the device state changes Return Values UX SUCCESS 0x00 This operation was successful UX MEMORY INSUFFICIENT 0x12 Not enough memory to initialize the stack Example Example of a device framework define DEVIC E FRAMEWORK LENGTH FULL SPEE UCHAR device framework full speed Device descriptor 0x12 0x01 0x10 Oxec 0x08 0x10 0x00
14. Download lInlenaces i su srensesbinon aen dee reet SdeeCeeh a kenamebadenanen ik enknekadenanekikenangta 10 DEBUGGING e Le EE ooh TT TI TL 10 Required Hard Disk Space 10 Target Considerations E 10 Configuration le tele 13 S rce ee an 15 Initialization of USBX resources 16 Definition of USB Device Controller 17 roubleshoolinig e zerereieneipu So o ofon rketabaa Siab odon ikekekraTketedon Ubekekentkatelasabebelsas 19 USBX Version ID sasa pse eto ae rada ean nan ea il ait ai ik 19 Chapter 3 Functional Components of USBX Device Stack 20 EXECUION OVBIVIEWI sa citi iii niin tare acai aa 20 at WE Eee LR AR ARR SAN RO stint ecu EN RONA Tm TT I TTT TTT 20 Application Interface Calls toc zeo p o eo o o a hed 21 USB Devite Stack APIS sasa sss os oe o EE 21 USB Device Class APIS ee 21 D vic Framework ca ae e eo alc iia a e ait dai aia 21 Definition of the Components of the Device Framework 21 Definition of the Strings of the Device Framework seeee tiii 22 Definition of the Languages Supported by the Device for each String 23 VBUS Manager I Ann a ee a odolo 24 Chapter 4 Description of USBX Device Services 25 ux device stack alternate setting get eeeeeeeeeeeeeeeenennnenntoo 26 ux device s
15. jobinfo ux pictbridge jobinfo filetype UX PICTBRIDGE FILE TYPES DEFAULT jobinfo ux pictbridge jobinfo dateprint UX PICTBRIDGE DATE PRINTS DEFAULT jobinfo ux pictbridge jobinfo filenameprint UX PICTBRIDGE FILE NAME PRINTS DEFAULT jobinfo ux pictbridge jobinfo imageoptimize UX PICTBRIDGE IMAGE OPTIMIZES OFF jobinfo gt ux pictbridge jobinfo layout UX PICTBRIDGE LAYOUTS DEFAULT jobinfo ux pictbridge jobinfo fixedsize UX PICTBRIDGE FIXED SIZE DEFAULT jobinfo ux pictbridge jobinfo cropping UX PICTBRIDGE CROPPINGS DEFAULT Program the callback function for reading the object data jobinfo ux pictbridge jobinfo object data read ux demo object data copy x This is a demo the fileID is hardwired 1 and 2 for scripts 3 for photo to be printed printinfo ux pictbridge printinfo fileid UX PICTBRIDGE OBJECT HANDLE PRINT ux utility memory copy printinfo ux pictbridge printinfo filename Pictbridge demo file 20 ux utility memory copy printinfo ux pictbridge printinfo date 01 01 2008 10 x Fill in the object info to be printed First get the pointer to the object container in the job info structure object UX SLAVE CLASS PIMA OBJECT jobinfo gt ux pictbridge jobinfo object Store the o
16. 0 DFU Write II UX SLAVE CLASS DEU NOTIFICATION END DOWNLOAD The major challenge of the DFU class is getting the right application on the host to perform the download the firmware There is no application supplied by Microsoft or the USB IF Some shareware exist and they work reasonably well on Linux and to a lesser extent on Windows On Linux one can use dfu utils to be found here http wiki openmoko org wiki Dfu util A lot of information on dfu utils can also be found on this link http www libusb org wiki windows backend The Linux implementation of DFU performs correctly the reset sequence between the host and the device and therefore the device does not need to do it Linux can accept for the bmAttributes bitWillDetach to be 0 Windows on the other side requires the device to perform the reset On Windows the USB registry must be able to associate the USB device with its PID VID and the USB library which will in turn be used by the DFU application This can be easily done with the free utility Zadig which can be found here http sourceforge net projects libwdi files zadig Running Zadig for the first time will show this screen Zio E eoo M Device Options Help validity Sensor PID 0011 E Edit Driver WinUSB v2 1 0 3 gt libusb win32 v1 2 6 0 S More Information WinUSB libusbx USBID 138A 0011 libusb win32 Replace Driver v libusbK wCID X WinUSB Microsoft
17. 0x04 0x02 0x10 0x45 0x4c 0x20 0x43 0x44 0x43 0x45 0x43 0x4d 0x20 0x44 0x65 0x76 0x69 0x63 0x64 Serial Number string descriptor Index 3 0001 0x09 0x04 0x03 0x04 0x30 0x30 0x30 0x31 x MAC Address string descriptor Index 4 001E5841B879 0x09 0x04 0x04 0x0C 0x30 0x30 0x31 0x45 0x35 0x38 0x34 0x31 0x42 0x38 0x37 0x39 The MAC address string descriptor is used by the CDC ECM class to reply to the host queries as to what MAC address the device is answering to at the TCP IP protocol It can be set to the device choice but must be defined here Theinitialization of the CDC ECM class is as follows x Set the parameters for callback when insertion extraction of a CDC device Set to NULL cdc ecm parameter ux slave class cdc ecm instance activate UX NULL cdc ecm parameter ux slave class cdc ecm instance deactivate UX NULL Define a NODE ID cdc ecm parameter ux slave class cdc ecm parameter local node id 0 0x00 cdc ecm parameter ux slave class cdc ecm parameter local node id 1 Oxle cdc ecm parameter ux slave class cdc ecm parameter local node id 2 0x58 cdc ecm parameter ux slave class cdc ecm parameter local node id 3 0x41 cdc ecm parameter ux slave class cdc ecm parameter local node id 4 0xb8 cdc ecm parameter ux slave class cdc ecm parameter local node id 5
18. 7 October 2015 Renesas SynergyTM Platform User s Manual Software TENESAS Renesas Electronics Corporation R11UM0007EU0570
19. FIXED SIZE DEFAULT FixedSizes 1 UX PICTBRIDGE FIXED SIZE 35IX5I FixedSizes 2 UX PICTBRIDGE FIXED SIZE 4IXGI FixedSizes 3 UX PICTBRIDGE FIXED SIZE 51X71 FixedSizes 4 UX PICTBRIDGE FIXED SIZE 7CMX10CM FixedSizes 5 UX_PICTBRIDGE_FIXED_SIZE_LETTER FixedSizes 6 UX PICTBRIDGE FIXED SIZE A4 Croppings 0 UX PICTBRIDGE CROPPINGS DEFAULT Croppings 1 UX PICTBRIDGE CROPPINGS OFF Croppings 2 UX PICTBRIDGE CROPPINGS ON The state machine of the DPS host will be set to Idle and ready to accept a new print job The host portion of Pictbridge can now be started as the example below shows Activate the pictbridge dpshost status ux pictbridge dpshost start spictbridge pima if status UX SUCCESS return The Pictbridge host function requires a callback when data is ready to be printed This is accomplished by passing a function pointer in the pictbridge host structure as follows Set a callback when an object is being received pictbridge ux pictbridge application object data write tx demo object data write This function has the following properties ux pictbridge application object data write Prototype UINT ux pictbridge application object data write UX PICTBRIDGE Writing a block of data for printing pictbridge UCHAR object buffer ULONG offset ULONG total length ULONG length Description This function is called when the DPS server needs to retrieve a data block from the DPS cl
20. The description of the DFU capabilities are as follows Name Offset Size type Description bmAttributes 2 1 Bit field Bit 3 device will perform a bus detach attach sequence when it receives a DFU DETACH request The host must not issue a USB Reset bitWillDetach O no 1 yes Bit 2 device is able to communicate via USB after Manifestation phase bitManifestation Tolerant 0 no must see bus reset 1 yes Bit 1 upload capable bitCanUpload 0 no 1 yes Bit 0 download capable bitCanDnload 0 no 1 yes wDetachTimeOut 3 2 number Time in milliseconds that the device will wait after receipt of the DEU DETACH request If this time elapses without a USB reset then the device will terminate the Reconfiguration phase and revert back to normal operation This represents the maximum time that the device can wait depending on its timers etc USBX sets this value to 1000 ms wTransferSize 5 2 number Maximum number of bytes that the device can accept per control write operation USBX sets this value to 64 bytes The declaration of the DEU class is as follows Store the DFU parameters dfu parameter ux slave class dfu parameter instance activate tx demo thread dfu activate dfu parameter ux slave class dfu parameter instance deactivate tx demo thread dfu deactivate dfu parameter ux slave class dfu parameter read tx demo th
21. The following example illustrates this service status ux device stack interface delete interface value If status equals UX SUCCESS the operation was successful ux device stack interface set Prototype UINT ux device stack interface set Description Change the alternate setting of the interface UCHAR PTR device framework ULONG device framework length ULONG alternate setting value This function is called when the host requests a change of the alternate setting for the interface Parameters device framework device framework length alternate setting value Return Values UX SUCCESS 0x00 UX_ERROR OxFF Example UCHAR PIR device framework ULONG device framework le ULONG alternate setting v UINT status The following example illus status ux device stack inter x If status equals UX SUCCESS Address of the device framework for this interface Length of the device framework Alternate setting value to be used by this interface This operation was successful No interface exists ngth alue trates this service face set device framework device framework length alternate setting value the operation was successful ux device stack interface start Start search for a class to own an interface instance Prototype UINT ux device stack interface start UX SLAVE INTERFACE interface Description This function is called w
22. USBX names are unique and will not interfere with the previous USBX installation Step 3 Add a call to ux system initialize at or near the beginning of tx application define This is where the USBX resources are initialized Step 4 Add a call to ux device stack initialize Step 5 Add one or more calls to initialize the required USBX classes either host and or devices classes Step 6 Add one or more calls to initialize the device controller available in the system Step 7 Step 8 It may be required to modify the tx low level initialize c file to add low level hardware initialization and interrupt vector routing This is specific to the hardware platform and will not be discussed here Compile application source code and link with the USBX and ThreadX run time libraries FileX and or Netx may also be required if the USB storage class and or USB network classes are to be compiled in us a or ux lib and tx a or tx lib The resulting can be downloaded to the target and executed Configuration Options There are several configuration options for building the USBX library All options are located in the ux port h The list below details each configuration option Additional development tool options are described in the readme usbx txt file supplied on the distribution disk UX PERIODIC RATE This value represents how many ticks per seconds for a specific hardware platform The default is 1000 indicating 1 tick per millisecon
23. buffer object offset Where we are starting to read the data block object length Length to be returned actual length Actual length returned Return Value UX SUCCESS 0x00 This operation was successful UX ERROR 0x01 The application could not retrieve data Example Copy the object data UINT ux demo object data copy UX PICTBRIDGE pictbridge UCHAR object buffer ULONG object offset ULONG object length ULONG actual length Copy the demanded object data portion ux utility memory copy object buffer image object offset object length Update the actual length actual length object length We have copied the requested data Return OK return UX SUCCESS Pictbridge host implementation The host implementation of Pictbridge is different from the client The first thing to do in a Pictbridge host environment is to register the Pima class as the example below shows status ux host stack class register ux system host class pima name if status UX SUCCI return ux host class pima entry This class is the generic PTP layer sitting between the USB host stack and the Pictbridge layer The next step is to initialize the Pictbridge default values for print services as follows Pictbridge field Value DpsVersion O 0x00010000 DpsVersion 1 0x00010001 DpsVersion 2 0x00000000 VendorSpecificVersion 0x00010000 PrintServiceAvailable 0
24. default The definition of each language for the string descriptors is in the form of an array of languages definition defined as follows define LANGUAGE ID FRAMEWORK LENGTH 2 UCHAR language id framework English 0x09 0x04 To support additional languages simply add the language code double byte definition after the default English code The language code has been defined by Microsoft in the document Developing International Software for Windows 95 and Windows NT Nadine Kano Microsoft Press Redmond WA VBUS Manager In most USB device designs VBUS is not part of the USB Device core but rather connected to an external GPIO which monitors the line signal As a result VBUS has to be managed separately from the device controller driver It is up to the application to provide the device controller with the address of the VBUS 10 VBUS must be initialized prior to the device controller initialization Depending on the platform specification for monitoring VBUS it is possible to let the controller driver handle VBUS signals after the VBUS IO is initialized or if this is not possible the application has to provide the code for handling VBUS If the application wishes to handle VBUS by itself its only requirement is to call the function ux device stack disconnect when it detects that a device has been extracted It is not necessary to inform the controller when a device is inserted because
25. device class hid event buffer 1 0 The 6 next bytes are keys We only have one key here hid event ux device class hid event buffer 2 key Set the keyboard event ux device class hid event set hid shid event The callback defined at the initialization of the HID class performs the opposite of sending an event It gets as input the event sent by the host The prototype of the callback is as follows hid_callback Getting an event from the HID class Prototype UINT hid callback UX SLAVE CLASS HID hid UX SLAVE CLASS HID EVENT hid event Description This function is called when the host sends a HID report to the application Parameters hid Pointer to the hid class instance hid event Pointer to structure of the hid event Example The following example shows how to interpret an event for a HID keyboard UINT tx demo thread hid callback UX SLAVE CLASS HID hid UX SLAVE CLASS HID EVENT hid event There was an event Analyze it Is it NUM LOCK if hid event ux device class hid event buffer O amp HID NUM LOCK MASK Set the Num lock flag num lock flag UX TRUE else Reset the Num lock flag num lock flag UX FALSE x There was an event Analyze it Is it CAPS LOCK if hid event ux device class hid event buffer O amp HID CAPS LOCK MASK Set the Caps lock flag caps lock flag UX T
26. device descriptors Additional strings indexes can be embedded into individual interfaces Assuming the device framework above has three string indexes embedded into the device descriptor the string framework definition could look like this x String Device Framework Byte 0 and 1 Word containing the language ID 0x0904 for US Byte 2 Byte containing the index of the descriptor Byte 3 Byte containing the length of the descriptor string GVA define STRING FRAMEWORK LENGTH 38 UCHAR string framework Manufacturer string descriptor Index 1 0x09 0x04 0x01 OxOo 0x45 0x78 0x70 Ox72 0x65 0x73 0x20 Ox4c Ox6f 0x67 0x69 0x63 Product string descriptor Index 2 0x09 0x04 0x02 OxOo Ox4D Ox4C 0x36 0x39 0x36 0x35 0x30 0x30 0x20 0x53 0x44 Ox4B Serial Number string descriptor Index 3 0x09 0x04 0x03 0x04 0x30 0x30 0x30 0x31 If different strings have to be used for each speed different indexes must be used as the indexes are speed agnostic The encoding of the string is UNICODE based For more information on the UNICODE encoding standard refer to the following publication The Unicode Standard Worldwide Character Encoding Version 1 Volumes 1 and 2 The Unicode Consortium Addison Wesley Publishing Company Reading MA Definition of the Languages Supported by the Device for each String USBX has the ability to support multiple languages although English is the
27. media removable flag 0x80 storage parameter ux slave class storage parameter lun 0 ux slave class storage media read tx demo thread flash media read storage parameter ux slave class storage parameter lun 0 ux slave class storage media write tx demo thread flash media write storage parameter ux slave class storage parameter lun 0 ux slave class storage media status tx demo thread flash media status Initialize the device storage class The class is connected with interface 0 status us device stack class register ux system slave class storage name ux device class storage entry ux device class storage thread 0 VOID amp storage parameter Register the OKI USB device controllers available in this system status ux dcd m16965 initialize 0x7BB00000 0 0xB7A00000 If status equals UX SUCCESS registration was successful Troubleshooting USBX is delivered with a demonstration file and a simulation environment It is always a good idea to get the demonstration platform running first either on the target hardware or a specific demonstration platform If the demonstration system does not work try the following things to narrow the problem USBX Version ID The current version of USBX is available both to the user and the application software during run time The programmer can obtain the USBX version from examination of
28. of PIMA This example uses Pictbridge as a client for PIMA x Initialize the first XML object valid in the pictbridge instance Initialize the handle type and file name The storage handle and the object handle have a fixed value of 1 in our implementation object info pictbridge gt ux pictbridge object client object info ux device class pima object format UX DEVICE CLASS PIMA OFC SCRIPT object info ux device class pima object storage id 1 object info ux device class pima object handle id 2 ux utility string to unicode ux pictbridge ddiscovery name object info ux device class pima object filename x Initialize the head and tail of the notification round robin buffers At first the head and tail are pointing to the beginning of the array BEJ pictbridge ux pictbridge event array head pictbridge ux pictbridge event array pictbridge ux pictbridge event array tail pictbridge ux pictbridge event array pictbridge ux pictbridge event array end pictbridge ux pictbridge event array UX PICTBRIDGE MAX EVENT NUMBER Initialialize the pima device parameter pictbridge ux pictbridge pima parameter ux device class pima parameter manufacturer pictbridge gt ux pictbridge dpslocal ux pictbridge devinfo vendor name pictbridge ux pictbridge pima parameter ux device class pima parameter model pict
29. the controller IO ULONG dcd mg Interrupt used by the controller ULONG dcd vbus address Address of the VBUS GPIO The following example is the initialization of USBX in device mode with the storage device class and the OKI controller x Initialize USBX Memory ux system initialize memory pointer 128 1024 0 0 x The code below is required for installing the device portion of USBX status ux device stack initialize sdevice framework high speed DEVICE FRAMEWORK LENGTH HIGH SPEED amp device framework full speed DEVICE FRAMEWORK LENGTH FULL SPEED amp string framework STRING FRAMEWORK LENGTH language id framework LANGUAGE ID FRAMEWORK LENGTH UX NULL If status equals UX SUCCESS installation was successful Store the number of LUN in this device storage instance single LUN storage parameter ux slave class storage parameter number lun 1 Initialize the storage class parameters for reading writing to the Flash Disk storage parameter ux slave class storage parameter lun 0 ux slave class storage media last lba Oxle6bfe storage parameter ux slave class storage parameter lun 0 ux slave class storage media block length 512 storage parameter ux slave class storage parameter lun 0 ux slave class storage media type 0 storage parameter ux slave class storage parameter lun 0 ux slave class storage
30. the controller will wake up when the BUS RESET assert deassert signal is detected Chapter 4 Description of USBX Device Services ux device stack alternate setting get Get current alternate setting for an interface value Prototype UINT ux device stack alternate setting get ULONG interface value Description This function is used by the USB host to obtain the current alternate setting for a specific interface value It is called by the controller driver when a GET INTERFACE request is received Input Parameter interface value Interface value for which the current alternate setting is queried Return Values UX SUCCESS 0x00 The data transfer was completed UX ERROR OxFF Wrong interface value Example ULONG interface value UINT status The following example illustrates this service status ux device stack alternate setting get interface value If status equals UX SUCCESS the operation was successful ux device stack alternate setting set Set current alternate setting for an interface value Prototype UINT ux device stack alternate setting set ULONG interface value ULONG alternate setting value Description This function is used by the USB host to set the current alternate setting for a specific interface value It is called by the controller driver when a SET INTERFACE request is received When the SET INTERFACE is completed the values of the alternate settings are applied to the c
31. the device can have its firmware updated on the fly The DFU class works in 3 steps First the device mounts as normal using the class exported An application on the host Windows or Linux will exercise the DFU class and send a request to reset the device into DFU mode The device will disappear from the bus for a short time enough for the host and the device to detect a RESET sequence and upon restarting the device will be exclusively in DFU mode waiting for the host application to send a firmware upgrade When the firmware upgrade has been completed the host application resets the device and upon re enumeration the device will revert to its normal operation with the new firmware A DFU device framework will look like this UCHAR device framework full speed Device descriptor 0x12 0x01 0x10 0x01 0x00 0x00 0x00 0x40 0x99 0x99 0x00 0X00 0x00 0X007 0x01 0x02 0x03 0x01 Configuration descriptor 0x09 0x02 Oxlb 0x00 0x01 0x01 0x00 OxcO 0x32 Interface descriptor for DFU 0x09 0x04 0x00 0x00 0x00 OxFE 0x00 0x01 0x01 Functional descriptor for DFU 0x09 0x21 OxOf OxE8 0x03 0x40 0x00 0x00 0Ox01 be In this example the DFU descriptor is not associated with any other classes It has a simple interface descriptor and no other endpoints attached to it There is a Functional descriptor that describes the specifics of the DFU capabilities of the device
32. the local system and send it back to the host Parameters pima object object handle buffer object length requested object actual length Example UINT ux pic UX PICTBRIDGE E CLASS PIMA OBJ UX SLAV U U LONG objec LONG objec D F Es UCHAR ULONG UINT Get the pointer to the pictbridge x Check the object handle UX PIC tbridge dpsclient object data get UX SLAV handle OCH length requ pic CT kobj Pointer to the pima class instance Handle of the object Object buffer address Object data length requested by the client to the application Object data length returned by the application E CLASS PIMA pima AR object buffer ULONG object offset ested ULONG object actual length tbridge ect info pima object buffer actu stat TBRIDGE pi the XML script object If the handle is not 1 or 2 Pictbridge instance If this is handle 1 or 2 al length us zj ma gt ux device class pima application we need to return LA this is a JPI EG picture or other object to be printed if object handle UX PICTBRIDGE OBJECT HANDLE HOST RESPONSE object handle UX PICTBRIDGE OBJECT HANDLE CLIENT REQUEST x Check what XML object is requested It is either a request script or a response
33. the storage device UX DEVICE CLASS OC ET OBJECT INFO 0x1008 Return information about an object such as the name of the object its creation date modification date UX DEVICE CLASS OC ET OBJECT 0x1009 Return the data pertaining to a specific object UX DEVICE CLASS OC ET THUMB 0x100A Send the thumbnail if available about an object UX DEVICE CLASS OC ELETE OBJECT 0x100B Delete an object on the media UX DEVICE CLASS OC END OBJECT INFO 0x100C Send to the device information about an object for its creation on the media UX DEVICE CLASS OC END OBJECT 0x100D Send data for an object to the device UX DEVICE CLASS OC FORMAT STORE 0Ox100F Clean the device media UX DEVICE CLASS OC ESET DEVICE 0x0110 Reset the target devic Operation Code Value Description UX DEVICE CLASS PIMA EC CANCEL TRANSACTION 0x4001 Cancels the current transaction UX DEVICE CLASS PIMA EC OBJECT ADDED 0x4002 An object has been added to the device media and can be retrieved by the host UX DEVICE CLASS PIMA EC O
34. 00 OxXFF Data Class Interface Descriptor Requirement 9 bytes 0x09 0x04 0x01 0x00 Ox02 0x0A 0x00 0x00 0x00 First alternate setting Endpoint 1 descriptor 7 bytes 0x07 0x05 0x02 0x02 0x40 0x00 0x00 Endpoint 2 descriptor 7 bytes 0x07 0x05 0x81 0x02 0x40 0x00 0x00 The CDC ACM class uses a composite device framework to group interfaces control and data As a result care should be taken when defining the device descriptor USBX relies on the IAD descriptor to know internally how to bind interfaces The IAD descriptor should be declared before the interfaces and contain the first interface of the CDC ACM class and how many interfaces are attached The CDC ACM class also uses a union functional descriptor which performs the same function as the newer IAD descriptor Although a Union Functional descriptor must be declared for historical reasons and compatibility with the host side it is not used by USBX The initialization of the CDC ACM class expects the following parameters Set the parameters for callback when insertion extraction of a CDC device parameter ux slave class cdc acm instance activate tx demo cdc instance activate parameter ux slave class cdc acm instance deactivate tx demo cdc instance deactivate Initialize the device cdc class This class owns both interfaces starting with 0 status ux device stack class register ux system slave class cdc acm na
35. 02 06 00 NO REFERENCE POSITION FOUND 02 08 00 LOGICAL UNIT COMMUNICATION FAILURE 02 08 01 LOGICAL UNIT COMMUNICATION TIME OUT 02 08 80 LOGICAL UNIT COMMUNICATION OVERRUN 02 3A 00 MEDIUM NOT PRESENT 02 54 00 USB TO HOST SYSTEM INTERFACE FAILURE 02 80 00 INSUFFICIENT RESOURCES 02 FF FF UNKNOWN ERROR 03 02 00 NO SEEK COMPLETE 03 03 00 WRITE FAULT 03 10 00 ID CRC ERROR 03 11 00 UNRECOVERED READ ERROR 03 12 00 ADDRESS MARK NOT FOUND FOR ID FIELD 03 13 00 ADDRESS MARK NOT FOUND FOR DATA FIELD 03 14 00 RECORDED ENTITY NOT FOUND 03 30 01 CANNOT READ MEDIUM UNKNOWN FORMAT 03 31 01 FORMAT COMMAND FAILED 04 40 NN DIAGNOSTIC FAILURE ON COMPONENT NN 80H FFH 05 1A 00 PARAMETER LIST LENGTH ERROR 05 20 00 INVALID COMMAND OPERATION CODE 05 21 00 LOGICAL BLOCK ADDRESS OUT OF RANGE 05 24 00 INVALID FIELD INCOMMAND PACKET 05 25 00 LOGICAL UNIT NOT SUPPORTED 05 26 00 INVALID FIELD IN PARAMETER LIST 05 26 01 PARAMETER NOT SUPPORTED 05 26 02 PARAMETER VALUE INVALID 05 39 00 SAVING PARAMETERS NOT SUPPORT 06 28 00 NOT READY TO READY TRANSITION MEDIA CHANGED 06 29 00 POWER ON RESET OR BUS DEVICE RESET OCCURRED 06 2F 00 COMMANDS CLEARED BY ANOTHER INITIATOR 07 27 00 WRITE PROTECTED MEDIA 0B 4E 00 OVERLAPPED COMMAND ATTEMPTED Multiple SCSI LUN The USBX device storage class supports multiple LUNs It is therefore possible to create a storage device that acts as a CD ROM and a Flash disk at the same time In su
36. 1 RENESAS am d D Cp lt i USBXTM Device Stack User s Manual Software Renesas Synergy M Platform synergygallery renesas com Renesas Electronics Rev 5 7 www renesas com EME em the high performance USB stack User Guide for USBX Device Stack Express Logic Inc 858 613 6640 Toll Free 888 THREADX FAX 858 521 4259 http www expresslogic com 1999 2014 by Express Logic Inc All rights reserved This document and the associated USBX software are the sole property of Express Logic Inc Each contains proprietary information of Express Logic Inc Reproduction or duplication by any means of any portion of this document without the prior written consent of Express Logic Inc is expressly forbidden Express Logic Inc reserves the right to make changes to the specifications described herein at any time and without notice in order to improve design or reliability of USBX The information in this document has been carefully checked for accuracy however Express Logic Inc makes no warranty pertaining to the correctness of this document Trademarks FileX and ThreadX are registered trademarks of Express Logic Inc and USBX NetX picokernel preemption threshold and event chaining are trademarks of Express Logic Inc All other product and company names are trademarks or registered trademarks of their respective holders Warranty Limitations Express Logic Inc makes no warranty of an
37. 131 OTG controller status ux otg lpc3131 initialize 0x19000000 lpc3131 vbus function tx demo change mode callback In this example we initialize the LPC3131 in OTG mode by passing a VBUS function and a callback for mode change from host to slave or vice versa The callback function should simply record the new mode and wake up a pending thread to act up the new state void tx demo change mode callback ULONG mode Simply save the otg mode otg mode mode Wake up the thread that is waiting ux utility semaphore put amp mode change semaphore The mode value that is passed can have the following values e UX OTG MODE IDLE e UX OTG MODE SLAVE e UX OTG MODE HOST The application can always check what the device is by looking at the variable _ux system otg ux system otg device type Its values can be e UX OTG DEVICE A e UX OTG DEVICE B e UX OTG DEVICE IDLE A USB OTG host device can always ask for a role swap by issuing the command Ask the stack to perform a HNP swap with the device We relinquish the host role to A device ux host stack role swap storage ux host class storage device For a slave device there is no command to issue but the slave device can set a state to change the role which will be picked up by the host when it issues a GET STATUS and the swap will then be initiated We are a B device ask for role swap The next GET STATUS from the host w
38. 66 74 76 81 interface descriptor 23 39 54 59 60 64 68 74 102 L N nest 4 14 19 49 51 52 memory insufficient 30 38 NGIX ei enl RR ro te 2 8 62 63 66 Ost rere 5 6 7 8 110 111 112 Picture Transfer Protocol 78 101 PIMA class 78 82 85 86 88 90 93 96 98 101 102 103 107 DIDO s s nn ras 57 58 power management 8 111 PTP responder 4 78 OUEN 76 reset sequence 68 71 RNDIS class 4 64 SCSI logical UNit 15 SOMADMONOGS uro po as de oj 112 slave 19 31 38 46 47 49 50 52 53 55 61 62 65 66 69 70 75 84 111 112 stack EE ara au A fava kako 7 target 10 12 13 14 20 70 73 79 106 ThreadX 2 6 8 10 12 13 14 22 timer Dck eee eee eeeeeeeeeeeeeeeeeeeeeeeeeeeeeees 14 FACE KU aO 8 INI ODE a E o an vasa an 25 USB device 3 4 9 18 21 22 26 49 54 59 64 68 74 78 USB device controller 3 18 USB device stack 3 21 22 USB host stack 107 USB Essais 55 67 68 71 78 USB protocol EE 7 9 USBX pictbridge 5 6 101 USBXKihiread sua a a 14 VBUS 4 18 21 26 35 110 111 VESON e ra kete ab tanko oseto anoj iia 20 Renesas SynergyTM Platform User s Manual Software Publication Date Rev 5
39. BJECT REMOVED 0x4003 An object has been deleted from the device media UX DEVICE CLASS PIMA EC STORE ADDED 0x4004 A media has been added to the device UX DEVICE CLASS PIMA EC STORE REMOVED 0x4005 A media has been deleted from the device UX DEVICE CLASS PIMA EC DEVICE PROP CHANGED 0x4006 Device properties have changed UX DEVICE CLASS PIMA EC OBJECT INFO CHANGED 0x4007 An object information has changed UX DEVICE CLASS PIMA EC DEVICE INFO CHANGE 0x4008 A device has changed UX DEVICE CLASS PIMA EC REQUEST OBJECT TRANSFER 0x4009 The device requests the transfer of an object from the host UX DEVICE CLASS PIMA EC STORE FULL 0x400A Device reports the media is full UX DEVICE CLASS PIMA EC DEVICE RESET 0x400B Device reports it was reset UX DEVICE CLASS PIMA EC STORAGE INFO CHANGED 0x400C Storage information has changed on the device UX DEVICE CLASS PIMA EC CAPTURE COMPLETE 0x400D Capture is completed The USBX PIMA device class uses a TX Thread to listen to PIMA commande from the host A PIMA command is composed of a command block a data block and a status phase The function ux device c
40. ICE FRAMEWORK LENGTH FULL SPEED amp string framework STRING FRAMEWORK LENGTH language id framework LANGUAGE ID FRAMEWORK LENGTH UX NULL x If status equals UX SUCCESS initialization was successful ux device stack interface delete Delete a stack interface Prototype UINT ux device stack interface delete UX SLAVE INTERFACE interface Description This function is called when an interface should be removed An interface is either removed when a device is extracted or following a bus reset or when there is a new alternate setting Input Parameter interface Pointer to the interface to remove Return Value UX SUCCESS 0x00 This operation was successful Example UINT status The following example illustrates this service status ux device stack interface delete interface If status equals UX SUCCESS the operation was successful ux device stack interface get Get the current interface value Prototype UINT ux device stack interface get UINT interface value Description This function is called when the host queries the current interface The device returns the current interface value Input Parameter interface value Interface value to return Return Values UX SUCCESS 0x00 This operation was successful UX ERROR OxFF No interface exists Example ULONG interface value UINT status
41. If this is handle 1 or 2 this is a JPI X7 pima gt ux device class _ pima application T we need to return EG picture or other object to be printed Lf object handle UX PICTBRIDGE OBJECT HANDLE HOST RESPONSE object handle UX PICTBRIDGE OBJECT HANDLE CLIENT REQUEST Check what XML object is requested It is either a request script or a response LE object_handle UX PICTBRIDGE OBJECT HANDLE HOST RESPONSE object info UX SLAVE CLASS PIMA OBJECT pictbridge ux pictbridge object host else object info UX SLAVE CLASS PIMA OBJECT pictbridge ux pictbridge object client else x Get the object info from the job info structure UX SLAVE object info CLASS PIMA OBJECT pictbridge gt ux pictbridge jobinfo ux pictbridge jobinfo object Return the pointer to this object object object info FL We are done return UX SUCCESS ux device class pima object data get Prototype UINT U U Description LONG object ux device class pima object info get UX SLAV UCHAR object buffer LONG object length requested ULONG object actual length handle Return the object data E CLASS PIMA pima ULONG object offset This function is called when the PIMA class needs to retrieve the object data in
42. LASS STORAGE BUFFER SIZE else transfer length total length Copy the Storage Buffer into the transfer request memory ux utility memory copy transfer request gt ux slave transfer request data pointer media memory transfer length x Send the data payload back to the caller status ux device transfer request transfer request transfer length transfer length T If status equals UX SUCCESS the operation was successful Update the buffer address media memory transfer length Update the length to remain total length transfer length ux device stack transfer request abort Cancel a transfer request Prototype UINT ux device stack transfer abort UX SLAVE TRANSFER transfer request ULONG completion code Description This function is called when an application needs to cancel a transfer request or when the stack needs to abort a transfer request associated with an endpoint Parameters transfer request Pointer to the transfer request completion code Error code to be returned to the class waiting for this transfer request to complete Return Value UX SUCCESS 0x00 This operation was successful Example UINT status x The following example illustrates how to abort a transfer when a bus reset has been detected on the bus status ux device stack transfer abort transfer request UX TRANSFER BUS
43. RESET If status equals UX SUCCESS the operation was successful Chapter 5 USBX Device Class Considerations USB Device Storage Class The USB device storage class allows for a storage device embedded in the system to be made visible to a USB host The USB device storage class does not by itself provide a storage solution It merely accepts and interprets SCSI requests coming from the host When one of these requests is a read or a write command it will invoke a pre defined call back to a real storage device handler such as an ATA device driver or a Flash device driver When initializing the device storage class a pointer structure is given to the class that contains all the information necessary An example is given below Store the number of LUN in this device storage instance single LUN storage parameter ux slave class storage parameter number lun 1 x Initialize the storage class parameters for reading writing to the Flash Disk n torage parameter ux slave class storage parameter lun 0 ux slave class storage media last lba Oxle6bfe storage parameter ux slave class storage parameter lun 0 ux slave class storage media block length 512 storage parameter ux slave class storage parameter lun 0 ux slave class storage media type 0 storage parameter ux slave class storage parameter lun 0 ux slave class storage media removable flag 0x80
44. RUE else Reset the Caps lock flag caps lock flag UX FALSE USB Device PIMA Class PTP Responder The USB device PIMA class allows for a USB host system Initiator to connect to a PIMA device Resonder to transfer media files USBX Pima Class is conforming to the USB IF PIMA 15740 class also known as PTP class for Picture Transfer Protocol USBX device side PIMA class supports the following operations Operation code Value Description UX DEVICE CLASS PIMA OC GET DEVICE INFO 0x1001 Obtain the device supported operations and events UX DEVICE CLASS OC PEN SESSION 0x1002 Open a session between the host and the device UX DEVICE CLASS OC OSE SESSION 0x1003 Close a session between the host and the device UX DEVICE CLASS OC GET STORAGE IDS 0x1004 Returns the storage ID for the device USBX PIMA uses one storage ID only UX DEVICE CLASS OC Di HI STORAGE INFO T 0x1005 Return information about the storage object such as max capacity and free space UX DEVICE CLASS OC Di HI NUM OBJECTS 0x1006 Return the number of objects contained in the storage device UX DEVICE CLASS OC ET OBJECT HANDLI EI We 0x1007 Return an array of handles of the objects on
45. VE CLASS CDC ACM cdc acm UCHAR buffer ULONG requested length ULONG actual length Description This function is called when an application needs to read from the OUT data pipe OUT from the host IN from the device Parameters cdc acm Pointer to the cdc class instance buffer Buffer address where data will be stored requested length The maximum length we expect actual length The length returned into the buffer Return Value UX SUCCESS 0x00 This operation was successful UX CONFIGURATION HANDLE UNKNOWN 0x51 Device is no longer in the configured state UX TRANSFER NO ANSWER 0x22 No answer from device The device was probably disconnected while the transfer was pending Example Read from the CDC class status ux device class cdc acm read cdc buffer UX DEMO BUFFER SIZE actual length if status UX SUCCESS return ux device class cdc acm write Writing to a CDC ACM pipe Prototype UINT ux device class cdc acm write UX SLAVE CLASS CDC ACM cdc acm UCHAR buffer ULONG requested length ULONG actual length Description This function is called when an application needs to write to the IN data pipe IN from the host OUT from the device Parameters cdc acm Pointer to the cdc class instance buffer Buffer address where data is stored requested length The length of the buffer to write actual length The length returned into the buffer after write is per
46. ace high 0 pictbridge ux pictbridge pima parameter ux device class pima parameter storage free space image 0 pictbridge ux pictbridge pima parameter ux device class pima parameter storage description _ux pictbridge volume description pictbridge ux pictbridge pima parameter ux device class pima parameter storage volume label _ux pictbridge volume label pictbridge ux pictbridge pima parameter ux device class pima parameter object number get ux pictbridge dpsclient object number get pictbridge ux pictbridge pima parameter ux device class pima parameter object handles get ux pictbridge dpsclient object handles get ct 5 Q pictbridge ux pictbridge pima parameter ux device class pima parameter object info get ux pictbridge dpsclient object info get pictbridge ux pictbridge pima parameter ux device class pima parameter object data get ux pictbridge dpsclient object data get pictbridge ux pictbridge pima parameter ux device class pima parameter object info send ux pictbridge dpsclient object info send pictbridge ux pictbridge pima parameter ux device class pima parameter object data send ux pictbridge dpsclient object data send pictbridge ux pictbridge pima parameter Q ux device class pima parameter object delete ux pictbridge dpsclient object delete
47. ation using both NetX and USBX CDC ECM class will activate the NetX network stack in its usual way but in addition needs to activate the USB network stack as follows Initialize the NetX system nx system initialize Perform the initialization of the network driver This will initialize the USBX network layer ux network driver init The USB network stack needs to be activated only once and is not specific to CDC ECM but is required by any USB class that requires NetX services The CDC ECM class will be recognized by MAC OS and Linux hosts But there is no driver supplied by Microsoft Windows to recognize CDC ECM natively Some commercial products do exist for Windows platforms and they supply their own inf file This file will need to be modified the same way as the CDC ACM inf template to match the PID VID of the USB network device USB Device RNDIS Class The USB device RNDIS class allows for a USB host system to communicate with the device as a ethernet device This class is based on the Microsoft proprietary implementation and is specific to Windows platforms A RNDIS compliant device framework needs to be declared by the device stack An example is found here below unsigned char device framework full speed x Device descriptor 0x02 bDeviceClass RNDIS class code 0x00 bDeviceSubclass RNDIS class sub code 0x00 bDeviceProtocol RNDIS Device protocol idVendor amp idProduct http www linux usb or
48. basic steps to install and use USBX with your ThreadX application Chapter 3 is titled Functional Components of USBX Device Stack Chapter 4 is titled Description of USBX Device Services Chapter 5 is titled USBX Device Class Considerations Chapter 6 is titled USBX DPUMP Class Considerations Chapter 7 is titled USBX Pictbridge Implementation Chapter 8 is titled USBX OTG Chapter 1 Introduction to USBX USBX is a full featured USB stack for deeply embedded applications This chapter introduces USBX describing its applications and benefits USBX features USBX support the three existing USB specifications 1 1 2 0 and OTG 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 all the data transfer types of the USB protocols control bulk interrupt and isochronous USBX supports both the host side and the device side Each side is comprised of three layers e Controller layer e Stack layer e Class layer The relationship between the USB layers is as follows Class Driver Class Driver 9JEMIJOS Host Controller Device Controller Driver river l l l l l l l l l l l l l Host Stack i Device Stack l l l l l l l l l l l l Host Controller Device Controller 1 1 Host sid
49. bject format JPEG picture object gt ux device class pima object format UX DEVICE CLASS PIMA OFC EXIF JPEG a a a object ux device class pima object compressed siz IMAGE LEN object ux device class pima object offset 0 object gt ux device class pima object handle id UX PICTBRIDGE OBJECT HANDLE PRINT object gt ux device class pima object length IMAGE LEN File name is in Unicode ux utility string to unicode JPEG Image object gt ux device class pima object filename And start the job status ux pictbridge dpsclient api start job spictbridge The Pictbridge client now has a print job to do and will fetch the image blocks at a time from the application through the callback defined in the field jobinfo ux pictbridge jobinfo object data read The prototype of that function is defined as ux pictbridge jobinfo object data read Copying a block of data from user space for printing Prototype UINT ux pictbridge jobinfo object data read UX PICTBRIDGE pictbridge UCHAR object buffer ULONG object offset ULONG object length ULONG actual length Description This function is called when the DPS client needs to retrieve a data block to print to the target Pictbridge printer Parameters pictbridge Pointer to the pictbridge class instance object buffer Pointer to object
50. bridge ux pictbridge dpslocal ux pictbridge devinfo product name pictbridge ux pictbridge pima parameter ux device class pima parameter serial number pictbridge gt ux pictbridge dpslocal ux pictbridge devinfo serial no pictbridge ux pictbridge pima parameter ux device class pima parameter storage id 1 pictbridge ux pictbridge pima parameter ux device class pima parameter storage type UX DEVICE CLASS PIMA STC FIXED RAM pictbridge ux pictbridge pima parameter ux device class pima parameter storage file system type UX DEVICE CLASS PIMA FSTC GENERIC FLAT pictbridge ux pictbridge pima parameter ux device class pima parameter storage access capability UX DEVICE CLASS PIMA AC READ WRITE pictbridge ux pictbridge pima parameter ux device class pima parameter storage max capacity low pictbridge ux pictbridge dpslocal ux pictbridge devinfo storage size pictbridge ux pictbridge pima parameter ct x ct ux device class pima parameter storage max capacity high 0 pictbridge ux pictbridge pima parameter ux device class pima parameter storage free space low pictbridge gt Ju ux pictbridge dpslocal ux pictbridge devinfo storage size pictbridge ux pictbridge pima parameter ux device class pima parameter storage free sp
51. by the host Return Values UX SUCCESS 0x00 The data transfer was completed UX ERROR OxFF The transfer was not completed Example ULONG descriptor type ULONG request index ULONG host length UINT status The following example illustrates this service status ux device stack configuration send descriptor type request index host length If status equals UX SUCCESS the operation was successful ux device stack disconnect Disconnect device stack Prototype UINT ux device stack disconnect VOID Description The VBUS manager calls this function when there is a device disconnection The device stack will inform all classes registered to this device and will thereafter release all the device resources Input Parameter None Return Value UX SUCCESS 0x00 The device was disconnected Example UINT status The following example illustrates this service status ux device stack disconnected If status equals UX SUCCESS the operation was successful ux device stack endpoint stall Request endpoint Stall condition Prototype UINT ux device stack endpoint stall UX SLAVE ENDPOINT endpoint Description This function is called by the USB device class when an endpoint should return a Stall condition to the host Input Parameter endpoint The endpoint on which the Stall condition is requested Return Value UX SUCCESS 0x00 This operation was
52. ch a case the initialization would be slightly different Here is an example for a Flash Disk and CD ROM Store the number of LUN in this device storage instance storage parameter ux slave class storage parameter number lun 2 Initialize the storage class parameters for reading writing to the Flash Disk storage parameter ux slave class storage parameter lun 0 ux slave class storage media last lba Ox7bbff torage param e x slave cla ter ux slave class s Ss storage m torage param e x slave cla edia blo torage param ck length e ter ux slave class s ss storage m torage param e x slave cla ter ux slave edia type class s Ss storage m torage param e x slave cla ter ux slave edia rem class s Ss storage m torage parame 0 DH torage param ovable flag e torage param d e torage param e x slave cla ter ux slave dia rea class s Ss storage m tx dem storage parame ux slave cla edia wri torage param te e o thread flash media write SS S tx dem Initialize the CD ROM torage param e x slave cla af ter ux slave class s ss storage m torage param e x slave cla ter ux slave edia las class s Ss storage m torage param e x slave cla edia blo t
53. che safe memory size Input parameters VOID regular memory pool start Beginning of the regular memory pool ULONG regular memory size Size of the regular memory pool VOID cache safe memory pool start Beginning of the cache safe memory pool ULONG cache safe memory size Size of the cache safe memory pool Not all systems require the definition of cache safe memory In such a system the values passed during the initialization for the memory pointer will be set to UX NULL and the size of the pool to 0 USBX will then use the regular memory pool in lieu of the cache safe pool In a system where the regular memory is not cache safe and a controller requires to perform DMA memory like OHCI EHCI controllers amongst others it is necessary to define a memory pool in a cache safe zone Definition of USB Device Controller Only one USB device controller can be defined at any time to operate in device mode The application initialization file should contain this definition The example below refers to the OKI USB device controller For other controllers the function entry definition has to be changed accordingly The following line performs the definition of an OKI controller ux dcd m16965 initialize 0x7BBOO0O000 0 OxB7A00000 The USB device initialization has the following prototype UINT ux dcd m16965 initialize ULONG dcd io ULONG dcd irg ULONG dcd vbus address with the following parameters ULONG dcd io Address of
54. class hid parameter callback tx demo thread hid callback Initialize the device hid class The class is connected with interface 0 status ux device stack class register ux system slave class hid name ux device class hid entry 1 0 VOID amp hid parameter if status UX SUCCESS return The application needs to pass to the HID class a HID report descriptor and its length The report descriptor is a collection of items that describe the device For more information on the HID grammar refer to the HID USB class specification In addition to the report descriptor the application passes a call back when a HID event happens The USBX HID class supports the following standard HID commands from the host Command name Value Description UX DEVICE CLASS HID COMMAND GET REPORT 0x01 Get a report from the device UX DEVICE CLASS HID COMMAND GET IDLE 0x02 G the idle frequency of the interrupt endpoint E the device UX DEVICE CLASS HID COMMA H mi EPORT 0x09 Set a report to the device e UX DEVICE CLASS HID COMMAND GET PROTOCOL 0x03 Get the protocol running on e ND S ND S UX DEVICE CLASS HID COMMA ET IDLE 0x0a S the idle frequency of the interrupt endpoint UX DEVICE CLASS HID COMMAND SET PROTOCOL 0x0b Get the
55. d UX THREAD STACK SIZE This value is the size of the stack in bytes for the USBX threads It can be typically 1024 or 2048 bytes depending on the processor used and the host controller UX THREAD PRIORITY ENUM This is the ThreadX priority value for the USBX enumeration threads that monitors the bus topology UX THREAD PRIORITY CLASS This is the ThreadX priority value for the standard USBX threads UX THREAD PRIORITY KEYBOARD This is the ThreadX priority value for the USBX HID keyboard class UX THREAD PRIORITY DCD This is the ThreadX priority value for the device controller thread UX NO TIME SLICE If defined to 1 the ThreadX target port does not use time slice UX MAX SLAVE LUN This value represents the current number of SCSI logical units represented in the device storage class driver UX SLAVE REQUEST CONTROL MAX LENGTH This value represents the maximum number of bytes received on a control endpoint in the device stack The default is 256 bytes but can be reduced in memory constraint environments UX SLAVE REQUEST DATA MAX LENGTH This value represents the maximum number of bytes received on a bulk endpoint in the device stack The default is 4096 bytes but can be reduced in memory constraint environments USBX Device Stack USBX Device Controllers Source Code Tree The USBX files are provided in several directories USBX Core USBX Host Stack USBX Hos
56. dpoint buffer and posts a transaction on this endpoint waiting for the host to issue a request to read from this endpoint This provides a loopback mechanism between the Bulk Out and Bulk In endpoints Chapter 7 USBX Pictbridge implementation UBSX supports the full Pictbridge implementation both on the host and the device Pictbridge sits on top of USBX PIMA class on both sides The PictBridge standards allows the connection of a digital still camera or a smart phone directly to a printer without a PC enabling direct printing to certain Pictbridge aware printers When a camera or phone is connected to a printer the printer is the USB host and the camera is the USB device However with Pictbridge the camera will appear as being the host and commands are driven from the camera The camera is the storage server the printer the storage client The camera is the print client and the printer is of course the print server Pictbridge uses USB as a transport layer but relies on PTP Picture Transfer Protocol for the communication protocol The following is a diagram of the commands responses between the DPS client and the DPS server when a print job occurs Li 4 GC ge d Storage Device Storage Server Print Client K Application starts print Get File Data SCH DPS_ConfigurePrintServices DPS_GetCapabilities DPS StartJob DPS GetFile DPS GetFilelnfo DPS NotifyDeviceStatus
57. e Device side l Product Highlights Complete ThreadX processor support No royalties Complete ANSI C source code Real time performance Responsive technical support Multiple class support Multiple class instances Integration of classes with ThreadX FileX and NetX Support for USB devices with multiple configuration Support for USB composite devices Support for USB power management Support for USB OTG Export trace events for TraceX Powerful Services of USBX 9JEMPJEH Complete USB Device Framework Support USBX can support the most demanding USB devices including multiple configurations multiple interfaces and multiple alternate settings Easy To Use APIS USBX provides the very best deeply embedded USB stack in a manner that is easy to understand and use The USBX API makes the services intuitive and consistent By using the provided USBX class APIs the user application does not need to understand the complexity of the USB protocols Chapter 2 USBX Installation Host Considerations Computer Type Embedded development is usually performed on IBM PC or Unix host computers After the application is compiled linked and located on the host it is downloaded to the target hardware for execution Download Interfaces Usually the target download is done over an RS 232 serial interface although parallel interfaces USB and Ethernet are becoming more popular See the development tool documentation for availabl
58. e host that matches the device descriptor ExpressLogic supplies a template for the RNDIS class and it can be found in the usbx windows host files directory For more recent version of Windows the file RNDIS Template inf should be used This file needs to be modified to reflect the PID VID used by the device The PID VID will be specific to the final customer when the company and the product are registered with the USB IF In the inf file the fields to modify are located here ELogicDevices SELogicDevices RNDIS USB VID xxxx amp PID 0000 ogicDevices NT 5 1 ELogicDevice RNDIS NT 5 1 USB VID xxxx amp PID 0000 Pe m 3 pl In the device framework of the RNDIS device the PID VID are stored in the device descriptor see the device descriptor declared above When a USB host systems discovers the USB RNDIS device it will mount a network interface and the device can be used with network protocol stack See the host Operating System for reference USB Device DFU Class The USB device DFU class allows for a USB host system to update the device firmware based on a host application The DFU class is a USB IF standard class USBX DFU class is relatively simple It device descriptor does not require anything but a control endpoint Most of the time this class will be embedded into a USB composite device The device can be anything such as a storage device or a comm device and the added DFU interface can inform the host that
59. e options Debugging Tools Debugging is done typically over the same link as the program image download A variety of debuggers exist ranging from small monitor programs running on the target through Background Debug Monitor BDM and In Circuit Emulator ICE tools Of course the ICE tool provides the most robust debugging of actual target hardware Required Hard Disk Space The source code for USBX is delivered in ASCII format and requires approximately 500 KBytes of space on the host computer s hard disk Please review the supplied readme usbx txt file for additional host system considerations and options Target Considerations USBX requires between 24 KBytes and 64 KBytes of Read Only Memory ROM on the target in host mode The amount of memory required is dependent on the type of controller used and the USB classes linked to USBX Another 32 KBytes of the target s Random Access Memory RAM are required for USBX global data structures and memory pool This memory pool can also be adjusted depending on the expected number of devices on the USB and the type of USB controller The USBX device side requires roughly 10 12K of ROM depending on the type of device controller The RAM memory usage depends on the type of class emulated by the device USBX also relies on ThreadX semaphores mutexes and threads for multiple thread protection and I O suspension and periodic processing for monitoring the USB bus topology Product Distributio
60. e thread 0 USB Device CDC ACM Class The USB device CDC ACM class allows for a USB host system to communicate with the device as a serial device This class is based on the USB standard and is a subset of the CDC standard A CDC ACM compliant device framework needs to be declared by the device stack An example is found here below unsigned char device framework full speed x Device descriptor 18 bytes 0x02 bDeviceClass CDC class code 0x00 bDeviceSubclass CDC class sub code 0x00 bDeviceProtocol CDC Device protocol idVendor amp idProduct http www linux usb org usb ids 0x12 Ox01 Ox10 Ox01 OxEF 0x02 OxO1 0x08 0x84 0x84 0x00 0x00 0x00 0x01 0x01 0x02 0x03 0x01 Configuration 1 descriptor 9 bytes 0x09 0x02 Ox4b 0x00 0x02 0x01 0x00 0x40 0x00 Interface association descriptor 8 bytes 0x08 0x0b 0x00 0x02 0x02 0x02 0x00 0x00 Communication Class Interface Descriptor Requirement 9 bytes x 0x09 0x04 0x00 0x00 0x01 0x02 0x02 0x01 0x00 Header Functional Descriptor 5 bytes 0x05 0x24 0x00 0x10 Ox01 ACM Functional Descriptor 4 bytes 0x04 0x24 0x02 0x0f Union Functional Descriptor 5 bytes 0x05 0x24 0x06 0x00 Master interface 0x01 x Slave interface Call Management Functional Descriptor 5 bytes 0x05 0x24 0x01 0x03 0x01 Data interface A Endpoint 1 descriptor 7 bytes 0x07 0x05 0x83 0x03 0x08 0x
61. evice HID Class The USB device HID class allows for a USB host system to connect to a HID device with specific HID client capabilities USBX HID device class is relatively simple compared to the host side It is closely tied to the behavior of the device and its HID descriptor Any HID client requires first to define a HID device framework as the example below UCHAR device framework full speed Device descriptor 0x12 Ox01 Ox10 Ox01 0x00 Ox00 03007 Ox08 Ox81 OxOA Ox01 Ox01 0x007 Ox00 0x00 OxOO 0x00 0x01 Configuration descriptor 0x09 0x02 0x22 0x00 0x01 0x01 0x00 OxcO 0x32 Interface descriptor 0x09 0x04 0x00 0x00 0x01 0x03 0x00 0x00 0x00 HID descriptor 0x097 0x21 0xl0 Ox01 0x21 Ox01 0x22 Ox3f 0X007 Endpoint descriptor Interrupt 0x07 0x05 0x81 0x03 0x08 0x00 0x08 he The HID framework contains an interface descriptor that describes the HID class and the HID device subclass The HID interface can be a standalone class or part of a composite device Follows is a HID descriptor and the interrupt endpoint The initialization of the HID class is as follow using a USB keyboard as an example Initialize the hid class parameters for a keyboard hid parameter ux device class hid parameter report address hid keyboard report hid parameter ux device class hid parameter report length HID KEYBOARD REPORT LENGTH hid parameter ux device
62. face Descriptor Requirement 9 bytes 0x09 0x04 0x00 0x00 0x01 0x02 0x06 0x00 0x00 Header Functional Descriptor 5 bytes 0x05 0x24 Ox00 Ox10 0X01 ECM Functional Descriptor 13 bytes OxOD 0x24 OxOF 0x04 0x00 0x00 0x00 0x00 OxEA 0x05 0x00 0x00 0x00 Union Functional Descriptor 5 bytes 0x05 0x24 0x06 0x00 0x01 Endpoint descriptor Interrupt 0x07 0x05 0x83 0x03 0x08 0x00 0x08 Data Class Interface Descriptor Alternate Setting 0 0 endpoints 9 bytes 0x09 0x04 0x01 0x00 0x00 0x0A 0x00 0x00 0x00 Data Class Interface Descriptor Alternate Setting 1 2 endpoints 9 bytes 0x09 0x04 0x01 0x01 0x02 0x0A 0x00 0x00 0x00 First alternate setting Endpoint 1 descriptor 7 bytes 0x07 0x05 0x02 0x02 0x40 0x00 0x00 Endpoint 2 descriptor 7 bytes 0x07 0x05 0x81 0x02 0x40 0x00 0x00 The CDC ECM class uses a very similar device descriptor approach to the CDC ACM and also requires a IAD descriptor See the CDC ACM class for definition In addition to the regular device framework the CDC ECM requires special string descriptors An example is given below unsigned char string framework Manufacturer string descriptor Index 1 Express Logic 0x09 0x04 0x01 OxOo 0x45 0x78 0x70 0x72 0x65 0x73 0x20 Ox4c Ox6f 0x67 0x69 0x63 EL CDCECM Device Product string descriptor Index 2 0x09
63. ferently when connected to a high speed or full speed host The typical differences are the size of each endpoint and the power consumed by the device The definition of the device component takes the form of a byte string that follows the USB specification The definition is contiguous and the order in which the framework is represented in memory will be the same as the one returned to the host during enumeration Following is an example of a device framework for a high speed USB Flash Disk define DEVICE FRAMEWORK LENGTH HIGH SPEED 60 UCHAR device framework high speed Device descriptor 0x12 0x01 0x00 0x02 0x00 0x00 0x00 0x40 0x0a 0x07 0x25 0x40 0x01 0x00 0x01 0x02 0x03 0X01 Device qualifier descriptor 0x0a 0x06 0x00 0x02 0x00 0x00 0x00 0x40 0x01 0x00 Configuration descriptor 0x09 0x02 0x20 0x00 0x01 0x01 0x00 OxcO 0x32 Interface descriptor 0x09 0x04 0x00 0x00 0x02 0x08 0x06 0x50 0x00 Endpoint descriptor Bulk Out 0x07 0x05 0x01 0x02 0x00 0x02 0x00 Endpoint descriptor Bulk In 0x07 0x05 0x82 0x02 0x00 0x02 0x00 D I Definition of the Strings of the Device Framework Strings are optional in a device Their purpose is to let the USB host know about the manufacturer of the device the product name and the revision number through Unicode strings The main strings are indexes embedded in the
64. formed Return Value UX SUCCESS 0x00 This operation was successful UX CONFIGURATION HANDLE UNKNOWN 0x51 Device is no longer in the configured state UX TRANSFER NO ANSWER 0x22 No answer from device The device was probably disconnected while the transfer was pending Example Write to the CDC class bulk in pipe status ux device class cdc acm write cdc buffer UX DEMO BUFFER SIZE actual length if status UX SUCCESS return USB Device CDC ECM Class The USB device CDC ECM class allows for a USB host system to communicate with the device as a ethernet device This class is based on the USB standard and is a subset of the CDC standard A CDC ACM compliant device framework needs to be declared by the device stack An example is found here below unsigned char device framework full speed x Device descriptor 18 bytes 0x02 bDeviceClass CDC ECM class code 0x06 bDeviceSubclass CDC ECM class sub code 0x00 bDeviceProtocol CDC ECM Device protocol idVendor amp idProduct http www linux usb org usb ids 0x3939 idVendor ExpressLogic test GI 0x12 0x01 0x10 0x01 0x02 0x00 0x00 0x08 0x39 0x39 0x08 0x08 0x00 0x01 0x01 0x02 03 0x01 Configuration 1 descriptor 9 bytes 0x09 0x02 0x58 0x00 0x02 0x01 0x00 0x40 0x00 Interface association descriptor 8 bytes 0x08 0x0b 0x00 0x02 0x02 0x06 0x00 0x00 Communication Class Inter
65. g usb ids 0x3939 idVendor ExpressLogic test GIZ 0x12 0x01 0x10 0x01 0x02 0x00 0x00 0x40 Oxb4 0x04 0x27 0x11 0x00 0x01 0x01 0x02 0x03 0x01 Configuration 1 descriptor 0x09 0x02 0x4b 0x00 0x02 0x01 0x00 0x40 0x00 Interface association descriptor 8 bytes 0x08 Ox0b 0x00 0x02 0x02 0x02 0x00 0x00 Communication Class Interface Descriptor Requirement 0x09 0x04 0x00 0x00 0x01 0x02 0x02 0x00 0x00 Header Functional Descriptor 0x05 0x24 0x00 0x10 0x01 ACM Functional Descriptor 0x04 0x24 0x02 0x00 Union Functional Descriptor 0x05 0x24 0x06 0x00 0x01 Call Management Functional Descriptor 0x05 0x24 0x01 0x00 0x01 Endpoint 1 descriptor 0x07 0x05 0x83 0x03 0x08 0x00 OxFF Data Class Interface Descriptor Requirement 0x09 0x04 0x01 0x00 0x02 0x0A 0x00 0x00 0x00 First alternate setting Endpoint 1 descriptor 0x07 0x05 0x02 0x02 0x40 0x00 0x00 Endpoint 2 descriptor 0x07 0x05 0x81 0x02 0x40 0x00 0x00 be The RNDIS class uses a very similar device descriptor approach to the CDC ACM and CDC ECM and also requires a IAD descriptor See the CDC ACM class for definition and requirements for the device descriptor The activation of the RNDIS class is as follows Set the parameters for callback when insertion extraction of a CDC device Set to NULL
66. hen an interface has been selected by the host and the device stack needs to search for a device class to own this interface instance Input Parameter interface Pointer to the interface created Return Values UX SUCCESS 0x00 This operation was successful UX NO CLASS MATCH 0x57 No class exists for this interface Example UINT status The following example illustrates this service status ux device stack interface start interface If status equals UX SUCCESS the operation was successful ux device stack transfer request Request to transfer data to the host Prototype UINT ux device stack transfer request UX SLAVE TRANSFER transfer request ULONG slave length ULONG host length Description This function is called when a class or the stack wants to transfer data to the host The host always polls the device but the device can prepare data in advance Parameters transfer request Pointer to the transfer request slave length Length the device wants to return host length Length the host has requested Return Values UX SUCCESS 0x00 This operation was successful UX ERROR OxXFF Transport error Example UINT status The following example illustrates how to transfer more data than an application requests while total length How much can we send in this transfer if total length UX SLAVE CLASS STORAGE BUFFER SIZE transfer length UX SLAVE C
67. ient to print to the local printer Parameters pictbridge object buffer object offset total length length Return Value UX SUCCESS 0x00 UX_ERROR 0x01 Example Copy the object data Pointer to the pictbridge class instance Pointer to object buffer Where we are starting to read the data block Entire length of object Length of this buffer This operation was successful The application could not print data UINT tx demo object data write UX PICTBRIDGE pictbridge UCHAR object buffer ULONG offset ULONG total length ULONG length UINT status Send the data to the local printer status local printer data send object buffer length We have printed the requested data Return status return status Chapter 8 USBX OTG USBX supports the OTG functionalities of USB when an OTG compliant USB controller is available in the hardware design USBX supports OTG in the core USB stack But for OTG to function it requires a specific USB controller USBX OTG controller functions can be found in the usbx otg directory The current USBX version only supports the NXP LPC3131 with full OTG capabilities The regular controller driver functions host or device can still be found in the standard USBX usbx_ device controllers and usbx host controllers but the usbx otg directory contains the specific OTG functions associated with the USB controller There are 4 categories of functions fo
68. ill get the status change and do the HNP _ux system otg ux system otg slave role swap flag UX OTG HOST REQUEST FLAG Index API USB device class 3 22 USB device stack 3 22 bulk in 23 39 40 100 103 bulk OW sss sas staki 23 39 100 102 callback 4 50 55 61 62 65 70 74 76 77 82 92 105 108 111 112 CDC ACM class 54 55 56 61 65 CDC ECM class 4 59 class container 30 class instance 8 57 58 76 77 85 86 88 90 93 96 98 106 109 Class aver 7 configuration 4 8 14 30 32 33 34 70 configuration descriptor 23 39 68 74 102 Controller laver 7 device descriptor 22 23 39 54 59 64 68 74 102 device framework 3 22 24 25 40 device side 7 10 17 22 34 78 99 DFU class 4 68 69 70 71 73 DIP UMP Asset sa 5 6 99 100 EHCI controller 18 endpoint descriptor 23 39 40 59 74 102 103 FIle E 2 8 13 firmware so cu kk ds 68 70 71 73 functional descriptor 55 68 69 handle 26 82 86 87 88 90 91 92 93 96 97 98 105 HID Class in 4 74 75 76 77 hostconltollerssssj vasa au ue 14 e Ce sme e 7 22 55 74 80 host eeneg 17 initialization 13 18 22 26 41 51 55 61 62 63
69. interfaces status ux device stack class register ux system slave class rndis name ux device class rndis entry 1 0 parameter As for the CDC ECM the RNDIS class requires 2 nodes one local and one remote but there is no requirement to have a string descriptor describing the remote node However due to Microsoft proprietary messaging mechanism some extra parameters are required First the vendor ID has to be passed Likewise the driver version of the RNDIS A vendor string must also be given The RNDIS class has built in APIs for transferring data both ways but they are hidden to the application as the user application will communicate with the USB Ethernet device through NetX The USBX RNDIS class is closely tied to ExpressLogic NetX Network stack An application using both NetX and USBX RNDIS class will activate the NetX network stack in its usual way but in addition needs to activate the USB network stack as follows Initialize the NetX system nx system initialize Perform the initialization of the network driver This will initialize the USBX network layer ux network driver init The USB network stack needs to be activated only once and is not specific to RNDIS but is required by any USB class that requires NetX services The RNDIS class will not be recognized by MAC OS and Linux hosts as it is specific to Microsoft operating systems On windows platforms a inf file needs to be present on th
70. ion of the PIMA device class 75 ux device class pima object _ number_get n 79 ux device class pima object handles get 80 ux device class pima object info get 82 ux device class pima object data get 84 ux device class pima object info send 87 ux device class pima object data send 89 ux device class pima object delete cs eeesssssesesseeessesssesesesseeseseseees 91 Chapter 6 USBX DPUMP Class Considerations 92 USBX DPUMP Device Class 93 Chapter 7 USBX Pictbridge implementation 94 Pictbridge client implementation EEN 95 ux pictbridge jobinfo object data read 99 Pictbridge host implementation 100 ux_pictbridge application object data wrte sssssssssseseeeseseeeeeees 102 Chapters USBXO TG sss o e ee ee aieeaii 103 About This Guide This guide provides comprehensive information about USBX the high performance USB foundation software from Express Logic Inc It is intended for the embedded real time software developer The developer should be familiar with standard real time operating system functions the USB specification and the C programming language For technical information related to USB see the USB specification and USB Class specifications that can be downloaded at http www USB org developers Organization Chapter 1 contains an introduction to USBX Chapter 2 gives the
71. lass The device stack will issue a UX SLAVE CLASS COMMAND CHANGE to the class that owns this interface to reflect the change of alternate setting Parameters interface value Interface value for which the current alternate setting is set alternate setting value The new alternate setting value Return Values UX SUCCESS 0x00 The data transfer was completed UX INTERFACE HANDLE UNKNOWN 0x52 No interface attached UX ERROR OxFF Wrong interface value Example ULONG interface value ULONG alternate setting value The following example illustrates this service status ux device stack alternate setting set interface value alternate setting value If status equals UX SUCCESS the operation was successful ux device stack class register Register a new USB device class Prototype UINT ux device stack class register UCHAR class name UINT class entry function struct UX SLAVE CLASS COMMAND STRUCT ULONG configuration number ULONG interface number VOID parameter Description This function is used by the application to register a new USB device class This registration starts a class container and not an instance of the class A class should have an active thread and be attached to a specific interface Some classes expect a parameter or parameter list For instance the device storage class would expect the geometry of the storage device it is trying to emulate The paramete
72. lass The PIMA device class needs some parameters supplied by the application during the initialization The following parameters describe the device and storage information e ux device class pima manufacturer e ux device class pima model e ux device class pima device version e ux device class pima serial number e ux device class pima storage id e ux device class pima storage type e ux device class pima storage file system typ e ux device class pima storage access capability e ux device class pima storage max capacity low e ux device class pima storage max capacity high e ux device class pima storage free space low e ux device class pima storage free space high e ux device class pima storage fr space imag e ux device class pima storage description e ux device class pima storage volume label The PIMA class also requires the registration of callback into the application to inform the application of certain events or retrieve store data from to the local media The callbacks are e ux device class pima object number get e ux device class pima object handles get e ux device class pima object info get e ux device class pima object data get e ux device class pima object info send e ux device class pima object data send e ux device class pima object delete The following example shows how to initialize the client side
73. lass pima thread posts a request to the stack to receive a PIMA command from the host side The PIMA command is decoded and verified for content If the command block is valid it branches to the appropriate command handler Most PIMA commands can only be executed when a session has been opened by the host The only exception is the command ux DEVICE CLASS PIMA OC GET DEVICE INFO With USBX PIMA implementation only one session can be opened between an Initiator and Responder at any time All transactions within the single session are blocking and no new transaction can begin before the previous one completed PIMA transactions are composed of 3 phases a command phase an optional data phase and a response phase If a data phase is present it can only be in one direction The Initiator always determines the flow of the PIMA operations but the Responder can initiate events back to the Initiator to inform status changes that happened during a session The following diagram shows the transfer of a data object between the host and the PIMA device class Ze gt N re N PIMA device class Application amp by PIMA Host classs Application CG Get Device Info Open Session Application Gets Object pima gt ux device class pima object data get Object Data Object Data Close Session Initialization of the PIMA device c
74. me ux device class cdc acm entry 1 0 parameter The 2 parameters defined are callback pointers into the user applications that will be called when the stack activates or deactivate this class The CDC ACM is based on a USB IF standard and is automatically recognized by MAC Os and Linux operating systems On Windows platforms this class requires a inf file ExpressLogic supplies a template for the CDC ACM class and it can be found in the usbx windows host files directory For more recent version of Windows the file CDC ACM Template Win7 64bit inf should be used This file needs to be modified to reflect the PID VID used by the device The PID VID will be specific to the final customer when the company and the product are registered with the USB IF In the inf file the fields to modify are located here DeviceList DESCRIPTIONS DriverInstall USB VID 8484 amp PID 0000 DeviceList NTamd64 DESCRIPTIONS DriverInstall USB VID 8484 amp PID 0000 In the device framework of the CDC ACM device the PID VID are stored in the device descriptor see the device descriptor declared above When a USB host systems discovers the USB CDC ACM device it will mount a serial class and the device can be used with any serial terminal program See the host Operating System for reference The CDC ACM class APIs are defined below ux device class cdc acm read Read from CDC ACM pipe Prototype UINT ux device class cdc acm read UX SLA
75. n Two USBX packages are available standard and premium The standard package includes minimal source code while the premium package contains the complete USBX source code Either package is shipped on a single CD The content of the distribution CD depends on the target processor development tools and the USBX package Following is a list of the important files common to most product distributions readme usbx txt This file contains specific information about the USBX port including information about the target processor and the development tools ux api h This C header file contains all system equates data structures and service prototypes ux port h This C header file contains all development tool specific data definitions and structures ux lib This is the binary version of the USBX C library It is distributed with the standard package demo usbx c The C file containing a simple USBX demo All filenames are in lower case This naming convention makes it easier to convert the commands to Unix development platforms Installation of USBX is straightforward The following general instructions apply to virtually any installation However the readme usbx generic txt file should be examined for changes specific to the actual development tool environment Step 1 Backup the USBX distribution disk and store it in a safe location Step2 Use the same directory in which you previously installed ThreadX on the host hard drive All
76. ntaining the index of the descriptor Byte containing the length of the descriptor string 0x0904 for US Manufacturer string descriptor Index 1 0x09 03047 Ox01 OxOo 0x45 0x78 0x70 0x72 0x65 0x73 0x20 Ox4c Ox6f 0x67 0x69 0x63 Product string descriptor Index 2 0x09 0x04 0x02 OxOo Ox4D Ox4C 0x36 0x39 0x36 0x35 0x30 0x30 0x20 0x53 0x44 Ox4B Serial Number string descriptor Index 3 0x09 0x04 0x03 0x04 0x30 0x30 0x30 0x31 a language besides English Multiple languages are supported on the device the Unicode language code must to add to the language_id framework array and the length be appended adjusted accordingly define LANGUAGE ID FRAMEWORK LENGTH 2 UCHAR language id framework wi 0x04 English 0x09 D I The application can request a call back when the controller changes its state The two main states for the controller are UX DEVICE SUSPENDED UX DEVICE RESUMED If the application does not need Suspend Resume signals it would supply a UX NULL function UINT status x The code below is required for installing the device portion of USBX example wf status There is no call back for device status change in this ux_device_stack_initialize device framework high speed D EVIC E FRAM EWORK LI ENGTH HIGH SPE ED amp device framework full speed DEV
77. ociation ULONG object handles array ULONG object handles max number This function is called when the PIMA class needs to retrieve the object handles array in the local system and send it back to the host Parameters pima Pointer to the pima class instance object handles format code Format code for the handles object handles association Object association code object handle array Address where to store the handles object handles max number Maximum number of handles in the array Example UINT ux pictbridge dpsclient object handles get UX SLAVE CLASS PIMA pima UX PICTBRIDGE pictbridge UX SLAVE CLASS PIMA OBJECT object info pic Set the Get the pointer to the Pictbridge instance ictbridge UX PICTBRIDGE pima gt ux device class pima application pictbridge ux pictbridge pima VOID pima code and associations pima pointer to the pictbridge instance ULONG object handles format code ULONG object handles association ULONG object handles array ULONG object handles max number y We say we have one object but the caller might specify differnt format object_info pictbridge gt ux pictbridge_object_client Insert in the array the number of found handles so far 0 0 ux utility long put UCHAR object_handles_array Check th type demanded if object_handles_format_code object_handles_format_code
78. orage param t lba e e torage param ck length ter ux slave class s Ss storage m torage param e ux slave class s ter ux slave edia typ class s torage param u e x slave class s ter ux slave torage media removable flag class s torage param e e DH Wu torage parame torage parame torage param e ux slave cla ter ux slave torage media read class s SS S tx dem storage parame ux slave cla torage media write o thread cdrom media write tx dem torage parame SS S tx dem Initialize class is connected with interface 0 status tx demo 0x04 O ter l 21 25 ter l ter l ter l ter l ter l caaf ter l ter l ter l ter l ter l 2048 0x80 thread f 0x80 thread cd n 0 lash media read ter ux slave class storage parameter lun 0 torage media status o thread flash media status the storage class LUN parameters for reading writing to ALLT n 1 rom media read n 1 ter ux slave class storage parameter lun 1 torage media status o thread cdrom media status the device storage class for a Flash disk and CD ROM The ux device stack class register ux system slave class storage name ux device class storage entry VOID x storage parameter ux device class storag
79. per se but rather an example that illustrates how to create a simple device by using 2 bulk pipes and sending data back and forth on these 2 pipes The DPUMP class could be used to start a custom class or for legacy RS232 devices USB DPUMP flow chart Host Application DPUMP Host Class USB HostStack USB Device Stack DPUMP Device Class Thread Write a packet Wait for a packet ux host class dpump write Ux host stack transfer request ux device stack transfer request Wait for OUT packet on Bulk Out I lt DATA SENT OVER USB T Wait for transfer completion Wait for transfer _ux_host_class_dpump_read _ux_device_stack_transfer_request completion E m a Receive transfer status and data length sent Write a packet l Receive a packet l a l l l Wait for IN packet on Bulk IN _ux host stack transfer request l DATA SENT OVER USB get Wait for transfer Wait for transfer S completion completion pr d Receive transfer status data packet and data length received USBX DPUMP Device Class The device DPUMP class uses a thread which is started upon connection to the USB host The thread waits for a packet coming on the Bulk Out endpoint When a packet is received it copies the content to the Bulk In en
80. pima object handle id object handle Get the pointer to the object buffer pima object buffer object info gt ux device class pima object buffer x Check the phase We should wait for the object to be completed and the response sent back before parsing the object if phase UX DEVICE CLASS PIMA OBJECT TRANSFER PHASE ACTIVE Copy the demanded object data portion ux utility memory copy pima object buffer object offset object buffer object length Save the length of this object object info ux device class pima object length object length We are not done yet return UX SUCCESS else Completion of transfer We are done return UX SUCCESS ux device class pima object delete Prototype Delete a local object UINT ux device class pima object delete UX SLAVE CLASS PIMA pima ULONG object handle Description This function is called when the PIMA class needs to delete an object on the local storage Parameters pima Pointer to the pima class instance object handle Handle of the object Example UINT ux pictbridge dpsclient object delete UX SLAV E CLASS PIMA pima ULONG object handle Delete the object pointer by the handle Chapter 6 USBX DPUMP Class Considerations USBX contains a DPUMP class for the host and device side This class is not a standard class
81. protocol running on the device The Get and Set report are the most commonly used commands by HID to transfer data back and forth between the host and the device Most commonly the host sends data on the control endpoint but can receive data either on the interrupt endpoint or by issuing a GET REPORT command to fetch the data on the control endpoint The HID class can send data back to the host on the interrupt endpoint by using the ux device class hid event set function Its definition is below ux device class hid event set Setting an event to the HID class Prototype UINT ux device class hid event set UX SLAVE CLASS HID hid UX SLAVE CLASS HID EVENT hid event Description This function is called when an application needs to send a HID event back to the host The function is not blocking it merely puts the report into a circular queue and returns to the application Parameters hid Pointer to the hid class instance hid event Pointer to structure of the hid event Return Value UX SUCCESS 0x00 This operation was successful UX ERROR 0x01 Error on round robin queue Example Inser hid even a key into the keyboard event Length is fixed to 8 ux device class hid event length 8 AR First byte is a modifier byte hid event ux device class hid event buffer 0 0 Second byte is reserved hid event ux
82. r an OTG controller in addition to the usual host device functions VBUS specific functions Start and Stop of the controller USB role manager Interrupt handlers VBUS functions Each controller needs to have a VBUS manager to change the state of VBUS based on power management requirements Usually this function only performs turning on or off VBUS Start and Stop the controller Unlike a regular USB implementation OTG requires the host and or the device stack to be activated and deactivated when the role changes USB role Manager The USB role manager receives commands to change the state of the USB There are several states that need transitions to and from State Value Description UX OTG IDLE 0 The device is Idle Usually not connected to anything UX OTG IDLE TO HOST Device is connected with type A connector UX OTG IDLE TO SLAVE Device is connected with type B connector UX OTG HOST TO IDLE Host device got disconnected UX OTG HOST TO SLAVE Role swap from Host to Slave UX OTG SLAVE TO IDLE Slave device is disconnected OO SIG IV UX OTG SLAVE TO HOST Role swap from Slave to Host Interrupt handlers Both host and device controller drivers for OTG needs different interrupt handlers to monitor signals beyond traditional USB interrupts in particular signals due to SRP and VBUS How to initialize a USB OTG controller We use the NXP LPC3131 as an example here Initialize the LPC3
83. r field is therefore dependent on the class requirement and can be a value or a pointer to a structure filled with the class values Parameters class entry function The entry function of the class Configuration number The configuration number this class is attached to interface number The interface number this class is attached to parameter A pointer to a class specific parameter list Return Values UX SUCCESS 0x00 The data transfer was completed UX MEMORY INSUFFICIENT 0x52 Not enough memory UX THREAD ERROR OxFF Cannot create a class thread Example UINT status The following example illustrates this service x Initialize the device storage class The class is connected with interface 1 status ux device stack class register ux system slave class storage name ux device class storage entry li dno VOID amp parameter If status equals UX SUCCESS the operation was successful ux device stack configuration get Get the current configuration Prototype UINT ux device stack configuration get VOID Description This function is used by the host to obtain the current configuration running in the device Input Parameter None Return Value UX SUCCESS 0x00 The data transfer was completed Example UINT status The following example illustrates this service status ux device stack configuration get If status equals UX SUCCESS the operation was successful
84. read dfu read dfu parameter ux slave class dfu parameter write tx demo thread dfu write dfu parameter ux slave class dfu parameter get status tx demo thread dfu get status dfu parameter ux slave class dfu parameter notify tx demo thread dfu notify dfu parameter ux slave class dfu parameter framework device framework dfu dfu parameter ux slave class dfu parameter framework length DEVICE FRAMEWORK LENGTH DFU x Initialize the device dfu class The class is connected with interface 1 on configuration l status ux device stack class register ux system slave class dfu name ux device class dfu entry 1 0 VOID amp dfu parameter if status UX SUCCESS return The DFU class needs to work with a device firmware application specific to the target Therefore it defines several call back to read and write blocks of firmware and to get status from the firmware update application The DFU class also has a notify callback function to inform the application when a begin and end of transfer of the firmware occur Following is the description of a typical DFU application flow USBX DFU Class Device Application DFU Detach DFU Download UX SLAVE CLASS DFU NOTIFICATION BEGIN DOWNLOAD DFU Download Size 0 DFU Write DFU Download Size 0 DFU Write DFU Download Size
85. read write Iba is the sector address to read The return value can have either the value UX SUCCESS or UX ERROR indicating a successful or unsuccessful operation These operations do not need to return any other error codes If there is an error in any operation the storage class will invoke the status call back function This function has the following prototype ULONG tx demo thread media status ULONG media id The calling parameter media id is not currently used and should always be 0 In the future it may be used to distinguish multiple storage devices or storage devices with multiple SCSI LUNs This version of the storage class does not support multiple instances of the storage class or storage devices with multiple SCSI LUNs The return value is a SCSI error code that can have the following format Bits 0 7 Sense_key Bits 8 15 Additional Sense Code Bits 16 23 Additional Sense Code Qualifier The following table provides the possible Sense ASC ASCQ combinations Sense ASC ASCQ Description Key 00 00 00 NO SENSE 01 17 01 RECOVERED DATA WITH RETRIES 01 18 00 RECOVERED DATA WITH ECC 02 04 01 LOGICAL DRIVE NOT READY BECOMING READY 02 04 02 LOGICAL DRIVE NOT READY INITIALIZATION REQUIRED 02 04 04 LOGICAL UNIT NOT READY FORMAT IN PROGRESS 02 04 FF LOGICAL DRIVE NOT READY DEVICE IS BUSY
86. s below Initialize the Pictbridge string components ux utility memory copy ictbridge ux pictbridge dpslocal ux pictbridge devinfo vendor name xpressLogic 13 ux utility memory copy pictbridge ux pictbridge dpslocal ux pictbridge devinfo product name EL Pictbridge Camera 21 LI ux utility memory copy pictbridge ux pictbridge dpslocal ux pictbridge devinfo serial no ABC 123 771 9 ux utility memory copy pictbridge ux pictbridge dpslocal ux pictbridge devinfo dpsversions Iso E PT pictbridge ux pictbridge dpslocal ux pictbridge devinfo vendor specific version 0x0100 Start the Pictbridge client status ux pictbridge dpsclient start amp pictbridge if status UX SUCCESS return The parameters passed to the pictbridge client are as follows pictbridge ux pictbridge dpslocal ux pictbridge devinfo vendor name String of Vendor name pictbridge ux pictbridge dpslocal ux pictbridge devinfo product name String of product name pictbridge ux pictbridge dpslocal ux pictbridge devinfo serial no String of serial number pictbridge ux pictbridge dpslocal ux pictbridge devinfo dpsversions String of version pictbridge ux pictbridge dpslocal ux pictbridge devinfo vendor specific version Value set to 0x0100 The next step is for the device and the host to synchronize and be ready to e
87. sclient object info send UX SLAVE CLASS PIMA pima UX SLAVE CLASS PIMA OBJECT object ULONG object handle UX PICTBRIDGE pictbridge UX SLAVE CLASS PIMA OBJECT object info UCHAR string discovery name UX PICTBRIDGE MAX FILE NAME SIZE Get the pointer to the Pictbridge instance pictbridge UX PICIBRIDGE pima ux device class pima application We only have one object object info UX SLAVE CLASS PIMA OBJECT pictbridge gt ux pictbridge object host Copy the demanded object info set ux utility memory copy object info object UX SLAVE CLASS PIMA OBJECT DATA LENGTH x Store the object handle In Pictbridge we only receive XML scripts so the handle is hardwired to l object info ux device class pima object handle id 1 object handle 1 x Check state machine If we are in discovery pending mode check file name of this object if pictbridge gt ux pictbridge discovery state UX_PICTBRIDGE DPSCLIENT DISCOVERY PENDING T We are in the discovery mode Check for file name It must match HDISCVRY DPS in Unicode mode Check if this is a script if object info gt ux device class pima object format UX DEVICE CLASS PIMA OFC SCRIPT x Yes this is a script We need to search for the HDISCVRY DPS file name Get the file name in a ascii format
88. successful Example UINT status The following example illustrates this service status ux device_stack_endpoint_stall endpoint If status equals UX SUCCESS the operation was successful ux device stack host wakeup Wake up the host Prototype UINT ux device stack host wakeup VOID Description This function is called when the device wants to wake up the host This command is only valid when the device is in suspend mode It is up to the device application to decide when it wants to wake up the USB host For instance a USB modem can wake up a host when it detects a RING signal on the telephone line Input Parameter None Return values UX SUCCESS 0x00 The call was successful UX ERROR OxFF The call failed the device was probably not in the suspended mode Example UINT status The following example illustrates this service status ux device stack host wakeup If status equals UX SUCCESS the operation was successful ux device stack initialize Initialize USB device stack Prototype UINT ux device stack initialize UCHAR PTR device framework high speed LONG device framework length high speed CHAR PTR device framework full speed LONG device framework length full speed CHAR PTR string framework LONG string framework length CHAR PTR language id framework LONG language id framework length INT ux system slave change function ULONG
89. t Controllers mee USBX OTG USBX Device Classes USBX Host Classes USBX Network USBX Examples Windows host files In order to make the files recognizable by their names the following convention has been adopted File Suffix Name File description ux_host_stack usbx host stack core files ux_host_class usbx host stack classes files ux hcd usbx host stack controller driver files ux device stack usbx device stack core files ux device class usbx device stack classes files ux dcd usbx device stack controller driver files ux otg usbx otg controller driver related files ux pictbridge usbx pictbridge files ux utility usbx utility functions demo usbx demonstration files for USBX Initialization of USBX resources USBX has its own memory manager The memory needs to be allocated to USBX before the host or device side of USBX is initialized USBX memory manager can accommodate systems where memory can be cached The following function initializes USBX memory resources with 128K of regular memory and no separate pool for cache safe memory x Initialize USBX Memory ux system initialize memory pointer 128 1024 UX NULL 0 The prototype for the ux system initialize is as follows UINT ux system initialize VOID regular memory pool start ULONG regular memory size VOID cache safe memory pool start ULONG ca
90. tack alternate setting_set eeaeee eeaeee 27 UK OEVICE S ICKVGIASS TOOISIOR o cota ned vos evo kudo iva kudo ivo nanas 28 ux device stack_configuration_ get 30 ux device stack configuration set 31 ux_device_stack_descriptor_send EE 32 UX device Stack UISCONNEO sa a ea ne ose 33 ux device slack e dpolnislalle s xe sss ee 34 ux device _stack_host_Wwakeup nn nnnnnnnnnnnnnn nnen 35 UDKCEJEVICE Ee IMUNAN ZO sr ereto em ER A AN SK 36 ux device stack interface delete s lee ssssssssssssees 40 ux device stack interface get 41 ux device stack interface SOL eege 42 ux device stack interface start 43 ux device stack transfer request 44 ux device stack transfer reouest abort n 46 Chapter 5 USBX Device Class Considerations 47 USB Device Storage Class 47 MONDIGSGS EUN soo TREA TETO GA ENI EUS SE EUS VAS STIVI EVE E Ea 49 USB Device GOG AGM Glas um rn ONE SIDOS a kt ad savo dk 51 ux device class cdc acm read sesssssssssssssceesessssssnssssssss 54 UX deviCerclasS COC ACI WIIIE ss om o o a e E meea l 55 USB Device EE 56 USB Device RNDIS Class aa dee ONO GIL EO eege d s 60 LSBD vi e her 63 Tee UI 69 ux device class hid event Set sn no eeno none blendo da 71 We Beete Lins a LANCI EL GESIS A A AT A NUAN INAN AS a 72 USB Device PIMA Class PTP Responder 73 Initializat
91. the usbx txt file In addition this file also contains a version history of the corresponding port Application software can obtain the USBX version by examining the global string ux version id which is defined in ux port h Chapter 3 Functional Components of USBX Device Stack This chapter contains a description of the high performance USBX embedded USB device stack from a functional perspective Execution Overview USBX for the device is composed of several components Initialization Application interface calls Device Classes USB Device Stack Device controller VBUS manager The following diagram illustrates the USBX Device stack Storage Class CDC Class Custom Class VBUS Manager Initialization In order to activate USBX the function ux system initialize must be called This function initializes the memory resources of USBX In order to activate USBX device facilities the function ux device stack initialize must be called This function will in turn initialize all the resources used by the USBX device stack such as ThreadX threads mutexes and semaphores Itis up to the application initialization to activate the USB device controller and one or more USB classes Contrary to the USB host side the device side can have only one USB controller driver running at any time When the classes have been registered to the stack and the device controller s initializa
92. tion function has been called the bus is active and the stack will reply to bus reset and host enumeration commands Application Interface Calls There are two levels of APIs in USBX USB Device Stack APIs USB Device Class APIs Normally a USBX application should not have to call any of the USB device stack APIs Most applications will only access the USB Class APIs USB Device Stack APIs The device stack APIs are responsible for the registration of USBX device components such as classes and the device framework USB Device Class APIS The Class APIs are very specific to each USB class Most of the common APIs for USB classes provided services such as opening closing a device and reading from and writing to a device The APIs are similar in nature to the host side Device Framework The USB device side is responsible for the definition of the device framework The device framework is divided into three categories as described in the following sections Definition of the Components of the Device Framework The definition of each component of the device framework is related to the nature of the device and the resources utilized by the device Following are the main categories e Device Descriptor e Configuration Descriptor e Interface Descriptor e Endpoint Descriptor USBX supports device component definition for both high and full speed low speed being treated the same way as full speed This allows the device to operate dif
93. we are don with the cycle pictbridge ux pictbridge host client state machine UX PICTBRIDGE STATE MACHINE IDLE T We have copied the requested data Return OK return UX SUCCESS else Get the object info from the job info structure object info UX SLAVE CLASS PIMA OBJECT pictbridge gt ux pictbridge jobinfo ux pictbridge jobinfo object Obtain the data from the application jobinfo callback status pictbridge ux pictbridge jobinfo ux pictbridge jobinfo object data read pictbridge object buffer object offset object length requested amp actual length Save the length returned object actual length actual length Return the application status return status x Could not find the handle return UX DEVICE CLASS PIMA RC INVALID OBJECT HANDLI EI lt H ux device class pima object info send Host sends the object information Prototype UINT ux device class pima object info send UX SLAVE CLASS PIMA pima UX SLAVE CLASS PIMA OBJECT object ULONG object handle Description This function is called when the PIMA class needs to receive the object information in the local system for future storage Parameters pima Pointer to the pima class instance object Pointer to the object object handle Handle of the object Example UINT ux pictbridge dp
94. x30010000 Qualities 0 UX PICTBRIDGE QUALITIES DEFAULT Qualities 1 UX PICTBRIDGE QUALITIES NORMAL Qualities 2 UX PICTBRIDGE QUALITIES DRAFT Qualities 3 UX PICTBRIDGE QUALITIES FINE PaperSizes 0 UX PICTBRIDGE PAPER SIZES DEFAULT PaperSizes 1 UX PICTBRIDGE PAPER SIZES 4IX6Il PaperSizes 2 UX PICTBRIDGE PAPER SIZES L PaperSizes 3 UX_PICTBRIDGE_PAPER_SIZES 2L PaperSizes 4 UX PICTBRIDGE PAPER SIZES LETTER PaperTypes 0 UX PICTBRIDGE PAPER TYPES DEFAULT PaperTypes 1 UX PICTBRIDGE PAPER TYPES PLAIN PaperTypes 2 UX_PICTBRIDGE_PAPER_TYPES PHOTO FileTypes 0 FileTypes 1 UX PICTBRIDGE FILE TYPES DEFAULT UX PICTBRIDGE FILE TYPES EXIF JPEG FileTypes 2 UX PICTBRIDGE FILE TYPES JFIF FileTypes 3 UX PICTBRIDGE FILE TYPES DPOF DatePrints 0 UX PICTBRIDGE DATE PRINTS DEFAULT DatePrints 1 UX PICTBRIDGE DATE PRINTS OFF DatePrints 2 UX PICTBRIDGE DATE PRINTS ON FileNamePrints O FileNamePrints 1 FileNamePrints 2 UX PICTBRIDGE FILE NAME PRINTS DEFAULT UX PICTBRIDGE FILE NAME PRINTS OFF UX PICTBRIDGE FILE NAME PRINTS ON ImageOptimizes 0 UX PICTBRIDGE IMAGE OPTIMIZES DEFAULT ImageOptimizes 1 UX PICTBRIDGE IMAGE OPTIMIZES OFF ImageOptimizes 2 UX PICTBRIDGE IMAGE OPTIMIZES ON Layouts o UX PICTBRIDGE LAYOUTS DEFAULT Layouts 1 UX PICTBRIDGE LAYOUTS 1 UP BORDER Layouts 2 UX PICTBRIDGE LAYOUTS INDEX PRINT Layouts 3 UX PICTBRIDGE LAYOUTS 1 UP BORDERLESS FixedSizes 0 UX PICTBRIDGE
95. xchange information This is done by waiting on an event flag as follows We should wait for the host and the client to discover one another status ux utility event flags get amp pictbridge ux pictbridge event flags group UX PICTBRIDGE EVENT FLAG DISCOVERY TX AND CLEAR UX PICTBRIDGE EVENT TIMEOUT actual flags If the state machine is in the DISCOVERY COMPLETE state the camera side the DPS client will gather information regarding the printer and its capabilities If the DPS client is ready to accept a print job its status will be set to UX PICTBRIDGE NEW JOB TRUE It can be checked below x Check if the printer is ready for a prin E t job pictbridge ux pictbridge dpsclient ux pictbridge devinfo newjobok UX PICTBRIDGE NEW JOB TRUE We can print something T Next some print joib descriptors need to be filled as follows We can start a new job Fill in the JobConfig and PrintInfo structures jobinfo spictbridge ux pictbridge jobinfo Attach a printinfo structure to the job jobinfo gt ux pictbridge jobinfo printinfo start amp printinfo Set the default values for print job jobinfo ux pictbridge jobinfo quality UX PICTBRIDGE QUALITIES DEFAULT jobinfo ux pictbridge jobinfo papersize UX PICTBRIDGE PAPER SIZES DEFAULT jobinfo ux pictbridge jobinfo papertype UX PICTBRIDGE PAPER TYPES DEFAULT
96. y kind that the USBX producis will meet the USER s requirements or will operate in the manner specified by the USER or that the operation of the USBX products will operate uninterrupted or error free or that any defects that may exist in the USBX products will be corrected after the warranty period Express Logic Inc makes no warranties of any kind either expressed or implied including but not limited to the implied warranties of merchantability and fitness for a particular purpose with respect to the USBX products No oral or written information or advice given by Express Logic Inc its dealers distributors agents or employees shall create any other warranty or in any way increase the scope of this warranty and licensee may not rely on any such information or advice Part Number 000 1010 Revision 5 7 Contents COMENES en ra E E lao sda vak etn 3 About TRIS GUIE si suet oun o do duko daii d dlras SOV o nuo da eb da oekove dd dunuu 6 Chapter 1 Introduction to USBX nes 7 ISB KIGAS o o boo o o bikos di kaskada extends kanbo da kad ada ana kana i kaban kako 7 Product e e Ile LEE 8 Powerful Services of USBX cccccccccccccccceececeeeeeececeeeeeceeceeeeeeeeeeeeeeseeeeeeeeeeseeess 8 Complete USB Device Framework Support essseeeeee ess seeseeeaannos 9 sadis Us ARIS SES nn nan nent A ORT 9 Chapter 2 USBX Installation es 10 Host Considerations RSS a aa E eh EE EE la kaa ka ka lada 10 E EE 10
Download Pdf Manuals
Related Search
Related Contents
GPP 2.5, 5.0, 7.5 & 9.0 Portable Electrofishers - Smith-Root USER INSTRUCTIONS - Flowserve Corporation Teledyne 2230R User's Manual Lirio by Philips Suspension light 57037/31/LI catalogue outils spéciaux type trumpf Nokia 5320 XpressMusic Bedienungsanleitung EPSON TM-T20 - Pos-Spain, todo para el punto de Venta. Descargar Manual Copyright © All rights reserved.
Failed to retrieve file