Skip to content

Commit d34508a

Browse files
committed
add note for blocking tuh_configuration_set(), tuh_interface_set()
1 parent 878f2b5 commit d34508a

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/host/usbh.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,15 @@ bool tuh_configuration_set(uint8_t daddr, uint8_t config_num,
10301030
.user_data = user_data
10311031
};
10321032

1033-
return tuh_control_xfer(&xfer);
1033+
bool ret = tuh_control_xfer(&xfer);
1034+
1035+
// if blocking, user_data could be pointed to xfer_result
1036+
if ( !complete_cb && user_data )
1037+
{
1038+
*((xfer_result_t*) user_data) = xfer.result;
1039+
}
1040+
1041+
return ret;
10341042
}
10351043

10361044
bool tuh_interface_set(uint8_t daddr, uint8_t itf_num, uint8_t itf_alt,
@@ -1062,7 +1070,15 @@ bool tuh_interface_set(uint8_t daddr, uint8_t itf_num, uint8_t itf_alt,
10621070
.user_data = user_data
10631071
};
10641072

1065-
return tuh_control_xfer(&xfer);
1073+
bool ret = tuh_control_xfer(&xfer);
1074+
1075+
// if blocking, user_data could be pointed to xfer_result
1076+
if ( !complete_cb && user_data )
1077+
{
1078+
*((xfer_result_t*) user_data) = xfer.result;
1079+
}
1080+
1081+
return ret;
10661082
}
10671083

10681084
//--------------------------------------------------------------------+

src/host/usbh.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,13 @@ bool tuh_edpt_open(uint8_t dev_addr, tusb_desc_endpoint_t const * desc_ep);
168168
// Set Configuration (control transfer)
169169
// config_num = 0 will un-configure device. Note: config_num = config_descriptor_index + 1
170170
// true on success, false if there is on-going control transfer or incorrect parameters
171+
// if complete_cb == NULL i.e blocking, user_data should be pointed to xfer_reuslt_t*
171172
bool tuh_configuration_set(uint8_t daddr, uint8_t config_num,
172173
tuh_xfer_cb_t complete_cb, uintptr_t user_data);
173174

174175
// Set Interface (control transfer)
175176
// true on success, false if there is on-going control transfer or incorrect parameters
177+
// if complete_cb == NULL i.e blocking, user_data should be pointed to xfer_reuslt_t*
176178
bool tuh_interface_set(uint8_t daddr, uint8_t itf_num, uint8_t itf_alt,
177179
tuh_xfer_cb_t complete_cb, uintptr_t user_data);
178180

0 commit comments

Comments
 (0)