Devtab entries, Name, Synopsis – Comtrol eCos User Manual

Page 691: Write operations, Dev/usb1r

Advertising
background image

Devtab Entries

Name

Devtab Entries

— Data endpoint data structure

Synopsis

/dev/usb0c

/dev/usb1r

/dev/usb2w

Devtab Entries

USB device drivers provide two ways of transferring data between host and peripheral. The first involves USB-
specific functionality such as

usbs_start_rx_buffer

. This provides non-blocking I/O: a transfer is started, and

some time later the device driver will call a supplied completion function. The second uses the conventional I/O
model: there are entries in the device table corresponding to the various endpoints. Standard calls such as

open

can then be used to get a suitable handle. Actual I/O happens via blocking

read

and

write

calls. In practice the

blocking operations are simply implemented using the underlying non-blocking functionality.

Each endpoint will have its own devtab entry. The exact names are controlled by the device driver package, but
typically the root will be

/dev/usb

. This is followed by one or more decimal digits giving the endpoint number,

followed by

c

for a control endpoint,

r

for a receive endpoint (host to peripheral), and

w

for a transmit endpoint (pe-

ripheral to host). If the target hardware involves more than one USB device then different roots should be used, for
example

/dev/usb0c

and

/dev/usb1_0c

. This may require explicit manipulation of device driver configuration

options by the application developer.

At present the devtab entry for a control endpoint does not support any I/O operations.

write

operations

cyg_io_write

and similar functions in higher-level packages can be used to perform a transfer from peripheral to

host. Successive write operations will not be coalesced. For example, when doing a 1000 byte write to an endpoint
that uses the bulk transfer protocol this will involve 15 full-size 64-byte packets and a terminating 40-byte packet.
USB device drivers are not expected to do any locking, and if higher-level code performs multiple concurrent write
operations on a single endpoint then the resulting behaviour is undefined.

A USB

write

operation will never transfer less data than specified. It is the responsibility of higher-level code to

ensure that the amount of data being transferred is acceptable to the host-side code. Usually this will be defined
by a higher-level protocol. If an attempt is made to transfer more data than the host expects then the resulting
behaviour is undefined.

There are two likely error conditions.

EPIPE

indicates that the connection between host and target has been broken.

EAGAIN

indicates that the endpoint has been stalled, either at the request of the host or by other activity inside the

peripheral.

587

Advertising