USBLib_FindDeviceRef (SWI &56350)

USBLib_FindDeviceRef (SWI &56350) — Obtains a device reference

On Entry

R0device number
R1controller reference

On Exit

R0device reference

Use

This call is used to obtain a device reference from a device number and controller reference.

Note

The device reference will have its registration count incremented which will require freeing with USBLib_ReferenceDeregister (SWI &56372) when the reference is no longer required.

Example 3.1. Using USBLib_FindDeviceRef

An example of this calls use, the dev is from a "new device" message obtained either by using the USBLib_DevMgrFindFree (SWI &5635A) call or from a registered message handler.

REM find host controller reference
SYS "USBLib_FindObject",0,controller_name$,USB_REFERENCE_CONTROLLER%,0 TO hc_ref%

REM find device reference
SYS "USBLib_FindDeviceRef",device_number,hc_ref% TO dev_ref%

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

REM do stuff using the reference

REM we don't need the device reference, so deregister it
SYS "USBLib_ReferenceDeregister", dev_ref%, USB_REFERENCE_DEVICE%

	

Related SWIs

USBLib_GetDefaultPipe (SWI &56355)

USBLib_FindDevice (SWI &5634F)

Related Information

usb_find_device_ref