1 <!-- Copyright (C) 2003 Red Hat, Inc. -->
2 <!-- This material may be distributed only subject to the terms -->
3 <!-- and conditions set forth in the Open Publication License, v1.0 -->
4 <!-- or later (the latest version is presently available at -->
5 <!-- http://www.opencontent.org/openpub/). -->
6 <!-- Distribution of the work or derivative of the work in any -->
7 <!-- standard (paper) book form is prohibited unless prior -->
8 <!-- permission is obtained from the copyright holder. -->
12 >Initializing the USB-ethernet Package</TITLE
13 ><meta name="MSSmartTagsPreventParsing" content="TRUE">
16 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
19 TITLE="eCos Reference Manual"
20 HREF="ecos-ref.html"><LINK
22 TITLE="eCos Support for Developing USB-ethernet Peripherals"
23 HREF="io-usb-slave-eth.html"><LINK
26 HREF="usbseth-intro.html"><LINK
28 TITLE="USB-ethernet Data Transfers"
29 HREF="usbseth-data.html"></HEAD
40 SUMMARY="Header navigation table"
49 >eCos Reference Manual</TH
57 HREF="usbseth-intro.html"
71 HREF="usbseth-data.html"
82 NAME="USBSETH-INIT">Initializing the USB-ethernet Package</H1
93 > -- Initializing the USB-ethernet Package</DIV
95 CLASS="REFSYNOPSISDIV"
111 CLASS="FUNCSYNOPSISINFO"
112 >#include <cyg/io/usb/usbs_eth.h></PRE
120 >void usbs_eth_init</CODE
121 >(usbs_eth* usbeth, usbs_control_endpoint* ep0, usbs_rx_endpoint* ep1, usbs_tx_endpoint* ep2, unsigned char* mac_address);</CODE
135 >The USB-ethernet package is not tied to any specific hardware. It
136 requires certain functionality: there must be USB-slave hardware
137 supported by a device driver; there must also be two endpoints for
138 bulk transfers between host and peripheral, one for each direction;
139 there must also be a control endpoint, although of course that is
140 implicit with any USB hardware.</P
142 >However, USB-slave hardware may well provide more endpoints than the
143 minimum required for ethernet support. Some of those endpoints might
144 be used by other packages, while other endpoints might be used
145 directly by the application, or might not be needed for the peripheral
146 being built. There is also the possibility of a USB peripheral that
147 supports multiple configurations, with the ethernet support active in
148 only some of those configurations. The USB-ethernet package has no
149 knowledge about any of this, so it relies on higher-level code to tell
150 it which endpoints should be used and other information. This is the
156 >The first argument identifies the specific
160 > data structure that is affected. It
161 is expected that the vast majority of affected applications will only
162 provide a single USB-ethernet device to a single host, and the package
163 automatically provides a suitable data structure
167 > to support this. If multiple
171 > structures are needed for some
172 reason then these need to be instantiated by other code, and each one
173 needs to be initialised by a call to
179 >The next three arguments identify the endpoints that should be used
180 for USB communications: a control endpoint, a receive endpoint for
181 ethernet packets coming from the host to the peripheral, and a
182 transmit endpoint for ethernet packets going in the other direction.
183 Obviously all three endpoints should be provided by the same USB
184 hardware. The USB-ethernet package assumes that it has sole access to
185 the receive and transmit endpoints, subject to the use of
188 >usbs_eth_disable</TT
193 > control functions. The package
194 also assumes that no other code is interested in USB state changes or
195 class control messages: it installs handlers
197 HREF="usbseth-control.html"
200 >usbs_eth_state_change_handler</TT
205 HREF="usbseth-control.html"
208 >usbs_eth_class_control_handler</TT
211 in the control endpoint. If any other code does need to handle USB
212 state changes or class control messages then replacement handlers
213 should be installed after the call to
217 >, and those replacements should
218 invoke the USB-ethernet ones when appropriate.</P
220 >The final argument to <TT
224 the MAC address (or Ethernet Station Address) that should be provided
225 to the host-side device driver. Since the USB-ethernet package does not
226 interact directly with a real ethernet device it cannot obtain the MAC
227 address from any hardware. Instead, it must be supplied by higher-level
228 code. The details depend on the <A
229 HREF="usbseth-intro.html#AEN17377"
232 USB-ethernet package is being used.</P
237 > should normally happen
238 after the enumeration data has been provided but before the underlying
239 USB device driver has been started. If the USB device were to be
240 started first then a connection between host and peripheral could be
241 established immediately, and the host-side device driver would attempt
242 to contact the USB-ethernet package for information such as the MAC
251 CLASS="PROGRAMLISTING"
253 main(int argc, char** argv)
255 unsigned char host_MAC[6] = { 0x40, 0x5d, 0x90, 0xa9, 0xbc, 0x02 };
257 usbs_sa11x0_ep0.enumeration_data = &usb_enum_data;
259 usbs_eth_init(&usbs_eth0, &usbs_sa11x0_ep0, &usbs_sa11x0_ep1, &usbs_sa11x0_ep2, host_MAC);
261 usbs_start(&usbs_sa11x0_ep0);
273 SUMMARY="Footer navigation table"
284 HREF="usbseth-intro.html"
302 HREF="usbseth-data.html"
318 HREF="io-usb-slave-eth.html"
326 >USB-ethernet Data Transfers</TD