add note for blocking tuh_configuration_set(), tuh_interface_set()

This commit is contained in:
hathach 2023-03-21 18:13:25 +07:00
parent 878f2b54fe
commit d34508a316
2 changed files with 20 additions and 2 deletions

View File

@ -1030,7 +1030,15 @@ bool tuh_configuration_set(uint8_t daddr, uint8_t config_num,
.user_data = user_data
};
return tuh_control_xfer(&xfer);
bool ret = tuh_control_xfer(&xfer);
// if blocking, user_data could be pointed to xfer_result
if ( !complete_cb && user_data )
{
*((xfer_result_t*) user_data) = xfer.result;
}
return ret;
}
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,
.user_data = user_data
};
return tuh_control_xfer(&xfer);
bool ret = tuh_control_xfer(&xfer);
// if blocking, user_data could be pointed to xfer_result
if ( !complete_cb && user_data )
{
*((xfer_result_t*) user_data) = xfer.result;
}
return ret;
}
//--------------------------------------------------------------------+

View File

@ -168,11 +168,13 @@ bool tuh_edpt_open(uint8_t dev_addr, tusb_desc_endpoint_t const * desc_ep);
// Set Configuration (control transfer)
// config_num = 0 will un-configure device. Note: config_num = config_descriptor_index + 1
// true on success, false if there is on-going control transfer or incorrect parameters
// if complete_cb == NULL i.e blocking, user_data should be pointed to xfer_reuslt_t*
bool tuh_configuration_set(uint8_t daddr, uint8_t config_num,
tuh_xfer_cb_t complete_cb, uintptr_t user_data);
// Set Interface (control transfer)
// true on success, false if there is on-going control transfer or incorrect parameters
// if complete_cb == NULL i.e blocking, user_data should be pointed to xfer_reuslt_t*
bool tuh_interface_set(uint8_t daddr, uint8_t itf_num, uint8_t itf_alt,
tuh_xfer_cb_t complete_cb, uintptr_t user_data);