USBLib_GetDefaultPipe (SWI &56355)

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

On Entry

R0device reference

On Exit

R0preserved
R2pipe handle

Use

This call takes a device reference and returns a pipe connected to the devices control endpoint. USBLib_CtrlMsg (SWI &5635E) 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 &5635A)) see Chapter 3, Driver Initialisation for more details.

This example is identical in function to the one show in Example 4.1, “Obtaining a control pipe”.

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 &56350)

USBLib_CtrlMsg (SWI &5635E)

Related Information

usb_get_default_pipe