Changeset 6843a9c in mainline for uspace/lib/usbhost/include/usb/host/usb_transfer_batch.h
- Timestamp:
- 2012-06-29T13:02:14Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 722912e
- Parents:
- ba72f2b (diff), 0bbd13e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhost/include/usb/host/usb_transfer_batch.h
rba72f2b r6843a9c 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 28 29 /** @addtogroup libusbhost 29 30 * @{ … … 32 33 * USB transfer transaction structures. 33 34 */ 35 34 36 #ifndef LIBUSBHOST_HOST_USB_TRANSFER_BATCH_H 35 37 #define LIBUSBHOST_HOST_USB_TRANSFER_BATCH_H … … 43 45 #define USB_SETUP_PACKET_SIZE 8 44 46 45 typedef struct usb_transfer_batch usb_transfer_batch_t;46 47 /** Structure stores additional data needed for communication with EP */ 47 struct usb_transfer_batch {48 typedef struct usb_transfer_batch { 48 49 /** Endpoint used for communication */ 49 50 endpoint_t *ep; … … 66 67 */ 67 68 size_t setup_size; 68 /** Actually used portion of the buffer */69 size_t transfered_size;70 /** Indicates success/failure of the communication */71 int error;72 69 /** Host controller function, passed to callback function */ 73 70 ddf_fun_t *fun; 71 72 /** Actually used portion of the buffer 73 * This member is never accessed by functions provided in this header, 74 * with the exception of usb_transfer_batch_finish. For external use. 75 */ 76 size_t transfered_size; 77 /** Indicates success/failure of the communication 78 * This member is never accessed by functions provided in this header, 79 * with the exception of usb_transfer_batch_finish. For external use. 80 */ 81 int error; 74 82 75 83 /** Driver specific data */ … … 77 85 /** Callback to properly remove driver data during destruction */ 78 86 void (*private_data_dtor)(void *p_data); 79 } ;87 } usb_transfer_batch_t; 80 88 81 89 /** Printf formatting string for dumping usb_transfer_batch_t. */ … … 93 101 94 102 95 usb_transfer_batch_t * usb_transfer_batch_ get(103 usb_transfer_batch_t * usb_transfer_batch_create( 96 104 endpoint_t *ep, 97 105 char *buffer, … … 105 113 void (*private_data_dtor)(void *p_data) 106 114 ); 115 void usb_transfer_batch_destroy(const usb_transfer_batch_t *instance); 107 116 108 void usb_transfer_batch_finish(usb_transfer_batch_t *instance, 109 const void* data, size_t size); 110 void usb_transfer_batch_call_in(usb_transfer_batch_t *instance); 111 void usb_transfer_batch_call_out(usb_transfer_batch_t *instance); 112 void usb_transfer_batch_dispose(usb_transfer_batch_t *instance); 117 void usb_transfer_batch_finish_error(const usb_transfer_batch_t *instance, 118 const void* data, size_t size, int error); 113 119 114 /** Helper function, calls callback and correctly destroys batch structure. 115 * 116 * @param[in] instance Batch structure to use. 117 */ 118 static inline void usb_transfer_batch_call_in_and_dispose( 119 usb_transfer_batch_t *instance) 120 { 121 assert(instance); 122 usb_transfer_batch_call_in(instance); 123 usb_transfer_batch_dispose(instance); 124 } 125 /*----------------------------------------------------------------------------*/ 126 /** Helper function calls callback and correctly destroys batch structure. 127 * 128 * @param[in] instance Batch structure to use. 129 */ 130 static inline void usb_transfer_batch_call_out_and_dispose( 131 usb_transfer_batch_t *instance) 132 { 133 assert(instance); 134 usb_transfer_batch_call_out(instance); 135 usb_transfer_batch_dispose(instance); 136 } 137 /*----------------------------------------------------------------------------*/ 138 /** Helper function, sets error value and finishes transfer. 120 /** Finish batch using stored error value and transferred size. 139 121 * 140 122 * @param[in] instance Batch structure to use. 141 123 * @param[in] data Data to copy to the output buffer. 142 * @param[in] size Size of @p data.143 * @param[in] error Set batch status to this error value.144 124 */ 145 static inline void usb_transfer_batch_finish _error(146 usb_transfer_batch_t *instance, const void* data, size_t size, int error)125 static inline void usb_transfer_batch_finish( 126 const usb_transfer_batch_t *instance, const void* data) 147 127 { 148 128 assert(instance); 149 instance->error = error;150 usb_transfer_batch_finish(instance, data, size);129 usb_transfer_batch_finish_error( 130 instance, data, instance->transfered_size, instance->error); 151 131 } 152 /*----------------------------------------------------------------------------*/ 153 /** Helper function, determines batch direction absed on the present callbacks154 * @param[in] instance Batch structure to use .132 133 /** Determine batch direction based on the callbacks present 134 * @param[in] instance Batch structure to use, non-null. 155 135 * @return USB_DIRECTION_IN, or USB_DIRECTION_OUT. 156 136 */ … … 175 155 assert(false); 176 156 } 157 177 158 #endif 159 178 160 /** 179 161 * @}
Note:
See TracChangeset
for help on using the changeset viewer.