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

Changeset d02834c in mainline


Ignore:
Timestamp:
2011-12-12T12:58:06Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
03ffb69
Parents:
a56a13c
Message:

libusbdev: Add USB device communication wrappers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbdev/include/usb/dev/usb_device_connection.h

    ra56a13c rd02834c  
    8282        return usb_device_connection_initialize(connection, hc_conn, 0);
    8383}
     84
     85/*----------------------------------------------------------------------------*/
     86static inline int usb_device_register_endpoint(usb_device_connection_t *conn,
     87    usb_endpoint_t ep, usb_transfer_type_t type, usb_direction_t direction,
     88    size_t packet_size, unsigned interval)
     89{
     90        assert(conn);
     91        return usb_hc_register_endpoint(conn->hc_connection,
     92            conn->address, ep, type, direction, packet_size, interval);
     93}
     94/*----------------------------------------------------------------------------*/
     95static inline int usb_device_unregister_endpoint(usb_device_connection_t *conn,
     96    usb_endpoint_t ep, usb_direction_t direction)
     97{
     98        assert(conn);
     99        return usb_hc_unregister_endpoint(conn->hc_connection,
     100            conn->address, ep, direction);
     101}
     102/*----------------------------------------------------------------------------*/
     103static inline int usb_device_control_read(usb_device_connection_t *conn,
     104    usb_endpoint_t ep, uint64_t setup, void *data, size_t size, size_t *rsize)
     105{
     106        assert(conn);
     107        return usb_hc_control_read(conn->hc_connection,
     108            conn->address, ep, setup, data, size, rsize);
     109}
     110/*----------------------------------------------------------------------------*/
     111static inline int usb_device_control_write(usb_device_connection_t *conn,
     112    usb_endpoint_t ep, uint64_t setup, const void *data, size_t size)
     113{
     114        assert(conn);
     115        return usb_hc_control_write(conn->hc_connection,
     116            conn->address, ep, setup, data, size);
     117}
     118/*----------------------------------------------------------------------------*/
     119/** Wrapper for read calls with no setup stage.
     120 * @param[in] connection hc connection to use.
     121 * @param[in] address USB device address.
     122 * @param[in] endpoint USB device endpoint.
     123 * @param[in] data Data buffer.
     124 * @param[in] size Size of the buffer.
     125 * @param[out] real_size Size of the transferred data.
     126 * @return Error code.
     127 */
     128static inline int usb_device_read(usb_device_connection_t *conn,
     129    usb_endpoint_t ep, void *data, size_t size, size_t *real_size)
     130{
     131        return usb_device_control_read(conn, ep, 0, data, size, real_size);
     132}
     133/*----------------------------------------------------------------------------*/
     134/** Wrapper for write calls with no setup stage.
     135 * @param connection hc connection to use.
     136 * @param address USB device address.
     137 * @param endpoint USB device endpoint.
     138 * @param data Data buffer.
     139 * @param size Size of the buffer.
     140 * @return Error code.
     141 */
     142static inline int usb_device_write(usb_device_connection_t *conn,
     143    usb_endpoint_t ep, const void *data, size_t size)
     144{
     145        return usb_device_control_write(conn, ep, 0, data, size);
     146}
    84147#endif
    85148/**
Note: See TracChangeset for help on using the changeset viewer.