Data endpoints, Name, Synopsis – Comtrol eCos User Manual
Page 709: Receive and transmit data structures, Usbs_rx_endpoint
Data Endpoints
Name
Data Endpoints
— Data endpoint data structures
Synopsis
#include
<
cyg/io/usb/usbs.h
>
typedef struct usbs_rx_endpoint {
void
(*start_rx_fn)(struct usbs_rx_endpoint*);
void
(*set_halted_fn)(struct usbs_rx_endpoint*, cyg_bool);
void
(*complete_fn)(void*, int);
void*
complete_data;
unsigned char*
buffer;
int
buffer_size;
cyg_bool
halted;
} usbs_rx_endpoint;
typedef struct usbs_tx_endpoint {
void
(*start_tx_fn)(struct usbs_tx_endpoint*);
void
(*set_halted_fn)(struct usbs_tx_endpoint*, cyg_bool);
void
(*complete_fn)(void*, int);
void*
complete_data;
const unsigned char* buffer;
int
buffer_size;
cyg_bool
halted;
} usbs_tx_endpoint;
Receive and Transmit Data Structures
In addition to a single usbs_control_endpoint data structure per USB slave device, the USB device driver should
also provide receive and transmit data structures corresponding to the other endpoints. The names of these are
determined by the device driver. For example, the SA1110 USB device driver package provides
usbs_sa11x0_ep1
for receives and
usbs_sa11x0_ep2
for transmits.
Unlike control endpoints, the common USB slave package does provide a number of utility routines to manipulate
data endpoints. For example
can be used to receive data from the host into a buffer. In
addition the USB device driver can provide devtab entries such as
/dev/usbs1r
and
/dev/usbs2w
, so higher-level
code can
open
these devices and then perform blocking
read
and
write
operations.
However, the operation of data endpoints and the various endpoint-related functions is relatively straightforward.
First consider a usbs_rx_endpoint structure. The device driver will provide the members
start_rx_fn
and
set_halted_fn
, and it will maintain the
halted
field. To receive data, higher-level code sets the
buffer
,
buffer_size
,
complete_fn
and optionally the
complete_data
fields. Next the
start_rx_fn
member
should be called. When the transfer has finished the device driver will invoke the completion function, using
complete_data
as the first argument and a size field for the second argument. A negative size indicates an
error of some sort:
-EGAIN
indicates that the endpoint has been halted, usually at the request of the host;
-EPIPE
605