Changeset db2cb04 in mainline
- Timestamp:
- 2011-09-16T10:18:16Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 25d224c6
- Parents:
- 8b54fe6
- Location:
- uspace/lib/usbhost
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhost/include/usb/host/usb_transfer_batch.h
r8b54fe6 rdb2cb04 44 44 45 45 typedef struct usb_transfer_batch usb_transfer_batch_t; 46 /** Structure stores additional data needed for communication with EP */ 46 47 struct usb_transfer_batch { 48 /** Endpoint used for communication */ 47 49 endpoint_t *ep; 50 /** Function called on completion (IN version) */ 48 51 usbhc_iface_transfer_in_callback_t callback_in; 52 /** Function called on completion (OUT version) */ 49 53 usbhc_iface_transfer_out_callback_t callback_out; 54 /** Argument to pass to the completion function */ 50 55 void *arg; 56 /** Place for data to send/receive */ 51 57 char *buffer; 58 /** Size of memory pointed to by buffer member */ 52 59 size_t buffer_size; 60 /** Place to store SETUP data needed by control transfers */ 53 61 char setup_buffer[USB_SETUP_PACKET_SIZE]; 62 /** Used portion of setup_buffer member 63 * 64 * SETUP buffer must be 8 bytes for control transfers and is left 65 * unused for all other transfers. Thus, this field is either 0 or 8. 66 */ 54 67 size_t setup_size; 68 /** Actually used portion of the buffer */ 55 69 size_t transfered_size; 70 /** Indicates success/failure of the communication */ 56 71 int error; 72 /** Host controller function, passed to callback function */ 57 73 ddf_fun_t *fun; 74 75 /** Driver specific data */ 58 76 void *private_data; 77 /** Callback to properly remove driver data during destruction */ 59 78 void (*private_data_dtor)(void *p_data); 60 79 }; … … 117 136 } 118 137 /*----------------------------------------------------------------------------*/ 138 /** Helper function, sets error value and finishes transfer. 139 * 140 * @param[in] instance Batch structure to use. 141 * @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 */ 119 145 static inline void usb_transfer_batch_finish_error( 120 146 usb_transfer_batch_t *instance, const void* data, size_t size, int error) … … 124 150 usb_transfer_batch_finish(instance, data, size); 125 151 } 152 /*----------------------------------------------------------------------------*/ 153 /** Helper function, determines batch direction absed on the present callbacks 154 * @param[in] instance Batch structure to use. 155 * @return USB_DIRECTION_IN, or USB_DIRECTION_OUT. 156 */ 157 static inline usb_direction_t usb_transfer_batch_direction( 158 const usb_transfer_batch_t *instance) 159 { 160 assert(instance); 161 if (instance->callback_in) { 162 assert(instance->callback_out == NULL); 163 assert(instance->ep == NULL 164 || instance->ep->transfer_type == USB_TRANSFER_CONTROL 165 || instance->ep->direction == USB_DIRECTION_IN); 166 return USB_DIRECTION_IN; 167 } 168 if (instance->callback_out) { 169 assert(instance->callback_in == NULL); 170 assert(instance->ep == NULL 171 || instance->ep->transfer_type == USB_TRANSFER_CONTROL 172 || instance->ep->direction == USB_DIRECTION_OUT); 173 return USB_DIRECTION_OUT; 174 } 175 assert(false); 176 } 126 177 #endif 127 178 /** -
uspace/lib/usbhost/src/usb_transfer_batch.c
r8b54fe6 rdb2cb04 78 78 } 79 79 /*----------------------------------------------------------------------------*/ 80 /** Mark batch as finished and continue with next step.80 /** Mark batch as finished and run callback. 81 81 * 82 82 * @param[in] instance Batch structure to use. 83 * 83 * @param[in] data Data to copy to the output buffer. 84 * @param[in] size Size of @p data. 84 85 */ 85 86 void usb_transfer_batch_finish(
Note:
See TracChangeset
for help on using the changeset viewer.