<!-- Copyright (C) 2002 Red Hat, Inc. -->
|
<!-- Copyright (C) 2002 Red Hat, Inc. -->
|
<!-- This material may be distributed only subject to the terms -->
|
<!-- This material may be distributed only subject to the terms -->
|
<!-- and conditions set forth in the Open Publication License, v1.0 -->
|
<!-- and conditions set forth in the Open Publication License, v1.0 -->
|
<!-- or later (the latest version is presently available at -->
|
<!-- or later (the latest version is presently available at -->
|
<!-- http://www.opencontent.org/openpub/). -->
|
<!-- http://www.opencontent.org/openpub/). -->
|
<!-- Distribution of substantively modified versions of this -->
|
<!-- Distribution of substantively modified versions of this -->
|
<!-- document is prohibited without the explicit permission of the -->
|
<!-- document is prohibited without the explicit permission of the -->
|
<!-- copyright holder. -->
|
<!-- copyright holder. -->
|
<!-- Distribution of the work or derivative of the work in any -->
|
<!-- Distribution of the work or derivative of the work in any -->
|
<!-- standard (paper) book form is prohibited unless prior -->
|
<!-- standard (paper) book form is prohibited unless prior -->
|
<!-- permission is obtained from the copyright holder. -->
|
<!-- permission is obtained from the copyright holder. -->
|
<HTML
|
<HTML
|
><HEAD
|
><HEAD
|
><TITLE
|
><TITLE
|
>Introduction</TITLE
|
>Introduction</TITLE
|
><meta name="MSSmartTagsPreventParsing" content="TRUE">
|
><meta name="MSSmartTagsPreventParsing" content="TRUE">
|
<META
|
<META
|
NAME="GENERATOR"
|
NAME="GENERATOR"
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.64
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.64
|
"><LINK
|
"><LINK
|
REL="HOME"
|
REL="HOME"
|
TITLE="eCos USB Slave Support"
|
TITLE="eCos USB Slave Support"
|
HREF="io-usb-slave.html"><LINK
|
HREF="io-usb-slave.html"><LINK
|
REL="PREVIOUS"
|
REL="PREVIOUS"
|
TITLE="eCos USB Slave Support"
|
TITLE="eCos USB Slave Support"
|
HREF="io-usb-slave.html"><LINK
|
HREF="io-usb-slave.html"><LINK
|
REL="NEXT"
|
REL="NEXT"
|
TITLE="USB Enumeration Data"
|
TITLE="USB Enumeration Data"
|
HREF="usbs-enum.html"></HEAD
|
HREF="usbs-enum.html"></HEAD
|
><BODY
|
><BODY
|
CLASS="REFENTRY"
|
CLASS="REFENTRY"
|
BGCOLOR="#FFFFFF"
|
BGCOLOR="#FFFFFF"
|
TEXT="#000000"
|
TEXT="#000000"
|
LINK="#0000FF"
|
LINK="#0000FF"
|
VLINK="#840084"
|
VLINK="#840084"
|
ALINK="#0000FF"
|
ALINK="#0000FF"
|
><DIV
|
><DIV
|
CLASS="NAVHEADER"
|
CLASS="NAVHEADER"
|
><TABLE
|
><TABLE
|
WIDTH="100%"
|
WIDTH="100%"
|
BORDER="0"
|
BORDER="0"
|
CELLPADDING="0"
|
CELLPADDING="0"
|
CELLSPACING="0"
|
CELLSPACING="0"
|
><TR
|
><TR
|
><TH
|
><TH
|
COLSPAN="3"
|
COLSPAN="3"
|
ALIGN="center"
|
ALIGN="center"
|
>eCos USB Slave Support</TH
|
>eCos USB Slave Support</TH
|
></TR
|
></TR
|
><TR
|
><TR
|
><TD
|
><TD
|
WIDTH="10%"
|
WIDTH="10%"
|
ALIGN="left"
|
ALIGN="left"
|
VALIGN="bottom"
|
VALIGN="bottom"
|
><A
|
><A
|
HREF="io-usb-slave.html"
|
HREF="io-usb-slave.html"
|
>Prev</A
|
>Prev</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="80%"
|
WIDTH="80%"
|
ALIGN="center"
|
ALIGN="center"
|
VALIGN="bottom"
|
VALIGN="bottom"
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="10%"
|
WIDTH="10%"
|
ALIGN="right"
|
ALIGN="right"
|
VALIGN="bottom"
|
VALIGN="bottom"
|
><A
|
><A
|
HREF="usbs-enum.html"
|
HREF="usbs-enum.html"
|
>Next</A
|
>Next</A
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
><HR
|
><HR
|
ALIGN="LEFT"
|
ALIGN="LEFT"
|
WIDTH="100%"></DIV
|
WIDTH="100%"></DIV
|
><H1
|
><H1
|
><A
|
><A
|
NAME="USBS-INTRO"
|
NAME="USBS-INTRO"
|
>Introduction</A
|
>Introduction</A
|
></H1
|
></H1
|
><DIV
|
><DIV
|
CLASS="REFNAMEDIV"
|
CLASS="REFNAMEDIV"
|
><A
|
><A
|
NAME="AEN6"
|
NAME="AEN6"
|
></A
|
></A
|
><H2
|
><H2
|
>Name</H2
|
>Name</H2
|
>Introduction -- eCos support for USB slave devices</DIV
|
>Introduction -- eCos support for USB slave devices</DIV
|
><DIV
|
><DIV
|
CLASS="REFSECT1"
|
CLASS="REFSECT1"
|
><A
|
><A
|
NAME="AEN9"
|
NAME="AEN9"
|
></A
|
></A
|
><H2
|
><H2
|
>Introduction</H2
|
>Introduction</H2
|
><P
|
><P
|
>The eCos USB slave support allows developers to produce USB
|
>The eCos USB slave support allows developers to produce USB
|
peripherals. It consists of a number of different eCos packages:</P
|
peripherals. It consists of a number of different eCos packages:</P
|
><P
|
><P
|
></P
|
></P
|
><OL
|
><OL
|
TYPE="1"
|
TYPE="1"
|
><LI
|
><LI
|
><P
|
><P
|
>Device drivers for specific implementations of USB slave hardware, for
|
>Device drivers for specific implementations of USB slave hardware, for
|
example the on-chip USB Device Controller provided by the Intel SA1110
|
example the on-chip USB Device Controller provided by the Intel SA1110
|
processor. A typical USB peripheral will only provide one USB slave
|
processor. A typical USB peripheral will only provide one USB slave
|
port and therefore only one such device driver package will be needed.
|
port and therefore only one such device driver package will be needed.
|
Usually the device driver package will be loaded automatically when
|
Usually the device driver package will be loaded automatically when
|
you create an eCos configuration for target hardware that has a USB
|
you create an eCos configuration for target hardware that has a USB
|
slave device. If you select a target which does have a USB slave
|
slave device. If you select a target which does have a USB slave
|
device but no USB device driver is loaded, this implies that no such
|
device but no USB device driver is loaded, this implies that no such
|
device driver is currently available.</P
|
device driver is currently available.</P
|
></LI
|
></LI
|
><LI
|
><LI
|
><P
|
><P
|
>The common USB slave package. This serves two purposes. It defines the
|
>The common USB slave package. This serves two purposes. It defines the
|
API that specific device drivers should implement. It also provides
|
API that specific device drivers should implement. It also provides
|
various utilities that will be needed by most USB device drivers and
|
various utilities that will be needed by most USB device drivers and
|
applications, such as handlers for standard control messages.
|
applications, such as handlers for standard control messages.
|
Usually this package will be loaded automatically at the same time as
|
Usually this package will be loaded automatically at the same time as
|
the USB device driver.</P
|
the USB device driver.</P
|
></LI
|
></LI
|
><LI
|
><LI
|
><P
|
><P
|
>The common USB package. This merely provides some information common
|
>The common USB package. This merely provides some information common
|
to both the host and slave sides of USB, such as details of the
|
to both the host and slave sides of USB, such as details of the
|
control protocol. It is also used to place the other USB-related
|
control protocol. It is also used to place the other USB-related
|
packages appropriately in the overall configuration hierarchy. Usually
|
packages appropriately in the overall configuration hierarchy. Usually
|
this package will be loaded at the same time as the USB device driver.</P
|
this package will be loaded at the same time as the USB device driver.</P
|
></LI
|
></LI
|
><LI
|
><LI
|
><P
|
><P
|
>Class-specific USB support packages. These make it easier to develop
|
>Class-specific USB support packages. These make it easier to develop
|
specific classes of USB peripheral, such as a USB-ethernet device. If
|
specific classes of USB peripheral, such as a USB-ethernet device. If
|
no suitable package is available for a given class of peripheral then
|
no suitable package is available for a given class of peripheral then
|
the USB device driver can instead be accessed directly from
|
the USB device driver can instead be accessed directly from
|
application code. Such packages will never be loaded automatically
|
application code. Such packages will never be loaded automatically
|
since the configuration system has no way of knowing what class of USB
|
since the configuration system has no way of knowing what class of USB
|
peripheral is being developed. Instead developers have to add the
|
peripheral is being developed. Instead developers have to add the
|
appropriate package or packages explicitly.</P
|
appropriate package or packages explicitly.</P
|
></LI
|
></LI
|
></OL
|
></OL
|
><P
|
><P
|
>These packages only provide support for developing USB peripherals,
|
>These packages only provide support for developing USB peripherals,
|
not USB hosts.</P
|
not USB hosts.</P
|
></DIV
|
></DIV
|
><DIV
|
><DIV
|
CLASS="REFSECT1"
|
CLASS="REFSECT1"
|
><A
|
><A
|
NAME="AEN22"
|
NAME="AEN22"
|
></A
|
></A
|
><H2
|
><H2
|
>USB Concepts</H2
|
>USB Concepts</H2
|
><P
|
><P
|
>Information about USB can be obtained from a number of sources
|
>Information about USB can be obtained from a number of sources
|
including the <A
|
including the <A
|
HREF="http://www.usb.org/"
|
HREF="http://www.usb.org/"
|
TARGET="_top"
|
TARGET="_top"
|
>USB Implementers Forum
|
>USB Implementers Forum
|
web site</A
|
web site</A
|
>. Only a brief summary is provided here.</P
|
>. Only a brief summary is provided here.</P
|
><P
|
><P
|
>A USB network is asymmetrical: it consists of a single host, one or
|
>A USB network is asymmetrical: it consists of a single host, one or
|
more slave devices, and possibly some number of intermediate hubs. The
|
more slave devices, and possibly some number of intermediate hubs. The
|
host side is significantly more complicated than the slave side.
|
host side is significantly more complicated than the slave side.
|
Essentially, all operations are initiated by the host. For example, if
|
Essentially, all operations are initiated by the host. For example, if
|
the host needs to receive some data from a particular USB peripheral
|
the host needs to receive some data from a particular USB peripheral
|
then it will send an IN token to that peripheral; the latter should
|
then it will send an IN token to that peripheral; the latter should
|
respond with either a NAK or with appropriate data. Similarly, when
|
respond with either a NAK or with appropriate data. Similarly, when
|
the host wants to transmit data to a peripheral it will send an OUT
|
the host wants to transmit data to a peripheral it will send an OUT
|
token followed by the data; the peripheral will return a NAK if it is
|
token followed by the data; the peripheral will return a NAK if it is
|
currently unable to receive more data or if there was corruption,
|
currently unable to receive more data or if there was corruption,
|
otherwise it will return an ACK. All transfers are check-summed and
|
otherwise it will return an ACK. All transfers are check-summed and
|
there is a clearly-defined error recovery process. USB peripherals can
|
there is a clearly-defined error recovery process. USB peripherals can
|
only interact with the host, not with each other.</P
|
only interact with the host, not with each other.</P
|
><P
|
><P
|
>USB supports four different types of communication: control messages,
|
>USB supports four different types of communication: control messages,
|
interrupt transfers, isochronous transfers, and bulk transfers.
|
interrupt transfers, isochronous transfers, and bulk transfers.
|
Control messages are further subdivided into four categories:
|
Control messages are further subdivided into four categories:
|
standard, class, vendor and a reserved category. All USB peripherals
|
standard, class, vendor and a reserved category. All USB peripherals
|
must respond to certain standard control messages, and usually this
|
must respond to certain standard control messages, and usually this
|
will be handled by the common USB slave package (for complicated
|
will be handled by the common USB slave package (for complicated
|
peripherals, application support will be needed). Class and vendor
|
peripherals, application support will be needed). Class and vendor
|
control messages may be handled by an class-specific USB support
|
control messages may be handled by an class-specific USB support
|
package, for example the USB-ethernet package will handle control
|
package, for example the USB-ethernet package will handle control
|
messages such as getting the MAC address or enabling/disabling
|
messages such as getting the MAC address or enabling/disabling
|
promiscuous mode. Alternatively, some or all of these messages will
|
promiscuous mode. Alternatively, some or all of these messages will
|
have to be handled by application code.</P
|
have to be handled by application code.</P
|
><P
|
><P
|
>Interrupt transfers are used for devices which need to be polled
|
>Interrupt transfers are used for devices which need to be polled
|
regularly. For example, a USB keyboard might be polled once every
|
regularly. For example, a USB keyboard might be polled once every
|
millisecond. The host will not poll the device more frequently than
|
millisecond. The host will not poll the device more frequently than
|
this, so interrupt transfers are best suited to peripherals that
|
this, so interrupt transfers are best suited to peripherals that
|
involve a relatively small amount of data. Isochronous transfers are
|
involve a relatively small amount of data. Isochronous transfers are
|
intended for multimedia-related peripherals where typically a large
|
intended for multimedia-related peripherals where typically a large
|
amount of video or audio data needs to be exchanged continuously.
|
amount of video or audio data needs to be exchanged continuously.
|
Given appropriate host support a USB peripheral can reserve some of
|
Given appropriate host support a USB peripheral can reserve some of
|
the available bandwidth. Isochronous transfers are not reliable; if a
|
the available bandwidth. Isochronous transfers are not reliable; if a
|
particular packet is corrupted then it will just be discarded and
|
particular packet is corrupted then it will just be discarded and
|
software is expected to recover from this. Bulk transfers are used for
|
software is expected to recover from this. Bulk transfers are used for
|
everything else: after taking care of any pending control, isochronous
|
everything else: after taking care of any pending control, isochronous
|
and interrupt transfers the host will use whatever bandwidth remains
|
and interrupt transfers the host will use whatever bandwidth remains
|
for bulk transfers. Bulk transfers are reliable.</P
|
for bulk transfers. Bulk transfers are reliable.</P
|
><P
|
><P
|
>Transfers are organized into USB packets, with the details depending
|
>Transfers are organized into USB packets, with the details depending
|
on the transfer type. Control messages always involve an initial
|
on the transfer type. Control messages always involve an initial
|
8-byte packet from host to peripheral, optionally followed by some
|
8-byte packet from host to peripheral, optionally followed by some
|
additional packets; in theory these additional packets can be up to 64
|
additional packets; in theory these additional packets can be up to 64
|
bytes, but hardware may limit it to 8 bytes. Interrupt transfers
|
bytes, but hardware may limit it to 8 bytes. Interrupt transfers
|
involve a single packet of up to 64 bytes. Isochronous transfers
|
involve a single packet of up to 64 bytes. Isochronous transfers
|
involve a single packet of up to 1024 bytes. Bulk transfers involve
|
involve a single packet of up to 1024 bytes. Bulk transfers involve
|
multiple packets. There will be some number, possibly zero, of 64-byte
|
multiple packets. There will be some number, possibly zero, of 64-byte
|
packets. The transfer is terminated by a single packet of less than 64
|
packets. The transfer is terminated by a single packet of less than 64
|
bytes. If the transfer involves an exact multiple of 64 bytes than the
|
bytes. If the transfer involves an exact multiple of 64 bytes than the
|
final packet will be 0 bytes, consisting of just a header and checksum
|
final packet will be 0 bytes, consisting of just a header and checksum
|
which typically will be generated by the hardware. There is no
|
which typically will be generated by the hardware. There is no
|
pre-defined limit on the size of a bulk transfer. Instead higher-level
|
pre-defined limit on the size of a bulk transfer. Instead higher-level
|
protocols are expected to handle this, so for a USB-ethernet
|
protocols are expected to handle this, so for a USB-ethernet
|
peripheral the protocol could impose a limit of 1514 bytes of data
|
peripheral the protocol could impose a limit of 1514 bytes of data
|
plus maybe some additional protocol overhead.</P
|
plus maybe some additional protocol overhead.</P
|
><P
|
><P
|
>Transfers from the host to a peripheral are addressed not just to that
|
>Transfers from the host to a peripheral are addressed not just to that
|
peripheral but to a specific endpoint within that peripheral.
|
peripheral but to a specific endpoint within that peripheral.
|
Similarly, the host requests incoming data from a specific endpoint
|
Similarly, the host requests incoming data from a specific endpoint
|
rather than from the peripheral as a whole. For example, a combined
|
rather than from the peripheral as a whole. For example, a combined
|
keyboard/touchpad device could provide the keyboard events on endpoint
|
keyboard/touchpad device could provide the keyboard events on endpoint
|
1 and the mouse events on endpoint 2. A given USB peripheral can have
|
1 and the mouse events on endpoint 2. A given USB peripheral can have
|
up to 16 endpoints for incoming data and another 16 for outgoing data.
|
up to 16 endpoints for incoming data and another 16 for outgoing data.
|
However, given the comparatively high speed of USB I/O this endpoint
|
However, given the comparatively high speed of USB I/O this endpoint
|
addressing is typically implemented in hardware rather than software,
|
addressing is typically implemented in hardware rather than software,
|
and the hardware will only implement a small number of endpoints.
|
and the hardware will only implement a small number of endpoints.
|
Endpoint 0 is generally used only for control messages.</P
|
Endpoint 0 is generally used only for control messages.</P
|
><P
|
><P
|
>In practice, many of these details are irrelevant to application code
|
>In practice, many of these details are irrelevant to application code
|
or to class packages. Instead, such higher-level code usually just
|
or to class packages. Instead, such higher-level code usually just
|
performs blocking <TT
|
performs blocking <TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>read</TT
|
>read</TT
|
> and
|
> and
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>write</TT
|
>write</TT
|
>, or non-blocking USB-specific calls, to
|
>, or non-blocking USB-specific calls, to
|
transfer data between host and target via a specific endpoint. Control
|
transfer data between host and target via a specific endpoint. Control
|
messages are more complicated but are usually handled by existing
|
messages are more complicated but are usually handled by existing
|
code.</P
|
code.</P
|
><P
|
><P
|
>When a USB peripheral is plugged into the host there is an initial
|
>When a USB peripheral is plugged into the host there is an initial
|
enumeration and configuration process. The peripheral provides
|
enumeration and configuration process. The peripheral provides
|
information such as its class of device (audio, video, etc.), a
|
information such as its class of device (audio, video, etc.), a
|
vendor id, which endpoints should be used for what kind of data, and
|
vendor id, which endpoints should be used for what kind of data, and
|
so on. The host OS uses this information to identify a suitable host
|
so on. The host OS uses this information to identify a suitable host
|
device driver. This could be a generic driver for a class of
|
device driver. This could be a generic driver for a class of
|
peripherals, or it could be a vendor-specific driver. Assuming a
|
peripherals, or it could be a vendor-specific driver. Assuming a
|
suitable driver is installed the host will then activate the USB
|
suitable driver is installed the host will then activate the USB
|
peripheral and perform additional application-specific initialisation.
|
peripheral and perform additional application-specific initialisation.
|
For example for a USB-ethernet device this would involve obtaining an
|
For example for a USB-ethernet device this would involve obtaining an
|
ethernet MAC address. Most USB peripherals will be fairly simple, but
|
ethernet MAC address. Most USB peripherals will be fairly simple, but
|
it is possible to build multifunction peripherals with multiple
|
it is possible to build multifunction peripherals with multiple
|
configurations, interfaces, and alternate interface settings.</P
|
configurations, interfaces, and alternate interface settings.</P
|
><P
|
><P
|
>It is not possible for any of the eCos packages to generate all the
|
>It is not possible for any of the eCos packages to generate all the
|
enumeration data automatically. Some of the required information such
|
enumeration data automatically. Some of the required information such
|
as the vendor id cannot be supplied by generic packages; only by the
|
as the vendor id cannot be supplied by generic packages; only by the
|
application developer. Class support code such as the USB-ethernet
|
application developer. Class support code such as the USB-ethernet
|
package could in theory supply some of the information automatically,
|
package could in theory supply some of the information automatically,
|
but there are also hardware dependencies such as which endpoints get
|
but there are also hardware dependencies such as which endpoints get
|
used for incoming and outgoing ethernet frames. Instead it is the
|
used for incoming and outgoing ethernet frames. Instead it is the
|
responsibility of the application developer to provide all the
|
responsibility of the application developer to provide all the
|
enumeration data and perform some additional initialisation. In
|
enumeration data and perform some additional initialisation. In
|
addition, the common USB slave package can handle all the standard
|
addition, the common USB slave package can handle all the standard
|
control messages for a simple USB peripheral, but for something like a
|
control messages for a simple USB peripheral, but for something like a
|
multifunction peripheral additional application support is needed.</P
|
multifunction peripheral additional application support is needed.</P
|
><DIV
|
><DIV
|
CLASS="NOTE"
|
CLASS="NOTE"
|
><BLOCKQUOTE
|
><BLOCKQUOTE
|
CLASS="NOTE"
|
CLASS="NOTE"
|
><P
|
><P
|
><B
|
><B
|
>Note: </B
|
>Note: </B
|
>The initial implementation of the eCos USB slave packages involved
|
>The initial implementation of the eCos USB slave packages involved
|
hardware that only supported control and bulk transfers, not
|
hardware that only supported control and bulk transfers, not
|
isochronous or interrupt. There may be future changes to the USB
|
isochronous or interrupt. There may be future changes to the USB
|
code and API to allow for isochronous and interrupt transfers,
|
code and API to allow for isochronous and interrupt transfers,
|
especially the former. Other changes may be required to support
|
especially the former. Other changes may be required to support
|
different USB devices. At present there is no support for USB remote
|
different USB devices. At present there is no support for USB remote
|
wakeups, since again it is not supported by the hardware.</P
|
wakeups, since again it is not supported by the hardware.</P
|
></BLOCKQUOTE
|
></BLOCKQUOTE
|
></DIV
|
></DIV
|
></DIV
|
></DIV
|
><DIV
|
><DIV
|
CLASS="REFSECT1"
|
CLASS="REFSECT1"
|
><A
|
><A
|
NAME="AEN38"
|
NAME="AEN38"
|
></A
|
></A
|
><H2
|
><H2
|
>eCos USB I/O Facilities</H2
|
>eCos USB I/O Facilities</H2
|
><P
|
><P
|
>For protocols other than control messages, eCos provides two ways of
|
>For protocols other than control messages, eCos provides two ways of
|
performing USB I/O. The first involves device table or devtab entries such
|
performing USB I/O. The first involves device table or devtab entries such
|
as <A
|
as <A
|
HREF="usbs-devtab.html"
|
HREF="usbs-devtab.html"
|
><TT
|
><TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>/dev/usb1r</TT
|
>/dev/usb1r</TT
|
></A
|
></A
|
>,
|
>,
|
with one entry per endpoint per USB device. It is possible to
|
with one entry per endpoint per USB device. It is possible to
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>open</TT
|
>open</TT
|
> these devices and use conventional blocking
|
> these devices and use conventional blocking
|
I/O functions such as <TT
|
I/O functions such as <TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>read</TT
|
>read</TT
|
> and
|
> and
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>write</TT
|
>write</TT
|
> to exchange data between host and
|
> to exchange data between host and
|
peripheral.</P
|
peripheral.</P
|
><P
|
><P
|
>There is also a lower-level USB-specific API, consisting of functions
|
>There is also a lower-level USB-specific API, consisting of functions
|
such as <A
|
such as <A
|
HREF="usbs-start-rx.html"
|
HREF="usbs-start-rx.html"
|
><TT
|
><TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>usbs_start_rx_buffer</TT
|
>usbs_start_rx_buffer</TT
|
></A
|
></A
|
>.
|
>.
|
A USB device driver will supply a data structure for each endpoint,
|
A USB device driver will supply a data structure for each endpoint,
|
for example a <A
|
for example a <A
|
HREF="usbs-data.html"
|
HREF="usbs-data.html"
|
><SPAN
|
><SPAN
|
CLASS="STRUCTNAME"
|
CLASS="STRUCTNAME"
|
>usbs_rx_endpoint</SPAN
|
>usbs_rx_endpoint</SPAN
|
></A
|
></A
|
>
|
>
|
structure for every receive endpoint. The first argument to
|
structure for every receive endpoint. The first argument to
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>usbs_start_rx_buffer</TT
|
>usbs_start_rx_buffer</TT
|
> should be a pointer to such
|
> should be a pointer to such
|
a data structure. The USB-specific API is non-blocking: the initial
|
a data structure. The USB-specific API is non-blocking: the initial
|
call merely starts the transfer; some time later, once the transfer
|
call merely starts the transfer; some time later, once the transfer
|
has completed or has been aborted, the device driver will invoke a
|
has completed or has been aborted, the device driver will invoke a
|
completion function.</P
|
completion function.</P
|
><P
|
><P
|
>Control messages are different. With four different categories of
|
>Control messages are different. With four different categories of
|
control messages including application and vendor specific ones, the
|
control messages including application and vendor specific ones, the
|
conventional
|
conventional
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>open</TT
|
>open</TT
|
>/<TT
|
>/<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>read</TT
|
>read</TT
|
>/<TT
|
>/<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>write</TT
|
>write</TT
|
>
|
>
|
model of I/O cannot easily be applied. Instead, a USB device driver
|
model of I/O cannot easily be applied. Instead, a USB device driver
|
will supply a <A
|
will supply a <A
|
HREF="usbs-control.html"
|
HREF="usbs-control.html"
|
><SPAN
|
><SPAN
|
CLASS="STRUCTNAME"
|
CLASS="STRUCTNAME"
|
>usbs_control_endpoint</SPAN
|
>usbs_control_endpoint</SPAN
|
></A
|
></A
|
>
|
>
|
data structure which can be manipulated appropriately. In practice the
|
data structure which can be manipulated appropriately. In practice the
|
standard control messages will usually be handled by the common USB
|
standard control messages will usually be handled by the common USB
|
slave package, and other control messages will be handled by
|
slave package, and other control messages will be handled by
|
class-specific code such as the USB-ethernet package. Typically,
|
class-specific code such as the USB-ethernet package. Typically,
|
application code remains responsible for supplying the <A
|
application code remains responsible for supplying the <A
|
HREF="usbs-enum.html"
|
HREF="usbs-enum.html"
|
>enumeration data</A
|
>enumeration data</A
|
> and for actually <A
|
> and for actually <A
|
HREF="usbs-start.html"
|
HREF="usbs-start.html"
|
>starting</A
|
>starting</A
|
> up the USB device.</P
|
> up the USB device.</P
|
></DIV
|
></DIV
|
><DIV
|
><DIV
|
CLASS="REFSECT1"
|
CLASS="REFSECT1"
|
><A
|
><A
|
NAME="AEN60"
|
NAME="AEN60"
|
></A
|
></A
|
><H2
|
><H2
|
>Enabling the USB code</H2
|
>Enabling the USB code</H2
|
><P
|
><P
|
>If the target hardware contains a USB slave device then the
|
>If the target hardware contains a USB slave device then the
|
appropriate USB device driver and the common packages will typically
|
appropriate USB device driver and the common packages will typically
|
be loaded into the configuration automatically when that target is
|
be loaded into the configuration automatically when that target is
|
selected (assuming a suitable device driver exists). However, the
|
selected (assuming a suitable device driver exists). However, the
|
driver will not necessarily be active. For example a processor might
|
driver will not necessarily be active. For example a processor might
|
have an on-chip USB device, but not all applications using that
|
have an on-chip USB device, but not all applications using that
|
processor will want to use USB functionality. Hence by default the USB
|
processor will want to use USB functionality. Hence by default the USB
|
device is disabled, ensuring that applications do not suffer any
|
device is disabled, ensuring that applications do not suffer any
|
memory or other penalties for functionality that is not required.</P
|
memory or other penalties for functionality that is not required.</P
|
><P
|
><P
|
>If the application developer explicitly adds a class support package
|
>If the application developer explicitly adds a class support package
|
such as the USB-ethernet one then this implies that the USB device is
|
such as the USB-ethernet one then this implies that the USB device is
|
actually needed, and the device will be enabled automatically.
|
actually needed, and the device will be enabled automatically.
|
However, if no suitable class package is available and the USB device
|
However, if no suitable class package is available and the USB device
|
will instead be accessed by application code, it is necessary to
|
will instead be accessed by application code, it is necessary to
|
enable the USB device manually. Usually the easiest way to do this is
|
enable the USB device manually. Usually the easiest way to do this is
|
to enable the configuration option
|
to enable the configuration option
|
<TT
|
<TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>CYGGLO_IO_USB_SLAVE_APPLICATION</TT
|
>CYGGLO_IO_USB_SLAVE_APPLICATION</TT
|
>, and the USB device
|
>, and the USB device
|
driver and related packages will adjust accordingly. Alternatively,
|
driver and related packages will adjust accordingly. Alternatively,
|
the device driver may provide some configuration options to provide
|
the device driver may provide some configuration options to provide
|
more fine-grained control.</P
|
more fine-grained control.</P
|
></DIV
|
></DIV
|
><DIV
|
><DIV
|
CLASS="NAVFOOTER"
|
CLASS="NAVFOOTER"
|
><HR
|
><HR
|
ALIGN="LEFT"
|
ALIGN="LEFT"
|
WIDTH="100%"><TABLE
|
WIDTH="100%"><TABLE
|
WIDTH="100%"
|
WIDTH="100%"
|
BORDER="0"
|
BORDER="0"
|
CELLPADDING="0"
|
CELLPADDING="0"
|
CELLSPACING="0"
|
CELLSPACING="0"
|
><TR
|
><TR
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="left"
|
ALIGN="left"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="io-usb-slave.html"
|
HREF="io-usb-slave.html"
|
>Prev</A
|
>Prev</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="34%"
|
WIDTH="34%"
|
ALIGN="center"
|
ALIGN="center"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="io-usb-slave.html"
|
HREF="io-usb-slave.html"
|
>Home</A
|
>Home</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="right"
|
ALIGN="right"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="usbs-enum.html"
|
HREF="usbs-enum.html"
|
>Next</A
|
>Next</A
|
></TD
|
></TD
|
></TR
|
></TR
|
><TR
|
><TR
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="left"
|
ALIGN="left"
|
VALIGN="top"
|
VALIGN="top"
|
>eCos USB Slave Support</TD
|
>eCos USB Slave Support</TD
|
><TD
|
><TD
|
WIDTH="34%"
|
WIDTH="34%"
|
ALIGN="center"
|
ALIGN="center"
|
VALIGN="top"
|
VALIGN="top"
|
> </TD
|
> </TD
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="right"
|
ALIGN="right"
|
VALIGN="top"
|
VALIGN="top"
|
>USB Enumeration Data</TD
|
>USB Enumeration Data</TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
></DIV
|
></DIV
|
></BODY
|
></BODY
|
></HTML
|
></HTML
|
|
|