USB_ManageDeviceAddresses (SWI&55388)
Prev | Chapter 2. Core SWI Calls | Next

## Name

USB_ManageDeviceAddresses (SWI&55388) — Manages device addresses.

## On Entry

R0 | Pointer to host controller structure.
R1 | Pointer to device structure or zero
R2 | Device number ???
R3 |
Value | Definition | Description
--- | --- | ---
0 | USB_DEVICE_ADDRESS_OP_CHANGE | Allows to change the actual address of a device to another unused but reserved address.
1 | USB_DEVICE_ADDRESS_OP_CLAIM | Reserves a device address for a device.
2 | USB_DEVICE_ADDRESS_OP_RELEASE | Releases a device address
R4 | Reserved. Must be set to zero.
R5 | Reserved. Must be set to zero.

## On Exit

R0 | preserved
R1 | Error code Table A.1
R2 | Depends on the behavior control. At USB_DEVICE_ADDRESS_OP_CHANGE the old device address is returned, at USB_DEVICE_ADDRESS_OP_CLAIM the reserved device address is returned and at USB_DEVICE_ADDRESS_OP_RELEASE the released device address is returned. USB_DEVICE_AUTO_NUMBER will be returned if an error occurs.
R3, R4, R5 | Preserved

## Use

References will be kept in every case.

In fact the SWI contains 3 different function which allows you to manage to device addresses for a given controller. The functions are also used internally by the USB module at USB_DeviceRegister/USB_DeviceDeregister.

At USB_DEVICE_ADDRESS_OP_CLAIM you must pass a reference to the device for which the new address is reserved. Normally this is done by USB_DeviceRegister and you will not use this function. The only usage for a normal program is to reserve an address for changing the device address. In this case you must pass a device reference zero. You can either reserve a given address or let the USB module determine an unused number for you if passing USB_DEVICE_AUTO_NUMBER.

With USB_DEVICE_ADDRESS_OP_CHANGE you can change the number of a device. Please note that all transactions belonging to this device (that means on all endpoints!) will be aborted during this process. You must reserve a new device number by using USB_DEVICE_ADDRESS_OP_CLAIM before. At USB_DEVICE_ADDRESS_OP_CHANGE you must pass the reference to the device together with the new number.

USB_DEVICE_ADDRESS_OP_RELEASE will normally be used automatically if USB_DeviceDeregister is called. It puts the address back into a list of unused devices. It can be used by normal programs together with a device reference of zero if an USB Standard address change request for which an address has been allocated by using USB_DEVICE_ADDRESS_OP_CLAIM before fails.

Normally changing of the device address from the default device address to a usual address will be done by the USB Hub module driver (using the calls described above) so you will never have to use this call by your own programs.

## Related SWI's

USB_DeviceRegister (SWI&55382)

USB_DeviceDeregister (SWI&55383)

Prev | Up | Next
USB_FindObject (SWI&55387) | Home | USB_BufferMalloc (SWI&55389)