Changeset db2cb04 in mainline


Ignore:
Timestamp:
2011-09-16T10:18:16Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
25d224c6
Parents:
8b54fe6
Message:

libusbhost: Add batch direction function and doxygen comments.

Location:
uspace/lib/usbhost
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbhost/include/usb/host/usb_transfer_batch.h

    r8b54fe6 rdb2cb04  
    4444
    4545typedef struct usb_transfer_batch usb_transfer_batch_t;
     46/** Structure stores additional data needed for communication with EP */
    4647struct usb_transfer_batch {
     48        /** Endpoint used for communication */
    4749        endpoint_t *ep;
     50        /** Function called on completion (IN version) */
    4851        usbhc_iface_transfer_in_callback_t callback_in;
     52        /** Function called on completion (OUT version) */
    4953        usbhc_iface_transfer_out_callback_t callback_out;
     54        /** Argument to pass to the completion function */
    5055        void *arg;
     56        /** Place for data to send/receive */
    5157        char *buffer;
     58        /** Size of memory pointed to by buffer member */
    5259        size_t buffer_size;
     60        /** Place to store SETUP data needed by control transfers */
    5361        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         */
    5467        size_t setup_size;
     68        /** Actually used portion of the buffer */
    5569        size_t transfered_size;
     70        /** Indicates success/failure of the communication */
    5671        int error;
     72        /** Host controller function, passed to callback function */
    5773        ddf_fun_t *fun;
     74
     75        /** Driver specific data */
    5876        void *private_data;
     77        /** Callback to properly remove driver data during destruction */
    5978        void (*private_data_dtor)(void *p_data);
    6079};
     
    117136}
    118137/*----------------------------------------------------------------------------*/
     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 */
    119145static inline void usb_transfer_batch_finish_error(
    120146    usb_transfer_batch_t *instance, const void* data, size_t size, int error)
     
    124150        usb_transfer_batch_finish(instance, data, size);
    125151}
     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 */
     157static 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}
    126177#endif
    127178/**
  • uspace/lib/usbhost/src/usb_transfer_batch.c

    r8b54fe6 rdb2cb04  
    7878}
    7979/*----------------------------------------------------------------------------*/
    80 /** Mark batch as finished and continue with next step.
     80/** Mark batch as finished and run callback.
    8181 *
    8282 * @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.
    8485 */
    8586void usb_transfer_batch_finish(
Note: See TracChangeset for help on using the changeset viewer.