1 <!-- Copyright (C) 2001 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 substantively modified versions of this -->
7 <!-- document is prohibited without the explicit permission of the -->
8 <!-- copyright holder. -->
9 <!-- Distribution of the work or derivative of the work in any -->
10 <!-- standard (paper) book form is prohibited unless prior -->
11 <!-- permission is obtained from the copyright holder. -->
15 >Initializing the USB-ethernet Package</TITLE
18 CONTENT="Modular DocBook HTML Stylesheet Version 1.64
21 TITLE="eCos Support for Developing USB-ethernet Peripherals"
22 HREF="io-usb-slave-eth.html"><LINK
25 HREF="usbseth-intro.html"><LINK
27 TITLE="USB-ethernet Data Transfers"
28 HREF="usbseth-data.html"></HEAD
47 >eCos Support for Developing USB-ethernet Peripherals</TH
55 HREF="usbseth-intro.html"
68 HREF="usbseth-data.html"
79 >Initializing the USB-ethernet Package</A
91 > -- Initializing the USB-ethernet Package</DIV
93 CLASS="REFSYNOPSISDIV"
113 CLASS="FUNCSYNOPSISINFO"
114 >#include <cyg/io/usb/usbs_eth.h></PRE
122 >void usbs_eth_init</CODE
123 >(usbs_eth* usbeth, usbs_control_endpoint* ep0, usbs_rx_endpoint* ep1, usbs_tx_endpoint* ep2, unsigned char* mac_address);</CODE
137 >The USB-ethernet package is not tied to any specific hardware. It
138 requires certain functionality: there must be USB-slave hardware
139 supported by a device driver; there must also be two endpoints for
140 bulk transfers between host and peripheral, one for each direction;
141 there must also be a control endpoint, although of course that is
142 implicit with any USB hardware.</P
144 >However, USB-slave hardware may well provide more endpoints than the
145 minimum required for ethernet support. Some of those endpoints might
146 be used by other packages, while other endpoints might be used
147 directly by the application, or might not be needed for the peripheral
148 being built. There is also the possibility of a USB peripheral that
149 supports multiple configurations, with the ethernet support active in
150 only some of those configurations. The USB-ethernet package has no
151 knowledge about any of this, so it relies on higher-level code to tell
152 it which endpoints should be used and other information. This is the
158 >The first argument identifies the specific
162 > data structure that is affected. It
163 is expected that the vast majority of affected applications will only
164 provide a single USB-ethernet device to a single host, and the package
165 automatically provides a suitable data structure
169 > to support this. If multiple
173 > structures are needed for some
174 reason then these need to be instantiated by other code, and each one
175 needs to be initialised by a call to
181 >The next three arguments identify the endpoints that should be used
182 for USB communications: a control endpoint, a receive endpoint for
183 ethernet packets coming from the host to the peripheral, and a
184 transmit endpoint for ethernet packets going in the other direction.
185 Obviously all three endpoints should be provided by the same USB
186 hardware. The USB-ethernet package assumes that it has sole access to
187 the receive and transmit endpoints, subject to the use of
190 >usbs_eth_disable</TT
195 > control functions. The package
196 also assumes that no other code is interested in USB state changes or
197 class control messages: it installs handlers
199 HREF="usbseth-control.html"
202 >usbs_eth_state_change_handler</TT
207 HREF="usbseth-control.html"
210 >usbs_eth_class_control_handler</TT
213 in the control endpoint. If any other code does need to handle USB
214 state changes or class control messages then replacement handlers
215 should be installed after the call to
219 >, and those replacements should
220 invoke the USB-ethernet ones when appropriate.</P
222 >The final argument to <TT
226 the MAC address (or Ethernet Station Address) that should be provided
227 to the host-side device driver. Since the USB-ethernet package does not
228 interact directly with a real ethernet device it cannot obtain the MAC
229 address from any hardware. Instead, it must be supplied by higher-level
230 code. The details depend on the <A
231 HREF="usbseth-intro.html#AEN22"
234 USB-ethernet package is being used.</P
239 > should normally happen
240 after the enumeration data has been provided but before the underlying
241 USB device driver has been started. If the USB device were to be
242 started first then a connection between host and peripheral could be
243 established immediately, and the host-side device driver would attempt
244 to contact the USB-ethernet package for information such as the MAC
253 CLASS="PROGRAMLISTING"
255 main(int argc, char** argv)
257 unsigned char host_MAC[6] = { 0x40, 0x5d, 0x90, 0xa9, 0xbc, 0x02 };
259 usbs_sa11x0_ep0.enumeration_data = &usb_enum_data;
261 usbs_eth_init(&usbs_eth0, &usbs_sa11x0_ep0, &usbs_sa11x0_ep1, &usbs_sa11x0_ep2, host_MAC);
263 usbs_start(&usbs_sa11x0_ep0);
285 HREF="usbseth-intro.html"
293 HREF="io-usb-slave-eth.html"
301 HREF="usbseth-data.html"
320 >USB-ethernet Data Transfers</TD