USB_PipeOpen (SWI&5538B)
Prev | Chapter 2. Core SWI Calls | Next

## Name

USB_PipeOpen (SWI&5538B) — Opens a pipe for data transfer for a given endpoint.

## On Entry

R0 | Pointer to endpoint structure.
R1 |
Value | Definition | Description
--- | --- | ---
0 | USB_PIPE_OPEN_EXCLUSIVE | Opens a pipe with exclusive access.
1 | USB_PIPE_OPEN_SHARED | Opens a pipe in a non exclusive manner.
R2 | Reserved. Must be set to zero.

## On Exit

R0 | Pointer to pipe structure or zero if an error occurred.
R1 | Error code Table A.1
R2 | Preserved

## Use

A reference to the pipe structure is registered automatically if call is successful.

One application only is responsible for handling a pipe to an endpoint of a device. If the pipe to this endpoint has been already opened by another program this function will fail. You can share a pipe between several applications if USB_PIPE_OPEN_SHARED is set. In this case the opening of the pipe will be successful if it has not been opened before or it has been opened before in shared mode. Trying to open a pipe exclusively which has been opened before in shared mode will fail. Also trying to open a pipe in shared mode which has opened before in exclusive mode will fail. Normally only the default pipe of a device shall be opened in shared mode. Note that activities of several programs on the same pipe may damage each other read the chapter about pipes for details.

Bus capacity is checked and claimed if the pipe is opened by the first program.

This function will reset internally some values like data toggle.

### Note

The actual version of the USB module is handling pipes internally using the endpoint structures. You will therefore get back the pointer to the endpoint structure as passed to the function as a parameter. However this may change in the future.

## Related SWI's

USB_PipeClose (SWI&5538C)

Prev | Up | Next
USB_BufferFree (SWI&5538A) | Home | USB_PipeClose (SWI&5538C)