/* usb/lib/clear-pipe.h
 *
 * (c) 2002 Simtec Electronics
 *
 * Ben Dooks
 *
 * USB pipe/endpoint clearing functions
 *
 * $Id: clear-pipe.h,v 1.9 2003/10/13 13:41:32 ben Exp $
 *
 * This Library file is part of the Simtec Electronics USB stack development
 *   suite.
 * Specific licence is granted to use this file by third parties for the
 *   development of USB device drivers.
 *
*/

#ifndef __USB_LIB_CLEARPIPE_H
#define __USB_LIB_CLEARPIPE_H "$Id: clear-pipe.h,v 1.9 2003/10/13 13:41:32 ben Exp $"

/** send an request to clear an halt condition
 *
 * @param pipe pipe that has been halted
 * @param defpipe the default pipe for this device associated with pipe
 * @param buf urb to use for sending request
 * @param wait waiting mode to use
 * @param result pointer to take result
 * @return pointer to waiting result
 */

/*
 *
 * if the buffer is set to NULL, then the system will form a buffer for
 * you, and wait until the request is completed (wait is ignored in this case)
 * otherwise, the call will return having started the request, and the result
 * should be polled with usb_request_get_state()
 *
 * note, once the pipe is cleared, it is your responsibility to call
 * usb_pipe_clear() with the correct flags. For a bulk pipe, this would
 * be USB_PIPE_CLEAR_TOGGLE | USB_PIPE_CLEAR_ACTIVATE to get the pipe
 * back to a running state.
*/

extern usb_wait_t * usblib_send_clear_halt(usb_pipe_t *pipe,
					   usb_pipe_t *defpipe,
					   usb_buffer_t *buf,
					   usb_wait_t *wait, int *result);

/** clear a stall condition from a pipe
 * This call will send the necessary control message to the device to
 * clear the halt, and re-activate the pipe. Note, since this call sends
 * an message, it will block until the message is sent.
 *
 * the return code is an standard USB_RESULT code, and will be USB_RESULT_OK
 * if the call is ok.
 *
 * @memo clear a stall condition from a pipe
 * @param pipe pipe to clear
 * @return result code
*/

extern int usblib_clear_pipe_halt(usb_pipe_t *pipe);

#endif /* __USB_LIB_CLEARPIPE_H */
