Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 11feca8 in mainline


Ignore:
Timestamp:
2010-12-09T10:10:04Z (11 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master
Children:
f5e39475
Parents:
0a5a950
Message:

Add wrappers for control transactions

Wrappers for both control read and control write transfer are ready.

Location:
uspace/lib/usb
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/include/usb/usbdrv.h

    r0a5a950 r11feca8  
    7272int usb_drv_psync_control_write_status(int, usb_target_t);
    7373
     74int usb_drv_psync_control_write(int, usb_target_t,
     75    void *, size_t, void *, size_t);
     76
    7477
    7578int usb_drv_async_control_read_setup(int, usb_target_t,
     
    8386int usb_drv_psync_control_read_data(int, usb_target_t, void *, size_t, size_t *);
    8487int usb_drv_psync_control_read_status(int, usb_target_t);
     88
     89int usb_drv_psync_control_read(int, usb_target_t,
     90    void *, size_t, void *, size_t, size_t *);
     91
    8592
    8693
  • uspace/lib/usb/src/drvpsync.c

    r0a5a950 r11feca8  
    100100
    101101
     102/** Perform complete control write transaction over USB.
     103 *
     104 * The DATA stage is performed only when @p data is not NULL and
     105 * @p data_size is greater than zero.
     106 *
     107 * @param phone Open phone to host controller.
     108 * @param target Target device and endpoint.
     109 * @param setup_packet Setup packet data.
     110 * @param setup_packet_size Size of the setup packet.
     111 * @param data Data to be sent.
     112 * @param data_size Size of the @p data buffer.
     113 * @return Error code.
     114 */
     115int usb_drv_psync_control_write(int phone, usb_target_t target,
     116    void *setup_packet, size_t setup_packet_size,
     117    void *data, size_t data_size)
     118{
     119        int rc;
     120       
     121        rc = usb_drv_psync_control_write_setup(phone, target,
     122            setup_packet, setup_packet_size);
     123        if (rc != EOK) {
     124                return rc;
     125        }
     126
     127        if ((data != NULL) && (data_size > 0)) {
     128                rc = usb_drv_psync_control_write_data(phone, target,
     129                    data, data_size);
     130                if (rc != EOK) {
     131                        return rc;
     132                }
     133        }
     134
     135        rc = usb_drv_psync_control_write_status(phone, target);
     136
     137        return rc;
     138}
     139
    102140
    103141int usb_drv_psync_control_read_setup(int phone, usb_target_t target,
     
    137175}
    138176
     177
     178/** Perform complete control read transaction over USB.
     179 *
     180 * @param phone Open phone to host controller.
     181 * @param target Target device and endpoint.
     182 * @param setup_packet Setup packet data.
     183 * @param setup_packet_size Size of the setup packet.
     184 * @param data Storage for read data.
     185 * @param data_size Size of the @p data buffer.
     186 * @param actual_data_size Storage for number of actually transferred data from
     187 *        device.
     188 * @return Error code.
     189 */
     190int usb_drv_psync_control_read(int phone, usb_target_t target,
     191    void *setup_packet, size_t setup_packet_size,
     192    void *data, size_t data_size, size_t *actual_data_size)
     193{
     194        int rc;
     195       
     196        rc = usb_drv_psync_control_read_setup(phone, target,
     197            setup_packet, setup_packet_size);
     198        if (rc != EOK) {
     199                return rc;
     200        }
     201
     202        rc = usb_drv_psync_control_read_data(phone, target,
     203            data, data_size, actual_data_size);
     204        if (rc != EOK) {
     205                return rc;
     206        }
     207
     208        rc = usb_drv_psync_control_read_status(phone, target);
     209
     210        return rc;
     211}
     212
     213
     214
     215
    139216/**
    140217 * @}
Note: See TracChangeset for help on using the changeset viewer.