USBLib_GetDefaultPipe (SWI &56340)
Prev | 3.5. Transaction SWIs | Next

## Name

USBLib_GetDefaultPipe (SWI &56340) — Obtains a devices default pipe

## On Entry

R0 | device reference

## On Exit

R0 | preserved
R2 | pipe handle

## Use

This call takes a device reference and returns a pipe connected to the devices control endpoint. USBLib_CtrlMsg (SWI &56340) can then be used to send control transactions on the pipe.

Example 3.2. Using USBLib_GetDefaultPipe

This example shows how to obtain a default pipe given a controller name and device number. These are typically obtained from the information in a new device message, usually obtained when the device is found using usb_devmgr_find_free(USBLib_DevMgrFindFree (SWI &56340)) see Chapter 3 for more details.

This example is identical in function to the one show in Example 4.1.

    DEF FNget_default_pipe(controller_name$,device_number%)
      LOCAL endpoint%,pipe%,controller%

      SYS "USB_FindObject",0,controller_name$,

      REM we now need the device reference for this device
      SYS "USBLib_FindDevice", controller_name$, device_number% TO controller%, device%

      PRINT "     device ref is &";~device%
      PRINT " controller ref is &";~controller%

      REM we don't need the controller reference, so deregister it
      SYS "USBLib_ReferenceDeregister", controller%, USB_REFERENCE_CONTROLLER%

      REM we need the default pipe to
      SYS "USBLib_GetDefaultPipe", device% TO ,,pipe%

      PRINT "           pipe at &";~pipe%

    =pipe%

## Related SWIs

USBLib_FindDeviceRef (SWI &56340)

USBLib_CtrlMsg (SWI &56340)

## Related Information

usb_get_default_pipe

Prev | Up | Next
USBLib_DecodeTransactionResult (SWI &56340) | Home | USBLib_SelectInterface (SWI &56340)