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 >USB-ethernet State Handling</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
25 TITLE="USB-ethernet Data Transfers"
26 HREF="usbseth-data.html"><LINK
28 TITLE="Network Device for the eCos TCP/IP Stack"
29 HREF="usbseth-netdev.html"></HEAD
40 SUMMARY="Header navigation table"
49 >eCos Reference Manual</TH
57 HREF="usbseth-data.html"
71 HREF="usbseth-netdev.html"
82 NAME="USBSETH-CONTROL">USB-ethernet State Handling</H1
90 >USB-ethernet State Handling -- Maintaining the USB-ethernet connection with the host</DIV
92 CLASS="REFSYNOPSISDIV"
108 CLASS="FUNCSYNOPSISINFO"
109 >#include <cyg/io/usb/usbs_eth.h></PRE
117 >usbs_control_return usbs_eth_class_control_handler</CODE
118 >(usbs_control_endpoint* ep0, void* callback_data);</CODE
124 >void usbs_eth_state_change_handler</CODE
125 >(usbs_control_endpoint* ep0, void* callback_data, usbs_state_change change, int old_state);</CODE
131 >void usbs_eth_disable</CODE
132 >(usbs_eth* usbseth>);</CODE
138 >void usbs_eth_enable</CODE
139 >(usbs_eth* usbseth>);</CODE
153 >When the USB-ethernet package is initialized by a call to <A
154 HREF="usbseth-init.html"
162 >usbs_eth_state_change_handler</TT
164 USB state changes. This allows the package to detect when the
165 connection between the host and the peripheral is established or
166 broken, resulting in internal calls to
173 >usbs_eth_disable</TT
174 > respectively. This is
175 appropriate if no other code needs to access the USB device. However,
176 if there is other code, either other USB-related packages or the
177 application itself, that needs to perform I/O over the USB bus, then
178 typically the USB-ethernet package should not have exclusive access to
179 state change events. Instead, the assumption is that higher-level
180 code, typically provided by the application, will install an
181 alternative state change handler in the control endpoint data
182 structure after the call to <TT
186 alternative handler will either chain into
189 >usbs_eth_state_change_handler</TT
191 or else it will invoke <TT
197 >usbs_eth_disable</TT
198 > directly. For further details of
199 state change handlers and control endpoints generally, see the
200 documentation for the common USB-slave package.</P
208 >usbs_eth_class_control_handler</TT
210 endpoint data structure as the appropriate handler for class-specific
211 USB control messages. This code will handle the ethernet-specific
213 HREF="usbseth-protocol.html"
214 >control messages </A
216 requests by the host to enable or disable promiscuous mode or to
217 obtain the MAC address. If the USB device is not shared with any other
218 code then this is both necessary and sufficient. However, if other code
219 is involved and if that code also needs to process certain control
220 messages, higher-level code should install its own handler and chain
221 to the USB-ethernet one when appropriate. It should be noted that the
222 request code is encoded in just a single byte, so there is a real
223 possibility that exactly the same number will be used by different
224 protocols for different requests. Any such problems will have to be
225 identified and resolved by application developers, and may involve
226 modifying the source code for the USB-ethernet package.</P
228 >As an alternative to chaining the state change handler, higher-level
229 code can instead call <TT
231 >usbs_eth_disable</TT
236 > directly. These functions may
237 also be called if the USB-ethernet package should become inactive for
238 reasons not related directly to events on the USB bus. The main effect
242 > is to restart receive
243 operations and to allow transmits. The main effect of
246 >usbs_eth_disable</TT
247 > is to block further transmits:
248 any current receive operations need to be aborted at the USB level,
249 for example by halting the appropriate endpoint.</P
256 SUMMARY="Footer navigation table"
267 HREF="usbseth-data.html"
285 HREF="usbseth-netdev.html"
295 >USB-ethernet Data Transfers</TD
301 HREF="io-usb-slave-eth.html"
309 >Network Device for the eCos TCP/IP Stack</TD