00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00034 #ifndef LIBUSBHOST_HOST_BATCH_H
00035 #define LIBUSBHOST_HOST_BATCH_H
00036
00037 #include <adt/list.h>
00038
00039 #include <usbhc_iface.h>
00040 #include <usb/usb.h>
00041 #include <usb/host/endpoint.h>
00042
00043 typedef struct usb_transfer_batch usb_transfer_batch_t;
00044 struct usb_transfer_batch {
00045 endpoint_t *ep;
00046 link_t link;
00047 usbhc_iface_transfer_in_callback_t callback_in;
00048 usbhc_iface_transfer_out_callback_t callback_out;
00049 void *arg;
00050 char *buffer;
00051 char *data_buffer;
00052 size_t buffer_size;
00053 char *setup_buffer;
00054 size_t setup_size;
00055 size_t transfered_size;
00056 void (*next_step)(usb_transfer_batch_t *);
00057 int error;
00058 ddf_fun_t *fun;
00059 void *private_data;
00060 void (*private_data_dtor)(void *p_data);
00061 };
00062
00063 void usb_transfer_batch_init(
00064 usb_transfer_batch_t *instance,
00065 endpoint_t *ep,
00066 char *buffer,
00067 char *data_buffer,
00068 size_t buffer_size,
00069 char *setup_buffer,
00070 size_t setup_size,
00071 usbhc_iface_transfer_in_callback_t func_in,
00072 usbhc_iface_transfer_out_callback_t func_out,
00073 void *arg,
00074 ddf_fun_t *fun,
00075 void *private_data,
00076 void (*private_data_dtor)(void *p_data)
00077 );
00078
00079 void usb_transfer_batch_call_in_and_dispose(usb_transfer_batch_t *instance);
00080 void usb_transfer_batch_call_out_and_dispose(usb_transfer_batch_t *instance);
00081 void usb_transfer_batch_finish(usb_transfer_batch_t *instance);
00082 void usb_transfer_batch_dispose(usb_transfer_batch_t *instance);
00083
00084 static inline void usb_transfer_batch_finish_error(
00085 usb_transfer_batch_t *instance, int error)
00086 {
00087 assert(instance);
00088 instance->error = error;
00089 usb_transfer_batch_finish(instance);
00090 }
00091
00092 static inline usb_transfer_batch_t *usb_transfer_batch_from_link(link_t *l)
00093 {
00094 assert(l);
00095 return list_get_instance(l, usb_transfer_batch_t, link);
00096 }
00097
00098 #endif
00099