/* drivers/dfu/usb/dfu/dfu.h
 *
 * (c) 2002 Simtec Electronics
 *
 * Ben Dooks
 *
 * USB DFU Class - driver functions
 *
 * $Id: dfu.h,v 1.5 2003/08/08 10:19:17 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_DFU_DFU_H
#define __USB_DFU_DFU_H "$Id: dfu.h,v 1.5 2003/08/08 10:19:17 ben Exp $"

#define USBDFU_RESULT_OK	   (0)
#define USBDFU_RESULT_WAIT	   (1)	/* need to wait for timeout */
#define USBDFU_RESULT_WAITREQ	   (2)	/* need to wait for request to finish*/
#define USBDFU_RESULT_DOWNLOAD	   (3)	/* request more data to send */
#define USBDFU_RESULT_UPLOAD	   (4)	/* need to take data out of buffer */
#define USBDFU_RESULT_NOP          (5)  /* no-op, re-poll */
#define USBDFU_RESULT_FAILED       (-1) /* err: failed - cannot continue */
#define USBDFU_RESULT_INVALIDSTATE (6)  /* err: can't do that */
#define USBDFU_RESULT_DONE         (7)  /* finished (still needs reset)*/

/* usbdfu_op
 *
 * the usbdfu_op function takes account of the current state of the system
 * and updates it accordinly. The return code is one of the USBDFU_RESULT_
 * codes, and indicates what action needs to be taken next.
 *
 * the following results have data written into the data field for the
 * callee to process:
 *
 * USBDFU_RESULT_WAIT		Data contains timeout in milliseconds
 * USBDFU_RESULT_WAITREQ	No data needed for this
 * USBDFU_RESULT_DOWLOAD	Data contains maximum size to download
 * USBDFU_RESULT_UPLOAD	Data contains size of data to read
*/

extern int usbdfu_op(usbdfu_state_t *state, int *data);

extern int usbdfu_init(usbdfu_state_t *state);

extern int usbdfu_download(usbdfu_state_t *state, void *data, int sz);

extern int usbdfu_fatal_err(usbdfu_state_t *state, const char *msg, ...);

/* struct for keeping track of data if needed */
struct usbdfu_data {
       unsigned char *ptr;
       unsigned int  left;
};


#endif /* __USB_DFU_DFU_H */
