1 <!-- Copyright (C) 2002 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 >Halted Endpoints</TITLE
16 ><meta name="MSSmartTagsPreventParsing" content="TRUE">
19 CONTENT="Modular DocBook HTML Stylesheet Version 1.64
22 TITLE="eCos USB Slave Support"
23 HREF="io-usb-slave.html"><LINK
25 TITLE="Sending Data to the Host"
26 HREF="usbs-start-tx.html"><LINK
28 TITLE="Control Endpoints"
29 HREF="usbs-control.html"></HEAD
48 >eCos USB Slave Support</TH
56 HREF="usbs-start-tx.html"
69 HREF="usbs-control.html"
89 >Halted Endpoints -- Support for Halting and Halted Endpoints</DIV
91 CLASS="REFSYNOPSISDIV"
111 CLASS="FUNCSYNOPSISINFO"
112 >#include <cyg/io/usb/usbs.h></PRE
120 >cyg_bool usbs_rx_endpoint_halted</CODE
121 >(usbs_rx_endpoint* ep);</CODE
127 >void usbs_set_rx_endpoint_halted</CODE
128 >(usbs_rx_endpoint* ep, cyg_bool new_state);</CODE
134 >void usbs_start_rx_endpoint_wait</CODE
135 >(usbs_rx_endpoint* ep, void (*)(void*, int) complete_fn, void * complete_data);</CODE
142 usbs_tx_endpoint_halted</CODE
143 >(usbs_tx_endpoint* ep);</CODE
149 >void usbs_set_tx_endpoint_halted</CODE
150 >(usbs_tx_endpoint* ep, cyg_bool new_state);</CODE
156 >void usbs_start_tx_endpoint_wait</CODE
157 >(usbs_tx_endpoint* ep, void (*)(void*, int) complete_fn, void * complete_data);</CODE
174 >Normal USB traffic involves straightforward handshakes, with either an
178 > to indicate that a packet was transferred
179 without errors, or a <TT
182 > if an error occurred, or
183 if a peripheral is currently unable to process another packet from the
184 host, or has no packet to send to the host. There is a third form of
188 >, which indicates that the
189 endpoint is currently <I
194 >When an endpoint is halted it means that the host-side code needs to
195 take some sort of recovery action before communication over that
196 endpoint can resume. The exact circumstances under which this can
197 happen are not defined by the USB specification, but one example would
198 be a protocol violation if say the peripheral attempted to transmit
199 more data to the host than was permitted by the protocol in use. The
200 host can use the standard control messages get-status, set-feature and
201 clear-feature to examine and manipulate the halted status of a given
202 endpoint. There are USB-specific functions which can be used inside
203 the peripheral to achieve the same effect. Once an endpoint has been
204 halted the host can then interact with the peripheral using class or
205 vendor control messages to perform appropriate recovery, and then the
206 halted condition can be cleared.</P
208 >Halting an endpoint does not constitute a device state change, and
209 there is no mechanism by which higher-level code can be informed
210 immediately. However, any ongoing receive or transmit operations will
211 be aborted with an <TT
215 receives or transmits will fail immediately with the same error.</P
217 >There are six functions to support halted endpoints, one set for
218 receive endpoints and another for transmit endpoints, with both sets
219 behaving in essentially the same way. The first,
222 >usbs_rx_endpoint_halted</TT
223 >, can be used to determine
224 whether or not an endpoint is currently halted: it takes a single
225 argument that identifies the endpoint of interest. The second
228 >usbs_set_rx_endpoint_halted</TT
230 used to change the halted condition of an endpoint: it takes two
231 arguments; one to identify the endpoint and another to specify the new
232 state. The last function
235 >usbs_start_rx_endpoint_wait</TT
236 > operates in much the
239 >usbs_start_rx_buffer</TT
241 endpoint is no longer halted the device driver will invoke the
242 supplied completion function with a status of 0. The completion
243 function has the same signature as that for a transfer operation.
244 Often it will be possible to use a single completion function and have
245 the foreground code invoke either
248 >usbs_start_rx_buffer</TT
252 >usbs_start_rx_endpoint_wait</TT
254 current state of the endpoint.</P
271 HREF="usbs-start-tx.html"
279 HREF="io-usb-slave.html"
287 HREF="usbs-control.html"
296 >Sending Data to the Host</TD
306 >Control Endpoints</TD