📄 c-periph.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><title> </title></head><body bgcolor="FFFFFF"><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="icons/contents.gif"></a><a href="c-hostStack.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><img border="0" src="icons/blank.gif"></p><font face="Helvetica, sans-serif" class="sans"><h1 class="H1Chapter" align="right"><i><a name="88000"></a> 2</i></h1><h1 align="right"><i>USB Peripheral Stack</i></h1></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="88053"></a></p><dd><p class="Body"><a name="88101"></a></p><dd><p class="Body"><a name="88102"></a></p><dd><p class="Body"><a name="88103"></a>This chapter documents the USB peripheral stack, which is an extension of the USB Developer's Kit, also known as the USB Kit. The USB peripheral stack interprets USB commands on USB devices running VxWorks.</p><dd><p class="Body"><a name="87149"></a>The USB peripheral stack includes the source code for the USB peripheral stack and firmware emulators.</p><dd><p class="Body"><a name="87152"></a>This chapter shows you how to write your own USB target controller driver and USB target firmware. The USB peripheral stack is designed to allow:</p></dl><dl class="margin"><dd><p class="listspace"><ul class="Bullet" type="disc"><li><a name="87153"></a>easy portability to RTOSs other than VxWorks</li></ul></p><dd><p class="listspace"><ul class="Bullet" type="disc"><li><a name="87154"></a>fast development of new target controller drivers</li></ul></p><dd><p class="listspace"><ul class="Bullet" type="disc"><li><a name="87155"></a>fast development of new target firmware</li></ul></p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="87157"></a>Tested Devices</i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="87158"></a>The following device has been tested with the Wind River USB peripheral stack:</p><dl class="margin"><dd><p class="Indent"><a name="88056"></a>Philips PDIUSBD12 evaluation kit</p></dl></dl></dl><br class="H2"><a name="87189"></a><br class="H2navbar"><font face="Helvetica, sans-serif" class="sans"><h3 class="H2"><i>2.1 Peripheral Stack Architecture </i></h3></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="87228"></a><a href="c-periph.html#87196">Figure 1</a> presents an overview of the USB peripheral stack. </dl></dl><p class="frame"><dl class="margin"><dd><p class="EntityTitle"><a name="87196"></a><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 1: <b>Peripheral Stack Overview</b></font></p></dl><dl class="margin"><dl class="margin"><dd><div class="Anchor"><a name="87227"></a><img class="figure" border="0" alt="" src="images/c-peripha.gif"></div></dl></dl></p><dl class="margin"><dl class="margin"></p><dd><p class="Body"><a name="87229"></a>At the bottom of the stack is the USB<i class="term"> target controller</i> (USB TC), the hardware part of the peripheral that connects to the USB. Many manufacturers build USB target controllers, which vary widely in implementation. The sample code provided by Wind River supports an evaluation kit from Philips based on the Philips PDIUSBD12 target chip. The PDIUSBD12 is a general purpose USB target chip that supports each of the four basic USB transfers: control, interrupt, bulk, and isochronous. In the evaluation kit, the PDIUSBD12 sits on a standalone printed circuit board; a separate ISA bus adapter card is used to connect the board to a standard PC system.</p><dd><p class="Body"><a name="87230"></a>For each type of target controller, there is a corresponding USB <i class="term">target controller driver</i> (TCD). The TCD provides a consistent, abstract view of the target controller to the upper software layers. </p><dd><p class="Body"><a name="87231"></a>The source for the pre-built Wind River driver for the Philips PDIUSBD12 is contained in the library <b class="library">usbTcdPhilipsPdiusbd12EvalLib</b>. However, given the range of USB target chips available, there is a good chance a customer does not use the Philips PDIUSBD12, and even less likely a customer uses the Philips evaluation kit as part of an actual product. You should be prepared to customize or replace the sample USB target controller driver provided with the USB peripheral stack.</p><dd><p class="Body"><a name="87232"></a>Above the TCD sits the <b class="library">usbTargLib</b> library, a hardware-independent module that provides an abstract set of services for simplifying the job of writing USB target applications. This library incorporates automatic handling, where possible, for USB requests. When automatic processing is not possible, <b class="library">usbTargLib</b> relies on the target application to complete USB transactions. </p><dd><p class="Body"><a name="87233"></a>At run-time, one or more TCDs are attached to <b class="library">usbTargLib</b>. For each TCD, a single target application is also registered with <b class="library">usbTargLib</b>; and <b class="library">usbTargLib</b> becomes responsible for routing requests and responses between the TCD and the target application. Architecturally, <b class="library">usbTargLib</b> is capable of handling multiple TCDs and their corresponding target applications. As a practical matter, however, few peripherals have more than one target controller, TCD, and target application.</p><dd><p class="Body"><a name="87234"></a>At the top of the peripheral stack sits the target application. The target application is the module that gives the peripheral its personality. In response to USB requests received by the TCD and routed through <b class="library">usbTargLib</b>, it is the target application's responsibility to provide appropriate responses. For example, when a request is received to get a USB descriptor from the peripheral, it is the target application's responsibility to provide the contents of the descriptor.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="87236"></a>Peripheral Module Roadmap</i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="87240"></a><a href="c-periph.html#87244">Figure 2</a> illustrates the functional relationships between the modules that comprise Wind River's USB peripheral driver stack. </dl></dl><p class="frame"><dl class="margin"><dd><p class="EntityTitle"><a name="87244"></a><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 2: <b>Peripheral Module Roadmap</b></font></p></dl><dl class="margin"><dl class="margin"><dd><div class="Anchor"><a name="87315"></a><img class="figure" border="0" alt="" src="images/c-periph2.gif"></div></dl></dl></p><dl class="margin"><dl class="margin"></p><dd><p class="Body"><a name="87316"></a>The peripheral stack shares a consistent architectural approach with the USB host driver stack, as well as a number of common libraries. (Compare <a href="c-periph.html#87244">Figure 2</a> in this supplement with the figures in <a href="/folk/docs/usb/1.1.2/guide/c-chapter.html#91472"><i class="title">1.2 Architecture Overview</i></a>.)</p><dd><p class="Body"><a name="87320"></a>Modules that are unique to the USB peripheral stack are described in this section. For information on modules shared with the host stack, please see <a href="/folk/docs/usb/1.1.2/guide/c-chapter.html#91472"><i class="title">1.2 Architecture Overview</i></a>. For additional information on USB-related libraries and subroutines, see the associated reference pages in the online <i class="title">VxWorks Reference Manual: USB Libraries</i>.</p></dl></dl><dl class="margin"><dd><font face="Helvetica, sans-serif" size="-1" class="sans"><h5 class="HU"><i><a name="87321"></a><b class="library">usbTool</b></i></h5></font><dl class="margin"><dd><p class="Body"><a name="87322"></a>This module is a test application that exercises both the Wind River USB host and peripheral stacks. The <b class="library">usbTool</b> functions that control the peripheral stack are independent of those that control the host stack. In fact, if a VxWorks target has both USB host and peripheral hardware, <b class="library">usbTool</b> can be used to control both simultaneously and the two can talk to one another!</p></dl><dd><font face="Helvetica, sans-serif" size="-1" class="sans"><h5 class="HU"><i><a name="87323"></a><b class="library">usbTargPhilipsD12EvalLib</b></i></h5></font><dl class="margin"><dd><p class="Body"><a name="87324"></a>The Philips PDIUSBD12 evaluation kit includes a reference firmware implementation. This firmware is implemented as a DOS application. When running, the firmware makes the PDIUSBD12 look like a test device recognizable by a Windows-based Philips test program. The Philips test program allows the user to exercise certain functions on the PDIUSBD12 evaluation board. The <b class="library">usbTargPhilipsD12EvalLib</b> module is a target application that emulates the behavior of the Philips reference firmware. Thus, the Philips test program communicates with the PDIUSBD12 evaluation board when the PDIUSBD12 is under the control of the Wind River USB peripheral stack.</p></dl><dd><font face="Helvetica, sans-serif" size="-1" class="sans"><h5 class="HU"><i><a name="87325"></a><b class="library">usbTargPrnLib</b></i></h5></font><dl class="margin"><dd><p class="Body"><a name="87326"></a>This module is a very simple (and incomplete) example of a target application that acts like a USB printer. This module was originally developed to test USB bulk transfers through the PDIUSBD12; its emulation of a printer is not complete enough to allow it to talk to a standard Windows host, for example.</p></dl><dd><font face="Helvetica, sans-serif" size="-1" class="sans"><h5 class="HU"><i><a name="87327"></a><b class="library">usbTargKbdLib</b></i></h5></font><dl class="margin"><dd><p class="Body"><a name="87328"></a>Like <b class="library">usbTargPrnLib</b>, this module is a very simple and incomplete example of a target application that acts like a USB keyboard. It was originally developed to test USB interrupt transfers through the PDIUSBD12.</p><dd><p class="Body"><a name="87329"></a>Taken together, the three libraries (<b class="library">usbTargPhilipsD12EvalLib</b>, <b class="library">usbTargPrnLib</b>, and <b class="library">usbTargKbdLib</b>) are useful principally to demonstrate how simple it is to create a target application on top of the <b class="library">usbTargLib</b> interface.</p></dl><dd><font face="Helvetica, sans-serif" size="-1" class="sans"><h5 class="HU"><i><a name="87330"></a><b class="library">usbTargLib</b></i></h5></font><dl class="margin"><dd><p class="Body"><a name="87331"></a>This module is the core of the USB peripheral stack. It is responsible for routing requests between TCDs and their corresponding target applications. The <b class="library">usbTargLib</b> module automatically manages the default control pipe for each TCD and provides default handlers, where meaningful, for each USB control request. This module also incorporates the necessary functions to allow target applications to transfer data across the USB, either in response to control requests or on other USB pipes.</p></dl><dd><font face="Helvetica, sans-serif" size="-1" class="sans"><h5 class="HU"><i><a name="87332"></a><b class="library">usbTcdLib</b></i></h5></font><dl class="margin"><dd><p class="Body"><a name="87333"></a>This module provides functions to invoke each of the services provided by a USB TCD. It is used by <b class="library">usbTargLib </b>to communicate with underlying HCDs. The functions in <b class="library">usbTcdLib</b> are not called directly by modules other than <b class="library">usbTargLib</b>.</p></dl><dd><font face="Helvetica, sans-serif" size="-1" class="sans"><h5 class="HU"><i><a name="87334"></a><b class="library">usbTcdPdiusbd12EvalLib</b></i></h5></font><dl class="margin">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -