sys/bus/u4b/usb_request.c
usb_error_t
usbd_req_set_address(struct usb_device *udev, struct lock *lock, uint16_t addr)
{
	struct usb_device_request req;
	usb_error_t err;

	DPRINTFN(6, "setting device address=%d\n", addr);

	req.bmRequestType = UT_WRITE_DEVICE;
	req.bRequest = UR_SET_ADDRESS;
	USETW(req.wValue, addr);
	USETW(req.wIndex, 0);
	USETW(req.wLength, 0);

	err = USB_ERR_INVAL;

	/* check if USB controller handles set address */
	if (udev->bus->methods->set_address != NULL)
		err = (udev->bus->methods->set_address) (udev, lock, addr);

	if (err != USB_ERR_INVAL)
		goto done;

	/* Setting the address should not take more than 1 second ! */
	err = usbd_do_request_flags(udev, lock, &req, NULL,
	    USB_DELAY_STATUS_STAGE, NULL, 1000);

done:
	/* allow device time to set new address */
	usb_pause_mtx(lock,
	    USB_MS_TO_TICKS(USB_SET_ADDRESS_SETTLE));

	return (err);
}
/*------------------------------------------------------------------------*
 *	usbd_req_set_address
 *
 * This function is used to set the address for an USB device. After
 * port reset the USB device will respond at address zero.
 *
 * Returns:
 *    0: Success
 * Else: Failure
 *------------------------------------------------------------------------*/
usbd_req_set_address
This function is used to set the address for an USB device. After
port reset the USB device will respond at address zero.

Success
Else: Failure
usbd_req_set_address This function is used to set the address for an USB device . After port reset the USB device will respond at address zero . Success Else : Failure
usb_error_t
usbd_req_set_address(struct usb_device *udev, struct lock *lock, uint16_t addr)
{
	struct usb_device_request req;
	usb_error_t err;
	DPRINTFN(6, "setting device address=%d\n", addr);
	req.bmRequestType = UT_WRITE_DEVICE;
	req.bRequest = UR_SET_ADDRESS;
	USETW(req.wValue, addr);
	USETW(req.wIndex, 0);
	USETW(req.wLength, 0);
	err = USB_ERR_INVAL;
	if (udev->bus->methods->set_address != NULL)
		err = (udev->bus->methods->set_address) (udev, lock, addr);
	if (err != USB_ERR_INVAL)
		goto done;
	err = usbd_do_request_flags(udev, lock, &req, NULL,
	    USB_DELAY_STATUS_STAGE, NULL, 1000);
done:
	usb_pause_mtx(lock,
	    USB_MS_TO_TICKS(USB_SET_ADDRESS_SETTLE));
	return (err);
}
usb_error_t usbd_req_set_address ( struct usb_device * udev , struct lock * lock , uint16_t addr ) { struct usb_device_request req ; usb_error_t err ; DPRINTFN ( 6 , " \n " , addr ) ; req . bmRequestType = UT_WRITE_DEVICE ; req . bRequest = UR_SET_ADDRESS ; USETW ( req . wValue , addr ) ; USETW ( req . wIndex , 0 ) ; USETW ( req . wLength , 0 ) ; err = USB_ERR_INVAL ; if ( udev -> bus -> methods -> set_address != NULL ) err = ( udev -> bus -> methods -> set_address ) ( udev , lock , addr ) ; if ( err != USB_ERR_INVAL ) goto done ; err = usbd_do_request_flags ( udev , lock , & req , NULL , USB_DELAY_STATUS_STAGE , NULL , 1000 ) ; done : usb_pause_mtx ( lock , USB_MS_TO_TICKS ( USB_SET_ADDRESS_SETTLE ) ) ; return ( err ) ; }
usbd_req_set_address
 This function is used to set the address for an USB device.
usbd_req_set_address This function is used to set the address for an USB device .
/* check if USB controller handles set address */ /* Setting the address should not take more than 1 second ! */ /* allow device time to set new address */