Comtrol eCos User Manual

Page 710

Advertising
background image

Data Endpoints

indicates that the connection between the host and the peripheral has been broken. Certain device drivers may
generate other error codes.

If higher-level code needs to halt or unhalt an endpoint then it can invoke the

set_halted_fn

member. When

an endpoint is halted, invoking

start_rx_fn

wit

buffer_size

set to 0 indicates that higher-level code wants

to block until the endpoint is no longer halted; at that point the completion function will be invoked.

USB device drivers are allowed to assume that higher-level protocols ensure that host and peripheral agree on the
amount of data that will be transferred, or at least on an upper bound. Therefore there is no need for the device
driver to maintain its own buffers, and copy operations are avoided. If the host sends more data than expected then
the resulting behaviour is undefined.

Transmit endpoints work in essentially the same way as receive endpoints. Higher-level code should set the

buffer

and

buffer_size

fields to point at the data to be transferred, then call

start_tx_fn

, and the

device driver will invoked the completion function when the transfer has completed.

USB device drivers are not expected to perform any locking. If at any time there are two concurrent receive
operations for a given endpoint, or two concurrent transmit operations, then the resulting behaviour is undefined.
It is the responsibility of higher-level code to perform any synchronisation that may be necessary. In practice,
conflicts are unlikely because typically a given endpoint will only be accessed sequentially by just one part of the
overall system.

606

Advertising