1: uhs_status_t Usbh_Api_SetAddress(
2:
struct usb_control_block* ucb,
3:
struct usbd_usb_deviceinfo* usbdev,
4:
const uhs_ubit16_t address
5: )
6: {
7: uhs_status_t retval =
UDI_OK;
8:
9:
10:
if( Usbh_susres_get_state() != USBH_SUSRES_STS_IDLE ){
11: uhs_debug_print (DBG_ERR, ("ERROR : Don't Call Current State!!"));
12: CORE_REPORT_ERROR(
USBC_ILLEGAL_ERROR );
13:
return UDI_STAT_INVALID_STATE;
14: }
15:
16:
if (( ucb == NULL ) || ( usbdev == NULL )) {
17: CORE_REPORT_ERROR(
USBC_INVALID_PARAMETER );
18:
return UDI_STAT_DATA_ERROR;
19: }
20:
21: 22:
Usbh_Api_FixupPipeInfo(
23: &ucb->pipe,
24: ucb->usbdev->usbdev_DevNum,
25:
USB_DEFAULT_EP_NUM,
26:
USB_PACKETID_OUT,
27:
USB_TRANS_CONTROL, 28: ucb->usbdev->usbdev_EpMaxpktOut[
USB_DEFAULT_EP_NUM]
29: );
30:
31: retval =
Usbh_Api_SyncControlMsg(
32: ucb,
33: USB_DEVICE_REQUEST_TYPE_HOST_TO_DEVICE |
34: USB_DEVICE_REQUEST_TYPE_STANDARD_TYPE |
35: USB_DEVICE_REQUEST_TYPE_DEVICE_RECIPIENT,
36: USB_DEVICE_REQUEST_SET_ADDRESS,
37: address & 0xffU,
38: address >> 8,
39: 0,
40: 0,
41: NULL,
42: 0 );
43:
44:
if( retval !=
UDI_OK) {
45: CORE_REPORT_WARNING(
USBC_ILLEGAL_ERROR);
46: }
47:
48:
return retval;
49: }